Skip to content

implement shortcut for more data types in Natural/fold #2596

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions dhall/src/Dhall/Eval.hs
Original file line number Diff line number Diff line change
Expand Up @@ -529,11 +529,10 @@ eval !env t0 =
-- https://github.com/ghcjs/ghcjs/issues/782
go zero (fromIntegral n' :: Integer) where
go !acc 0 = acc
go (VNaturalLit x) m =
case vApp succ (VNaturalLit x) of
VNaturalLit y | x == y -> VNaturalLit x
notNaturalLit -> go notNaturalLit (m - 1)
go acc m = go (vApp succ acc) (m - 1)
go acc m =
-- Detect a shortcut: if succ acc == acc then return acc immediately.
let next = vApp succ acc
in if conv env next acc then acc else go next (m - 1)
_ -> inert
NaturalBuild ->
VPrim $ \case
Expand Down