haskell - Type Families extension does not work as described -
on the haskell wiki page type families, there following list of examples:
type family f :: * type instance f [int] = int -- ok! type instance f string = char -- ok! type instance f (f a) = -- wrong: type parameter mentions type family type instance f (forall a. (a, b)) = b -- wrong: forall type appears in type parameter type instance f float = forall a.a -- wrong: right-hand side may not forall type type instance -- ok! f (maybe int) = int f (maybe bool) = bool f (maybe a) = string type instance -- wrong: conflicts earlier instances (see below) f int = float f = [a] type family g b :: * -> * type instance g int = (,) -- wrong: must 2 type parameters type instance g int char float = double -- wrong: must 2 type parameters
this demonstrates type instance where
valid syntax under extension. following code not compile me ghc 7.4.2:
{-# language typefamilies #-} type family f :: * type instance f (maybe int) = int f (maybe bool) = bool f (maybe a) = string
the error message is:
test.hs:4:15: parse error on input `where'
since parsing error, looks syntax not supported, missing requisite extension, or else amiss?
this appears case of premature documentation. according this blog post, syntax part of feature added ghc head, it's not yet valid in released version of ghc.
Comments
Post a Comment