Reflection functional dependency as an associated type?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Reflection functional dependency as an associated type?

Brandon Moore-2
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
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Reflection functional dependency as an associated type?

Richard Eisenberg-2
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 <[hidden email]> wrote:

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
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe