diff --git a/protolude.cabal b/protolude.cabal index 54811fd5f..d0eb8df5d 100644 --- a/protolude.cabal +++ b/protolude.cabal @@ -50,6 +50,7 @@ library default-extensions: NoImplicitPrelude OverloadedStrings + FlexibleContexts MultiParamTypeClasses ghc-options: diff --git a/src/Protolude.hs b/src/Protolude.hs index e9d9efb37..6c6a056f0 100644 --- a/src/Protolude.hs +++ b/src/Protolude.hs @@ -7,10 +7,12 @@ module Protolude ( module X, module Base, identity, + map, (&), uncons, applyN, print, + show, LText, LByteString, @@ -29,9 +31,13 @@ import Base as Base hiding ( putStr , putStrLn , print + , show ) import qualified Base as PBase +-- Used for 'show' +import Data.String (String) + -- Maybe'ized version of partial functions import Safe as X ( headMay @@ -297,6 +303,9 @@ x & f = f x identity :: a -> a identity x = x +map :: Functor f => (a -> b) -> f a -> f b +map = fmap + uncons :: [a] -> Maybe (a, [a]) uncons [] = Nothing uncons (x:xs) = Just (x, xs) @@ -306,3 +315,6 @@ applyN n f = X.foldr (.) identity (X.replicate n f) print :: (X.MonadIO m, PBase.Show a) => a -> m () print = liftIO . PBase.print + +show :: (Show a, StringConv String b) => a -> b +show x = toS (PBase.show x)