haskell - How do I write a function which behaves differently depending on which monad is at the base of the transformer stack -
(at point more of puzzle i'd know how solve solution expect use in practice)
i'm trying write function rundebug
following specification: argument has type io ()
; return type (monad m) => m ()
; depending on m
, behaves in 1 of 2 different ways; if monadio m
, rundebug = liftio
, , otherwise rundebug = const (return ())
.
the approaches i've tried relied on type class like
class monaddebug m rundebug :: io () -> m ()
i've tried using monadbase
, , i've tried using monadio
overlapping instances, of them have run issues ambiguity.
i think works writing instances each transformer, i've been hoping avoid that.
write instances of monaddebug
each transformer , each base monad interested in supporting.
Comments
Post a Comment