summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouisWasserman <>2011-01-05 17:58:49 (GMT)
committerLuite Stegeman <luite@luite.com>2011-01-05 17:58:49 (GMT)
commite14aa5f3f373f152d218f7bcfff5e193f91003d2 (patch)
tree2bc69fe5406fb6b40f7f2ac83202722ba7870375
parenta64cb556648093364cd96b0bc485007fb1fc1ba6 (diff)
version 0.6.00.6.0
-rw-r--r--Data/TrieMap/MultiRec/Ord.hs4
-rw-r--r--Data/TrieMap/Regular/TH.hs35
-rw-r--r--Data/TrieMap/Rep/Instances.hs4
-rw-r--r--Data/TrieMap/Rep/TH.hs10
-rw-r--r--Data/TrieMap/Representation.hs8
-rw-r--r--TrieMap.cabal2
6 files changed, 21 insertions, 42 deletions
diff --git a/Data/TrieMap/MultiRec/Ord.hs b/Data/TrieMap/MultiRec/Ord.hs
index c41a288..74e3be4 100644
--- a/Data/TrieMap/MultiRec/Ord.hs
+++ b/Data/TrieMap/MultiRec/Ord.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE FlexibleInstances, TypeOperators, MultiParamTypeClasses, Rank2Types #-}
+{-# LANGUAGE FlexibleInstances, TypeOperators, MultiParamTypeClasses, Rank2Types, GADTs #-}
module Data.TrieMap.MultiRec.Ord where
@@ -98,4 +98,4 @@ instance HOrd phi U where
-- compareH0 pf (Tag a) (Tag b) = hcompare pf a b
--
-- instance HOrd phi f => HOrd0 phi (HFix f) where
--- compareH0 pf (HIn a) (HIn b) = hcompare pf a b \ No newline at end of file
+-- compareH0 pf (HIn a) (HIn b) = hcompare pf a b
diff --git a/Data/TrieMap/Regular/TH.hs b/Data/TrieMap/Regular/TH.hs
index a8fbc7f..071efd0 100644
--- a/Data/TrieMap/Regular/TH.hs
+++ b/Data/TrieMap/Regular/TH.hs
@@ -9,34 +9,13 @@ import Language.Haskell.TH
deriveM :: Q [Dec] -> Q [Dec]
deriveM decs = do
iT@(InstanceD cxt inst _:_) <- decs
- (InstanceD _ _ myDecs:_) <- [d|
- instance (TrieKeyT f m, Ord (f k), TrieKey k mm) => TrieKey (f k) (m k) where
- emptyM = emptyT
- nullM = nullT
- lookupM = lookupT
- lookupIxM = lookupIxT
- assocAtM = assocAtT
--- updateAtM = updateAtT
-
- alterM = alterT
- alterLookupM = alterLookupT
- traverseWithKeyM = traverseWithKeyT
- foldWithKeyM = foldWithKeyT
- foldlWithKeyM = foldlWithKeyT
- mapEitherM = mapEitherT
- splitLookupM = splitLookupT
- unionM = unionT
- isectM = isectT
- diffM = diffT
- extractM = extractT
--- extractMinM = extractMinT
--- extractMaxM = extractMaxT
--- alterMinM = alterMinT
--- alterMaxM = alterMaxT
- isSubmapM = isSubmapT
- fromListM = fromListT
- fromAscListM = fromAscListT
- fromDistAscListM = fromDistAscListT |]
+ let myDecs = zipWith (\ m t -> ValD (VarP m) (NormalB (VarE t)) [])
+ ['emptyM, 'nullM, 'lookupM, 'lookupIxM, 'assocAtM, 'alterM, 'alterLookupM, 'traverseWithKeyM,
+ 'foldWithKeyM, 'foldlWithKeyM, 'mapEitherM, 'splitLookupM, 'unionM, 'isectM, 'diffM, 'extractM,
+ 'isSubmapM, 'fromListM, 'fromAscListM, 'fromDistAscListM]
+ ['emptyT, 'nullT, 'lookupT, 'lookupIxT, 'assocAtT, 'alterT, 'alterLookupT, 'traverseWithKeyT,
+ 'foldWithKeyT, 'foldlWithKeyT, 'mapEitherT, 'splitLookupT, 'unionT, 'isectT, 'diffT, 'extractT,
+ 'isSubmapT, 'fromListT, 'fromAscListT, 'fromDistAscListT]
k <- mkVar "k"
let triekey = ConT ''TrieKey
let triemap = ConT ''TrieMap
diff --git a/Data/TrieMap/Rep/Instances.hs b/Data/TrieMap/Rep/Instances.hs
index 298ed96..3a7b1d7 100644
--- a/Data/TrieMap/Rep/Instances.hs
+++ b/Data/TrieMap/Rep/Instances.hs
@@ -251,10 +251,6 @@ instance Repr ISet.IntSet where
toRep = toRep . ISet.toList
fromRep = ISet.fromDistinctAscList . fromRep
-$(genRepT [d|
- instance ReprT IMap.IntMap where
- toRepTMap f m = List [(toRep k, f a) | (k, a) <- IMap.assocs m]
- fromRepTMap f (List xs) = IMap.fromDistinctAscList [(fromRep k, f a) | (k, a) <- xs] |])
type instance RepT Seq.Seq = []
type instance Rep (Seq.Seq a) = [Rep a]
diff --git a/Data/TrieMap/Rep/TH.hs b/Data/TrieMap/Rep/TH.hs
index 6901c92..42566ed 100644
--- a/Data/TrieMap/Rep/TH.hs
+++ b/Data/TrieMap/Rep/TH.hs
@@ -31,14 +31,10 @@ genRepT ff = do
genRepT :: Q [Dec] -> Q [Dec]
genRepT decs = do
iT@(InstanceD cxt (reprt `AppT` f) _:_) <- decs
- (InstanceD _ _ myDecs:_) <- [d|
- instance (ReprT f, Repr a) => Repr (f a) where
- toRep = toRepTMap toRep
- fromRep = fromRepTMap fromRep
- |]
+ let myDecs = [ValD (VarP 'toRep) (NormalB (AppE (VarE 'toRepTMap) (VarE 'toRep))) [],
+ ValD (VarP 'fromRep) (NormalB (AppE (VarE 'fromRepTMap) (VarE 'fromRep))) []]
a <- mkVar "a"
- repr <- conT ''Repr
- return (InstanceD (repr `AppT` a:cxt) (repr `AppT` (f `AppT` a)) myDecs :iT)
+ return (InstanceD (ClassP ''Repr [a]:cxt) (ConT ''Repr `AppT` (f `AppT` a)) myDecs :iT)
(~>) :: Type -> Type -> Type
a ~> b = AppT (AppT ArrowT a) b
diff --git a/Data/TrieMap/Representation.hs b/Data/TrieMap/Representation.hs
index 7f1d221..38df4c0 100644
--- a/Data/TrieMap/Representation.hs
+++ b/Data/TrieMap/Representation.hs
@@ -1,6 +1,14 @@
+{-# LANGUAGE TemplateHaskell, QuasiQuotes #-}
module Data.TrieMap.Representation (Repr(..), ReprT(..), Rep, RepT) where
import Data.TrieMap.Rep
import Data.TrieMap.Rep.Instances
+import Data.TrieMap.Rep.TH
import Data.TrieMap.Regular.Rep
+import Data.TrieMap.Regular.Base
+import qualified Data.IntMap as IMap
+$(genRepT [d|
+ instance ReprT IMap.IntMap where
+ toRepTMap f m = List [(toRep k, f a) | (k, a) <- IMap.assocs m]
+ fromRepTMap f (List xs) = IMap.fromDistinctAscList [(fromRep k, f a) | (k, a) <- xs] |]) \ No newline at end of file
diff --git a/TrieMap.cabal b/TrieMap.cabal
index 22439a9..4de5752 100644
--- a/TrieMap.cabal
+++ b/TrieMap.cabal
@@ -1,5 +1,5 @@
name: TrieMap
-version: 0.5.4
+version: 0.6.0
tested-with: GHC
category: Algorithms
synopsis: Automatic type inference of generalized tries.