In going from ghc-6.6 to ghc-6.7, I've lost some GADT pattern matching that
I'd really like to have back. The message:
c:/conal/Haskell/Eros/src/gadt-example.hs:23:32:
GADT pattern match in non-rigid context for `:*'
Tell GHC HQ if you'd like this to unify the context
In the pattern: a :* b
In a lambda abstraction: \ (a :* b) -> ((f a) :* b)
In the second argument of `($)', namely
`\ (a :* b) -> ((f a) :* b)'
and the relevant code:
-- | Statically typed type representations
data Ty :: * -> * where
(:*) :: Ty a -> Ty b -> Ty (a, b)
(:->) :: Ty a -> Ty b -> Ty (a->b)
OtherTy :: TypeRep -> Ty a
-- | Type transformations
newtype TyFun a b = TyFun { unTyFun :: Ty a -> Ty b }
instance Arrow TyFun where
TyFun f >>> TyFun g = TyFun (f >>> g)
first (TyFun f) = TyFun $ \ (a :* b) -> (f a :* b)
second (TyFun g) = TyFun $ \ (a :* b) -> (a :* g b)
Full test module attached with many more example matchings.
I'd really like to get this code working in ghc-6.7. How likely is that?
The best alternative I know is *much* less readable.
Thanks, - Conal
{-# OPTIONS -fglasgow-exts #-}
import Data.Typeable
import Control.Arrow
infixr 4 :->
infix 4 :*
-- | Statically typed type representations
data Ty :: * -> * where
(:*) :: Ty a -> Ty b -> Ty (a, b)
(:->) :: Ty a -> Ty b -> Ty (a->b)
OtherTy :: TypeRep -> Ty a
-- | Type transformations
newtype TyFun a b = TyFun { unTyFun :: Ty a -> Ty b }
instance Arrow TyFun where
TyFun f >>> TyFun g = TyFun (f >>> g)
first (TyFun f) = TyFun $ \ (a :* b) -> (f a :* b)
second (TyFun g) = TyFun $ \ (a :* b) -> (a :* g b)
{- -- lots more for DeepArrow
instance DeepArrow TyFun where
result (TyFun g) = TyFun $ \ (a :-> b) -> (a :-> g b)
idA = TyFun id
dupA = TyFun $ \ a -> a :* a
fstA = TyFun $ \ (a :* _) -> a
sndA = TyFun $ \ (_ :* b) -> b
funF = TyFun $ \ ((c :-> a) :* b) -> (c :-> (a :* b))
funS = TyFun $ \ (a :* (c :-> b)) -> (c :-> (a :* b))
funR = TyFun $ \ (a :-> c :-> b) -> (c :-> a :-> b)
curryA = TyFun $ \ ((a :* b) :-> c) -> (a :-> b :-> c)
uncurryA = TyFun $ \ (a :-> b :-> c) -> ((a :* b) :-> c)
swapA = TyFun $ \ (a :* b) -> (b :* a)
lAssocA = TyFun $ \ (a :* (b :* c)) -> ((a :* b) :* c)
rAssocA = TyFun $ \ ((a :* b) :* c) -> (a :* (b :* c))
-}_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc