packages feed

hx 0.2.1 → 0.3

raw patch · 4 files changed

+103/−9 lines, 4 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Haskell.X: breakLast :: [a] -> ([a], a)
+ Haskell.X: uneither :: Either a a -> a
+ Haskell.X.Ops: (->>) :: a -> (a -> b) -> b
+ Haskell.X.Ops: (<$>) :: Functor f => (a -> b) -> f a -> f b
+ Haskell.X.Ops: (=>>) :: Monad m => a -> (a -> b) -> m b
+ Haskell.X.Ops: (|>) :: (a -> b) -> (b -> c) -> (a -> c)
+ Haskell.X.Unsafe: debug :: Show b => b -> a -> a
+ Haskell.X.Unsafe: io :: IO a -> a
+ Haskell.X.Unsafe: trace :: Show a => a -> a

Files

hx.cabal view
@@ -1,6 +1,6 @@ Name:           hx-Version:        0.2.1-Synopsis:       Utility functions that some may feel are missing from Prelude and base.+Version:        0.3+Synopsis:       Haskell extras (missing utility functions). Description:    Utility functions that some may feel are missing from Prelude and base.                 .                 Some functions are taken from the package @hinduce-missingh@, which was@@ -8,8 +8,8 @@                  License:        MIT License-File:   LICENSE-Author:         Julian Fleischer <julian.fleischer@fu-berlin.de>-Maintainer:     Julian Fleischer <julian.fleischer@fu-berlin.de>+Author:         Julian Fleischer+Maintainer:     julian.fleischer@fu-berlin.de Build-Type:     Simple Cabal-Version:  >= 1.8 Category:       Utilities@@ -18,6 +18,8 @@  Library     Exposed-Modules:    Haskell.X+                        , Haskell.X.Ops+                        , Haskell.X.Unsafe      Build-Depends:      base >= 4 && < 5     Hs-Source-Dirs:     src
src/Haskell/X.hs view
@@ -1,14 +1,23 @@-{-# LANGUAGE Haskell2010, FlexibleInstances, OverlappingInstances #-}+{-# LANGUAGE Haskell2010, Safe #-} {-# OPTIONS -Wall #-} +-- |+-- Module       : Haskell.X+-- Copyright    : (c) Julian Fleischer 2013+-- License      : MIT (See LICENSE file in cabal package)+--+-- Maintainer   : julian.fleischer@fu-berlin.de+-- Stability    : provisional+-- Portability  : portable+--+-- Haskell extra utility functions. Best imported by @import qualified Haskell.X as X@. module Haskell.X where +import Prelude import Data.List import Data.Ord import Control.Arrow -- -- | Apply a function exhaustively. exhaustively :: Eq a => (a -> a) -> a -> a exhaustively = exhaustivelyBy (==)@@ -20,11 +29,11 @@     False -> exhaustivelyBy predicate func result   where result = func dat --- | Apply a monad function exhaustively.+-- | Apply a monadic function exhaustively. exhaustivelyM :: (Eq a, Monad m) => (a -> m a) -> a -> m a exhaustivelyM = exhaustivelyByM (==) --- | Apply a monad function exhaustively.+-- | Apply a monadic function exhaustively. exhaustivelyByM :: Monad m => (a -> a -> Bool) -> (a -> m a) -> a -> m a exhaustivelyByM predicate func dat = do     result <- func dat@@ -96,5 +105,18 @@     segmentations = zip (inits as) (tails as)     segments = dropWhile ((< size) . count2 . fst) segmentations     (segment, rest) = head segments++-- | @breakLast xs == (init xs, last xs)@+breakLast :: [a] -> ([a], a)+breakLast [a] = ([], a)+breakLast (a:as) =+    let (init', last') = breakLast as+    in  (a:init', last')+breakLast _ = error "Haskell.X.breakLast: empty list"++-- | If an Either contains the same types in Left and Right,+-- unify it by dropping the Either wrapper.+uneither :: Either a a -> a+uneither = either id id  
+ src/Haskell/X/Ops.hs view
@@ -0,0 +1,40 @@+{-# LANGUAGE Haskell2010, Safe #-}+{-# OPTIONS -Wall #-}++-- |+-- Module       : Haskell.X.Ops+-- Copyright    : (c) Julian Fleischer 2013+-- License      : MIT (See LICENSE file in cabal package)+--+-- Maintainer   : julian.fleischer@fu-berlin.de+-- Stability    : provisional+-- Portability  : portable+--+-- Haskell extra operators. Do not import qualified.+module Haskell.X.Ops (+    (->>), (=>>), (|>), (<$>)+  ) where++import Prelude+import Data.Functor++-- | @flip ($)@, fixity is @infixl 1@ (like @>>=@ but for non-monadic functions)+(->>) :: a -> (a -> b) -> b+(->>) = flip ($)++infixl 1 ->>++-- | Like @->>@, but wraps its result so that it can be used in a monad.+-- Fixity is @infixl 1@.+(=>>) :: Monad m => a -> (a -> b) -> m b+x =>> f = return (f x)++infixl 1 =>>++-- | @flip (.)@, fixity is @infixl 9@ (same as for @.@), from F#.+(|>) :: (a -> b) -> (b -> c) -> (a -> c)+(|>) = flip (.)++infixl 9 |>++
+ src/Haskell/X/Unsafe.hs view
@@ -0,0 +1,30 @@+{-# LANGUAGE Haskell2010, Unsafe #-}+{-# OPTIONS -Wall #-}++-- |+-- Module       : Haskell.X.Unsafe+-- Copyright    : (c) Julian Fleischer 2013+-- License      : MIT (See LICENSE file in cabal package)+--+-- Maintainer   : julian.fleischer@fu-berlin.de+-- Stability    : provisional+--+-- Unsafe functions (use for debugging only).+module Haskell.X.Unsafe where++import qualified Debug.Trace as Debug+import System.IO.Unsafe++-- | @trace x@ shows and returns @x@.+trace :: Show a => a -> a+trace a = Debug.trace (show a) a++-- | @debug x a@ shows @x@ and returns @a@.+debug :: Show b => b -> a -> a+debug b a = Debug.trace (show b) a++-- | This is a shorthand for 'unsafePerformIO'.+io :: IO a -> a+io = unsafePerformIO++