Closed winitzki closed 2 weeks ago
/nix/store/l8j77jfvndani23bkp7kax82lsl4lh0c-binutils-2.35.2/bin/ranlib: dist/build/libHSdhall-1.42.1-C7GxurjhXWDFTD1LA7zHwI
-ghc8.10.7.a: No space left on device
I found one of the contributing factors to the disk issue: https://github.com/dhall-lang/dhall-lang/pull/1380
This is a continuation of https://github.com/dhall-lang/dhall-haskell/pull/2585
This PR implements a shortcut for Natural/fold for more data types. When the accumulator stops changing,
Natural/fold
should return immediately.First test: (This involves an accumulator of type
Natural
, which is already supported after the previous PR.)Second test shows a plausible use case: an integer division algorithm. Division proceeds by repeated subtraction, but we cannot know the required number of subtractions precisely. We know that to divide
x / y
we need no more thanx
subtractions.The accumulator has a more complicated type than just
Natural
. The implementation now requires us to be able to compareVal a
values of more complicated type.Please let me know how I can improve this Haskell code. I am new to Haskell.
What I did:
valEq
to compare twoVal a
values in case we can easily compare them (natural literals, record literals,Some()
, etc.)Natural/fold
: return immediately when the accumulator stops changingWhat I would like to do in addition to that:
Val