T9569.hs 748 Bytes
Newer Older
1
{-# OPTIONS_GHC -fno-warn-redundant-constraints #-}
Simon Peyton Jones's avatar
Simon Peyton Jones committed
2 3 4
{-# LANGUAGE RankNTypes, ConstraintKinds, KindSignatures, DataKinds, TypeFamilies #-}
module T9569 where

5
import GHC.Exts
Simon Peyton Jones's avatar
Simon Peyton Jones committed
6 7 8 9 10 11 12 13

data Proxy (c :: Constraint)

class Deferrable (c :: Constraint) where
  defer :: Proxy c -> (c => a) -> a

deferPair :: (Deferrable c1, Deferrable c2) =>
                  Proxy (c1,c2) -> ((c1,c2) => a) -> a
14
deferPair _ _ = undefined
Simon Peyton Jones's avatar
Simon Peyton Jones committed
15 16 17 18 19 20 21 22 23 24 25

instance (Deferrable c1, Deferrable c2) => Deferrable (c1,c2) where
    -- defer p f = deferPair p f     -- Succeeds
    defer = deferPair                -- Fails

{-
  [G] Deferrable c1, Deferrable c2

  [W] Proxy (c1,c2) -> ((c1,c2) => a) -> a ~ Proxy (c1x,c2x) -> ((c1x,c2x) => ax) -> ax
  [w] Deferrable c1x
  [w] Deferrable c2x
26
-}