By stepwise doing all-your-base, I encountered that a Just [1] was expected but a Nothing got, while my code was only able to return Justs at that stage:
rebase :: Integral a => a -> a -> [a] -> Maybe [Integer]
rebase inputBase outputBase input =
let x = fromBase (toInteger inputBase) input
in Just [x]
fromBase :: Integral a => Integer -> [a] -> Integer
fromBase b = go 0
where
go !n [] = n
go !n (d:ds) = go (n * (toInteger b) + (toInteger d)) ds
And I got following test-output (only one out of many):
### Failure in: 20:both bases are negative
test\Tests.hs:25
expected: Just [1]
but got: Nothing
After changing all occurences of (~=?) with (~?=) in the test/Tests.hs I got a more appropriate output in the testrun:
### Failure in: 20:both bases are negative
test\Tests.hs:25
expected: Nothing
but got: Just [1]
By stepwise doing
all-your-base, I encountered that aJust [1]was expected but aNothinggot, while my code was only able to returnJusts at that stage:And I got following test-output (only one out of many):
After changing all occurences of
(~=?)with(~?=)in thetest/Tests.hsI got a more appropriate output in the testrun: