Opened 5 years ago

Closed 5 years ago

#7217 closed bug (wontfix)

Unification of type variables in constraints

Reported by: sjoerd_visscher Owned by:
Priority: normal Milestone:
Component: Compiler Version: 7.6.1-rc1
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: None/Unknown Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


The following code works:

{-# LANGUAGE RankNTypes, ConstraintKinds, KindSignatures, GADTs #-}

import Data.Monoid
import GHC.Prim (Constraint)

data Dict :: Constraint -> * where
  Dict :: a => Dict a

f :: (c (), c String) => (forall a. Dict (c a) -> a) -> ((), String)
f g = (g Dict, g Dict)

test :: ((), String)
test = f g
    g :: Dict (Monoid a) -> a
    g Dict = mempty

But this doesn't:

f :: (c (), c String) => (forall a. c a => a) -> ((), String)
f g = (g, g)

test :: ((), String)
test = f g
    g :: Monoid a => a
    g = mempty

With the errors:

Could not deduce (c0 String, c0 ()) arising from a use of `f'

Could not deduce (Monoid a) arising from a use of `g'

So it seems that type variables in constraints are not unified. At first I thought this might not be easy to fix, but since there's a workaround I guess it should be possible.

Change History (1)

comment:1 Changed 5 years ago by sjoerd_visscher

Resolution: wontfix
Status: newclosed

On second thought, it is perfect as it is.

Note: See TracTickets for help on using tickets.