functor-combo 0.3.1 → 0.3.3
raw patch · 3 files changed
+24/−9 lines, 3 files
Files
- functor-combo.cabal +1/−1
- src/FunctorCombo/Pair.hs +4/−2
- src/FunctorCombo/StrictMemo.hs +19/−6
functor-combo.cabal view
@@ -1,5 +1,5 @@ Name: functor-combo-Version: 0.3.1+Version: 0.3.3 Cabal-Version: >= 1.6 Synopsis: Functor combinators with tries & zippers Category: Data
src/FunctorCombo/Pair.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE DeriveFunctor #-}+{-# LANGUAGE DeriveFunctor, DeriveDataTypeable #-} {-# LANGUAGE TypeOperators, TypeFamilies #-} {-# OPTIONS_GHC -Wall #-} @@ -31,6 +31,8 @@ import Data.Foldable (Foldable(..)) import Data.Traversable (Traversable(..)) import Control.Applicative (Applicative(..),liftA2)+import Data.Typeable (Typeable)+import Data.Data (Data) import FunctorCombo.Functor import FunctorCombo.ParScan@@ -41,7 +43,7 @@ infixl 1 :# -- | Uniform pairs-data Pair a = a :# a deriving (Functor,Eq,Show)+data Pair a = a :# a deriving (Functor,Eq,Show,Typeable,Data) -- Interpreting Pair a as Bool -> a or as Vec2 a, the instances follow -- inevitably from the principle of type class morphisms.
src/FunctorCombo/StrictMemo.hs view
@@ -2,8 +2,11 @@ , FlexibleContexts, DeriveFunctor, StandaloneDeriving , GADTs #-}-{-# OPTIONS_GHC -Wall -fno-warn-orphans #-}-{-# OPTIONS_GHC -fno-warn-unused-binds -fno-warn-unused-imports #-} -- temporary while testing++{-# OPTIONS_GHC -Wall -fno-warn-orphans #-}+{-# OPTIONS_GHC -fno-warn-unused-binds #-} -- TEMP+-- {-# OPTIONS_GHC -fno-warn-unused-imports #-} -- TEMP+ ---------------------------------------------------------------------- -- | -- Module : FunctorCombo.StrictMemo@@ -25,16 +28,17 @@ ) where import Data.Functor ((<$>))-import Data.Foldable (Foldable,toList)+import Data.Foldable (Foldable(..),toList)+import Data.Traversable (Traversable(..)) import Control.Applicative (Applicative(..),liftA2)-import Control.Arrow (first)+-- import Control.Arrow (first) -import Data.Tree+-- import Data.Tree import qualified Data.IntTrie as IT -- data-inttrie import Data.Tree -import Control.Compose (result,(<~)) -- TypeCompose+-- import Control.Compose (result,(<~)) -- TypeCompose import TypeUnary.Vec (Z,S,Vec(..),IsNat(..),Nat(..)) @@ -506,6 +510,15 @@ pureV :: Applicative (Trie k) => Nat n -> a -> TrieTree n k a pureV Zero = L pureV (Succ n) = B . pure . pureV n++instance Foldable (Trie k) => Foldable (TrieTree n k) where+ foldMap f (L a) = f a+ foldMap f (B ts) = (foldMap.foldMap) f ts++instance (Functor (Trie k), Foldable (Trie k), Traversable (Trie k)) =>+ Traversable (TrieTree n k) where+ traverse f (L a) = L <$> f a+ traverse f (B ts) = B <$> (traverse.traverse) f ts instance (HasTrie k, Functor (Trie k), IsNat n) => HasTrie (Vec n k) where type Trie (Vec n k) = TrieTree n k