packages feed

MemoTrie 0.4.1 → 0.4.2

raw patch · 2 files changed

+40/−15 lines, 2 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Data.MemoTrie: inTrie :: (HasTrie a, HasTrie c) => ((a -> b) -> (c -> d)) -> ((a :->: b) -> (c :->: d))
+ Data.MemoTrie: inTrie2 :: (HasTrie a, HasTrie c, HasTrie e) => ((a -> b) -> (c -> d) -> (e -> f)) -> ((a :->: b) -> (c :->: d) -> (e :->: f))
+ Data.MemoTrie: inTrie3 :: (HasTrie a, HasTrie c, HasTrie e, HasTrie g) => ((a -> b) -> (c -> d) -> (e -> f) -> (g -> h)) -> ((a :->: b) -> (c :->: d) -> (e :->: f) -> (g :->: h))

Files

MemoTrie.cabal view
@@ -1,5 +1,5 @@ Name:                MemoTrie-Version:             0.4.1+Version:             0.4.2 Cabal-Version:       >= 1.2 Synopsis:            Trie-based memo functions Category:            Data@@ -8,9 +8,6 @@   using tries.  It's based on some code I got from Spencer Janssen.   .   Project wiki page: <http://haskell.org/haskellwiki/MemoTrie>-  .-  The module documentation pages have links to colorized source code and-  to wiki pages where you can read and contribute user comments.  Enjoy!   .   &#169; 2008 by Conal Elliott; BSD3 license. Author:              Conal Elliott 
src/Data/MemoTrie.hs view
@@ -19,6 +19,7 @@ module Data.MemoTrie   ( HasTrie(..)   , memo, memo2, memo3, mup+  , inTrie, inTrie2, inTrie3   -- , untrieBits   ) where @@ -70,7 +71,25 @@ memo2 = mup memo memo3 = mup memo2 +-- | Apply a unary function inside of a trie+inTrie :: (HasTrie a, HasTrie c) =>+          ((a  ->  b) -> (c  ->  d))+       -> ((a :->: b) -> (c :->: d))+inTrie = untrie ~> trie +-- | Apply a binary function inside of a trie+inTrie2 :: (HasTrie a, HasTrie c, HasTrie e) =>+           ((a  ->  b) -> (c  ->  d) -> (e  ->  f))+        -> ((a :->: b) -> (c :->: d) -> (e :->: f))+inTrie2 = untrie ~> inTrie++-- | Apply a ternary function inside of a trie+inTrie3 :: (HasTrie a, HasTrie c, HasTrie e, HasTrie g) =>+           ((a  ->  b) -> (c  ->  d) -> (e  ->  f) -> (g  ->  h))+        -> ((a :->: b) -> (c :->: d) -> (e :->: f) -> (g :->: h))+inTrie3 = untrie ~> inTrie2++ ---- Instances  instance HasTrie () where@@ -299,27 +318,27 @@ -}  instance (HasTrie a, Monoid b) => Monoid (a :->: b) where-  mempty        = trie mempty-  s `mappend` t = trie (untrie s `mappend` untrie t)+  mempty  = trie mempty+  mappend = inTrie2 mappend  instance HasTrie a => Functor ((:->:) a) where-  fmap f t      = trie (fmap f (untrie t))+  fmap f = inTrie (fmap f)  instance HasTrie a => Applicative ((:->:) a) where-  pure b        = trie (pure b)-  tf <*> tx     = trie (untrie tf <*> untrie tx)+  pure b = trie (pure b)+  (<*>)  = inTrie2 (<*>)  instance HasTrie a => Monad ((:->:) a) where-  return a      = trie (return a)-  u >>= k       = trie (untrie u >>= untrie . k)+  return a = trie (return a)+  u >>= k  = trie (untrie u >>= untrie . k)  -- instance Category (:->:) where---   id            = trie id---   s . t         = trie (untrie s . untrie t)+--   id  = trie id+--   (.) = inTrie2 (.)  -- instance Arrow (:->:) where---   arr f         = trie (arr f)---   first t       = trie (first (untrie t))+--   arr f = trie (arr f)+--   first = inTrie first  {- @@ -331,3 +350,12 @@ type.  -}+++---- To go elsewhere++-- Matt Hellige's notation for @argument f . result g@.+-- <http://matt.immute.net/content/pointless-fun>++(~>) :: (a' -> a) -> (b -> b') -> ((a -> b) -> (a' -> b'))+g ~> f = (f .) . (. g)