Skip to content

Commit e615993

Browse files
authored
implement shortcut for more data types in Natural/fold (#2596)
1 parent 402fedc commit e615993

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

dhall/src/Dhall/Eval.hs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -529,11 +529,10 @@ eval !env t0 =
529529
-- https://github.com/ghcjs/ghcjs/issues/782
530530
go zero (fromIntegral n' :: Integer) where
531531
go !acc 0 = acc
532-
go (VNaturalLit x) m =
533-
case vApp succ (VNaturalLit x) of
534-
VNaturalLit y | x == y -> VNaturalLit x
535-
notNaturalLit -> go notNaturalLit (m - 1)
536-
go acc m = go (vApp succ acc) (m - 1)
532+
go acc m =
533+
-- Detect a shortcut: if succ acc == acc then return acc immediately.
534+
let next = vApp succ acc
535+
in if conv env next acc then acc else go next (m - 1)
537536
_ -> inert
538537
NaturalBuild ->
539538
VPrim $ \case

0 commit comments

Comments
 (0)