packages feed

acc 0.1 → 0.1.0.1

raw patch · 4 files changed

+72/−72 lines, 4 filesdep ~base

Dependency ranges changed: base

Files

acc.cabal view
@@ -1,5 +1,5 @@ name: acc-version: 0.1+version: 0.1.0.1 synopsis: Sequence optimized for monoidal construction and folding description:   Data structure intended for accumulating a sequence of elements@@ -26,7 +26,7 @@  library   hs-source-dirs: library-  default-extensions: BangPatterns, BlockArguments, ConstraintKinds, DataKinds, DefaultSignatures, DeriveDataTypeable, DeriveFoldable, DeriveFunctor, DeriveGeneric, DeriveTraversable, DerivingVia, EmptyDataDecls, FlexibleContexts, FlexibleInstances, FunctionalDependencies, GADTs, GeneralizedNewtypeDeriving, InstanceSigs, LambdaCase, LiberalTypeSynonyms, MagicHash, MultiParamTypeClasses, MultiWayIf, NoImplicitPrelude, NoMonomorphismRestriction, OverloadedStrings, PatternGuards, ParallelListComp, QuasiQuotes, RankNTypes, RecordWildCards, ScopedTypeVariables, StandaloneDeriving, StrictData, TemplateHaskell, TupleSections, TypeApplications, TypeFamilies, TypeOperators, UnboxedTuples, ViewPatterns+  default-extensions: BangPatterns, ConstraintKinds, DataKinds, DefaultSignatures, DeriveDataTypeable, DeriveFoldable, DeriveFunctor, DeriveGeneric, DeriveTraversable, EmptyDataDecls, FlexibleContexts, FlexibleInstances, FunctionalDependencies, GADTs, GeneralizedNewtypeDeriving, InstanceSigs, LambdaCase, LiberalTypeSynonyms, MagicHash, MultiParamTypeClasses, MultiWayIf, NoImplicitPrelude, NoMonomorphismRestriction, OverloadedStrings, PatternGuards, ParallelListComp, QuasiQuotes, RankNTypes, RecordWildCards, ScopedTypeVariables, StandaloneDeriving, StrictData, TemplateHaskell, TupleSections, TypeApplications, TypeFamilies, TypeOperators, UnboxedTuples, ViewPatterns   default-language: Haskell2010   exposed-modules:     Acc@@ -34,14 +34,14 @@     Acc.BinTree1     Acc.Prelude   build-depends:-    base >=4.13 && <5,+    base >=4.11 && <5,     deepseq >=1.4.4 && <1.5  benchmark benchmark   type: exitcode-stdio-1.0   hs-source-dirs: benchmark   main-is: Main.hs-  default-extensions: BangPatterns, BlockArguments, ConstraintKinds, DataKinds, DefaultSignatures, DeriveDataTypeable, DeriveFoldable, DeriveFunctor, DeriveGeneric, DeriveTraversable, DerivingVia, EmptyDataDecls, FlexibleContexts, FlexibleInstances, FunctionalDependencies, GADTs, GeneralizedNewtypeDeriving, InstanceSigs, LambdaCase, LiberalTypeSynonyms, MagicHash, MultiParamTypeClasses, MultiWayIf, NoImplicitPrelude, NoMonomorphismRestriction, OverloadedStrings, PatternGuards, ParallelListComp, QuasiQuotes, RankNTypes, RecordWildCards, ScopedTypeVariables, StandaloneDeriving, StrictData, TemplateHaskell, TupleSections, TypeApplications, TypeFamilies, TypeOperators, UnboxedTuples, ViewPatterns+  default-extensions: BangPatterns, ConstraintKinds, DataKinds, DefaultSignatures, DeriveDataTypeable, DeriveFoldable, DeriveFunctor, DeriveGeneric, DeriveTraversable, EmptyDataDecls, FlexibleContexts, FlexibleInstances, FunctionalDependencies, GADTs, GeneralizedNewtypeDeriving, InstanceSigs, LambdaCase, LiberalTypeSynonyms, MagicHash, MultiParamTypeClasses, MultiWayIf, NoImplicitPrelude, NoMonomorphismRestriction, OverloadedStrings, PatternGuards, ParallelListComp, QuasiQuotes, RankNTypes, RecordWildCards, ScopedTypeVariables, StandaloneDeriving, StrictData, TemplateHaskell, TupleSections, TypeApplications, TypeFamilies, TypeOperators, UnboxedTuples, ViewPatterns   default-language: Haskell2010   ghc-options:     -O2@@ -57,7 +57,7 @@ test-suite test   type: exitcode-stdio-1.0   hs-source-dirs: test-  default-extensions: BangPatterns, BlockArguments, ConstraintKinds, DataKinds, DefaultSignatures, DeriveDataTypeable, DeriveFoldable, DeriveFunctor, DeriveGeneric, DeriveTraversable, DerivingVia, EmptyDataDecls, FlexibleContexts, FlexibleInstances, FunctionalDependencies, GADTs, GeneralizedNewtypeDeriving, InstanceSigs, LambdaCase, LiberalTypeSynonyms, MagicHash, MultiParamTypeClasses, MultiWayIf, NoImplicitPrelude, NoMonomorphismRestriction, OverloadedStrings, PatternGuards, ParallelListComp, QuasiQuotes, RankNTypes, RecordWildCards, ScopedTypeVariables, StandaloneDeriving, StrictData, TemplateHaskell, TupleSections, TypeApplications, TypeFamilies, TypeOperators, UnboxedTuples, ViewPatterns+  default-extensions: BangPatterns, ConstraintKinds, DataKinds, DefaultSignatures, DeriveDataTypeable, DeriveFoldable, DeriveFunctor, DeriveGeneric, DeriveTraversable, EmptyDataDecls, FlexibleContexts, FlexibleInstances, FunctionalDependencies, GADTs, GeneralizedNewtypeDeriving, InstanceSigs, LambdaCase, LiberalTypeSynonyms, MagicHash, MultiParamTypeClasses, MultiWayIf, NoImplicitPrelude, NoMonomorphismRestriction, OverloadedStrings, PatternGuards, ParallelListComp, QuasiQuotes, RankNTypes, RecordWildCards, ScopedTypeVariables, StandaloneDeriving, StrictData, TemplateHaskell, TupleSections, TypeApplications, TypeFamilies, TypeOperators, UnboxedTuples, ViewPatterns   default-language: Haskell2010   main-is: Main.hs   build-depends:
library/Acc.hs view
@@ -1,3 +1,4 @@+{-# LANGUAGE CPP #-} module Acc (   Acc,@@ -43,37 +44,45 @@   foldMap f =     \ case       TreeAcc a ->-        foldMap f a+        BinTree1.foldMap f a       EmptyAcc ->         mempty+#if MIN_VERSION_base(4,13,0)   foldMap' f =     \ case       TreeAcc a ->-        foldMap' f a+        BinTree1.foldMap' f a       EmptyAcc ->         mempty+#endif   foldr step acc =     \ case       TreeAcc a ->-        foldr step acc a+        BinTree1.foldr step acc a       EmptyAcc ->         acc   foldr' step acc =     \ case       TreeAcc a ->-        foldr' step acc a+        BinTree1.foldr' step acc a       EmptyAcc ->         acc   foldl' step acc =     \ case       TreeAcc a ->-        foldl' step acc a+        BinTree1.foldl' step acc a       EmptyAcc ->         acc   sum =     foldl' (+) 0 -deriving instance Traversable Acc+instance Traversable Acc where+  traverse f =+    \ case+      TreeAcc a ->+        TreeAcc <$> BinTree1.traverse f a+      EmptyAcc ->+        pure EmptyAcc  instance Applicative Acc where   pure =@@ -110,6 +119,8 @@ instance Monoid (Acc a) where   mempty =     empty+  mappend =+    (<>)  instance IsList (Acc a) where   type Item (Acc a) = a@@ -120,7 +131,7 @@   toList =     \ case       TreeAcc a ->-        foldr (:) [] a+        BinTree1.foldr (:) [] a       _ ->         [] 
library/Acc/BinTree1.hs view
@@ -4,15 +4,16 @@   foldM,   ap,   fromList1,-  foldMapDef,-  foldMapDef',-  foldrDef,-  foldrDef',-  foldlDef',+  foldMap,+  foldMap',+  foldr,+  foldr',+  foldl',+  traverse, ) where -import Acc.Prelude hiding (foldM, ap)+import Acc.Prelude hiding (ap, foldM, foldl', foldr, foldr', foldMap, foldMap', traverse) import qualified Acc.Prelude as Prelude  @@ -27,18 +28,6 @@  deriving instance Functor BinTree1 -instance Foldable BinTree1 where-  foldMap =-    foldMapDef-  foldMap' =-    foldMapDef'-  foldr =-    foldrDef-  foldr' =-    foldrDef'-  foldl' =-    foldlDef'- foldM :: Monad m => (a -> b -> m a) -> a -> BinTree1 b -> m a foldM step !acc =   \ case@@ -51,8 +40,8 @@     Leaf c -> step acc c >>= \ acc' -> foldM step acc' b     Branch c d -> foldMOnBranch step acc c (Branch d b) -foldrDef :: (a -> b -> b) -> b -> BinTree1 a -> b-foldrDef step acc =+foldr :: (a -> b -> b) -> b -> BinTree1 a -> b+foldr step acc =   \ case     Branch a b ->       foldrOnBranch step acc a b@@ -63,12 +52,12 @@ foldrOnBranch step acc a b =   case a of     Leaf c ->-      step c (foldrDef step acc b)+      step c (foldr step acc b)     Branch c d ->       foldrOnBranch step acc c (Branch d b) -foldrDef' :: (a -> b -> b) -> b -> BinTree1 a -> b-foldrDef' step !acc =+foldr' :: (a -> b -> b) -> b -> BinTree1 a -> b+foldr' step !acc =   \ case     Branch a b -> foldrOnBranch' step acc a b     Leaf a -> step a acc@@ -76,11 +65,11 @@ foldrOnBranch' :: (a -> b -> b) -> b -> BinTree1 a -> BinTree1 a -> b foldrOnBranch' step acc a b =   case b of-    Leaf c -> foldrDef' step (step c acc) a+    Leaf c -> foldr' step (step c acc) a     Branch c d -> foldrOnBranch' step acc (Branch a c) d -foldlDef' :: (b -> a -> b) -> b -> BinTree1 a -> b-foldlDef' step !acc =+foldl' :: (b -> a -> b) -> b -> BinTree1 a -> b+foldl' step !acc =   \ case     Branch a b ->       foldlOnBranch' step acc a b@@ -91,49 +80,49 @@ foldlOnBranch' step acc a b =   case a of     Leaf c ->-      foldlDef' step (step acc c) b+      foldl' step (step acc c) b     Branch c d ->       foldlOnBranch' step acc c (Branch d b) -foldMapDef :: Monoid m => (a -> m) -> BinTree1 a -> m-foldMapDef =-  foldMapWithAcc mempty+foldMap :: Monoid m => (a -> m) -> BinTree1 a -> m+foldMap =+  foldMapTo mempty -foldMapWithAcc :: Monoid m => m -> (a -> m) -> BinTree1 a -> m-foldMapWithAcc acc map =+foldMapTo :: Monoid m => m -> (a -> m) -> BinTree1 a -> m+foldMapTo acc map =   \ case-    Branch a b -> foldMapOnBranch acc map a b+    Branch a b -> foldMapToOnBranch acc map a b     Leaf a -> acc <> map a -foldMapOnBranch :: Monoid m => m -> (a -> m) -> BinTree1 a -> BinTree1 a -> m-foldMapOnBranch acc map a b =+foldMapToOnBranch :: Monoid m => m -> (a -> m) -> BinTree1 a -> BinTree1 a -> m+foldMapToOnBranch acc map a b =   case a of-    Leaf c -> foldMapWithAcc (acc <> map c) map b-    Branch c d -> foldMapOnBranch acc map c (Branch d b)+    Leaf c -> foldMapTo (acc <> map c) map b+    Branch c d -> foldMapToOnBranch acc map c (Branch d b) -foldMapDef' :: Monoid m => (a -> m) -> BinTree1 a -> m-foldMapDef' =-  foldMapWithAcc' mempty+foldMap' :: Monoid m => (a -> m) -> BinTree1 a -> m+foldMap' =+  foldMapTo' mempty -foldMapWithAcc' :: Monoid m => m -> (a -> m) -> BinTree1 a -> m-foldMapWithAcc' !acc map =+foldMapTo' :: Monoid m => m -> (a -> m) -> BinTree1 a -> m+foldMapTo' !acc map =   \ case-    Branch a b -> foldMapOnBranch' acc map a b+    Branch a b -> foldMapToOnBranch' acc map a b     Leaf a -> acc <> map a -foldMapOnBranch' :: Monoid m => m -> (a -> m) -> BinTree1 a -> BinTree1 a -> m-foldMapOnBranch' acc map a b =+foldMapToOnBranch' :: Monoid m => m -> (a -> m) -> BinTree1 a -> BinTree1 a -> m+foldMapToOnBranch' acc map a b =   case a of-    Leaf c -> foldMapWithAcc' (acc <> map c) map b-    Branch c d -> foldMapOnBranch' acc map c (Branch d b)+    Leaf c -> foldMapTo' (acc <> map c) map b+    Branch c d -> foldMapToOnBranch' acc map c (Branch d b) -instance Traversable BinTree1 where-  traverse map =-    \ case-      Branch a b ->-        traverseOnBranch map a b-      Leaf a ->-        Leaf <$> map a+traverse :: Applicative f => (a -> f b) -> BinTree1 a -> f (BinTree1 b)+traverse map =+  \ case+    Branch a b ->+      traverseOnBranch map a b+    Leaf a ->+      Leaf <$> map a  traverseOnBranch :: Applicative f => (a -> f b) -> BinTree1 a -> BinTree1 a -> f (BinTree1 b) traverseOnBranch map a b =@@ -155,11 +144,11 @@ fromList1 :: a -> [a] -> BinTree1 a fromList1 a =   \ case-    b : c -> fromList1WithAcc (Leaf a) b c+    b : c -> fromList1To (Leaf a) b c     _ -> Leaf a -fromList1WithAcc :: BinTree1 a -> a -> [a] -> BinTree1 a-fromList1WithAcc leftTree a =+fromList1To :: BinTree1 a -> a -> [a] -> BinTree1 a+fromList1To leftTree a =   \ case-    b : c -> fromList1WithAcc (Branch leftTree (Leaf a)) b c+    b : c -> fromList1To (Branch leftTree (Leaf a)) b c     _ -> Branch leftTree (Leaf a)
library/Acc/Prelude.hs view
@@ -30,17 +30,17 @@ import Data.Function as Exports hiding (id, (.)) import Data.Functor as Exports import Data.Functor.Compose as Exports-import Data.Functor.Contravariant as Exports import Data.Int as Exports import Data.IORef as Exports import Data.Ix as Exports import Data.List as Exports hiding (sortOn, isSubsequenceOf, uncons, concat, foldr, foldl1, maximum, minimum, product, sum, all, and, any, concatMap, elem, foldl, foldr1, notElem, or, find, maximumBy, minimumBy, mapAccumL, mapAccumR, foldl') import Data.List.NonEmpty as Exports (NonEmpty(..)) import Data.Maybe as Exports-import Data.Monoid as Exports hiding (Alt)+import Data.Monoid as Exports hiding (Alt, First(..), Last(..), (<>)) import Data.Ord as Exports import Data.Proxy as Exports import Data.Ratio as Exports+import Data.Semigroup as Exports import Data.STRef as Exports import Data.String as Exports import Data.Traversable as Exports