1{-# OPTIONS -fglasgow-exts #-} 2 3module Labels (tests) where 4 5-- This module tests availability of field labels. 6 7import Test.HUnit 8 9import Data.Generics 10 11-- A datatype without labels 12data NoLabels = NoLabels Int Float 13 deriving (Typeable, Data) 14 15-- A datatype with labels 16data YesLabels = YesLabels { myint :: Int 17 , myfloat :: Float 18 } 19 deriving (Typeable, Data) 20 21-- Test terms 22noLabels = NoLabels 42 3.14 23yesLabels = YesLabels 42 3.14 24 25-- Main function for testing 26tests = ( constrFields $ toConstr noLabels 27 , constrFields $ toConstr yesLabels 28 ) ~=? output 29 30output = ([],["myint","myfloat"]) 31