Commit cc4f1a94 authored by chak@cse.unsw.edu.au.'s avatar chak@cse.unsw.edu.au.
Browse files

Template Haskell: test for equality constraints

parent fa0e334b
......@@ -16,6 +16,6 @@ genAnyClass name decls
= DataD [] anyName [] [constructor] []
where
anyName = mkName ("Any" ++ nameBase name ++ "1111")
constructor = ForallC [var_a] [AppT (ConT name) (VarT var_a)] $
constructor = ForallC [var_a] [ClassP name [VarT var_a]] $
NormalC anyName [(NotStrict, VarT var_a)]
var_a = mkName "a"
{-# OPTIONS -fglasgow-exts #-}
{-# LANGUAGE TypeFamilies #-}
module TH_tf1 where
$( [d| data family T a |] )
......
{-# OPTIONS -fglasgow-exts #-}
module TH_tf2 where
{-# LANGUAGE TypeFamilies #-}
import Language.Haskell.TH
module TH_tf2 where
$( [d| class C a where
data T a
......
{-# LANGUAGE TypeFamilies, FlexibleInstances, UndecidableInstances #-}
module TH_tf3 where
type family T a
$( [d| foo :: T [a] ~ Bool => a -> a
foo x = x |] )
$( [d| class C a
instance a ~ Int => C a |] )
\ No newline at end of file
......@@ -135,3 +135,4 @@ test('TH_sections', normal, compile, ['-v0'])
test('TH_tf1', normal, compile, ['-v0'])
test('TH_tf2', normal, compile, ['-v0'])
test('TH_tf3', normal, compile, ['-v0'])
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment