
On Mon, 19 Nov 2018 at 21:03, Olaf Klinke wrote:
* The top-level story is that I am trying to create a monad that somehow* *>*>* records the "intermediate steps" of computation.*
If it is only for knowing where things went wrong, ...
Thanks Olaf, no I think Ducis wants to stack the whole history of the computation.
If ... Then you need to stack a state transformer on top,
Yes a monad transformer might be it. Thank you for the example. As per my previous message, I'm not convinced it needs monads at all. Here's a dumb approach as a straw man, showing that type-changing steps are nothing special (or perhaps I mean type-preserving steps are nothing special ;-). Ducis could explain why this won't do nil = () cons x l = (x, l) start :: a -> (a,()) start x = cons x nil -- i.e. singleton x infixl 0 $>> ($>>) :: (b, _a) -> (b -> c) -> (c, (b, _a)) xs@(x, z) $>> f = cons (f x) xs eg = start 1 $>> (+ 1) $>> (+ 3) $>> double $>> show ===> ("10",(10,(5,(2,(1,()))))) I chose ($>>) to be similar to ($>) from the Control.FPipe package "trivial F#-style pipes for function composition and application". You could use Datakind `'[]` instead of the 'poor man's heterogeneous list' I've used, but that seems over-engineering. AntC