packages feed

universum 1.4.0 → 1.5.0

raw patch · 10 files changed

+312/−60 lines, 10 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

- Universum.Applicative: newtype Const a (b :: k) :: forall k. () => * -> k -> *
- Universum.Base: withFile :: () => FilePath -> IOMode -> Handle -> IO r -> IO r
- Universum.Container.Class: instance (TypeError ...) => Universum.Container.Class.Container (GHC.Base.Maybe a)
- Universum.Exception: instance GHC.Exception.Exception Universum.Exception.Bug
- Universum.Monad.Reexport: newtype ReaderT r (m :: k -> *) (a :: k) :: forall k. () => * -> k -> * -> k -> *
- Universum.Print: instance Universum.Print.Print Data.ByteString.Internal.ByteString
- Universum.Print: instance Universum.Print.Print Data.ByteString.Lazy.Internal.ByteString
- Universum.Print: instance Universum.Print.Print Data.Text.Internal.Lazy.Text
- Universum.Print: instance Universum.Print.Print Data.Text.Internal.Text
- Universum.Print: instance Universum.Print.Print [GHC.Types.Char]
- Universum.VarArg: instance (Universum.VarArg.SuperComposition (a -> b) d r1, r ~ (c -> r1)) => Universum.VarArg.SuperComposition (a -> b) (c -> d) r
- Universum.VarArg: instance (a ~ c, r ~ b) => Universum.VarArg.SuperComposition (a -> b) c r
+ Universum.Applicative: infixl 3 <|>
+ Universum.Applicative: newtype Const a (b :: k) :: forall k. () => Type -> k -> Type
+ Universum.Base: infix 4 <=
+ Universum.Base: infixl 7 `mod`
+ Universum.Base: type family CmpNat (a :: Nat) (b :: Nat) :: Ordering
+ Universum.Base: underflowError :: () => a
+ Universum.Container.Class: -- <a>Text</a>, <a>IntSet</a>, etc.) so we can't implement nice interface
+ Universum.Container.Class: -- associated type family instead of top-level family gives you more
+ Universum.Container.Class: -- control over element types.
+ Universum.Container.Class: -- family because some containers are monomorphic over element type (like
+ Universum.Container.Class: -- using old higher-kinded types approach. Implementing this as an
+ Universum.Container.Class: -- | Type of element for some container. Implemented as an asscociated type
+ Universum.Container.Class: instance (TypeError ...) => Universum.Container.Class.Container (GHC.Maybe.Maybe a)
+ Universum.Container.Reexport: infixl 0 `hashWithSalt`
+ Universum.Debug: traceIdWith :: (a -> Text) -> a -> a
+ Universum.Debug: traceShowIdWith :: Show s => (a -> s) -> a -> a
+ Universum.Exception: instance GHC.Exception.Type.Exception Universum.Exception.Bug
+ Universum.Functor.Reexport: infixr 9 `Compose`
+ Universum.Lifted.File: hClose :: MonadIO m => Handle -> m ()
+ Universum.Lifted.File: withFile :: (MonadIO m, MonadMask m) => FilePath -> IOMode -> (Handle -> m a) -> m a
+ Universum.Monad.Reexport: infixl 1 >>
+ Universum.Monad.Reexport: newtype ReaderT r (m :: k -> Type) (a :: k) :: forall k. () => Type -> k -> Type -> k -> Type
+ Universum.Monoid: infixr 6 <>
+ Universum.Print: hPrint :: (MonadIO m, Show a) => Handle -> a -> m ()
+ Universum.Print: hPutStr :: (Print a, MonadIO m) => Handle -> a -> m ()
+ Universum.Print: hPutStrLn :: (Print a, MonadIO m) => Handle -> a -> m ()
+ Universum.Print.Internal: class Print a
+ Universum.Print.Internal: hPutStr :: Print a => Handle -> a -> IO ()
+ Universum.Print.Internal: hPutStrLn :: Print a => Handle -> a -> IO ()
+ Universum.Print.Internal: instance Universum.Print.Internal.Print Data.ByteString.Internal.ByteString
+ Universum.Print.Internal: instance Universum.Print.Internal.Print Data.ByteString.Lazy.Internal.ByteString
+ Universum.Print.Internal: instance Universum.Print.Internal.Print Data.Text.Internal.Lazy.Text
+ Universum.Print.Internal: instance Universum.Print.Internal.Print Data.Text.Internal.Text
+ Universum.Print.Internal: instance Universum.Print.Internal.Print [GHC.Types.Char]
+ Universum.TypeOps: infixr 2 $
+ Universum.TypeOps: type family Each (c :: [k -> Constraint]) (as :: [k])
+ Universum.VarArg: infixl 8 ...
+ Universum.VarArg: instance (Universum.VarArg.SuperComposition (a -> b) d r1, r Data.Type.Equality.~ (c -> r1)) => Universum.VarArg.SuperComposition (a -> b) (c -> d) r
+ Universum.VarArg: instance (a Data.Type.Equality.~ c, r Data.Type.Equality.~ b) => Universum.VarArg.SuperComposition (a -> b) c r
- Universum: (%~) :: () => ASetter s t a b -> a -> b -> s -> t
+ Universum: (%~) :: () => ASetter s t a b -> (a -> b) -> s -> t
- Universum: (&) :: () => a -> a -> b -> b
+ Universum: (&) :: () => a -> (a -> b) -> b
- Universum: (<&>) :: Functor f => f a -> a -> b -> f b
+ Universum: (<&>) :: Functor f => f a -> (a -> b) -> f b
- Universum: (^..) :: () => s -> Getting Endo [a] s a -> [a]
+ Universum: (^..) :: () => s -> Getting (Endo [a]) s a -> [a]
- Universum: (^?) :: () => s -> Getting First a s a -> Maybe a
+ Universum: (^?) :: () => s -> Getting (First a) s a -> Maybe a
- Universum: over :: () => ASetter s t a b -> a -> b -> s -> t
+ Universum: over :: () => ASetter s t a b -> (a -> b) -> s -> t
- Universum: preuse :: MonadState s m => Getting First a s a -> m Maybe a
+ Universum: preuse :: MonadState s m => Getting (First a) s a -> m (Maybe a)
- Universum: preview :: MonadReader s m => Getting First a s a -> m Maybe a
+ Universum: preview :: MonadReader s m => Getting (First a) s a -> m (Maybe a)
- Universum: type Traversal s t a b = forall (f :: * -> *). Applicative f => a -> f b -> s -> f t
+ Universum: type Traversal s t a b = forall (f :: Type -> Type). Applicative f => a -> f b -> s -> f t
- Universum.Applicative: (<**>) :: Applicative f => f a -> f a -> b -> f b
+ Universum.Applicative: (<**>) :: Applicative f => f a -> f (a -> b) -> f b
- Universum.Applicative: (<*>) :: Applicative f => f a -> b -> f a -> f b
+ Universum.Applicative: (<*>) :: Applicative f => f (a -> b) -> f a -> f b
- Universum.Applicative: class Applicative f => Alternative (f :: * -> *)
+ Universum.Applicative: class Applicative f => Alternative (f :: Type -> Type)
- Universum.Applicative: class Functor f => Applicative (f :: * -> *)
+ Universum.Applicative: class Functor f => Applicative (f :: Type -> Type)
- Universum.Applicative: liftA2 :: Applicative f => a -> b -> c -> f a -> f b -> f c
+ Universum.Applicative: liftA2 :: Applicative f => (a -> b -> c) -> f a -> f b -> f c
- Universum.Applicative: liftA3 :: Applicative f => a -> b -> c -> d -> f a -> f b -> f c -> f d
+ Universum.Applicative: liftA3 :: Applicative f => (a -> b -> c -> d) -> f a -> f b -> f c -> f d
- Universum.Applicative: optional :: Alternative f => f a -> f Maybe a
+ Universum.Applicative: optional :: Alternative f => f a -> f (Maybe a)
- Universum.Base: [SomeNat] :: SomeNat
+ Universum.Base: [SomeNat] :: forall (n :: Nat). KnownNat n => Proxy n -> SomeNat
- Universum.Base: class Foldable (t :: * -> *)
+ Universum.Base: class Foldable (t :: Type -> Type)
- Universum.Base: class (Functor t, Foldable t) => Traversable (t :: * -> *)
+ Universum.Base: class (Functor t, Foldable t) => Traversable (t :: Type -> Type)
- Universum.Base: comparing :: Ord a => b -> a -> b -> b -> Ordering
+ Universum.Base: comparing :: Ord a => (b -> a) -> b -> b -> Ordering
- Universum.Base: concatMap :: Foldable t => a -> [b] -> t a -> [b]
+ Universum.Base: concatMap :: Foldable t => (a -> [b]) -> t a -> [b]
- Universum.Base: data Proxy (t :: k) :: forall k. () => k -> *
+ Universum.Base: data Proxy (t :: k) :: forall k. () => k -> Type
- Universum.Base: fmapDefault :: Traversable t => a -> b -> t a -> t b
+ Universum.Base: fmapDefault :: Traversable t => (a -> b) -> t a -> t b
- Universum.Base: foldMapDefault :: (Traversable t, Monoid m) => a -> m -> t a -> m
+ Universum.Base: foldMapDefault :: (Traversable t, Monoid m) => (a -> m) -> t a -> m
- Universum.Base: foldlM :: (Foldable t, Monad m) => b -> a -> m b -> b -> t a -> m b
+ Universum.Base: foldlM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b
- Universum.Base: foldrM :: (Foldable t, Monad m) => a -> b -> m b -> b -> t a -> m b
+ Universum.Base: foldrM :: (Foldable t, Monad m) => (a -> b -> m b) -> b -> t a -> m b
- Universum.Base: forM :: (Traversable t, Monad m) => t a -> a -> m b -> m t b
+ Universum.Base: forM :: (Traversable t, Monad m) => t a -> (a -> m b) -> m (t b)
- Universum.Base: getStackTrace :: IO Maybe [Location]
+ Universum.Base: getStackTrace :: IO (Maybe [Location])
- Universum.Base: infixl 6 `xor`
+ Universum.Base: infixl 6 -
- Universum.Base: mapAccumL :: Traversable t => a -> b -> (a, c) -> a -> t b -> (a, t c)
+ Universum.Base: mapAccumL :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c)
- Universum.Base: mapAccumR :: Traversable t => a -> b -> (a, c) -> a -> t b -> (a, t c)
+ Universum.Base: mapAccumR :: Traversable t => (a -> b -> (a, c)) -> a -> t b -> (a, t c)
- Universum.Base: mapM :: (Traversable t, Monad m) => a -> m b -> t a -> m t b
+ Universum.Base: mapM :: (Traversable t, Monad m) => (a -> m b) -> t a -> m (t b)
- Universum.Base: maximumBy :: Foldable t => a -> a -> Ordering -> t a -> a
+ Universum.Base: maximumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a
- Universum.Base: minimumBy :: Foldable t => a -> a -> Ordering -> t a -> a
+ Universum.Base: minimumBy :: Foldable t => (a -> a -> Ordering) -> t a -> a
- Universum.Base: sequence :: (Traversable t, Monad m) => t m a -> m t a
+ Universum.Base: sequence :: (Traversable t, Monad m) => t (m a) -> m (t a)
- Universum.Base: sequenceA :: (Traversable t, Applicative f) => t f a -> f t a
+ Universum.Base: sequenceA :: (Traversable t, Applicative f) => t (f a) -> f (t a)
- Universum.Base: showStackTrace :: IO Maybe String
+ Universum.Base: showStackTrace :: IO (Maybe String)
- Universum.Base: traverse :: (Traversable t, Applicative f) => a -> f b -> t a -> f t b
+ Universum.Base: traverse :: (Traversable t, Applicative f) => (a -> f b) -> t a -> f (t b)
- Universum.Base: type Type = *
+ Universum.Base: type Type = Type
- Universum.Base: withFrozenCallStack :: HasCallStack => HasCallStack -> a -> a
+ Universum.Base: withFrozenCallStack :: HasCallStack => (HasCallStack -> a) -> a
- Universum.Container.Class: and :: (Container t, (Element t ~ Bool)) => t -> Bool
+ Universum.Container.Class: and :: (Container t, Element t ~ Bool) => t -> Bool
- Universum.Container.Class: or :: (Container t, (Element t ~ Bool)) => t -> Bool
+ Universum.Container.Class: or :: (Container t, Element t ~ Bool) => t -> Bool
- Universum.Container.Reexport: curry :: () => (a, b) -> c -> a -> b -> c
+ Universum.Container.Reexport: curry :: () => ((a, b) -> c) -> a -> b -> c
- Universum.Container.Reexport: uncurry :: () => a -> b -> c -> (a, b) -> c
+ Universum.Container.Reexport: uncurry :: () => (a -> b -> c) -> (a, b) -> c
- Universum.Debug: trace :: Print b => b -> a -> a
+ Universum.Debug: trace :: Text -> a -> a
- Universum.Debug: traceM :: (Monad m) => Text -> m ()
+ Universum.Debug: traceM :: Monad m => Text -> m ()
- Universum.DeepSeq: ($!!) :: NFData a => a -> b -> a -> b
+ Universum.DeepSeq: ($!!) :: NFData a => (a -> b) -> a -> b
- Universum.Exception: [SomeException] :: SomeException
+ Universum.Exception: [SomeException] :: forall e. Exception e => e -> SomeException
- Universum.Exception: bracket :: MonadMask m => m a -> a -> m b -> a -> m c -> m c
+ Universum.Exception: bracket :: MonadMask m => m a -> (a -> m b) -> (a -> m c) -> m c
- Universum.Exception: bracketOnError :: MonadMask m => m a -> a -> m b -> a -> m c -> m c
+ Universum.Exception: bracketOnError :: MonadMask m => m a -> (a -> m b) -> (a -> m c) -> m c
- Universum.Exception: catch :: (MonadCatch m, Exception e) => m a -> e -> m a -> m a
+ Universum.Exception: catch :: (MonadCatch m, Exception e) => m a -> (e -> m a) -> m a
- Universum.Exception: catchAny :: MonadCatch m => m a -> SomeException -> m a -> m a
+ Universum.Exception: catchAny :: MonadCatch m => m a -> (SomeException -> m a) -> m a
- Universum.Exception: class MonadThrow m => MonadCatch (m :: * -> *)
+ Universum.Exception: class MonadThrow m => MonadCatch (m :: Type -> Type)
- Universum.Exception: class MonadCatch m => MonadMask (m :: * -> *)
+ Universum.Exception: class MonadCatch m => MonadMask (m :: Type -> Type)
- Universum.Exception: class Monad m => MonadThrow (m :: * -> *)
+ Universum.Exception: class Monad m => MonadThrow (m :: Type -> Type)
- Universum.Exception: generalBracket :: MonadMask m => m a -> a -> ExitCase b -> m c -> a -> m b -> m (b, c)
+ Universum.Exception: generalBracket :: MonadMask m => m a -> (a -> ExitCase b -> m c) -> (a -> m b) -> m (b, c)
- Universum.Exception: handleAny :: MonadCatch m => SomeException -> m a -> m a -> m a
+ Universum.Exception: handleAny :: MonadCatch m => (SomeException -> m a) -> m a -> m a
- Universum.Exception: mask :: MonadMask m => forall a. () => m a -> m a -> m b -> m b
+ Universum.Exception: mask :: MonadMask m => ((forall a. () => m a -> m a) -> m b) -> m b
- Universum.Exception: note :: (MonadError e m) => e -> Maybe a -> m a
+ Universum.Exception: note :: MonadError e m => e -> Maybe a -> m a
- Universum.Exception: try :: (MonadCatch m, Exception e) => m a -> m Either e a
+ Universum.Exception: try :: (MonadCatch m, Exception e) => m a -> m (Either e a)
- Universum.Exception: tryAny :: MonadCatch m => m a -> m Either SomeException a
+ Universum.Exception: tryAny :: MonadCatch m => m a -> m (Either SomeException a)
- Universum.Exception: uninterruptibleMask :: MonadMask m => forall a. () => m a -> m a -> m b -> m b
+ Universum.Exception: uninterruptibleMask :: MonadMask m => ((forall a. () => m a -> m a) -> m b) -> m b
- Universum.Function: ($) :: () => a -> b -> a -> b
+ Universum.Function: ($) :: () => (a -> b) -> a -> b
- Universum.Function: (.) :: () => b -> c -> a -> b -> a -> c
+ Universum.Function: (.) :: () => (b -> c) -> (a -> b) -> a -> c
- Universum.Function: fix :: () => a -> a -> a
+ Universum.Function: fix :: () => (a -> a) -> a
- Universum.Function: flip :: () => a -> b -> c -> b -> a -> c
+ Universum.Function: flip :: () => (a -> b -> c) -> b -> a -> c
- Universum.Function: on :: () => b -> b -> c -> a -> b -> a -> a -> c
+ Universum.Function: on :: () => (b -> b -> c) -> (a -> b) -> a -> a -> c
- Universum.Functor.Reexport: (<$>) :: Functor f => a -> b -> f a -> f b
+ Universum.Functor.Reexport: (<$>) :: Functor f => (a -> b) -> f a -> f b
- Universum.Functor.Reexport: Compose :: f g a -> Compose
+ Universum.Functor.Reexport: Compose :: f (g a) -> Compose
- Universum.Functor.Reexport: [getCompose] :: Compose -> f g a
+ Universum.Functor.Reexport: [getCompose] :: Compose -> f (g a)
- Universum.Functor.Reexport: bimap :: Bifunctor p => a -> b -> c -> d -> p a c -> p b d
+ Universum.Functor.Reexport: bimap :: Bifunctor p => (a -> b) -> (c -> d) -> p a c -> p b d
- Universum.Functor.Reexport: class Bifunctor (p :: * -> * -> *)
+ Universum.Functor.Reexport: class Bifunctor (p :: Type -> Type -> Type)
- Universum.Functor.Reexport: class Functor (f :: * -> *)
+ Universum.Functor.Reexport: class Functor (f :: Type -> Type)
- Universum.Functor.Reexport: first :: Bifunctor p => a -> b -> p a c -> p b c
+ Universum.Functor.Reexport: first :: Bifunctor p => (a -> b) -> p a c -> p b c
- Universum.Functor.Reexport: fmap :: Functor f => a -> b -> f a -> f b
+ Universum.Functor.Reexport: fmap :: Functor f => (a -> b) -> f a -> f b
- Universum.Functor.Reexport: newtype Compose (f :: k -> *) (g :: k1 -> k) (a :: k1) :: forall k k1. () => k -> * -> k1 -> k -> k1 -> *
+ Universum.Functor.Reexport: newtype Compose (f :: k -> Type) (g :: k1 -> k) (a :: k1) :: forall k k1. () => k -> Type -> k1 -> k -> k1 -> Type
- Universum.Functor.Reexport: second :: Bifunctor p => b -> c -> p a b -> p a c
+ Universum.Functor.Reexport: second :: Bifunctor p => (b -> c) -> p a b -> p a c
- Universum.Lifted.Concurrent: modifyTVar' :: () => TVar a -> a -> a -> STM ()
+ Universum.Lifted.Concurrent: modifyTVar' :: () => TVar a -> (a -> a) -> STM ()
- Universum.Lifted.Concurrent: newTVar :: () => a -> STM TVar a
+ Universum.Lifted.Concurrent: newTVar :: () => a -> STM (TVar a)
- Universum.Lifted.Env: die :: MonadIO m => String -> m ()
+ Universum.Lifted.Env: die :: MonadIO m => String -> m a
- Universum.List.Reexport: break :: () => a -> Bool -> [a] -> ([a], [a])
+ Universum.List.Reexport: break :: () => (a -> Bool) -> [a] -> ([a], [a])
- Universum.List.Reexport: dropWhile :: () => a -> Bool -> [a] -> [a]
+ Universum.List.Reexport: dropWhile :: () => (a -> Bool) -> [a] -> [a]
- Universum.List.Reexport: filter :: () => a -> Bool -> [a] -> [a]
+ Universum.List.Reexport: filter :: () => (a -> Bool) -> [a] -> [a]
- Universum.List.Reexport: infixr 5 ++
+ Universum.List.Reexport: infixr 5 :|
- Universum.List.Reexport: iterate :: () => a -> a -> a -> [a]
+ Universum.List.Reexport: iterate :: () => (a -> a) -> a -> [a]
- Universum.List.Reexport: nonEmpty :: () => [a] -> Maybe NonEmpty a
+ Universum.List.Reexport: nonEmpty :: () => [a] -> Maybe (NonEmpty a)
- Universum.List.Reexport: scanl :: () => b -> a -> b -> b -> [a] -> [b]
+ Universum.List.Reexport: scanl :: () => (b -> a -> b) -> b -> [a] -> [b]
- Universum.List.Reexport: scanr :: () => a -> b -> b -> b -> [a] -> [b]
+ Universum.List.Reexport: scanr :: () => (a -> b -> b) -> b -> [a] -> [b]
- Universum.List.Reexport: sortBy :: () => a -> a -> Ordering -> [a] -> [a]
+ Universum.List.Reexport: sortBy :: () => (a -> a -> Ordering) -> [a] -> [a]
- Universum.List.Reexport: sortOn :: Ord b => a -> b -> [a] -> [a]
+ Universum.List.Reexport: sortOn :: Ord b => (a -> b) -> [a] -> [a]
- Universum.List.Reexport: sortWith :: Ord b => a -> b -> [a] -> [a]
+ Universum.List.Reexport: sortWith :: Ord b => (a -> b) -> [a] -> [a]
- Universum.List.Reexport: takeWhile :: () => a -> Bool -> [a] -> [a]
+ Universum.List.Reexport: takeWhile :: () => (a -> Bool) -> [a] -> [a]
- Universum.List.Reexport: unfoldr :: () => b -> Maybe (a, b) -> b -> [a]
+ Universum.List.Reexport: unfoldr :: () => (b -> Maybe (a, b)) -> b -> [a]
- Universum.List.Reexport: zipWith :: () => a -> b -> c -> [a] -> [b] -> [c]
+ Universum.List.Reexport: zipWith :: () => (a -> b -> c) -> [a] -> [b] -> [c]
- Universum.Monad.Reexport: (<$!>) :: Monad m => a -> b -> m a -> m b
+ Universum.Monad.Reexport: (<$!>) :: Monad m => (a -> b) -> m a -> m b
- Universum.Monad.Reexport: (<=<) :: Monad m => b -> m c -> a -> m b -> a -> m c
+ Universum.Monad.Reexport: (<=<) :: Monad m => (b -> m c) -> (a -> m b) -> a -> m c
- Universum.Monad.Reexport: (=<<) :: Monad m => a -> m b -> m a -> m b
+ Universum.Monad.Reexport: (=<<) :: Monad m => (a -> m b) -> m a -> m b
- Universum.Monad.Reexport: (>=>) :: Monad m => a -> m b -> b -> m c -> a -> m c
+ Universum.Monad.Reexport: (>=>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
- Universum.Monad.Reexport: (>>=) :: Monad m => m a -> a -> m b -> m b
+ Universum.Monad.Reexport: (>>=) :: Monad m => m a -> (a -> m b) -> m b
- Universum.Monad.Reexport: ExceptT :: m Either e a -> ExceptT e a
+ Universum.Monad.Reexport: ExceptT :: m (Either e a) -> ExceptT e a
- Universum.Monad.Reexport: MaybeT :: m Maybe a -> MaybeT a
+ Universum.Monad.Reexport: MaybeT :: m (Maybe a) -> MaybeT a
- Universum.Monad.Reexport: ReaderT :: r -> m a -> ReaderT r
+ Universum.Monad.Reexport: ReaderT :: (r -> m a) -> ReaderT r
- Universum.Monad.Reexport: StateT :: s -> m (a, s) -> StateT s a
+ Universum.Monad.Reexport: StateT :: (s -> m (a, s)) -> StateT s a
- Universum.Monad.Reexport: [runMaybeT] :: MaybeT a -> m Maybe a
+ Universum.Monad.Reexport: [runMaybeT] :: MaybeT a -> m (Maybe a)
- Universum.Monad.Reexport: ap :: Monad m => m a -> b -> m a -> m b
+ Universum.Monad.Reexport: ap :: Monad m => m (a -> b) -> m a -> m b
- Universum.Monad.Reexport: asks :: MonadReader r m => r -> a -> m a
+ Universum.Monad.Reexport: asks :: MonadReader r m => (r -> a) -> m a
- Universum.Monad.Reexport: class Applicative m => Monad (m :: * -> *)
+ Universum.Monad.Reexport: class Applicative m => Monad (m :: Type -> Type)
- Universum.Monad.Reexport: class Monad m => MonadFail (m :: * -> *)
+ Universum.Monad.Reexport: class Monad m => MonadFail (m :: Type -> Type)
- Universum.Monad.Reexport: class Monad m => MonadIO (m :: * -> *)
+ Universum.Monad.Reexport: class Monad m => MonadIO (m :: Type -> Type)
- Universum.Monad.Reexport: class (Alternative m, Monad m) => MonadPlus (m :: * -> *)
+ Universum.Monad.Reexport: class (Alternative m, Monad m) => MonadPlus (m :: Type -> Type)
- Universum.Monad.Reexport: class Monad m => MonadReader r (m :: * -> *) | m -> r
+ Universum.Monad.Reexport: class Monad m => MonadReader r (m :: Type -> Type) | m -> r
- Universum.Monad.Reexport: class Monad m => MonadState s (m :: * -> *) | m -> s
+ Universum.Monad.Reexport: class Monad m => MonadState s (m :: Type -> Type) | m -> s
- Universum.Monad.Reexport: class MonadTrans (t :: * -> * -> * -> *)
+ Universum.Monad.Reexport: class MonadTrans (t :: Type -> Type -> Type -> Type)
- Universum.Monad.Reexport: data IdentityT (f :: k -> *) (a :: k) :: forall k. () => k -> * -> k -> *
+ Universum.Monad.Reexport: data IdentityT (f :: k -> Type) (a :: k) :: forall k. () => k -> Type -> k -> Type
- Universum.Monad.Reexport: either :: () => a -> c -> b -> c -> Either a b -> c
+ Universum.Monad.Reexport: either :: () => (a -> c) -> (b -> c) -> Either a b -> c
- Universum.Monad.Reexport: filterM :: Applicative m => a -> m Bool -> [a] -> m [a]
+ Universum.Monad.Reexport: filterM :: Applicative m => (a -> m Bool) -> [a] -> m [a]
- Universum.Monad.Reexport: foldM :: (Foldable t, Monad m) => b -> a -> m b -> b -> t a -> m b
+ Universum.Monad.Reexport: foldM :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m b
- Universum.Monad.Reexport: foldM_ :: (Foldable t, Monad m) => b -> a -> m b -> b -> t a -> m ()
+ Universum.Monad.Reexport: foldM_ :: (Foldable t, Monad m) => (b -> a -> m b) -> b -> t a -> m ()
- Universum.Monad.Reexport: gets :: MonadState s m => s -> a -> m a
+ Universum.Monad.Reexport: gets :: MonadState s m => (s -> a) -> m a
- Universum.Monad.Reexport: join :: Monad m => m m a -> m a
+ Universum.Monad.Reexport: join :: Monad m => m (m a) -> m a
- Universum.Monad.Reexport: liftM2 :: Monad m => a1 -> a2 -> r -> m a1 -> m a2 -> m r
+ Universum.Monad.Reexport: liftM2 :: Monad m => (a1 -> a2 -> r) -> m a1 -> m a2 -> m r
- Universum.Monad.Reexport: liftM3 :: Monad m => a1 -> a2 -> a3 -> r -> m a1 -> m a2 -> m a3 -> m r
+ Universum.Monad.Reexport: liftM3 :: Monad m => (a1 -> a2 -> a3 -> r) -> m a1 -> m a2 -> m a3 -> m r
- Universum.Monad.Reexport: liftM4 :: Monad m => a1 -> a2 -> a3 -> a4 -> r -> m a1 -> m a2 -> m a3 -> m a4 -> m r
+ Universum.Monad.Reexport: liftM4 :: Monad m => (a1 -> a2 -> a3 -> a4 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m r
- Universum.Monad.Reexport: liftM5 :: Monad m => a1 -> a2 -> a3 -> a4 -> a5 -> r -> m a1 -> m a2 -> m a3 -> m a4 -> m a5 -> m r
+ Universum.Monad.Reexport: liftM5 :: Monad m => (a1 -> a2 -> a3 -> a4 -> a5 -> r) -> m a1 -> m a2 -> m a3 -> m a4 -> m a5 -> m r
- Universum.Monad.Reexport: local :: MonadReader r m => r -> r -> m a -> m a
+ Universum.Monad.Reexport: local :: MonadReader r m => (r -> r) -> m a -> m a
- Universum.Monad.Reexport: mapAndUnzipM :: Applicative m => a -> m (b, c) -> [a] -> m ([b], [c])
+ Universum.Monad.Reexport: mapAndUnzipM :: Applicative m => (a -> m (b, c)) -> [a] -> m ([b], [c])
- Universum.Monad.Reexport: mapMaybe :: () => a -> Maybe b -> [a] -> [b]
+ Universum.Monad.Reexport: mapMaybe :: () => (a -> Maybe b) -> [a] -> [b]
- Universum.Monad.Reexport: maybe :: () => b -> a -> b -> Maybe a -> b
+ Universum.Monad.Reexport: maybe :: () => b -> (a -> b) -> Maybe a -> b
- Universum.Monad.Reexport: mfilter :: MonadPlus m => a -> Bool -> m a -> m a
+ Universum.Monad.Reexport: mfilter :: MonadPlus m => (a -> Bool) -> m a -> m a
- Universum.Monad.Reexport: modify :: MonadState s m => s -> s -> m ()
+ Universum.Monad.Reexport: modify :: MonadState s m => (s -> s) -> m ()
- Universum.Monad.Reexport: modify' :: MonadState s m => s -> s -> m ()
+ Universum.Monad.Reexport: modify' :: MonadState s m => (s -> s) -> m ()
- Universum.Monad.Reexport: newtype ExceptT e (m :: * -> *) a
+ Universum.Monad.Reexport: newtype ExceptT e (m :: Type -> Type) a
- Universum.Monad.Reexport: newtype MaybeT (m :: * -> *) a
+ Universum.Monad.Reexport: newtype MaybeT (m :: Type -> Type) a
- Universum.Monad.Reexport: newtype StateT s (m :: * -> *) a
+ Universum.Monad.Reexport: newtype StateT s (m :: Type -> Type) a
- Universum.Monad.Reexport: reader :: MonadReader r m => r -> a -> m a
+ Universum.Monad.Reexport: reader :: MonadReader r m => (r -> a) -> m a
- Universum.Monad.Reexport: runExceptT :: () => ExceptT e m a -> m Either e a
+ Universum.Monad.Reexport: runExceptT :: () => ExceptT e m a -> m (Either e a)
- Universum.Monad.Reexport: state :: MonadState s m => s -> (a, s) -> m a
+ Universum.Monad.Reexport: state :: MonadState s m => (s -> (a, s)) -> m a
- Universum.Monad.Reexport: withState :: () => s -> s -> State s a -> State s a
+ Universum.Monad.Reexport: withState :: () => (s -> s) -> State s a -> State s a
- Universum.Monad.Reexport: zipWithM :: Applicative m => a -> b -> m c -> [a] -> [b] -> m [c]
+ Universum.Monad.Reexport: zipWithM :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m [c]
- Universum.Monad.Reexport: zipWithM_ :: Applicative m => a -> b -> m c -> [a] -> [b] -> m ()
+ Universum.Monad.Reexport: zipWithM_ :: Applicative m => (a -> b -> m c) -> [a] -> [b] -> m ()
- Universum.Monoid: Endo :: a -> a -> Endo a
+ Universum.Monoid: Endo :: (a -> a) -> Endo a
- Universum.Monoid: newtype Alt (f :: k -> *) (a :: k) :: forall k. () => k -> * -> k -> *
+ Universum.Monoid: newtype Alt (f :: k -> Type) (a :: k) :: forall k. () => k -> Type -> k -> Type
- Universum.Nub: ordNub :: (Ord a) => [a] -> [a]
+ Universum.Nub: ordNub :: Ord a => [a] -> [a]
- Universum.Nub: sortNub :: (Ord a) => [a] -> [a]
+ Universum.Nub: sortNub :: Ord a => [a] -> [a]

Files

CHANGES.md view
@@ -1,5 +1,37 @@+Unreleased+=====++1.5.0+=====++* Make `error`'s stacktrace exclude site of the `error` function itself.++* [#200](https://github.com/serokell/universum/pull/200):+  Implemented a lifted version of `withFile` and added `hClose` to+  `Universum.Lifted.File` as discussed previously in+  [#186](https://github.com/serokell/universum/issues/186).++* [#204](https://github.com/serokell/universum/issues/186):+  Make `trace` non-polymorphic over text argument, add `traceIdWith` and `traceShowIdWith`.++* [#197](https://github.com/serokell/universum/pull/197) `hPutStr`, `hPutStrLn`+  and `hPrint` added to `Universum.Print`. The interface for the backing+  typeclass `Universum.Print.Print` changed. It was also moved to the internal+  module `Universum.Print.Internal` and should be considered unstable.++  _Migration guide:_ The interface for the `Print` class should be considered+  internal and may be subject to sudden change. If you **must** implement your+  own instances, then import `Universum.Print.Internal` (be aware that there are+  name clashes in the functions from `Universum.Print` and+  `Universum.Print.Internal`)++* [#201](https://github.com/serokell/universum/pull/201) Generalized the type of+  `Universum.Lifted.Env.die`. Should not break existing code, apart from,+  perhaps, type inference.+ 1.4.0 =====+ * [#167](https://github.com/serokell/universum/issues/164):   `identity` has been removed. @@ -7,7 +39,7 @@ * [#177](https://github.com/serokell/universum/issues/177):   The `mask_` reexport from `safe-exceptions` has been removed. -  _Migration_guide:_ use `Control.Exception.Safe.mask_` from `safe-exceptions`+  _Migration guide:_ use `Control.Exception.Safe.mask_` from `safe-exceptions`   instead. * [#178](https://github.com/serokell/universum/issues/178):   `getArgs` has been removed.@@ -21,7 +53,7 @@   and `Data.Text.Lazy.IO.interact`, both from the `text` package. * [#180](https://github.com/serokell/universum/issues/180):   The `Lifted.ST` module has been removed.-  +   _Migration guide:_ use `liftIO` directly with functions from   `Control.Monad.ST` instead. * [#181](https://github.com/serokell/universum/issues/181):@@ -36,7 +68,7 @@   _Migration guide:_ use `Universum.id` instead. * [#170](https://github.com/serokell/universum/pull/170):   Remove `ElementConstraint` from the `Container` class.-  +   _Migration guide:_ remove `ElementConstraint` from every instance and every type signature. * [#174](https://github.com/serokell/universum/issues/174)   The `type-operators` dependency has been removed.@@ -58,7 +90,7 @@ * [#180](https://github.com/serokell/universum/issues/180):   The `Lifted.ST` module has been deprecated. To be removed in a future   version.-  +   _Migration guide:_ use `liftIO` directly with functions from   `Control.Monad.ST` instead. * [#181](https://github.com/serokell/universum/issues/181):
CONTRIBUTING.md view
@@ -2,9 +2,76 @@  ## :wave: Greetings Traveler! -I'm glad you're reading this, I really appreciate the effort you're+We are glad you're reading this, we really appreciate the effort you're putting in. Thank you for your help in making this library awesome! :sparkles: +### Versioning policy+The version of this library typically consists of at most four numbers (last numbers are assumed to be 0 if there are less than 4 numbers).+The semantics is `marketing.breaking.feature.fix`:+* `fix` is increased when set of exported definitions is not modified (all changes are not visible outside).+* `feature` is increased when set of exported definitions is strictly augmented.+* `breaking` is increased when breaking changes are made.+* `marketing` is increased for releases which are important from marketing perspective.++### Code modification policy++**tl;dr**++1. Issues with labels `type:not-code` and `type:fix` can be resolved at any time.+2. Issues with labels `type:feature` and `type:breaking` can be resolved only after being added to a milestone.+3. `features` releases happen at most once per two weeks.+3. `breaking` releases happen at most once per five weeks.++**Actual policy**++We think that a custom prelude shouldn't change often.+Because of that we have a semi-formal policy describing which modifications can be done to `universum` under which circumstances.+We split all issues into four semi-formally defined categories:+1. `not-code`.+Everything that doesn't modify source code (except non-Haddock comments), `.cabal` files, other files considered by GHC (if they exist).+Examples: fix a typo in README.md, fix something in CI configuration files, add a pull request template.+2. `fix`.+Everything that doesn't fit in `not-code`, but doesn't change set of exported definitions and their types or semantics.+Examples: fix compatibility with a new version of a library/compiler, improve performance of some function (keeping its semantics intact).+Note: despite the name, issues of this type do not necessary correspond to bug fixes.+3. `feature`.+Modifications which make set of exported definitions a superset of the old set of exported definitions.+I. e. all existing definitions are left intact, only something new is added.+Example: add a new function, re-export a type class, add a new instance of some type class.+4. `breaking`.+Basically all other changes.+Examples: remove of a function, rename a type class, change arguments order of a function.++Each issue should belong to only one category.+If an issue involves multiple changes of different types, it should be split into smaller issues++For each category we have a label on GitHub, these labels start with the `type:` prefix.+There is also the `type:unclear` label for issues which don't have a list of specific actions to be done.++Processing of an issue depends on its category. Specifically:+1. A `not-code` issue can be resolved at any time.+PRs can be merged whenever GitHub allows it.+Minimal number of approvals is set to 2 in GitHub settings.+2. Rules for the `fix` issues are the same as for `not-code` with an additional rule that PRs for such issues should increase the last component in the version and this version should be uploaded to Hackage as soon as the PR is merged (also new tag and release are created).+3. Work on the `feature` issues is organized in milestones.+Each milestone corresponds to a release which increases at least the third (`feature`) version component.+Scope of each milestone is discussed in issues and is set by maintainers.+In some cases a special issue can be created to discuss the scope of a particular milestone.+A `feature` issue is added to a milestone if such addition is approved by at least 3 people (by explicitly stating that in GH comments).+At least 2 of them must be from Serokell.+However, if there are 4 people (from which at least 3 are from Serokell) who disapprove this issue, it can't be added to a milestone.+A new `feature` release can happen only after at least 2 weeks have passed after last release (except `fix` releases).+PR can be merged only if the corresponding `feature` issue is in the upcoming milestone.+4. Work on the `breaking` issues is organized in almost the same way.+However, 4 approvals (at least 3 from Serokell) are necessary for inclusion into a milestone.+2 disapprovals from Serokell or 4 disapprovals in total are enough to prevent the issue from getting into a milestone.+If an issue is about removal of something (`x`), it should be done in two steps.+The first step is deprecation of `x` which happens in a `breaking` release.+The second step is deprecation of `x` which happens in another `breaking` release after deprecation of `x`.+There can't be more than one breaking release in less than 5 weeks.++Note: approval of any PR implies that the person who approves it confirms that the PR corresponds to the issue mentioned there and the issue has a correct type.+ ### How to contribute  #### Report bugs or feature request@@ -12,13 +79,18 @@ don't hesitate to create issues [here](https://github.com/serokell/universum/issues/new) in free format. +#### Share your opinion in existing issues and pull requests+We want `universum` to be suitable for as many Haskell developers as possible.+That's why we would greatly appreciate your comments in our issues and pull requests.+Please tell us whether you think that proposed modifications makes sense and are worth doing.+ #### Create a PR We love receiving pull requests from everyone. But, please, don't create a PR-without a corresponding issue. It's always better to discuss your future-work first. Even if such an issue exist it's still better to express your willing+without a corresponding issue. It's always a good idea to express your wish to do that issue under comment section. Thus you will show that you're doing that issue, and nobody else will accidentally do it in parallel with you. Furthermore you also can discuss the best way to implement that issue!+Make sure to read the [Code modification policy](#code-modification-policy) before starting your work on any issue.  To get started with this you should first fork, then clone the repo: 
README.md view
@@ -85,6 +85,8 @@    Things like `liftIO`, `ReaderT` type, `MVar`-related functions have unambiguous names,    are used in almost every non-trivial project, and it's really tedious to import them    manually every time.+5. Make changes only when there are enough good reasons to make these changes.+   We have a [code modification policy](CONTRIBUTING.md#code-modification-policy) which semi-formally describes pre-conditions for different types of changes.  Unlike `protolude`, we are: 
src/Universum/Base.hs view
@@ -63,7 +63,7 @@ import Numeric.Natural (Natural)  -- IO-import System.IO (FilePath, Handle, IOMode (..), stderr, stdin, stdout, withFile)+import System.IO (FilePath, Handle, IOMode (..), stderr, stdin, stdout)  -- Base typeclasses import Data.Eq (Eq (..))
src/Universum/Debug.hs view
@@ -1,7 +1,9 @@ {-# LANGUAGE CPP                #-} {-# LANGUAGE DeriveDataTypeable #-} {-# LANGUAGE DeriveGeneric      #-}+{-# LANGUAGE ImplicitParams     #-} {-# LANGUAGE KindSignatures     #-}+{-# LANGUAGE MagicHash          #-} {-# LANGUAGE PolyKinds          #-} {-# LANGUAGE RankNTypes         #-} {-# LANGUAGE Trustworthy        #-}@@ -10,7 +12,7 @@ #endif  -- | Functions for debugging. If you left these functions in your code--- then warning is generated to remind you about left usages. Also some+-- then warning is generated to remind you about left usages. Also, some -- functions (and data types) are convenient for prototyping.  module Universum.Debug@@ -19,33 +21,36 @@        , trace        , traceM        , traceId+       , traceIdWith        , traceShow        , traceShowId+       , traceShowIdWith        , traceShowM        , undefined        ) where  import Control.Monad (Monad, return) import Data.Data (Data)-import Data.Text (Text, unpack)+import Data.Text (Text, pack, unpack) import Data.Typeable (Typeable) import GHC.Generics (Generic) import System.IO.Unsafe (unsafePerformIO)  #if ( __GLASGOW_HASKELL__ >= 800 )-import GHC.Exts (RuntimeRep, TYPE)+import GHC.Exception (errorCallWithCallStackException)+import GHC.Exts (RuntimeRep, TYPE, raise#) -import Universum.Base (HasCallStack)+import Universum.Base (HasCallStack, callStack) #endif  import Universum.Applicative (pass)-import Universum.Print (Print, putStrLn)+import Universum.Print (putStrLn)  import qualified Prelude as P --- | Generalized over string version of 'Debug.Trace.trace' that leaves warnings.+-- | Version of 'Debug.Trace.trace' that leaves a warning and takes 'Text'. {-# WARNING trace "'trace' remains in code" #-}-trace :: Print b => b -> a -> a+trace :: Text -> a -> a trace string expr = unsafePerformIO (do     putStrLn string     return expr)@@ -54,32 +59,60 @@ #if ( __GLASGOW_HASKELL__ >= 800 ) error :: forall (r :: RuntimeRep) . forall (a :: TYPE r) . HasCallStack       => Text -> a+error s = raise# (errorCallWithCallStackException (unpack s) callStack) #else error :: Text -> a-#endif error s = P.error (unpack s)+#endif --- | Version of 'Debug.Trace.traceShow' that leaves warning.+-- | Version of 'Debug.Trace.traceShow' that leaves a warning. {-# WARNING traceShow "'traceShow' remains in code" #-} traceShow :: P.Show a => a -> b -> b-traceShow a b = trace (P.show a) b+traceShow a b = trace (pack (P.show a)) b --- | Version of 'Debug.Trace.traceShow' that leaves warning.+-- | Version of 'Debug.Trace.traceShowId' that leaves a warning. {-# WARNING traceShowId "'traceShowId' remains in code" #-} traceShowId :: P.Show a => a -> a-traceShowId a = trace (P.show a) a+traceShowId a = trace (pack (P.show a)) a --- | Version of 'Debug.Trace.traceShowM' that leaves warning.+{- | Version of 'Debug.Trace.traceId' that leaves a warning.+Useful to tag printed data, for instance:++@+traceIdWith (\x -> "My data: " <> show x) (veryLargeExpression)+@++This is especially useful with custom formatters:++@+traceIdWith (\x -> "My data: " <> pretty x) (veryLargeExpression)+@+-}+{-# WARNING traceIdWith "'traceIdWith' remains in code" #-}+traceIdWith :: (a -> Text) -> a -> a+traceIdWith f a = trace (f a) a++-- | Version of 'Debug.Trace.traceShowId' that leaves a warning.+-- Useful to tag printed data, for instance:+--+-- @+-- traceShowIdWith ("My data: ", ) (veryLargeExpression)+-- @+{-# WARNING traceShowIdWith "'traceShowIdWith' remains in code" #-}+traceShowIdWith :: P.Show s => (a -> s) -> a -> a+traceShowIdWith f a = trace (pack (P.show (f a))) a++-- | Version of 'Debug.Trace.traceShowM' that leaves a warning. {-# WARNING traceShowM "'traceShowM' remains in code" #-} traceShowM :: (P.Show a, Monad m) => a -> m ()-traceShowM a = trace (P.show a) pass+traceShowM a = trace (pack (P.show a)) pass --- | Version of 'Debug.Trace.traceM' that leaves warning and takes 'Text'.+-- | Version of 'Debug.Trace.traceM' that leaves a warning and takes 'Text'. {-# WARNING traceM "'traceM' remains in code" #-} traceM :: (Monad m) => Text -> m ()-traceM s = trace (unpack s) pass+traceM s = trace s pass --- | Version of 'Debug.Trace.traceId' that leaves warning and takes 'Text'.+-- | Version of 'Debug.Trace.traceId' that leaves a warning. {-# WARNING traceId "'traceId' remains in code" #-} traceId :: Text -> Text traceId s = trace s s@@ -89,7 +122,7 @@ data Undefined = Undefined     deriving (P.Eq, P.Ord, P.Show, P.Read, P.Enum, P.Bounded, Data, Typeable, Generic) --- | 'P.undefined' that leaves warning in code on every usage.+-- | 'P.undefined' that leaves a warning in code on every usage. {-# WARNING undefined "'undefined' function remains in code (or use 'error')" #-} #if ( __GLASGOW_HASKELL__ >= 800 ) undefined :: forall (r :: RuntimeRep) . forall (a :: TYPE r) . HasCallStack => a
src/Universum/Lifted/Env.hs view
@@ -36,6 +36,6 @@ -- | Lifted version of 'System.Exit.die'. -- 'XIO.die' is available since base-4.8, but it's more convenient to -- redefine it instead of using CPP.-die :: MonadIO m => String -> m ()+die :: MonadIO m => String -> m a die err = liftIO (System.IO.hPutStrLn stderr err) >> exitFailure {-# INLINE die #-}
src/Universum/Lifted/File.hs view
@@ -7,18 +7,22 @@ module Universum.Lifted.File        ( appendFile        , getLine-       , openFile        , readFile        , writeFile+       , withFile+       , openFile+       , hClose        ) where +import Control.Exception.Safe (MonadMask, bracket) import Control.Monad.Trans (MonadIO, liftIO)+import Data.Function ((.)) import Data.Text (Text) import Prelude (FilePath) import System.IO (Handle, IOMode)  import qualified Data.Text.IO as XIO-import qualified System.IO as XIO (openFile)+import qualified System.IO as XIO (openFile, hClose, IO)  ---------------------------------------------------------------------------- -- Text@@ -45,8 +49,37 @@ {-# INLINE writeFile #-}  -- | Lifted version of 'System.IO.openFile'.+--+-- See also 'withFile' for more information. openFile :: MonadIO m => FilePath -> IOMode -> m Handle openFile a b = liftIO (XIO.openFile a b) {-# INLINE openFile #-} --- 'withFile' can't be lifted into 'MonadIO', as it uses 'bracket'+-- | Close a file handle+--+-- See also 'withFile' for more information.+hClose :: MonadIO m => Handle -> m ()+hClose = liftIO . XIO.hClose+{-# INLINE hClose #-}++-- | Opens a file, manipulates it with the provided function and closes the+-- handle before returning. The 'Handle' can be written to using the+-- 'Universum.Print.hPutStr' and 'Universum.Print.hPutStrLn' functions.+--+-- 'withFile' is essentially the 'bracket' pattern, specialized to files. This+-- should be preferred over 'openFile' + 'hClose' as it properly deals with+-- (asynchronous) exceptions. In cases where 'withFile' is insufficient, for+-- instance because the it is not statically known when manipulating the+-- 'Handle' has finished, one should consider other safe paradigms for resource+-- usage, such as the @ResourceT@ transformer from the @resourcet@ package,+-- before resorting to 'openFile' and 'hClose'.+withFile :: (MonadIO m, MonadMask m) => FilePath -> IOMode -> (Handle -> m a) -> m a+withFile filePath mode f = bracket (openFile filePath mode) hClose f++{-# SPECIALIZE appendFile :: FilePath -> Text -> XIO.IO () #-}+{-# SPECIALIZE getLine :: XIO.IO Text #-}+{-# SPECIALIZE readFile :: FilePath -> XIO.IO Text #-}+{-# SPECIALIZE writeFile :: FilePath -> Text -> XIO.IO () #-}+{-# SPECIALIZE openFile :: FilePath -> IOMode -> XIO.IO Handle #-}+{-# SPECIALIZE hClose :: Handle -> XIO.IO () #-}+{-# SPECIALIZE withFile :: FilePath -> IOMode -> (Handle -> XIO.IO a) -> XIO.IO a #-}
src/Universum/Print.hs view
@@ -1,64 +1,90 @@+{-|+Module      : $header$+Description : Overloaded writing for String-like types+Copyright   : (c) Serokell 2018+License     : MIT+Maintainer  : Serokell <hi@serokell.io>+Stability   : experimental+Portability : portable++Generalizes the 'Base.putStr' family of functions for String likes such as lazy+and strict versions of 'Text' and 'ByteString'.++A caveat to using overloaded functions is that printing string literals raises+ambiguity errors in the presence of @OverloadedStrings@. To avoid this problem+wither add a type annotation @putStr ("Hello World!" :: Text)@ or use one of the+type constrained functions 'putText', 'putLText' etc.++You may add support for your own types by importing "Universum.Print.Internal"+and implementing 'Print'. However be advised that only the functions in this+module should be considered stable, not the interface for 'Print'.+-} {-# LANGUAGE ExplicitForAll    #-} {-# LANGUAGE FlexibleContexts  #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE Trustworthy       #-} --- | Generalization of 'Prelude.putStr' and 'Prelude.putStrLn' functions.- module Universum.Print-       ( Print (..)+       ( putStr+       , putStrLn        , print+       , Print        , putText        , putTextLn        , putLText        , putLTextLn+       -- ** Writing strings to an arbitrary 'Handle'+       , hPutStr+       , hPutStrLn+       , hPrint        ) where  import Data.Function ((.))  import Universum.Monad.Reexport (MonadIO, liftIO) -import qualified Prelude (print, putStr, putStrLn)+import Universum.Print.Internal (Print)+import qualified Universum.Print.Internal as I (hPutStrLn, hPutStr) -import qualified Data.ByteString.Char8 as BS-import qualified Data.ByteString.Lazy.Char8 as BL+import qualified Prelude (print)+import qualified System.IO as SIO (Handle, hPrint)  import qualified Data.Text as T-import qualified Data.Text.IO as T  import qualified Data.Text.Lazy as TL-import qualified Data.Text.Lazy.IO as TL  import qualified Universum.Base as Base --- | Polymorfic over string and lifted to 'MonadIO' printing functions.-class Print a where-  putStr :: MonadIO m => a -> m ()-  putStrLn :: MonadIO m => a -> m ()--instance Print T.Text where-  putStr = liftIO . T.putStr-  putStrLn = liftIO . T.putStrLn--instance Print TL.Text where-  putStr = liftIO . TL.putStr-  putStrLn = liftIO . TL.putStrLn+-- | Write a string like value @a@ to a supplied 'SIO.Handle'.+hPutStr :: (Print a, MonadIO m) => SIO.Handle -> a -> m ()+hPutStr h = liftIO . I.hPutStr h+{-# SPECIALIZE hPutStr :: Print a => SIO.Handle -> a -> Base.IO () #-} -instance Print BS.ByteString where-  putStr = liftIO . BS.putStr-  putStrLn = liftIO . BS.putStrLn+-- | Write a string like value @a@ to a supplied 'SIO.Handle', appending a+-- newline character.+hPutStrLn :: (Print a, MonadIO m) => SIO.Handle -> a -> m ()+hPutStrLn h = liftIO . I.hPutStrLn h+{-# SPECIALIZE hPutStrLn :: Print a => SIO.Handle -> a -> Base.IO () #-} -instance Print BL.ByteString where-  putStr = liftIO . BL.putStr-  putStrLn = liftIO . BL.putStrLn+-- | Write a string like value to @stdout@/.+putStr :: (Print a, MonadIO m) => a -> m ()+putStr = hPutStr Base.stdout+{-# SPECIALIZE putStr :: Print a => a -> Base.IO () #-} -instance Print [Base.Char] where-  putStr = liftIO . Prelude.putStr-  putStrLn = liftIO . Prelude.putStrLn+-- | Write a string like value to @stdout@ appending a newline character.+putStrLn :: (Print a, MonadIO m) => a -> m ()+putStrLn = hPutStrLn Base.stdout+{-# SPECIALIZE putStrLn :: Print a => a -> Base.IO () #-}  -- | Lifted version of 'Prelude.print'. print :: forall a m . (MonadIO m, Base.Show a) => a -> m () print = liftIO . Prelude.print+{-# SPECIALIZE print :: Base.Show a => a -> Base.IO () #-}++-- | Lifted version of 'System.IO.hPrint'+hPrint :: (MonadIO m, Base.Show a) => SIO.Handle -> a -> m ()+hPrint h = liftIO . SIO.hPrint h+{-# SPECIALIZE hPrint :: Base.Show a => SIO.Handle -> a -> Base.IO () #-}  -- | Specialized to 'T.Text' version of 'putStr' or forcing type inference. putText :: MonadIO m => T.Text -> m ()
+ src/Universum/Print/Internal.hs view
@@ -0,0 +1,53 @@+{-|+Module      : $header$+Description : Class machinery for overloaded writing of String-like types+Copyright   : (c) Justus Adam 2018+License     : MIT+Maintainer  : Serokell <hi@serokell.io>+Stability   : experimental+Portability : portable++You may import this module to define your own, custom instances of 'Print'. Be+advised however that this module is an internal API and may be subject to change+__even for minor version increments__.+-}+{-# LANGUAGE FlexibleInstances #-}+module Universum.Print.Internal (Print(..)) where++import qualified System.IO as SIO (hPutStr, hPutStrLn, Handle)++import qualified Data.ByteString.Char8 as BS+import qualified Data.ByteString.Lazy.Char8 as BL++import qualified Data.Text as T+import qualified Data.Text.IO as T++import qualified Data.Text.Lazy as TL+import qualified Data.Text.Lazy.IO as TL++import qualified Universum.Base as Base++-- | Support class to overload writing of string like values.+class Print a where+  hPutStr :: SIO.Handle -> a -> Base.IO ()+  hPutStrLn :: SIO.Handle -> a -> Base.IO ()++instance Print T.Text where+  hPutStr = T.hPutStr+  hPutStrLn = T.hPutStrLn++instance Print TL.Text where+  hPutStr = TL.hPutStr+  hPutStrLn = TL.hPutStrLn++instance Print BS.ByteString where+  hPutStr = BS.hPutStr+  hPutStrLn = BS.hPutStrLn++instance Print BL.ByteString where+  hPutStr = BL.hPutStr+  hPutStrLn = BL.hPutStrLn++instance Print [Base.Char] where+  hPutStr = SIO.hPutStr+  hPutStrLn = SIO.hPutStrLn
universum.cabal view
@@ -1,5 +1,5 @@ name:                universum-version:             1.4.0+version:             1.5.0 synopsis:            Custom prelude used in Serokell description:         See README.md file for more details. homepage:            https://github.com/serokell/universum@@ -61,6 +61,7 @@                            Universum.Monoid                            Universum.Nub                            Universum.Print+                               Universum.Print.Internal                            Universum.String                                Universum.String.Conversion                                Universum.String.Reexport