Type Familiesの Haskell wiki ページには、次の例のリストがあります。
type family F a :: *
type instance F [Int] = Int -- OK!
type instance F String = Char -- OK!
type instance F (F a) = a -- WRONG: type parameter mentions a type family
type instance F (forall a. (a, b)) = b -- WRONG: a forall type appears in a type parameter
type instance F Float = forall a.a -- WRONG: right-hand side may not be a forall type
type instance where -- OK!
F (Maybe Int) = Int
F (Maybe Bool) = Bool
F (Maybe a) = String
type instance where -- WRONG: conflicts with earlier instances (see below)
F Int = Float
F a = [a]
type family G a b :: * -> *
type instance G Int = (,) -- WRONG: must be two type parameters
type instance G Int Char Float = Double -- WRONG: must be two type parameters
type instance where
これは、この拡張子の下で有効な構文であることを示しています。ただし、次のコードは GHC 7.4.2 ではコンパイルできません。
{-# LANGUAGE TypeFamilies #-}
type family F a :: *
type instance where
F (Maybe Int) = Int
F (Maybe Bool) = Bool
F (Maybe a) = String
エラーメッセージは次のとおりです。
test.hs:4:15: 入力 `where' の解析エラー
これは解析エラーであるため、その構文はサポートされていないようです。必要な拡張子がないのでしょうか、それとも何か問題がありますか?