blob: fe525bd868f41fcb136433ea5eeff2cbcc2b343a [file] [log] [blame]
iproctorff8eb922007-07-25 19:06:13 +00001Haskell Thrift Bindings
2
Bryan Duxburydef30a62009-04-08 00:19:37 +00003License
4=======
5
6Licensed to the Apache Software Foundation (ASF) under one
7or more contributor license agreements. See the NOTICE file
8distributed with this work for additional information
9regarding copyright ownership. The ASF licenses this file
10to you under the Apache License, Version 2.0 (the
11"License"); you may not use this file except in compliance
12with the License. You may obtain a copy of the License at
13
14 http://www.apache.org/licenses/LICENSE-2.0
15
16Unless required by applicable law or agreed to in writing,
17software distributed under the License is distributed on an
18"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
19KIND, either express or implied. See the License for the
20specific language governing permissions and limitations
21under the License.
22
Anthony F. Molinarofa6eaca2010-09-27 17:33:47 +000023Compile
Bryan Duxbury6a3705c2009-04-07 23:23:39 +000024=======
iproctorff8eb922007-07-25 19:06:13 +000025
Anthony F. Molinarofa6eaca2010-09-27 17:33:47 +000026Use Cabal to compile and install; ./configure uses Cabal underneath, and that
27path is not yet well tested. Thrift's library and generated code should compile
28with pretty much any GHC extensions or warnings you enable (or disable).
29Please report this not being the case as a bug on
30https://issues.apache.org/jira/secure/CreateIssue!default.jspa
iproctorff8eb922007-07-25 19:06:13 +000031
Anthony F. Molinarofa6eaca2010-09-27 17:33:47 +000032Chances you'll need to muck a bit with Cabal flags to install Thrift:
iproctorff8eb922007-07-25 19:06:13 +000033
Anthony F. Molinarofa6eaca2010-09-27 17:33:47 +000034CABAL_CONFIGURE_FLAGS="--user" ./configure
iproctorff8eb922007-07-25 19:06:13 +000035
Anthony F. Molinarofa6eaca2010-09-27 17:33:47 +000036Base Types
37==========
iproctorff8eb922007-07-25 19:06:13 +000038
Anthony F. Molinarofa6eaca2010-09-27 17:33:47 +000039The mapping from Thrift types to Haskell's is:
iproctorff8eb922007-07-25 19:06:13 +000040
Anthony F. Molinarofa6eaca2010-09-27 17:33:47 +000041 * double -> Double
Anthony F. Molinaro687c4122010-10-05 16:47:52 +000042 * byte -> Data.Word.Word8
Anthony F. Molinarofa6eaca2010-09-27 17:33:47 +000043 * i16 -> Data.Int.Int16
44 * i32 -> Data.Int.Int32
45 * i64 -> Data.Int.Int64
Roger Meier6849f202012-05-18 07:35:19 +000046 * string -> Text
Anthony F. Molinarofa6eaca2010-09-27 17:33:47 +000047 * binary -> Data.ByteString.Lazy
48 * bool -> Boolean
Bryan Duxbury6a3705c2009-04-07 23:23:39 +000049
50Enums
51=====
52
Anthony F. Molinarofa6eaca2010-09-27 17:33:47 +000053Become Haskell 'data' types. Use fromEnum to get out the int value.
Bryan Duxbury6a3705c2009-04-07 23:23:39 +000054
Roger Meier6849f202012-05-18 07:35:19 +000055Lists
56=====
57
58Become Data.Vector.Vector from the vector package.
59
60Maps and Sets
61=============
62
63Become Data.HashMap.Strict.Map and Data.HashSet.Set from the
64unordered-containers package.
65
Bryan Duxbury6a3705c2009-04-07 23:23:39 +000066Structs
67=======
68
Anthony F. Molinarofa6eaca2010-09-27 17:33:47 +000069Become records. Field labels are ugly, of the form f_STRUCTNAME_FIELDNAME. All
Bryan Duxbury6a3705c2009-04-07 23:23:39 +000070fields are Maybe types.
71
72Exceptions
73==========
74
Roger Meier6849f202012-05-18 07:35:19 +000075Identical to structs. Use them with throw and catch from Control.Exception.
Bryan Duxbury6a3705c2009-04-07 23:23:39 +000076
77Client
78======
79
Anthony F. Molinarofa6eaca2010-09-27 17:33:47 +000080Just a bunch of functions. You may have to import a bunch of client files to
Bryan Duxbury6a3705c2009-04-07 23:23:39 +000081deal with inheritance.
82
83Interface
84=========
85
86You should only have to import the last one in the chain of inheritors. To make
87an interface, declare a label:
88
89 data MyIface = MyIface
90
91and then declare it an instance of each iface class, starting with the superest
92class and proceding down (all the while defining the methods). Then pass your
93label to process as the handler.
94
95Processor
96=========
97
98Just a function that takes a handler label, protocols. It calls the
99superclasses process if there is a superclass.