tidying
This commit is contained in:
@@ -87,6 +87,7 @@ library
|
|||||||
TypeFamilies
|
TypeFamilies
|
||||||
LambdaCase
|
LambdaCase
|
||||||
ViewPatterns
|
ViewPatterns
|
||||||
|
DataKinds
|
||||||
|
|
||||||
executable rlpc
|
executable rlpc
|
||||||
import: warnings
|
import: warnings
|
||||||
|
|||||||
@@ -116,19 +116,24 @@ conToRose (ConP cn as) = Fix . Branch cn <$> patToForrest `traverse` as
|
|||||||
|
|
||||||
getName = state $ fromJust . uncons @[IdP RlpcPs]
|
getName = state $ fromJust . uncons @[IdP RlpcPs]
|
||||||
|
|
||||||
test :: Expr' -> Branch Alter' -> Alter'
|
branchToCore :: Expr' -> Branch Alter' -> Alter'
|
||||||
test e (Branch cn as) = Alter (AltData cn) myBinds e'
|
branchToCore e (Branch cn as) = Alter (AltData cn) myBinds e'
|
||||||
where
|
where
|
||||||
|
-- gather binders for the /current/ pattern, and build an expression
|
||||||
|
-- matching subpatterns
|
||||||
(e', myBinds) = mapAccumL f e as
|
(e', myBinds) = mapAccumL f e as
|
||||||
|
|
||||||
f :: Expr' -> Tree Alter' -> (Expr', Name)
|
f :: Expr' -> Tree Alter' -> (Expr', Name)
|
||||||
f e (Left n) = (e, dsNameToName n)
|
f e (Left n) = (e, dsNameToName n)
|
||||||
f e (Right (n,cs)) = (e', dsNameToName n) where
|
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
|
runNames = runPureEff . evalState nameSupply
|
||||||
|
|
||||||
-- | debug tool
|
-- | debug helper
|
||||||
|
|
||||||
nameSupply :: [IdP RlpcPs]
|
nameSupply :: [IdP RlpcPs]
|
||||||
nameSupply = [ T.pack $ "$x_" <> show n | n <- [0..] ]
|
nameSupply = [ T.pack $ "$x_" <> show n | n <- [0..] ]
|
||||||
|
|||||||
Reference in New Issue
Block a user