blob: bbfe69977367d791f7426e4527f3d98891f9c467 [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
46 * string -> String
47 * 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
55Structs
56=======
57
Anthony F. Molinarofa6eaca2010-09-27 17:33:47 +000058Become records. Field labels are ugly, of the form f_STRUCTNAME_FIELDNAME. All
Bryan Duxbury6a3705c2009-04-07 23:23:39 +000059fields are Maybe types.
60
61Exceptions
62==========
63
Anthony F. Molinarofa6eaca2010-09-27 17:33:47 +000064Identical to structs. Throw them with throwDyn. Catch them with catchDyn.
Bryan Duxbury6a3705c2009-04-07 23:23:39 +000065
66Client
67======
68
Anthony F. Molinarofa6eaca2010-09-27 17:33:47 +000069Just a bunch of functions. You may have to import a bunch of client files to
Bryan Duxbury6a3705c2009-04-07 23:23:39 +000070deal with inheritance.
71
72Interface
73=========
74
75You should only have to import the last one in the chain of inheritors. To make
76an interface, declare a label:
77
78 data MyIface = MyIface
79
80and then declare it an instance of each iface class, starting with the superest
81class and proceding down (all the while defining the methods). Then pass your
82label to process as the handler.
83
84Processor
85=========
86
87Just a function that takes a handler label, protocols. It calls the
88superclasses process if there is a superclass.
iproctorff8eb922007-07-25 19:06:13 +000089