packages feed

hydrogen-prelude 0.14 → 0.15

raw patch · 3 files changed

+123/−2 lines, 3 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Hydrogen.Prelude: (*$*) :: Apply a => a
+ Hydrogen.Prelude: class Apply a
+ Hydrogen.Prelude: instance Apply ((a -> b -> c -> d -> e -> f) -> (a, b, c, d, e) -> f)
+ Hydrogen.Prelude: instance Apply ((a -> b -> c -> d -> e) -> (a, b, c, d) -> e)
+ Hydrogen.Prelude: instance Apply ((a -> b -> c -> d) -> (a, b, c) -> d)
+ Hydrogen.Prelude: instance Apply ((a -> b -> c) -> (a, b) -> c)
+ Hydrogen.Prelude: instance Apply ((a -> b) -> a -> b)
+ Hydrogen.Prelude: instance Default Bool
+ Hydrogen.Prelude: instance Default Int
+ Hydrogen.Prelude: instance Default Int16
+ Hydrogen.Prelude: instance Default Int32
+ Hydrogen.Prelude: instance Default Int64
+ Hydrogen.Prelude: instance Default Int8
+ Hydrogen.Prelude: instance Default Integer
+ Hydrogen.Prelude: instance Default Word16
+ Hydrogen.Prelude: instance Default Word32
+ Hydrogen.Prelude: instance Default Word64
+ Hydrogen.Prelude: instance Default Word8
+ Hydrogen.Prelude: instance Functor f => Apply ((a -> b -> c -> d -> e -> z) -> f (a, b, c, d, e) -> f z)
+ Hydrogen.Prelude: instance Functor f => Apply ((a -> b -> c -> d -> e) -> f (a, b, c, d) -> f e)
+ Hydrogen.Prelude: instance Functor f => Apply ((a -> b -> c -> d) -> f (a, b, c) -> f d)
+ Hydrogen.Prelude: instance Functor f => Apply ((a -> b -> c) -> f (a, b) -> f c)
+ Hydrogen.Prelude: instance Functor f => Apply ((a -> b) -> f a -> f b)
+ Hydrogen.Prelude: instance MonadPlus m => Default (m a)
+ Hydrogen.Prelude: uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d
+ Hydrogen.Prelude: uncurry4 :: (a -> b -> c -> d -> e) -> (a, b, c, d) -> e
+ Hydrogen.Prelude: uncurry5 :: (a -> b -> c -> d -> e -> f) -> (a, b, c, d, e) -> f

Files

README.md view
@@ -15,6 +15,8 @@   + [`ShowBox`](#showbox--forall-a-show-a--a--showbox)   + [`.|`, `.&`, `.^`](#----a--bool--a--bool--a--bool)   + [`List a`](#type-list-a--a)+  + [`Default a`](#class-default-a)+  + [`Apply a`](#class-apply-a) + [`re-exports`](#re-exports)   + [`Hydrogen.Prelude`](#hydrogenprelude)   + [`Hydrogen.Prelude.IO`](#hydrogenpreludeio)@@ -54,6 +56,8 @@  Beyond existing functions from well-known standard packages, this prelude defines a few utilities (mostly aimed at unifying functionality across different packages, like `containers` and `array`). +---+ ### `(!) :: Has a ⇒ a → HasKey a → HasValue a`  `(!)` is provided for several data types which associate a key and a value.@@ -67,6 +71,8 @@ + `Ord k ⇒ Map k v` with `HasValue → v` + `Ord k ⇒ MultiMap k v` with `HasValue → [v]` +---+ ### `(?) :: Container a ⇒ a → Contained a → Bool`  Check whether the element on the right is contained in the collection on the left.@@ -81,6 +87,8 @@ + `Ord k ⇒ Map k v` with `Contained → k` + `Ord k ⇒ MultiMap k v` with `Contained → k` +---+ ### `tmap`  A little bit like `fmap` but defined differently on some datatypes (applies e.g. to both components of a tuple).@@ -97,42 +105,81 @@ + `Map k v` + `MultiMap k v` +---+ ### `fmap` vs `map`  Hydrogen Prelude exports `fmap` as `map` - the way it ought to be. +---+ ### `__ :: a`  A handy shortcut for `undefined`. +---+ ### FSharp's `|>` (which is `flip ($)`)  Use it to pipe things from one function to the other, left to right:      head xs |> fromEnum |> show +---+ ### `safeHead :: a → [a] → a`  The head of the list, or the default given as first argument.      safeHead x xs = maybe x head . listToMaybe +---+ ### `ShowBox :: forall a. (Show a) ⇒ a → ShowBox` ###  Wrap anything that is showable (can be used to build heterogeneous lists). +---+ ### `.|, .&, .^ :: (a → Bool) → (a → Bool) → (a → Bool)`  Combines predicates.      filter (isDigit .| isLetter) +---+ ### `type List a = [a]` -A shorthand for the type of lists, if you prefer this more wordy version.+A longhand for the type of lists, if you prefer this more wordy version. +---++### `class Default a` ###++A class that provides the `def` function for default values for types.+Instances of `MonadPlus` automatically have an instance where `def = mzero`.++Default instances for most primitive types are also provided.++---++### `class Apply a` ###++Provides the `*$*` operator which is your all-purpose application operator.+It does uncurrying (if you want to apply a tupel result of a function to+a function that is curryied, works with tupels of up to 5 components) and+also works with `Applicative`, i.e. it also does `fmap . uncurry`:++    data Operator = Operator Value OperatorType Value++    parseInfixOperation :: Parser (Value, OperatorType, Value)++    ... Operator *$* parseInfixOperation ...+ re-exports ----------+  ### Hydrogen.Prelude 
hydrogen-prelude.cabal view
@@ -1,5 +1,5 @@ name:                 hydrogen-prelude-version:              0.14+version:              0.15 homepage:             http://scravy.de/hydrogen-prelude/ synopsis:             Hydrogen Prelude license:              MIT
src/Hydrogen/Prelude.hs view
@@ -48,6 +48,9 @@   , safeHeadAndTail   , safeHeadAndTail2   , firstJust+  , uncurry3+  , uncurry4+  , uncurry5   , map   , UUID   , Generic@@ -61,6 +64,7 @@   , Has (..)   , Container (..)   , Default (..)+  , Apply (..)   , __   ) where @@ -407,3 +411,73 @@ class Default a where      def :: a++instance Default Int where def = 0+instance Default Int8 where def = 0+instance Default Int16 where def = 0+instance Default Int32 where def = 0+instance Default Int64 where def = 0+instance Default Word8 where def = 0+instance Default Word16 where def = 0+instance Default Word32 where def = 0+instance Default Word64 where def = 0+instance Default Integer where def = 0++instance Default Bool where def = False+instance MonadPlus m => Default (m a) where def = mzero+++class Apply a where++    (*$*) :: a+++instance Apply ((a -> b) -> a -> b) where++    (*$*) = ($)++instance Apply ((a -> b -> c) -> (a, b) -> c) where++    (*$*) = uncurry++instance Apply ((a -> b -> c -> d) -> (a, b, c) -> d) where++    (*$*) = uncurry3++instance Apply ((a -> b -> c -> d -> e) -> (a, b, c, d) -> e) where++    (*$*) = uncurry4++instance Apply ((a -> b -> c -> d -> e -> f) -> (a, b, c, d, e) -> f) where++    (*$*) = uncurry5++instance Functor f => Apply ((a -> b) -> f a -> f b) where++    (*$*) = fmap++instance Functor f => Apply ((a -> b -> c) -> f (a, b) -> f c) where++    (*$*) = fmap . uncurry++instance Functor f => Apply ((a -> b -> c -> d) -> f (a, b, c) -> f d) where++    (*$*) = fmap . uncurry3++instance Functor f => Apply ((a -> b -> c -> d -> e) -> f (a, b, c, d) -> f e) where++    (*$*) = fmap . uncurry4++instance Functor f => Apply ((a -> b -> c -> d -> e -> z) -> f (a, b, c, d, e) -> f z) where++    (*$*) = fmap . uncurry5++uncurry3 :: (a -> b -> c -> d) -> (a, b, c) -> d+uncurry3 f (a, b, c) = f a b c++uncurry4 :: (a -> b -> c -> d -> e) -> (a, b, c, d) -> e+uncurry4 f (a, b, c, d) = f a b c d++uncurry5 :: (a -> b -> c -> d -> e -> f) -> (a, b, c, d, e) -> f+uncurry5 f (a, b, c, d, e) = f a b c d e+