haskell: finish template-haskell deriving implement

This commit is contained in:
tanakh
2010-09-24 01:24:13 +09:00
parent 6aa196cf55
commit 93bed9c5df
4 changed files with 75 additions and 19 deletions

View File

@@ -10,6 +10,13 @@ data T
$(deriveObject ''T)
data U
= C { c1 :: Int, c2 :: String }
| D { d1 :: Double }
deriving (Show)
$(deriveObject ''U)
main = do
let bs = pack $ A 123 "hoge"
print bs
@@ -17,3 +24,22 @@ main = do
let cs = pack $ B 3.14
print cs
print (unpack cs :: T)
let oa = toObject $ A 123 "hoge"
print oa
print (fromObject oa :: T)
let ob = toObject $ B 3.14
print ob
print (fromObject ob :: T)
let ds = pack $ C 123 "hoge"
print ds
print (unpack ds :: U)
let es = pack $ D 3.14
print es
print (unpack es :: U)
let oc = toObject $ C 123 "hoge"
print oc
print (fromObject oc :: U)
let od = toObject $ D 3.14
print od
print (fromObject od :: U)