[GHC] #5927: A type-level "implies" constraint on Constraints
GHC
ghc-devs at haskell.org
Thu Aug 18 19:49:15 UTC 2016
#5927: A type-level "implies" constraint on Constraints
-------------------------------------+-------------------------------------
Reporter: illissius | Owner:
Type: feature request | Status: new
Priority: normal | Milestone:
Component: Compiler (Type | Version: 7.4.1
checker) |
Resolution: | Keywords:
Operating System: Unknown/Multiple | Architecture:
| Unknown/Multiple
Type of failure: None/Unknown | Test Case:
Blocked By: | Blocking:
Related Tickets: | Differential Rev(s):
Wiki Page: |
-------------------------------------+-------------------------------------
Comment (by Iceland_jack):
Use case from [http://ozark.hendrix.edu/~yorgey/pub/twisted.pdf How to
Twist Pointers without Breaking Them]:
> {{{#!hs
> class Monoid m => Action m a where
> act :: m -> a -> a
> }}}
> ''[...]''
>
> We first formalise the action of monoids on functors. Intuitively, for a
monoid `m` to act on the functor `f`, it should act in a uniform way on
all the types `f a`. Therefore, we would like to assert a constraint
something like `forall a. Action m (f a)`. Unfortunately, Haskell does not
allow the use of universally quantified constraints and hence we need a
new type class.
>
> {{{#!hs
> class (Monoid m, Functor f) => ActionF m f where
> act' :: m -> f a -> f a
> }}}
--
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/5927#comment:18>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler
More information about the ghc-tickets
mailing list