nominolo / atto-lisp

Efficient parsing and encoding of Lisp expressions for Haskell.
Other
24 stars 16 forks source link

Fix a problem with fundeps on GHC 7.2 #5

Closed maoe closed 12 years ago

maoe commented 12 years ago

Introduced IsFunction type class, which was quoted from http://okmij.org/ftp/Haskell/typecast.html#is-function-type.

The problem is that we cannot compile Data.AttoLisp.Test with GHC 7.2.1:

maoe@maoe.local
% ghc Data/AttoLisp/Test.hs                         /Users/maoe/coding/haskell/atto-lisp
[1 of 2] Compiling Data.AttoLisp    ( Data/AttoLisp.hs, Data/AttoLisp.o )
[2 of 2] Compiling Data.AttoLisp.Test ( Data/AttoLisp/Test.hs, Data/AttoLisp/Test.o )

Data/AttoLisp/Test.hs:24:17:
    Couldn't match type `T.Text -> Integer -> Msg' with `Msg'
    When using functional dependencies to combine
      Data.AttoLisp.ParseList a a,
        arising from the dependency `a -> b'
        in the instance declaration at Data/AttoLisp.hs:314:10
      Data.AttoLisp.ParseList (T.Text -> Integer -> Msg) Msg,
        arising from a use of `struct' at Data/AttoLisp/Test.hs:24:17-22
    In the expression: struct "msg" Msg e
    In an equation for `parseLisp': parseLisp e = struct "msg" Msg e
nominolo commented 12 years ago

Thanks. I noticed that the IsFunction stuff is perhaps a bit too magical.

Did you test these changes with GHC 6.12 and 7.0? I played around with similar tricks, but I didn't get it to work reliably.

maoe commented 12 years ago

Hi,

I agree with you. This is a bit magical but works well.

I've compiled Data.AttoLisp.Test on GHC 6.12.3, 7.0.3 and 7.2.1. All of these have passed the tests. As Oleg mentioned in isFunction.hs, this trick should work on GHCi 6.2.1 and GHCi 6.4.