Reflection functional dependency as an associated type?

I was trying to make a bridge like this class MonadStateTF m where type StateOf m :: *instance (MonadState s m) => MonadStateTF m where type StateOF m = s to allow writing constraints on state monads without a dangling type parameter type NumMonad m = (MonadStateTF m, Num (StateOf m)) Unfortunately, the declaration type StateOF m = s complains that "s" isn't mentioned on the left hand side rather than somehow making use of the fundep. Brandon

Type families and functional dependencies play very poorly together. The internal GHC mechanisms to implement them are basically entirely separate, so I'm not surprised that this fails. I do think that what you want is type-safe, but just not supported right now.
Richard
On Oct 1, 2014, at 6:14 PM, Brandon Moore
I was trying to make a bridge like this
class MonadStateTF m where type StateOf m :: * instance (MonadState s m) => MonadStateTF m where type StateOF m = s
to allow writing constraints on state monads without a dangling type parameter type NumMonad m = (MonadStateTF m, Num (StateOf m))
Unfortunately, the declaration type StateOF m = s complains that "s" isn't mentioned on the left hand side rather than somehow making use of the fundep.
Brandon _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
participants (2)
-
Brandon Moore
-
Richard Eisenberg