@@ -158,6 +158,7 @@ strongNormalize' original = do
158
158
ExpressionApplication app -> goApp app
159
159
ExpressionLiteral {} -> return e
160
160
ExpressionHole h -> goHole h
161
+ ExpressionNatural n -> goNatural n
161
162
ExpressionInstanceHole h -> goInstanceHole h
162
163
ExpressionUniverse {} -> return e
163
164
ExpressionFunction f -> ExpressionFunction <$> goFunction f
@@ -169,6 +170,11 @@ strongNormalize' original = do
169
170
-- TODO it should normalize like an applied lambda
170
171
ExpressionCase c -> return (ExpressionCase c)
171
172
173
+ goNatural :: BuiltinNatural -> Sem r Expression
174
+ goNatural n = case squashBuiltinNatural n of
175
+ Left m -> ExpressionNatural <$> traverseOf builtinNaturalArg go m
176
+ Right e -> go e
177
+
172
178
goLet :: Let -> Sem r Let
173
179
goLet Let {.. } = do
174
180
clauses' <- mapM goLetClause _letClauses
@@ -268,6 +274,7 @@ weakNormalize' = go
268
274
ExpressionIden i -> goIden i
269
275
ExpressionHole h -> goHole h
270
276
ExpressionInstanceHole h -> goInstanceHole h
277
+ ExpressionNatural h -> goNatural h
271
278
ExpressionApplication a -> goApp a
272
279
ExpressionLiteral {} -> return e
273
280
ExpressionUniverse {} -> return e
@@ -276,6 +283,12 @@ weakNormalize' = go
276
283
ExpressionLambda {} -> return e
277
284
ExpressionLet {} -> return e
278
285
ExpressionCase {} -> return e
286
+
287
+ goNatural :: BuiltinNatural -> Sem r Expression
288
+ goNatural n = return $ case squashBuiltinNatural n of
289
+ Left m -> ExpressionNatural m
290
+ Right e -> e
291
+
279
292
goIden :: Iden -> Sem r Expression
280
293
goIden i = case i of
281
294
IdenFunction f -> do
@@ -383,13 +396,16 @@ runInferenceState inis = reinterpret (runState inis) $ \case
383
396
(ExpressionUniverse u, ExpressionUniverse u') -> check (u == u')
384
397
(ExpressionSimpleLambda a, ExpressionSimpleLambda b) -> goSimpleLambda a b
385
398
(ExpressionLambda a, ExpressionLambda b) -> goLambda a b
399
+ (ExpressionNatural a, ExpressionNatural b) -> goNatural a b
386
400
(ExpressionHole h, a) -> goHole h a
387
401
(a, ExpressionHole h) -> goHole h a
388
402
(_, ExpressionLet r) -> go normA (r ^. letExpression)
389
403
(ExpressionLiteral l, ExpressionLiteral l') -> check (l == l')
390
404
(ExpressionLiteral l, ExpressionApplication a) -> goUnaryNatLiteral l a
391
405
(ExpressionApplication a, ExpressionLiteral l) -> goUnaryNatLiteral l a
392
406
(ExpressionLet l, _) -> go (l ^. letExpression) normB
407
+ (ExpressionNatural {}, _) -> err
408
+ (_, ExpressionNatural {}) -> err
393
409
(ExpressionInstanceHole {}, _) -> err
394
410
(_, ExpressionInstanceHole {}) -> err
395
411
(ExpressionSimpleLambda {}, _) -> err
@@ -447,6 +463,11 @@ runInferenceState inis = reinterpret (runState inis) $ \case
447
463
failWhen (num1 /= num2)
448
464
inject ok
449
465
466
+ goNatural :: BuiltinNatural -> BuiltinNatural -> Sem r (Maybe MatchError )
467
+ goNatural a b
468
+ | a ^. builtinNaturalSuc == b ^. builtinNaturalSuc = go (a ^. builtinNaturalArg) (b ^. builtinNaturalArg)
469
+ | otherwise = err
470
+
450
471
goHole :: Hole -> Expression -> Sem r (Maybe MatchError )
451
472
goHole h t = do
452
473
r <- queryMetavar' h
0 commit comments