<div dir="auto">On Mon, 19 Nov 2018 at 21:03, Olaf Klinke wrote:</div><div dir="auto"><br></div><div dir="auto">><span style="white-space:pre-wrap;background-color:rgb(255,255,255)">></span><i style="white-space:pre-wrap;background-color:rgb(255,255,255)"> The top-level story is that I am trying to create a monad that somehow</i></div><div dir="auto"><span style="white-space:pre-wrap;background-color:rgb(255,255,255)"><i>></i>></span><i style="white-space:pre-wrap;background-color:rgb(255,255,255)"> records the "intermediate steps" of computation.</i></div><div dir="auto"><span style="white-space:pre-wrap;background-color:rgb(255,255,255)">>></span></div><pre style="white-space:pre-wrap;background-color:rgb(255,255,255)"><div dir="auto">
> If it is only for knowing where things went wrong, ...</div><div dir="auto"><br></div><div dir="auto">Thanks Olaf, no I think Ducis wants to stack the whole history of the computation.</div><div dir="auto"><br></div><div dir="auto">> If ... Then you need to stack a state transformer on top,</div><div dir="auto"><br></div><div dir="auto">Yes a monad transformer might be it. Thank you for the example.</div><div dir="auto"><br></div><div dir="auto">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</div><div dir="auto"><br></div><div dir="auto"><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica;min-height:13.8px">nil = ()<span style="font-size:12pt"></span></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica;min-height:13.8px">cons x l = (x, l)</p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica;min-height:13.8px"><br></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica"><span style="font-size:12pt">start :: a -> (a,())</span></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica"><span style="font-size:12pt">start x = cons x nil            -- i.e. singleton x</span></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica;min-height:13.8px"><br><span style="font-size:12pt"></span></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica"><span style="font-size:12pt">infixl 0 $>></span></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica"><span style="font-size:12pt">($>>) :: (b, _a) -> (b -> c) -> (c, (b, _a))</span></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica"><span style="font-size:12pt">xs@(x, z) $>> f = cons (f x) xs</span></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica;min-height:13.8px"><br><span style="font-size:12pt"></span></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica;min-height:13.8px"><br></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica"><span style="font-size:12pt">eg = start 1 $>> (+ 1) $>> (+ 3) $>> double $>> show </span></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica"><span style="font-size:12pt"><br></span></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica"><span style="font-size:12pt">===> </span><span style="font-size:12pt">("10",(10,(5,(2,(1,())))))</span></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica"><span style="font-size:12pt"><br></span></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica"><span style="font-size:12pt">I chose ($>>) to be similar to ($>) from the Control.FPipe package "trivial F#-style pipes for function composition and application".</span></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica"><span style="font-size:12pt"><br></span></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica"><span style="font-size:12pt">You could use Datakind `'[]` instead of the 'poor man's heterogeneous list' I've used, but that seems over-engineering.</span></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica"><span style="font-size:12pt"><br></span></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica"><span style="font-size:12pt"><br></span></p><p style="margin:0px;font-size:12px;line-height:normal;font-family:Helvetica"><span style="font-size:12pt">AntC</span></p></div></pre>