
2009/6/18 Niklas Broberg
GHC:
ctypedoc :: { LHsType RdrName } : 'forall' tv_bndrs '.' ctypedoc | context '=>' ctypedoc | gentypedoc
Notice GHC's recursive call to ctypedoc after the =>. I have no idea what the doc suffix on the production is intended to indicate though - and I was curious to find a separate set of rules that don't have that suffix:
The doc suffix says "can contain Haddock comments".
ctype :: { LHsType RdrName } : 'forall' tv_bndrs '.' ctype | context '=>' type | type
This one looks just like the one that haskell-src-exts uses - type instead of ctype after the =>.
You're not looking at the latest version of the code. I'm guessing you're looking at the stable version instead of the HEAD. In HEAD we have:
ctypedoc :: { LHsType RdrName } : 'forall' tv_bndrs '.' ctypedoc { LL $ mkExplicitHsForAllTy $2 (noLoc []) $4 } | context '=>' ctypedoc { LL $ mkImplicitHsForAllTy $1 $3 } -- A type of form (context => type) is an *implicit* HsForAllTy | ipvar '::' type { LL (HsPredTy (HsIParam (unLoc $1) $3)) } | typedoc { $1 }
This should accept both
multipleCtx :: (Eq a => Show a => a) multipleCtx = undefined
and
multipleCtx :: Eq a => Show a => a multipleCtx = undefined
The reason why ctypedoc and ctype were so different before, is because they drifted apart after ctypedoc was added. ctype was changed (I think during implementation of the TypeFamilies extension) without any changes to ctypedoc. This was fixed in HEAD not so long ago. If you need more information I can dig up the trac ticket :-) David