packages feed

hydrogen 0.2.0.0 → 0.3.0.0

raw patch · 3 files changed

+47/−17 lines, 3 filesdep ~Cabaldep ~QuickCheckdep ~basePVP ok

version bump matches the API change (PVP)

Dependency ranges changed: Cabal, QuickCheck, base, mtl

API changes (from Hackage documentation)

- H.Prelude: textMsg :: Error a => Text -> a
+ H.Prelude: boolToMaybe :: Bool -> Maybe ()
+ H.Prelude: onLeft :: (a -> c) -> Either a b -> Either c b
+ H.Prelude: onRight :: (b -> c) -> Either a b -> Either a c
+ H.Prelude: setCatMaybes :: Ord a => Set (Maybe a) -> Set a
+ H.Prelude: setSequence :: (Ord a, Applicative f) => Set (f a) -> f (Set a)
+ H.Prelude: traceVal :: Show a => a -> a
+ H.Prelude: whenJustM :: Monad m => m (Maybe a) -> (a -> m ()) -> m ()

Files

hydrogen.cabal view
@@ -1,5 +1,5 @@ name:           hydrogen-version:        0.2.0.0+version:        0.3.0.0 cabal-version:  >= 1.10 build-type:     Simple license:        GPL-3@@ -23,7 +23,7 @@   To use this package, use the `NoImplicitPrelude` language option, and import   "H.Prelude". category:       Prelude-tested-with:    GHC == 7.8.3+tested-with:    GHC == 7.10.1  Source-repository head   type: git@@ -43,11 +43,11 @@     ghc-options:       -Werror   build-depends:-    base       >= 4.7  && < 4.8,+    base       >= 4.7  && < 4.9,     bytestring >= 0.10 && < 0.11,     text       >= 1.2  && < 1.3,     containers >= 0.5  && < 0.6,-    mtl        >= 2.1  && < 2.2,+    mtl        >= 2.1  && < 2.3,     pretty     >= 1.1  && < 1.2   exposed-modules:     H.Chan@@ -76,11 +76,11 @@     ghc-options:       -Werror   build-depends:-    base       >= 4.7  && < 4.8,+    base       >= 4.7  && < 4.9,     containers >= 0.5  && < 0.6,-    mtl        >= 2.1  && < 2.2,-    QuickCheck >= 2.7  && < 2.8,-    Cabal      >= 1.10,+    mtl        >= 2.1  && < 2.3,+    QuickCheck >= 2.8  && < 2.9,+    Cabal      >= 1.10 && < 1.23,     hydrogen   default-extensions:     NoImplicitPrelude
src/H/Import.hs view
@@ -3,7 +3,7 @@   ( module Control.Applicative   , module Control.Category   , module Control.Monad-  , module Control.Monad.Error+  , module Control.Monad.Except   , module Control.Monad.Identity   , module Control.Monad.Reader   , module Control.Monad.State@@ -23,6 +23,8 @@   , module Data.Text   , module Data.Text.Encoding   , module Data.Traversable+  , module Data.Tuple+  , module Debug.Trace   , module Prelude   ) where @@ -30,8 +32,8 @@ import Control.Category import Control.Monad hiding   ( forM, forM_, mapM, mapM_, sequence, sequence_, msum )-import Control.Monad.Error hiding-  ( forM, forM_, mapM, mapM_, sequence, sequence_, msum, strMsg )+import Control.Monad.Except hiding+  ( forM, forM_, mapM, mapM_, sequence, sequence_, msum ) import Control.Monad.Identity hiding   ( forM, forM_, mapM, mapM_, sequence, sequence_, msum ) import Control.Monad.Reader hiding@@ -44,7 +46,7 @@ import Data.Either import Data.Foldable import Data.Function hiding (id, (.))-import Data.List (filter)+import Data.List (filter, map) import Data.Map (Map()) import Data.Maybe import Data.Monoid@@ -54,6 +56,8 @@ import Data.Text (Text(), pack, unpack) import Data.Text.Encoding (encodeUtf8, decodeUtf8) import Data.Traversable+import Data.Tuple (uncurry, curry, swap)+import Debug.Trace import Prelude   ( Num(..), Integral(..), Fractional(..), Real(..), RealFrac(..)   , Int, Integer, Rational, Eq(..), Enum(..), Bounded(..)
src/H/Util.hs view
@@ -1,9 +1,10 @@  module H.Util where -import qualified Control.Monad.Error as E import qualified Data.Map as M+import qualified Data.Set as S import qualified Data.Text as T+import Debug.Trace import qualified Prelude as P  import H.Import@@ -132,13 +133,38 @@   where     f' mx my = mx >>= \x -> my >>= \y -> f x y --- | Create an error from a message-textMsg :: (Error a) => Text -> a-textMsg = E.strMsg . unpack- -- | Like when, but the condition is also a monadic action whenM :: (Monad m) => m Bool -> m () -> m () whenM cond m = cond >>= \case   True  -> m   False -> return () +traceVal :: (Show a) => a -> a+traceVal x = traceShow x x++setCatMaybes :: (Ord a) => Set (Maybe a) -> Set a+setCatMaybes = S.minView >>> \case+  Nothing      -> S.empty+  Just (x, xs) -> maybe id S.insert x $ setCatMaybes xs++setSequence :: (Ord a, Applicative f) => Set (f a) -> f (Set a)+setSequence = S.minView >>> \case+  Nothing      -> pure S.empty+  Just (x, xs) -> S.insert <$> x <*> setSequence xs++onLeft :: (a -> c) -> Either a b -> Either c b+onLeft f = \case+  Left x  -> Left $ f x+  Right y -> Right y++onRight :: (b -> c) -> Either a b -> Either a c+onRight f = \case+  Left x  -> Left x+  Right y -> Right $ f y++whenJustM :: (Monad m) => m (Maybe a) -> (a -> m ()) -> m ()+whenJustM m f = m >>= maybe (return ()) f++boolToMaybe :: Bool -> Maybe ()+boolToMaybe False = Nothing+boolToMaybe True = Just ()