polymorphic show func
This commit is contained in:
@@ -50,6 +50,7 @@ library
|
|||||||
default-extensions:
|
default-extensions:
|
||||||
NoImplicitPrelude
|
NoImplicitPrelude
|
||||||
OverloadedStrings
|
OverloadedStrings
|
||||||
|
FlexibleContexts
|
||||||
MultiParamTypeClasses
|
MultiParamTypeClasses
|
||||||
|
|
||||||
ghc-options:
|
ghc-options:
|
||||||
|
|||||||
@@ -7,10 +7,12 @@ module Protolude (
|
|||||||
module X,
|
module X,
|
||||||
module Base,
|
module Base,
|
||||||
identity,
|
identity,
|
||||||
|
map,
|
||||||
(&),
|
(&),
|
||||||
uncons,
|
uncons,
|
||||||
applyN,
|
applyN,
|
||||||
print,
|
print,
|
||||||
|
show,
|
||||||
|
|
||||||
LText,
|
LText,
|
||||||
LByteString,
|
LByteString,
|
||||||
@@ -29,9 +31,13 @@ import Base as Base hiding (
|
|||||||
putStr
|
putStr
|
||||||
, putStrLn
|
, putStrLn
|
||||||
, print
|
, print
|
||||||
|
, show
|
||||||
)
|
)
|
||||||
import qualified Base as PBase
|
import qualified Base as PBase
|
||||||
|
|
||||||
|
-- Used for 'show'
|
||||||
|
import Data.String (String)
|
||||||
|
|
||||||
-- Maybe'ized version of partial functions
|
-- Maybe'ized version of partial functions
|
||||||
import Safe as X (
|
import Safe as X (
|
||||||
headMay
|
headMay
|
||||||
@@ -297,6 +303,9 @@ x & f = f x
|
|||||||
identity :: a -> a
|
identity :: a -> a
|
||||||
identity x = x
|
identity x = x
|
||||||
|
|
||||||
|
map :: Functor f => (a -> b) -> f a -> f b
|
||||||
|
map = fmap
|
||||||
|
|
||||||
uncons :: [a] -> Maybe (a, [a])
|
uncons :: [a] -> Maybe (a, [a])
|
||||||
uncons [] = Nothing
|
uncons [] = Nothing
|
||||||
uncons (x:xs) = Just (x, xs)
|
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 :: (X.MonadIO m, PBase.Show a) => a -> m ()
|
||||||
print = liftIO . PBase.print
|
print = liftIO . PBase.print
|
||||||
|
|
||||||
|
show :: (Show a, StringConv String b) => a -> b
|
||||||
|
show x = toS (PBase.show x)
|
||||||
|
|||||||
Reference in New Issue
Block a user