Automatic HEq instances for members of an HList-Collection of common programming errors
There are several flavors of HList’s labels. You are trying to use your own ‘ATag’ and ‘BTag’ phantoms as labels. The HList flavor you are using expects its ‘HNat’ types as labels: ‘HZero’ and ‘HSucc *’.
You need to import one of the Data.HList.Label1 to Label5 modules. And you will need to choose a TypeEq flavor, and the TypeCast flavor to match the TypeEq flavor:
{-# LANGUAGE TypeOperators #-}
import Data.HList
import Data.HList.Label5
import Data.HList.TypeCastGeneric1
import Data.HList.TypeEqGeneric1
data ATag
data BTag
type TagList = ATag :*: BTag :*: HNil
bIndex :: Int
bIndex = hNat2Integral (hFind (undefined :: BTag) (undefined :: TagList))
The above works and give ‘bIndex’ the value 1.
Originally posted 2013-11-09 19:01:41.