PureScript beginner here.
I’m building a small PureScript/Node application and I’m trying to use the
ReaderT pattern which is also popular in Haskell and which is used in the excellent Halogen Real World Guide.
As I was going through the implementation of
AppM I noticed that the types didn’t really line up, at least no in my head.
I started by lining up the signature for the new
MonadAsk instance that we’re creating:
MonadAsk r m -- from Pursuit MonadAsk e AppM -- what we're building
m ~ AppM.
But the typed hole for
asks from gives me
(ReaderT Env Aff a). Since
asks :: MonadAsk r m => (r -> a) -> m a, I concluded that
asks from :: m a ?a :: ReaderT Env Aff a
m ~ ReaderT Env Aff. Now there are two options. Either I’ve kinda sorta understood how this works and the newtype being a newtype just “vanishes” and therefore the
MonadAsk e AppM is really equivalent to its content,
MonadAsk e ReaderT Env Aff or I have some really profound misunderstanding here.
Here’s the full snippet with hopefully all the required context.
newtype AppM a = AppM (ReaderT Env Aff a) instance monadAskAppM :: TypeEquals e Env => MonadAsk e AppM where ask :: AppM e ask = AppM $ (asks from :: ?a)