Say I have a function (it doesn't have any practical application, just an academic interest, thus weird way to write it, with monoids, applicative functors and fixpoint combinators)
f :: Num a => a -> Sum a
f = fix ((<>) <$> Sum <*>)
It typechecks, but I can't be sure it does what it is expected to do before I can test it.
How would one go about testing and/or debugging it? I mean something like seeing the result after several iterations like it is possible with take 10 [1..]
.
I know a little about simple debugging facilities of ghci
like :break
and :step
, but it steps into non-terminating calculation so I can't inspect anything (it's even problematic to ^C
it). And I can't figure how to use trace
from Debug
module in this function either.
Any pointers would be appreciated.