util 0.1.10.1 → 0.1.11.0
raw patch · 4 files changed
+43/−2 lines, 4 filesPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
API changes (from Hackage documentation)
- Util: instance (GHC.Base.Applicative p, Data.Semigroup.Semigroup a) => Data.Semigroup.Semigroup (Util.Ap p a)
- Util: instance (GHC.Base.Applicative p, Data.Semigroup.Semigroup a, GHC.Base.Monoid a) => GHC.Base.Monoid (Util.Ap p a)
+ Util: curry4 :: ((a, b, c, d) -> e) -> a -> b -> c -> d -> e
+ Util: instance (GHC.Base.Applicative p, GHC.Base.Semigroup a) => GHC.Base.Semigroup (Util.Ap p a)
+ Util: instance (GHC.Base.Applicative p, GHC.Base.Semigroup a, GHC.Base.Monoid a) => GHC.Base.Monoid (Util.Ap p a)
+ Util: onnn :: (a -> a -> a -> a -> b) -> (c -> a) -> c -> c -> c -> c -> b
+ Util: uncurry4 :: (a -> b -> c -> d -> e) -> (a, b, c, d) -> e
+ Util.List: splitWhen :: (a -> Bool) -> [a] -> NonEmpty [a]
+ Util.Monad.ST.Unsafe: unsafeInterleaveWhileJust :: ST s (Maybe a) -> (a -> ST s ()) -> ST s [a]
- Util: infixl 0 `onn`
+ Util: infixl 0 `onnn`
Files
- Util.hs +10/−1
- Util/List.hs +13/−0
- Util/Monad/ST/Unsafe.hs +16/−0
- util.cabal +4/−1
Util.hs view
@@ -71,10 +71,13 @@ (∘∘) :: (c -> d) -> (a -> b -> c) -> (a -> b -> d) (f ∘∘ g) x y = f (g x y) -infixl 0 `onn`+infixl 0 `onn`, `onnn` onn :: (a -> a -> a -> b) -> (c -> a) -> c -> c -> c -> b onn f g x y z = f (g x) (g y) (g z) +onnn :: (a -> a -> a -> a -> b) -> (c -> a) -> c -> c -> c -> c -> b+onnn f g w x y z = f (g w) (g x) (g y) (g z)+ fst3 :: (a, b, c) -> a fst3 (x,_,_) = x @@ -136,8 +139,14 @@ uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d uncurry3 f (x, y, z) = f x y z +uncurry4 :: (a -> b -> c -> d -> e) -> (a, b, c, d) -> e+uncurry4 f (w, x, y, z) = f w x y z+ curry3 :: ((a, b, c) -> d) -> a -> b -> c -> d curry3 f x y z = f (x, y, z)++curry4 :: ((a, b, c, d) -> e) -> a -> b -> c -> d -> e+curry4 f w x y z = f (w, x, y, z) infix 4 ∈, ∉ (∈), (∉) :: (Eq a, Foldable f) => a -> f a -> Bool
+ Util/List.hs view
@@ -0,0 +1,13 @@+{-# LANGUAGE ViewPatterns #-}++module Util.List where++import Data.Bool+import Data.List.NonEmpty (NonEmpty (..))++splitWhen :: (a -> Bool) -> [a] -> NonEmpty [a]+splitWhen p = go+ where+ go = \ case+ [] -> []:|[]+ a:(go -> as:|ass) | p a -> []:|as:ass | True -> (a:as):|ass
+ Util/Monad/ST/Unsafe.hs view
@@ -0,0 +1,16 @@+module Util.Monad.ST.Unsafe where++import Prelude (seq)+import Control.Applicative+import Control.Category (Category (..))+import Control.Monad (Monad (..))+import Control.Monad.ST+import Control.Monad.ST.Unsafe+import Data.Maybe (Maybe (..))++unsafeInterleaveWhileJust :: ST s (Maybe a) -> (a -> ST s ()) -> ST s [a]+unsafeInterleaveWhileJust mma f = go+ where+ go = mma >>= unsafeInterleaveST . \ case+ Nothing -> pure []+ Just a -> (a :) <$> unsafeInterleaveST (a `seq` f a *> go)
util.cabal view
@@ -1,5 +1,5 @@ name: util-version: 0.1.10.1+version: 0.1.11.0 synopsis: Utilities -- description: license: BSD3@@ -14,12 +14,15 @@ library exposed-modules: Util , Util.Bits+ , Util.List+ , Util.Monad.ST.Unsafe -- other-modules: -- other-extensions: build-depends: base >=4.9 && <5 -- hs-source-dirs: default-language: Haskell2010 default-extensions: NoImplicitPrelude+ , LambdaCase , GeneralizedNewtypeDeriving , DeriveFunctor , DeriveFoldable