polymorphic show func

This commit is contained in:
Stephen Diehl
2016-04-18 10:35:34 -04:00
parent ed6d680c70
commit e442b31203
2 changed files with 13 additions and 0 deletions
+1
View File
@@ -50,6 +50,7 @@ library
default-extensions:
NoImplicitPrelude
OverloadedStrings
FlexibleContexts
MultiParamTypeClasses
ghc-options:
+12
View File
@@ -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)