Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. COI had no idea the Identity monad existed, and it looks like it's what I'm trying to get at. However, as I said while commenting Reid Barton's post, the idea behind creating this new monad and monad transformer is to hide the State monad from the user. How can I achieve this using what you stated in your message ?
      singulars
    2. CO@CharlieP: The problem is that StateT sandwiches the underlying monad in between the s -> and (a, s), while your attempted transformer failed to do that. If you prefer, you can choose to derive Monad (or even MonadState EInfo) for the newtype that Alasdair provided as well, but without using StateT or hand coding its equivalent you won't be able to use your monad as a transformer. Expanding the definition of StateT yields newtype RuntimeT m a = RuntimeT { unRuntimeT :: EInfo -> m (a, EInfo) } but your definition yields newtype RuntimeT m a = RuntimeT { unRuntimeT :: m (EInfo -> (a, EInfo)) }
      singulars
    3. COCharlie, you'd typically use Haskell's module system to hide the implementation details of `RuntimeT`. Provided you don't export `unR` or `R` the user need never know you used `StateT`. For example, you'll probably want a `runStateT` equivalent for `RuntimeT` - that can be implemented as `runRuntimeT = runStateT . unR`. Note it's type `RuntimeT m a -> EInfo -> m (a, EInfo)`. `StateT` doesn't appear anywhere, and somebody using this function can use it while being blissfully unaware of `StateT`'s existence. Similar functions can be written for get/put. Hope that helps.
      singulars
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload