1 module Data.HList.String
7 import Data.HList.Prelude
8 import Language.Haskell.TH
9 import Language.Haskell.TH.Quote
10 import Types.Data.Num.Decimal.Literals.TH
11 import Types.Data.Num.Ops
18 instance IntegerT c => HString (HCons c s)
20 hString :: QuasiQuoter
21 hString = QuasiQuoter quoteStrExp quoteStrPat
23 quoteStrExp :: String -> ExpQ
24 quoteStrExp [] = varE (mkName "hNil")
25 quoteStrExp (c:cs) = appsE [ varE (mkName "hCons")
26 , decLiteralV (toInteger $ fromEnum c)
30 quoteStrPat :: String -> PatQ
31 quoteStrPat [] = varP (mkName "HNil")
32 quoteStrPat (c:cs) = conP (mkName "HCons")
33 [ sigP wildP (decLiteralT $ toInteger $ fromEnum c)