iproctor | ff8eb92 | 2007-07-25 19:06:13 +0000 | [diff] [blame] | 1 | Haskell Thrift Bindings |
| 2 | |
Bryan Duxbury | 6a3705c | 2009-04-07 23:23:39 +0000 | [diff] [blame^] | 3 | Running |
| 4 | ======= |
iproctor | ff8eb92 | 2007-07-25 19:06:13 +0000 | [diff] [blame] | 5 | |
Bryan Duxbury | 6a3705c | 2009-04-07 23:23:39 +0000 | [diff] [blame^] | 6 | You need -fglasgow-exts. Use Cabal to compile and install. If you're trying to |
| 7 | manually compile or load via ghci, and you're using ghc 6.10 (or really if your |
| 8 | default base package has major version number 4), you must specify a version of |
| 9 | the base package with major version number 3. Furthermore if you have the syb |
| 10 | package installed you need to hide that package to avoid import conflicts. |
| 11 | Here's an example of what I'm talking about: |
iproctor | ff8eb92 | 2007-07-25 19:06:13 +0000 | [diff] [blame] | 12 | |
Bryan Duxbury | 6a3705c | 2009-04-07 23:23:39 +0000 | [diff] [blame^] | 13 | ghci -fglasgow-exts -package base-3.0.3.0 -hide-package syb -isrc Thrift.hs |
iproctor | ff8eb92 | 2007-07-25 19:06:13 +0000 | [diff] [blame] | 14 | |
Bryan Duxbury | 6a3705c | 2009-04-07 23:23:39 +0000 | [diff] [blame^] | 15 | To determine which versions of the base package you have installed use the |
| 16 | following command: |
iproctor | ff8eb92 | 2007-07-25 19:06:13 +0000 | [diff] [blame] | 17 | |
Bryan Duxbury | 6a3705c | 2009-04-07 23:23:39 +0000 | [diff] [blame^] | 18 | ghc-pkg list base |
iproctor | ff8eb92 | 2007-07-25 19:06:13 +0000 | [diff] [blame] | 19 | |
Bryan Duxbury | 6a3705c | 2009-04-07 23:23:39 +0000 | [diff] [blame^] | 20 | All of this is taken care of for you if you use Cabal. |
iproctor | ff8eb92 | 2007-07-25 19:06:13 +0000 | [diff] [blame] | 21 | |
Bryan Duxbury | 6a3705c | 2009-04-07 23:23:39 +0000 | [diff] [blame^] | 22 | |
| 23 | Enums |
| 24 | ===== |
| 25 | |
| 26 | become haskell data types. Use fromEnum to get out the int value. |
| 27 | |
| 28 | Structs |
| 29 | ======= |
| 30 | |
| 31 | become records. Field labels are ugly, of the form f_STRUCTNAME_FIELDNAME. All |
| 32 | fields are Maybe types. |
| 33 | |
| 34 | Exceptions |
| 35 | ========== |
| 36 | |
| 37 | identical to structs. Throw them with throwDyn. Catch them with catchDyn. |
| 38 | |
| 39 | Client |
| 40 | ====== |
| 41 | |
| 42 | just a bunch of functions. You may have to import a bunch of client files to |
| 43 | deal with inheritance. |
| 44 | |
| 45 | Interface |
| 46 | ========= |
| 47 | |
| 48 | You should only have to import the last one in the chain of inheritors. To make |
| 49 | an interface, declare a label: |
| 50 | |
| 51 | data MyIface = MyIface |
| 52 | |
| 53 | and then declare it an instance of each iface class, starting with the superest |
| 54 | class and proceding down (all the while defining the methods). Then pass your |
| 55 | label to process as the handler. |
| 56 | |
| 57 | Processor |
| 58 | ========= |
| 59 | |
| 60 | Just a function that takes a handler label, protocols. It calls the |
| 61 | superclasses process if there is a superclass. |
iproctor | ff8eb92 | 2007-07-25 19:06:13 +0000 | [diff] [blame] | 62 | |