Can you just wrap it? Something like this:
-- put your monad type here
type M a = Iteratee ... a
data W a = W (Iteratee ... a) deriving Typeable
unW (W x) = x
toDynW :: Typeable a = M a - Dynamic
toDynW x = toDynamic (W x)
castM :: (Typeable x, Typeable a) = x - Maybe (M a)
castM = unW . cast
One can do something a bit shorter
instance (Typeable a, Typeable1 m) = Typeable1 (Iteratee a m) where
typeOf1 i = mkTyConApp (mkTyCon Data.Enumerator.Iteratee)
[typeOf a, typeOf1 m]
where
(a,m) = peel i
peel :: Iteratee a m w - (a, m ())
peel = undefined
Is there any reasonable way to do this if I want to cast a monadic
value? For example:
castState :: (Typeable a, Typeable s, Typeable1 m, Typeable b) = a - Maybe
(StateT s m b)
castState = Data.Typeable.cast
None of the common monad transformers declare instances of Typeable,
so I don't know
On Tue, Feb 1, 2011 at 10:02 PM, John Millikin jmilli...@gmail.com wrote:
Is there any reasonable way to do this if I want to cast a monadic
value? For example:
castState :: (Typeable a, Typeable s, Typeable1 m, Typeable b) = a - Maybe
(StateT s m b)
castState = Data.Typeable.cast
None of
I would happily supply a patch to add the Typeable (and the few Data
instances that can be made) to transformers. I had to make similar ones in
my comonad-transformers package anyways.
-Edward Kmett
On Wed, Feb 2, 2011 at 1:02 AM, John Millikin jmilli...@gmail.com wrote:
Is there any