blob: 93a86c8deebb833b94e13256960f90091174ffb5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
{-# LANGUAGE TemplateHaskell #-}
module THA where
import Language.Haskell.TH
import Control.Monad (when)
th_a :: DecsQ
th_a = do
when (show (StrictConstructor1 123 True 4567) /= "StrictConstructor1 123 True 4567") $ error "TH validation error"
when (show (StrictConstructor2 123 True 4567) /= "StrictConstructor2 123 True 4567") $ error "TH validation error"
when (show (StrictConstructor3 123 True 4567) /= "StrictConstructor3 123 True 4567") $ error "TH validation error"
when (show (classMethod 'z') /= "True") $ error "TH validation error"
when (show (classMethod 'a') /= "False") $ error "TH validation error"
[d| a = () |]
data StrictType1 = StrictConstructor1 !Int !Bool Int deriving Show
data StrictType2 = StrictConstructor2 !Int !Bool !Int deriving Show
data StrictType3 = StrictConstructor3 !Int !Bool !Int deriving Show
class SingleMethodClass a where
classMethod :: a -> Bool
instance SingleMethodClass Char where
classMethod = (== 'z')
|