summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOleksandrZhabenko <>2019-11-08 16:37:00 (GMT)
committerhdiff <hdiff@hdiff.luite.com>2019-11-08 16:37:00 (GMT)
commita398a1240dc206cdbf2b0ebd794e290dee48ef14 (patch)
treef22ea94cc495ef0459a9fc5b5dd5c779c65bca12
parente6f905054aa5522cdd4369acbbf730c3c494264f (diff)
version 0.4.0.00.4.0.0
-rw-r--r--ChangeLog.md5
-rw-r--r--Data/List/InnToOut/Basic.hs (renamed from Data/List/InnToOut.hs)39
-rw-r--r--Data/List/InnToOut/Unsafe.hs44
-rw-r--r--mmsyn5.cabal4
4 files changed, 56 insertions, 36 deletions
diff --git a/ChangeLog.md b/ChangeLog.md
index 3166055..edda380 100644
--- a/ChangeLog.md
+++ b/ChangeLog.md
@@ -46,3 +46,8 @@
## 0.3.0.0 -- 2019-11-08
* Third version. Added functions with intermediate Monads.
+
+## 0.4.0.0 -- 2019-11-08
+
+* Fourth version. Changed the modules structure because of mixed safe and unsafe code and behaviour.
+
diff --git a/Data/List/InnToOut.hs b/Data/List/InnToOut/Basic.hs
index 7e70605..412f962 100644
--- a/Data/List/InnToOut.hs
+++ b/Data/List/InnToOut/Basic.hs
@@ -1,27 +1,21 @@
-- |
--- Module : Data.List.InnToOut
+-- Module : Data.List.InnToOut.Basic
-- Copyright : (c) OleksandrZhabenko 2019
-- License : MIT
--
-- Maintainer : olexandr543@yahoo.com
--
--- Various additional operations on lists. Some of them have additional intermediate Monads inside.
+-- Various additional operations on lists
--
-module Data.List.InnToOut
+module Data.List.InnToOut.Basic
(
- -- * Operations to apply a function that creates an inner list to an element of the outer list
+ -- * Operations to apply a function or different functions (some can create an inner list) to an element of the outer list
mapI
, mapI2
, mapI22
, mapI12
, mapI21
- -- * Operations to obtain intermediate Monads
- , mapI22M
- , mapI2M2
- , mapI2M2M
- , mapI12M
- , mapI2M1
) where
-- | Function that applies additional function @f :: a -> [a]@ to @a@ if @p a = True@
@@ -40,39 +34,16 @@ mapI22 :: (a -> Bool) -> (a -> b) -> (b -> d) -> (a -> c) -> (c -> d) -> [a] ->
mapI22 p f1 g f2 h = map (\x -> if p x then g (f1 x) else h (f2 x))
{-#INLINE mapI22#-}
--- | Variant of the function 'mapI22' in which the second intermediate result @c@ is in the @Monad m@.
-mapI22M :: Monad m => (a -> Bool) -> (a -> b) -> (b -> d) -> (a -> m c) -> (m c -> d) -> [a] -> [d]
-mapI22M p f1 g f2 h = map (\x -> if p x then g (f1 x) else h (f2 x))
-{-#INLINE mapI22M#-}
-
--- | Variant of the function 'mapI22' in which the first intermediate result @b@ is in the @Monad m@.
-mapI2M2 :: Monad m => (a -> Bool) -> (a -> m b) -> (m b -> d) -> (a -> c) -> (c -> d) -> [a] -> [d]
-mapI2M2 p f1 g f2 h = map (\x -> if p x then g (f1 x) else h (f2 x))
-{-#INLINE mapI2M2#-}
-
--- | Variant of the function 'mapI22' in which both the intermediate results @b@ and @c@ are in the Monads.
-mapI2M2M :: (Monad m0, Monad m) => (a -> Bool) -> (a -> m0 b) -> (m0 b -> d) -> (a -> m c) -> (m c -> d) -> [a] -> [d]
-mapI2M2M p f1 g f2 h = map (\x -> if p x then g (f1 x) else h (f2 x))
-{-#INLINE mapI2M2M#-}
-
-- | Function that can apply two different ways of computing something depending of the predicate value @p :: a -> Bool@ and the structure of transition the data for the @[a]@.
-- It is used if there are two ways to transform data and the first one consists of one function and another -- from two applied consequently ones. Similar to arrow techniques.
mapI12 :: (a -> Bool) -> (a -> c) -> (a -> b) -> (b -> c) -> [a] -> [c]
mapI12 p f g h = map (\x -> if p x then f x else h (g x))
{-#INLINE mapI12#-}
--- | Variant of the function 'mapI12' in which the second intermediate result @b@ is in the @Monad m@.
-mapI12M :: Monad m => (a -> Bool) -> (a -> c) -> (a -> m b) -> (m b -> c) -> [a] -> [c]
-mapI12M p f g h = map (\x -> if p x then f x else h (g x))
-{-#INLINE mapI12M#-}
-
-- | Function that can apply two different ways of computing something depending of the predicate value @p :: a -> Bool@ and the structure of transition the data for the @[a]@.
-- It is used if there are two ways to transform data and the first one consists of two applied consequently functions and the second -- from one applied function. Similar to arrow techniques.
mapI21 :: (a -> Bool) -> (a -> b) -> (b -> c) -> (a -> c) -> [a] -> [c]
mapI21 p f g h = map (\x -> if p x then g (f x) else h x)
{-#INLINE mapI21#-}
--- | Variant of the function 'mapI21' in which the first intermediate result @b@ is in the @Monad m@.
-mapI2M1 :: Monad m => (a -> Bool) -> (a -> m b) -> (m b -> c) -> (a -> c) -> [a] -> [c]
-mapI2M1 p f g h = map (\x -> if p x then g (f x) else h x)
-{-#INLINE mapI2M1#-}
+
diff --git a/Data/List/InnToOut/Unsafe.hs b/Data/List/InnToOut/Unsafe.hs
new file mode 100644
index 0000000..1ada772
--- /dev/null
+++ b/Data/List/InnToOut/Unsafe.hs
@@ -0,0 +1,44 @@
+-- |
+-- Module : Data.List.InnToOut.Unsafe
+-- Copyright : (c) OleksandrZhabenko 2019
+-- License : MIT
+--
+-- Maintainer : olexandr543@yahoo.com
+--
+-- Various additional operations on lists that have additional intermediate Monads inside.
+--
+
+module Data.List.InnToOut.Unsafe
+ (
+ -- * Operations to obtain intermediate Monads. Like the 'UnsafePerformIO' function they can have unpredictable behaviour. Use them ONLY if you surely know what you are doing.
+ mapI22M
+ , mapI2M2
+ , mapI2M2M
+ , mapI12M
+ , mapI2M1
+ ) where
+
+-- | Variant of the function 'Data.List.InnToOut.mapI22' in which the second intermediate result @c@ is in the @Monad m@.
+mapI22M :: Monad m => (a -> Bool) -> (a -> b) -> (b -> d) -> (a -> m c) -> (m c -> d) -> [a] -> [d]
+mapI22M p f1 g f2 h = map (\x -> if p x then g (f1 x) else h (f2 x))
+{-#INLINE mapI22M#-}
+
+-- | Variant of the function 'Data.List.InnToOut.mapI22' in which the first intermediate result @b@ is in the @Monad m@.
+mapI2M2 :: Monad m => (a -> Bool) -> (a -> m b) -> (m b -> d) -> (a -> c) -> (c -> d) -> [a] -> [d]
+mapI2M2 p f1 g f2 h = map (\x -> if p x then g (f1 x) else h (f2 x))
+{-#INLINE mapI2M2#-}
+
+-- | Variant of the function 'Data.List.InnToOut.mapI22' in which both the intermediate results @b@ and @c@ are in the Monads.
+mapI2M2M :: (Monad m0, Monad m) => (a -> Bool) -> (a -> m0 b) -> (m0 b -> d) -> (a -> m c) -> (m c -> d) -> [a] -> [d]
+mapI2M2M p f1 g f2 h = map (\x -> if p x then g (f1 x) else h (f2 x))
+{-#INLINE mapI2M2M#-}
+
+-- | Variant of the function 'Data.List.InnToOut.mapI12' in which the second intermediate result @b@ is in the @Monad m@.
+mapI12M :: Monad m => (a -> Bool) -> (a -> c) -> (a -> m b) -> (m b -> c) -> [a] -> [c]
+mapI12M p f g h = map (\x -> if p x then f x else h (g x))
+{-#INLINE mapI12M#-}
+
+-- | Variant of the function 'Data.List.InnToOut.mapI21' in which the first intermediate result @b@ is in the @Monad m@.
+mapI2M1 :: Monad m => (a -> Bool) -> (a -> m b) -> (m b -> c) -> (a -> c) -> [a] -> [c]
+mapI2M1 p f g h = map (\x -> if p x then g (f x) else h x)
+{-#INLINE mapI2M1#-}
diff --git a/mmsyn5.cabal b/mmsyn5.cabal
index f5a9d53..d6078fd 100644
--- a/mmsyn5.cabal
+++ b/mmsyn5.cabal
@@ -2,7 +2,7 @@
-- documentation, see http://haskell.org/cabal/users-guide/
name: mmsyn5
-version: 0.3.0.0
+version: 0.4.0.0
synopsis: Various additional operations on lists (some with intermediate Monads)
description: A small library to deal with a little bit more complex operations on lists than Data.List module
homepage: http://hackage.haskell.org/package/mmsyn5
@@ -17,7 +17,7 @@ extra-source-files: ChangeLog.md
cabal-version: >=1.10
library
- exposed-modules: Data.List.InnToOut
+ exposed-modules: Data.List.InnToOut.Basic, Data.List.InnToOut.Unsafe
-- other-modules:
-- other-extensions:
build-depends: base >=4.7 && <4.14