fromMaybe is working, but stuff feels a little messy/fragile
This commit is contained in:
@@ -48,8 +48,26 @@ length (Define env _) = S (length env)
|
||||
|
||||
lookup : Env -> Nat -> Maybe Val
|
||||
lookup (Define env v) Z = Just v
|
||||
lookup (Define env _) (S k) = Just (lookup env k)
|
||||
-- bug in unify? are the meta args backwards? It seems to quote back right..
|
||||
-- we're getting `Maybe Val` as meta3, and comparing:
|
||||
-- Maybe ?m3 =?= Maybe Val
|
||||
-- If I write "Just (lookup env k)" on RHS, it's wrong, but the error message is unusable (mainly due to FC)
|
||||
-- The FC is fine if I write lookup {Val} env k
|
||||
lookup (Define env _) (S k) = lookup env k
|
||||
lookup (ENil) x = Nothing
|
||||
|
||||
eval : Env -> Tm -> Val
|
||||
|
||||
cApp : Closure -> Val -> Val
|
||||
-- If I put Closure instead of MkClosure, it reports missing case, fix that (should be bad constructor or something)
|
||||
cApp (MkClosure env t) u = eval (Define env u) t
|
||||
|
||||
eval env (Var x) =
|
||||
case lookup env x of
|
||||
-- case doesn't use the new code. We've got a wildcard here that
|
||||
-- is forced to {Val}, but we don't have forcing/dotting
|
||||
-- I guess we see what Jesper says about dotting
|
||||
Just x => x
|
||||
|
||||
eval env (App t u) =
|
||||
let tv = eval env t
|
||||
tu = eval env u
|
||||
in ?
|
||||
|
||||
|
||||
25
newt/testcase3.newt
Normal file
25
newt/testcase3.newt
Normal file
@@ -0,0 +1,25 @@
|
||||
module Scratch2
|
||||
|
||||
data Nat : U where
|
||||
Z : Nat
|
||||
S : Nat -> Nat
|
||||
|
||||
data Maybe : U -> U where
|
||||
Just : {a : U} -> a -> Maybe a
|
||||
Nothing : {a : U} -> Maybe a
|
||||
|
||||
|
||||
-- failed to unify _:1 with Val
|
||||
-- Legit on RHS, IMO. On LHS, we should be dotting?
|
||||
-- I either need to unify and collect constraints or figure out how
|
||||
-- other systems manage this.
|
||||
|
||||
-- Note that an unused
|
||||
-- variable may stand for either a wildcard or a forced pattern. In the latter case our algorithm
|
||||
-- treats it as a let-bound variable in the right-hand side of the clause.
|
||||
|
||||
-- we need let-bound in environment but we do have define.
|
||||
|
||||
fromMaybe : Maybe Nat -> Nat
|
||||
fromMaybe (Just x) = x
|
||||
fromMaybe Nothing = Z
|
||||
Reference in New Issue
Block a user