1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
{-# LANGUAGE ExplicitForAll #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeInType #-}
{-# LANGUAGE TypeApplications #-}
module ExplicitForAllRules1 where
import Data.Proxy
import Data.Kind
-- From Proposal 0007 (w/ fix to "example")
{-# RULES
"example" forall a b. forall. map @a @b f = f
"example2" forall a. forall (x :: a). id x = x
#-}
{-# NOINLINE f #-}
f :: a -> b
f = undefined
-- More tests
{-# RULES
"example3" forall (a :: Type -> Type) (b :: a Int) c. forall x y. g @(Proxy b) @(Proxy c) x y = ()
"example4" forall (a :: Bool) (b :: Proxy a). forall x. g @(Proxy b) @() x = id @()
"example5" forall (a :: Type). forall. h @a = id @a
"example5" forall k (c :: k). forall (x :: Proxy c). id @(Proxy c) x = x
#-}
{-# NOINLINE g #-}
g :: a -> b -> ()
g _ _ = ()
{-# NOINLINE h #-}
h :: a -> a
h x = x
-- Should NOT have a parse error :(
{-# RULES "example6" forall a forall. g a forall = () #-}
-- Should generate a warning
{-# RULES "example7" forall a b. forall (x :: a). id x = x #-}
|