Haskell 类型族扩展无法按所述工作

Haskell 类型族扩展无法按所述工作,haskell,type-families,Haskell,Type Families,在上,有以下示例列表: 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 ins

在上,有以下示例列表:

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
这表明
类型实例,其中
在此扩展下是有效语法。但是,以下代码不适用于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'时分析错误


因为这是一个解析错误,看起来语法不受支持,所以我是缺少必要的扩展,还是有其他问题?

这似乎是过早编写文档的情况。据介绍,该语法是GHC HEAD最近添加的一项功能的一部分,但它在GHC的任何发布版本中都无效。

似乎这不是过早的文档,它从2013年1月开始在GHC中出现。只是Haskell平台的最新版本(我的GHC副本来自于此)只提供了2012年6月版本的GHC。我只需要升级我的GHC即可。如果维基注明了它所描述的功能的日期,那就太好了。@Dylan:GHC的最新发布版本是不到两周前的7.6.3,但它仍然不在那里。啊,我天真地认为,从博客发布的日期起,该功能将因此进入下一个版本。你知道为什么它还不是官方的吗?这似乎是一个非常有用的功能。@Dylan:7.6.3是一个错误修复版本。下一个重要的版本将是7.8.1,它应该包括这个特性,并计划在今年晚些时候发布。具有不同语法的类似功能现在仅适用于闭合类型族。