Commit 65262cd6 authored by Björn Peemöller 's avatar Björn Peemöller
Browse files

Allow record patterns inside functional patterns

parent 3c9c4f0c
......@@ -1024,8 +1024,9 @@ checkFPTerm p (ParenPattern t) = checkFPTerm p t
checkFPTerm p (TuplePattern _ ts) = mapM_ (checkFPTerm p) ts
checkFPTerm p (ListPattern _ ts) = mapM_ (checkFPTerm p) ts
checkFPTerm p (AsPattern _ t) = checkFPTerm p t
checkFPTerm p t@(RecordPattern _ _) = report $ errUnsupportedFPTerm "Record" p t
checkFPTerm p t@(LazyPattern _ _) = report $ errUnsupportedFPTerm "Lazy" p t
checkFPTerm p (RecordPattern _ fs) = mapM_ (checkFPTerm p)
[ t | Field _ _ t <- fs ]
checkFPTerm _ (FunctionPattern _ _) = ok -- do not check again
checkFPTerm _ (InfixFuncPattern _ _ _) = ok -- do not check again
......
......@@ -530,6 +530,10 @@ fp2Expr (InfixFuncPattern t1 op t2) =
fp2Expr (AsPattern v t) =
let (t', es) = fp2Expr t
in (mkVar v, (t' =:<= mkVar v) : es)
fp2Expr (RecordPattern c fs) =
let (fs', ess) = unzip [ (Field p f e, es) | Field p f t <- fs
, let (e, es) = fp2Expr t]
in (Record c fs', concat ess)
fp2Expr t = internalError $
"Desugar.fp2Expr: Unexpected constructor term: " ++ show t
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment