This commit is contained in:
crumbtoo
2024-02-07 11:19:36 -07:00
parent 868b63e6ef
commit d6529d50ff
2 changed files with 10 additions and 4 deletions

View File

@@ -87,6 +87,7 @@ library
TypeFamilies
LambdaCase
ViewPatterns
DataKinds
executable rlpc
import: warnings

View File

@@ -116,19 +116,24 @@ conToRose (ConP cn as) = Fix . Branch cn <$> patToForrest `traverse` as
getName = state $ fromJust . uncons @[IdP RlpcPs]
test :: Expr' -> Branch Alter' -> Alter'
test e (Branch cn as) = Alter (AltData cn) myBinds e'
branchToCore :: Expr' -> Branch Alter' -> Alter'
branchToCore e (Branch cn as) = Alter (AltData cn) myBinds e'
where
-- gather binders for the /current/ pattern, and build an expression
-- matching subpatterns
(e', myBinds) = mapAccumL f e as
f :: Expr' -> Tree Alter' -> (Expr', Name)
f e (Left n) = (e, dsNameToName n)
f e (Right (n,cs)) = (e', dsNameToName n) where
e' = Case (Var $ dsNameToName n) [test e cs]
e' = Case (Var $ dsNameToName n) [branchToCore e cs]
-- | debug helper
runNames :: Eff '[State [PsName]] c -> c
runNames = runPureEff . evalState nameSupply
-- | debug tool
-- | debug helper
nameSupply :: [IdP RlpcPs]
nameSupply = [ T.pack $ "$x_" <> show n | n <- [0..] ]