diff --git a/Data/Static.hs b/Data/Static.hs index 139a180..4ebfdf4 100644 --- a/Data/Static.hs +++ b/Data/Static.hs @@ -43,4 +43,25 @@ instance StaticElement (Maybe Char) where else Just (chr (I# (word2Int# v))) ) gen Nothing = gen (-1::Word32) - gen (Just c) = gen (fromIntegral (ord c)::Word32) \ No newline at end of file + gen (Just c) = gen (fromIntegral (ord c)::Word32) + +instance StaticElement a => StaticElement (a,a) where + extract addr i = let x1 = extract addr (i *# 2#) + x2 = extract addr (i *# 2# +# 1#) + in (x1,x2) + gen (x1,x2) = gen x1 ++ gen x2 + +instance StaticElement a => StaticElement (a,a,a) where + extract addr i = let x1 = extract addr (i *# 3#) + x2 = extract addr (i *# 3# +# 1#) + x3 = extract addr (i *# 3# +# 2#) + in (x1,x2,x3) + gen (x1,x2,x3) = gen x1 ++ gen x2 ++ gen x3 + +instance StaticElement a => StaticElement (a,a,a,a) where + extract addr i = let x1 = extract addr (i *# 4#) + x2 = extract addr (i *# 4# +# 1#) + x3 = extract addr (i *# 4# +# 2#) + x4 = extract addr (i *# 4# +# 3#) + in (x1,x2,x3,x4) + gen (x1,x2,x3,x4) = gen x1 ++ gen x2 ++ gen x3 ++ gen x4 \ No newline at end of file diff --git a/Setup.hs b/Setup.hs index 75dba6f..de719e6 100644 --- a/Setup.hs +++ b/Setup.hs @@ -5,8 +5,9 @@ import Data.Encoding.Preprocessor.Mapping import Data.Encoding.Preprocessor.XMLMappingBuilder main = defaultMainWithHooks (simpleUserHooks - {hookedPreProcessors = ("mapping",\_ _ -> mappingPreprocessor) - :("mapping2",\_ _ -> mappingPreprocessor) - :("xml",\_ _ -> xmlPreprocessor) - :(hookedPreProcessors simpleUserHooks) + {hookedPreProcessors = (("mapping",\_ _ -> mappingPreprocessor) + :("mapping2",\_ _ -> mappingPreprocessor) + :("xml",\_ _ -> xmlPreprocessor) + :(hookedPreProcessors simpleUserHooks) + ) })