X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Data%2FHList%2FString.hs;h=6d4d52ddfeba32fbaaad0c5488027a8ce81c1bd1;hb=57b97113a93d366f14278a12b8170a1c06e258a1;hp=bcec59c6d750ab623878087757d95302453fa7e3;hpb=4611522487b382b839a53e75e3feb2aac8764074;p=hs-rrdtool.git diff --git a/Data/HList/String.hs b/Data/HList/String.hs index bcec59c..6d4d52d 100644 --- a/Data/HList/String.hs +++ b/Data/HList/String.hs @@ -4,17 +4,24 @@ module Data.HList.String ) where -import Data.HList.Number import Data.HList.Prelude import Language.Haskell.TH import Language.Haskell.TH.Quote +import Types.Data.Num.Decimal.Literals.TH +import Types.Data.Num.Ops -class HString s +class (Show s, Eq s) => HString s instance HString HNil -instance HNat c => HString (HCons c s) +instance ( Show c + , Show s + , Eq c + , Eq s + , IntegerT c + ) + => HString (HCons c s) hString :: QuasiQuoter hString = QuasiQuoter quoteStrExp quoteStrPat @@ -22,12 +29,13 @@ hString = QuasiQuoter quoteStrExp quoteStrPat quoteStrExp :: String -> ExpQ quoteStrExp [] = varE (mkName "hNil") quoteStrExp (c:cs) = appsE [ varE (mkName "hCons") - , hNatLiteralE (fromEnum c) + , decLiteralV (toInteger $ fromEnum c) , quoteStrExp cs ] quoteStrPat :: String -> PatQ quoteStrPat [] = varP (mkName "HNil") -quoteStrPat (c:cs) = conP (mkName "HCons") [ hNatLiteralP (fromEnum c) - , quoteStrPat cs - ] +quoteStrPat (c:cs) = conP (mkName "HCons") + [ sigP wildP (decLiteralT $ toInteger $ fromEnum c) + , quoteStrPat cs + ]