okeuday_bak 2017-03-06 13:04:43
isn't it possible to have something like: let x = do { .,... multiple lines .... } in x ?
Koterpillar 2017-03-06 13:05:11
okeuday_bak: yes, separate "lines" with ;
centril 2017-03-06 13:05:20
okeuday_bak: seems awfully redundant tho
ski 2017-03-06 13:05:26
(s/lines/commands/)
ski 2017-03-06 13:05:54
if you use layout, then you don't need `;'s there
okeuday_bak 2017-03-06 13:06:52
ski: k
ski 2017-03-06 13:07:31
note that the body of the `do' must be indented more than `x' in that case
glguy 2017-03-06 13:07:41
I'm just wondering what that comma is going hiding amongst all those periods
okeuday_bak 2017-03-06 13:15:25
centril: yes, that is what I was attempting to do
centril 2017-03-06 13:16:22
okeuday_bak: OK, so the shape of your computation is similar to: WriterT (Except Err) ()
okeuday_bak 2017-03-06 13:17:15
centril: I wasn't sure how the Writer monad really works, the PutM type takes something, but Put sets it as (), so just not sure how PutM a uses a
centril 2017-03-06 13:17:16
oh wait...
okeuday_bak 2017-03-06 13:17:45
centril: I had expected that to be a detail related to being a Writer monad that is just merging pairs of things
centril 2017-03-06 13:17:49
okeuday_bak: the result is in the "writer" part of the monoid
centril 2017-03-06 13:19:46
okeuday_bak: unfortunately, the PutM type has no corresponding transformer
okeuday_bak 2017-03-06 13:20:06
centril: yeah, I was expecting to have to use mtl to wrap an error, if Either couldn't be used here
centril 2017-03-06 13:20:06
so you have to build the MonadError interface + the functions already made for PutM over it
okeuday_bak 2017-03-06 13:20:46
and MonadError is https://hackage.haskell.org/package/mtl-2.2.1/docs/Control-Monad-Error-Class.html right?
centril 2017-03-06 13:21:11
okeuday_bak: Just say: newtype EPutM e a = EPutM { _runEPutM :: Either e (PutM a) }
centril 2017-03-06 13:21:23
okeuday_bak: that's correct
okeuday_bak 2017-03-06 13:22:03
centril: Ok, thanks, I probably should read more before doing more though
centril 2017-03-06 13:22:04
then you need to build a bunch of functions that work with EPutM now instead
okeuday_bak 2017-03-06 13:22:37
centril: so I basically will need all my own put functions for all the different bits I may write, right?
centril 2017-03-06 13:23:28
okeuday_bak: it is pretty straight forward... you can make a higher order function that does :: (a -> Put) -> (a -> EPutM ())
okeuday_bak 2017-03-06 13:23:41
centril: k, cool
okeuday_bak 2017-03-06 13:23:55
centril: thanks for the insight
centril 2017-03-06 13:25:30
call it: liftPut :: (a -> Put) -> (a -> EPutM ()) ; liftPut f = EPutM . pure . f ;
centril 2017-03-06 13:26:11
okeuday_bak: then just take every function of the form :: a -> Put , for some a... for example: putWord8
okeuday_bak 2017-03-06 13:27:15
centril: ok, thanks
centril 2017-03-06 13:27:20
yw =)