Skip to content
Discussion options

You must be logged in to vote

If you do

import Effectful
import Effectful.Dispatch.Dynamic
import Effectful.State.Static.Local

data View v :: Effect where
  View :: View v m v
type instance DispatchOf (View v) = Dynamic

viewState :: State s :> es => Eff (View s : es) a -> Eff es a
viewState = interpret_ $ \View -> get

then you can use View directly (as you said). Defining a MonadReader instance is possible with

instance (View v :> es, MonadReader v (Eff es)) => MonadReader v (Eff es) where
  ask = send View

Note that it doesn't mention State. But it's a bad idea, since

  1. It's the only instance of MonadReader for (Eff es) that can be defined.
  2. It doesn't work very well with MonadReader's fundeps (hence the hack of putt…

Replies: 2 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by sirrus233
Comment options

You must be logged in to vote
5 replies
@arybczak
Comment options

@sirrus233
Comment options

@arybczak
Comment options

@sirrus233
Comment options

@arybczak
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants