mirror of
https://github.com/rgleichman/glance.git
synced 2024-09-11 15:05:41 +03:00
As patterns translated.
This commit is contained in:
parent
ea99c9bfe4
commit
f886a945e5
@ -20,6 +20,10 @@ import Translate(translateString, drawingsFromModule)
|
||||
-- Test reference lookup in case rhs.
|
||||
-- Have the file be a command line argument to main.
|
||||
-- In evalPatBind, give the edge from the rhs to the pattern a special arrowhead.
|
||||
-- Use GraphViz circles to represent rotateable icons.
|
||||
-- Line intersections should have a small circle. This could probably be done with
|
||||
-- a line ending.
|
||||
-- Move tests out of main.
|
||||
|
||||
-- TODO Later --
|
||||
-- Add function name and type to LambdaIcons.
|
||||
@ -311,7 +315,9 @@ patternTests = [
|
||||
"y = let F x y = g in x y",
|
||||
"F x = g x",
|
||||
"Foo (Bar x) (Baz y) = f 1 2 x y",
|
||||
"Foo x y = f 1 y x"
|
||||
"Foo x y = f 1 y x",
|
||||
"t@(x,y) = (x,y)",
|
||||
"y = let {t@(_,_) = (3,4)} in t + 3"
|
||||
]
|
||||
|
||||
lambdaTests = [
|
||||
|
@ -57,6 +57,14 @@ evalPLit :: Exts.Sign -> Exts.Literal -> State IDState (IconGraph, NameAndPort)
|
||||
evalPLit Exts.Signless l = evalLit l
|
||||
evalPLit Exts.Negative l = makeBox ('-' : showLiteral l)
|
||||
|
||||
evalPAsPat :: Name -> Pat -> State IDState GraphAndRef
|
||||
evalPAsPat n p = do
|
||||
(evaledPatGraph, evaledPatRef) <- evalPattern p
|
||||
let
|
||||
newBind = [(nameToString n, evaledPatRef)]
|
||||
newGraph = mempty{igBindings = newBind}
|
||||
pure (newGraph <> evaledPatGraph, evaledPatRef)
|
||||
|
||||
evalPattern :: Pat -> State IDState GraphAndRef
|
||||
evalPattern p = case p of
|
||||
PVar n -> pure (mempty, Left $ nameToString n)
|
||||
@ -65,7 +73,10 @@ evalPattern p = case p of
|
||||
-- TODO special tuple handling.
|
||||
PTuple _ patterns -> fmap Right <$> evalPApp (Exts.UnQual $ Ident "(,)") patterns
|
||||
PParen pat -> evalPattern pat
|
||||
PAsPat n subPat -> evalPAsPat n subPat
|
||||
PWildCard -> fmap Right <$> makeBox "_"
|
||||
_ -> error $ "evalPattern: No pattern in case for " ++ show p
|
||||
-- TODO: Other cases
|
||||
|
||||
--TODO: Consider making this have unique values.
|
||||
evalQName :: QName -> EvalContext -> State IDState (IconGraph, Reference)
|
||||
|
Loading…
Reference in New Issue
Block a user