haskell - How best to type "Any monad transformer stack containing m" -
i'd write function
fixproxy :: (monad m, proxy p) => (b -> m b) -> b -> () -> p a' () b m r fixproxy f () = runidentityp $ v <- respond a' <- lift (f a) fixproxy f a' v
which works you'd think until try run proxy
>>> :t \g -> runrvart . runwritert . runproxy $ fixproxy g 0 >-> tolistd (num a, randomsource m s, monadrandom (writert [a] (rvart n)), data.random.lift.lift n m) => (a -> writert [a] (rvart n) a) -> s -> m (a, [a])
where use rvart
intentionally highlight existence of lift
class in rvar
. lift
represents existence of natural transformation n :~> m
ought encapsulate i'm looking for, function like:
fixproxy :: (monad m, monad n, lift m n, proxy p) => (b -> m b) -> b -> () -> p a' () b n r
is lift
right answer (which require many orphan instances) or there more standard natural transformation mptc use?
note practical solution, described in comments below, like
runrvart . runwritert . runproxy $ hoistk lift (fixproxy (const $ sample stduniform) 0) >-> tolistd
Comments
Post a Comment