Skip to content

Commit bb490a7

Browse files
authored
Fix Natural/fold for GHCJS bindings (#985)
Fixes dhall-lang/dhall-lang#579 `Natural/fold` was misbehaving on GHCJS due to the use of `Natural` arithmetic (for some reason). This is a problem I've seen and fixed before, but needed to be fixed again after the migration to the new `Dhall.Eval` normalization engine. The fix is easy: use `Integer` instead of `Natural` for the accumulator of the fold and the bug disappears.
1 parent 3266260 commit bb490a7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

dhall/src/Dhall/Eval.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ eval !env t =
368368
VHLam (Typed "zero" natural) $ \zero ->
369369
let go !acc 0 = acc
370370
go acc n = go (vApp succ acc) (n - 1)
371-
in go zero n
371+
in go zero (fromIntegral n :: Integer)
372372
n ->
373373
VHLam (NaturalFoldCl n) $ \natural -> VPrim $ \succ -> VPrim $ \zero ->
374374
VNaturalFold n natural succ zero

0 commit comments

Comments
 (0)