I would like to write an object with the type signature:
genericFlip ::
( MonadReader (o (n c)) m
, MonadReader a n
, MonadReader b o
)
=> m (n (o c))
That is essentially a flip for monad readers.
Now it is easy enough to write the version of this that looks like:
genericFlip ::
( MonadReader (b -> a -> c) m
, MonadReader a n
, MonadReader b o
)
=> m (n (o c))
genericFlip = do
f <- ask
return $ do
a <- ask
return $ do
b <- ask
return $ f b a
Or even substitute (->) for Reader, but no matter how I wrack my brain I can't seem to make a definition that works for all readers.
Is it possible to make a total object that has this type signature in Haskell?
No. It's not possible.
There's nothing about the first signature that makes o traversable.