protolude 0.1.4 → 0.1.5
raw patch · 6 files changed
+56/−30 lines, 6 filesdep −semiring-simple
Dependencies removed: semiring-simple
Files
- protolude.cabal +2/−2
- src/Base.hs +4/−0
- src/Bifunctor.hs +16/−16
- src/Debug.hs +12/−9
- src/Protolude.hs +3/−3
- src/Semiring.hs +19/−0
protolude.cabal view
@@ -1,5 +1,5 @@ name: protolude-version: 0.1.4+version: 0.1.5 synopsis: A sensible set of defaults for writing custom Preludes. description: A sensible set of defaults for writing custom Preludes. homepage: https://github.com/sdiehl/protolude@@ -45,6 +45,7 @@ Show Either Functor+ Semiring Bifunctor default-extensions:@@ -64,7 +65,6 @@ async >= 2.1 && <2.2, deepseq >= 1.3 && <= 1.5, containers >= 0.5 && <0.6,- semiring-simple >= 0.1 && <1.1, mtl >= 2.1 && <2.3, transformers >= 0.4 && < 0.6, text >= 1.2 && <1.3,
src/Base.hs view
@@ -17,6 +17,10 @@ import GHC.Enum as X import GHC.Real as X import GHC.Float as X+import GHC.Err as X (+ undefined+ , error+ ) import GHC.Show as X ( Show(..) )
src/Bifunctor.hs view
@@ -10,38 +10,38 @@ import Control.Applicative ( Const(..) ) class Bifunctor p where- {-# MINIMAL bimap | first, second #-}+ {-# MINIMAL bimap | first, second #-} - bimap :: (a -> b) -> (c -> d) -> p a c -> p b d- bimap f g = first f . second g+ bimap :: (a -> b) -> (c -> d) -> p a c -> p b d+ bimap f g = first f . second g - first :: (a -> b) -> p a c -> p b c- first f = bimap f id+ first :: (a -> b) -> p a c -> p b c+ first f = bimap f id - second :: (b -> c) -> p a b -> p a c- second = bimap id+ second :: (b -> c) -> p a b -> p a c+ second = bimap id instance Bifunctor (,) where- bimap f g ~(a, b) = (f a, g b)+ bimap f g ~(a, b) = (f a, g b) instance Bifunctor ((,,) x1) where- bimap f g ~(x1, a, b) = (x1, f a, g b)+ bimap f g ~(x1, a, b) = (x1, f a, g b) instance Bifunctor ((,,,) x1 x2) where- bimap f g ~(x1, x2, a, b) = (x1, x2, f a, g b)+ bimap f g ~(x1, x2, a, b) = (x1, x2, f a, g b) instance Bifunctor ((,,,,) x1 x2 x3) where- bimap f g ~(x1, x2, x3, a, b) = (x1, x2, x3, f a, g b)+ bimap f g ~(x1, x2, x3, a, b) = (x1, x2, x3, f a, g b) instance Bifunctor ((,,,,,) x1 x2 x3 x4) where- bimap f g ~(x1, x2, x3, x4, a, b) = (x1, x2, x3, x4, f a, g b)+ bimap f g ~(x1, x2, x3, x4, a, b) = (x1, x2, x3, x4, f a, g b) instance Bifunctor ((,,,,,,) x1 x2 x3 x4 x5) where- bimap f g ~(x1, x2, x3, x4, x5, a, b) = (x1, x2, x3, x4, x5, f a, g b)+ bimap f g ~(x1, x2, x3, x4, x5, a, b) = (x1, x2, x3, x4, x5, f a, g b) instance Bifunctor Either where- bimap f _ (Left a) = Left (f a)- bimap _ g (Right b) = Right (g b)+ bimap f _ (Left a) = Left (f a)+ bimap _ g (Right b) = Right (g b) instance Bifunctor Const where- bimap f _ (Const a) = Const (f a)+ bimap f _ (Const a) = Const (f a)
src/Debug.hs view
@@ -12,7 +12,10 @@ notImplemented, ) where -import qualified Prelude as P+import Data.String (String)+import Control.Monad (Monad, return)++import qualified Base as P import qualified Debug.Trace as T {-# WARNING undefined "'undefined' remains in code" #-}@@ -20,27 +23,27 @@ undefined = P.undefined {-# WARNING error "'error' remains in code" #-}-error :: P.String -> a+error :: String -> a error = P.error {-# WARNING trace "'trace' remains in code" #-}-trace :: P.String -> a -> a+trace :: String -> a -> a trace = T.trace {-# WARNING traceShow "'traceShow' remains in code" #-}-traceShow :: P.Show a => a -> a-traceShow a = T.trace (P.show a) a+traceShow :: P.Show a => a -> b -> b+traceShow a b = T.trace (P.show a) b {-# WARNING traceShowM "'traceShowM' remains in code" #-}-traceShowM :: (P.Show a, P.Monad m) => a -> m ()+traceShowM :: (P.Show a, Monad m) => a -> m () traceShowM a = traceM (P.show a) {-# WARNING traceM "'traceM' remains in code" #-}-traceM :: (P.Monad m) => P.String -> m ()-traceM s = T.trace s (P.return ())+traceM :: (Monad m) => String -> m ()+traceM s = T.trace s (return ()) {-# WARNING traceIO "'traceIO' remains in code" #-}-traceIO :: P.String -> P.IO ()+traceIO :: String -> P.IO () traceIO = T.traceIO {-# WARNING notImplemented "'notImplemented' remains in code" #-}
src/Protolude.hs view
@@ -33,6 +33,8 @@ , putStrLn , print , show+ , error+ , undefined ) import qualified Base as PBase @@ -51,8 +53,6 @@ , tailSafe , lastDef , lastMay- , lookupJust- , findJust , foldr1May , foldl1May , atMay@@ -80,7 +80,7 @@ foldr1 , foldl1 )-import Data.Semiring as X+import Semiring as X import Data.Functor.Identity as X #if ( __GLASGOW_HASKELL__ >= 800 )
+ src/Semiring.hs view
@@ -0,0 +1,19 @@+{-# LANGUAGE Safe #-}+{-# LANGUAGE NoImplicitPrelude #-}++module Semiring (+ Semiring(..),+ zero,+) where++import Data.Monoid++-- | Alias for 'mempty'+zero :: Monoid m => m+zero = mempty++class Monoid m => Semiring m where+ {-# MINIMAL one, (<.>) #-}++ one :: m+ (<.>) :: m -> m -> m