diff options
author | Dr. ERDI Gergo <gergo@erdi.hu> | 2014-07-14 18:18:44 +0800 |
---|---|---|
committer | Dr. ERDI Gergo <gergo@erdi.hu> | 2014-07-14 18:18:44 +0800 |
commit | 698697656bb0501df40713aff847555e61b9411c (patch) | |
tree | cdaa857d11c09ee0eee8fa72b793003cf08fea16 /compiler/parser/Parser.y.pp | |
parent | 105f16f1862eee9c3dd2f8eda2947552f8e570f2 (diff) | |
download | haskell-wip/T8968.tar.gz |
Add parser for pattern synonym type signatures.wip/T8968
Syntax is of the form
pattern type Eq a => P a T b :: Num b => R a b
which declares a pattern synonym called P, with argument types a, T, and b.
Diffstat (limited to 'compiler/parser/Parser.y.pp')
-rw-r--r-- | compiler/parser/Parser.y.pp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/compiler/parser/Parser.y.pp b/compiler/parser/Parser.y.pp index 45b0a2bccc..4773e9be6a 100644 --- a/compiler/parser/Parser.y.pp +++ b/compiler/parser/Parser.y.pp @@ -829,12 +829,15 @@ role : VARID { L1 $ Just $ getVARID $1 } pattern_synonym_decl :: { LHsDecl RdrName } : 'pattern' pat '=' pat {% do { (name, args) <- splitPatSyn $2 - ; return $ LL . ValD $ mkPatSynBind name args $4 ImplicitBidirectional - }} + ; return $ LL . ValD $ mkPatSynBind name args $4 ImplicitBidirectional }} | 'pattern' pat '<-' pat {% do { (name, args) <- splitPatSyn $2 - ; return $ LL . ValD $ mkPatSynBind name args $4 Unidirectional - }} + ; return . LL $ ValD $ mkPatSynBind name args $4 Unidirectional }} + +pattern_synonym_sig :: { LSig RdrName } + : 'pattern' 'type' ctype '::' ctype + {% do { (name, details, ty, prov, req) <- splitPatSynSig $3 $5 + ; return . LL $ PatSynSig name details ty prov req }} vars0 :: { [Located RdrName] } : {- empty -} { [] } @@ -1445,6 +1448,7 @@ sigdecl :: { Located (OrdList (LHsDecl RdrName)) } { LL $ toOL [ LL $ SigD (TypeSig ($1 : reverse (unLoc $3)) $5) ] } | infix prec ops { LL $ toOL [ LL $ SigD (FixSig (FixitySig n (Fixity $2 (unLoc $1)))) | n <- unLoc $3 ] } + | pattern_synonym_sig { LL . unitOL $ LL . SigD . unLoc $ $1 } | '{-# INLINE' activation qvar '#-}' { LL $ unitOL (LL $ SigD (InlineSig $3 (mkInlinePragma (getINLINE $1) $2))) } | '{-# SPECIALISE' activation qvar '::' sigtypes1 '#-}' |