Hi all,
I tried compiling the file HaskellServer.hs from thrift-0.9.0/tutorial/hs with
ghc 7.6.3 to no avail.
On the commandline I called
> thrift --gen hs tutorial.thrift
> thrift --gen hs shared.thrift
which worked.
After that, I tried to compile with
> ghc HaskellServer.hs
but I get the following error output:
[1 of 7] Compiling Shared_Types ( Shared_Types.hs, Shared_Types.o ) [flags
changed]
[2 of 7] Compiling SharedService_Iface ( SharedService_Iface.hs,
SharedService_Iface.o ) [flags changed]
[3 of 7] Compiling SharedService ( SharedService.hs, SharedService.o )
[flags changed]
[4 of 7] Compiling Tutorial_Types ( Tutorial_Types.hs, Tutorial_Types.o )
[flags changed]
[5 of 7] Compiling Calculator_Iface ( Calculator_Iface.hs, Calculator_Iface.o )
[flags changed]
[6 of 7] Compiling Calculator ( Calculator.hs, Calculator.o ) [flags
changed]
[7 of 7] Compiling Main ( HaskellServer.hs, HaskellServer.o )
HaskellServer.hs:48:33:
Couldn't match type `GHC.Int.Int32' with `Int'
Expected type: Maybe Int
Actual type: Maybe GHC.Int.Int32
In the first argument of `fromJust', namely `k'
In the second argument of `(!)', namely `(fromJust k)'
In the second argument of `($)', namely `(myLog ! (fromJust k))'
HaskellServer.hs:73:60:
Couldn't match type `Int' with `GHC.Int.Int32'
Expected type: Maybe GHC.Int.Int32
Actual type: Maybe Int
In the `f_InvalidOperation_what' field of a record
In the second argument of `($)', namely
`InvalidOperation
{f_InvalidOperation_what = Just $ fromEnum $ op work,
f_InvalidOperation_why = Just "Cannot divide by 0"}'
In the expression:
throw
$ InvalidOperation
{f_InvalidOperation_what = Just $ fromEnum $ op work,
f_InvalidOperation_why = Just "Cannot divide by 0"}
HaskellServer.hs:74:64:
Couldn't match expected type `Data.Text.Lazy.Internal.Text'
with actual type `[Char]'
In the first argument of `Just', namely `"Cannot divide by 0"'
In the `f_InvalidOperation_why' field of a record
In the second argument of `($)', namely
`InvalidOperation
{f_InvalidOperation_what = Just $ fromEnum $ op work,
f_InvalidOperation_why = Just "Cannot divide by 0"}'
HaskellServer.hs:79:53:
Couldn't match type `[Char]' with `Data.Text.Lazy.Internal.Text'
Expected type: Data.Text.Lazy.Internal.Text
Actual type: String
In the return type of a call of `show'
In the first argument of `Just', namely `(show val)'
In the second argument of `SharedStruct', namely
`(Just (show val))'
HaskellServer.hs:80:52:
Couldn't match expected type `Int' with actual type `GHC.Int.Int32'
In the first argument of `M.insert', namely `logid'
In the second argument of `(.)', namely `(M.insert logid logEntry)'
In the second argument of `($)', namely
`return . (M.insert logid logEntry)'
Obviously, something's wrong with the types but I can't say if it's a problem
with my specific GHC version or with thrift itself.
I also tried the following command without any success:
> ghc -fglasgow-exts HaskellServer.hs
I've read a few issues that might be related to this problem (like [1]) but I
can't figure it out myself.
Can somebody point me in the right direction?
Regards,
mre
---
[1] https://issues.apache.org/jira/browse/THRIFT-1921