Safe Haskell | None |
---|
BasicPrelude mostly re-exports several key libraries in their entirety. The exception is Data.List, where various functions are replaced by similar versions that are either generalized, operate on Text, or are implemented strictly.
- module CorePrelude
- map :: Functor f => (a -> b) -> f a -> f b
- empty :: Monoid w => w
- (++) :: Monoid w => w -> w -> w
- concat :: Monoid w => [w] -> w
- intercalate :: Monoid w => w -> [w] -> w
- sum :: Num a => [a] -> a
- product :: Num a => [a] -> a
- show :: Show a => a -> Text
- read :: Read a => Text -> a
- readIO :: Read a => Text -> IO a
- readFile :: FilePath -> IO Text
- writeFile :: FilePath -> Text -> IO ()
- appendFile :: FilePath -> Text -> IO ()
- lines :: Text -> [Text]
- words :: Text -> [Text]
- unlines :: [Text] -> Text
- unwords :: [Text] -> Text
- textToString :: Text -> String
- ltextToString :: LText -> String
- encodeUtf8 :: Text -> ByteString
- decodeUtf8 :: ByteString -> Text
- getLine :: IO Text
- getContents :: IO Text
- interact :: (Text -> Text) -> IO ()
- gcd :: Integral a => a -> a -> a
- lcm :: Integral a => a -> a -> a
- type ShowS = String -> String
- showsPrec :: Show a => Int -> a -> ShowS
- showList :: Show a => [a] -> ShowS
- shows :: Show a => a -> ShowS
- showChar :: Char -> ShowS
- showString :: String -> ShowS
- showParen :: Bool -> ShowS -> ShowS
- type ReadS a = String -> [(a, String)]
- readsPrec :: Read a => Int -> ReadS a
- readList :: Read a => ReadS [a]
- reads :: Read a => ReadS a
- readParen :: Bool -> ReadS a -> ReadS a
- lex :: ReadS String
- readMay :: Read a => Text -> Maybe a
- putChar :: Char -> IO ()
- getChar :: IO Char
- readLn :: Read a => IO a
Module exports
module CorePrelude
Enhanced exports
Simpler name for a typeclassed operation
intercalate :: Monoid w => w -> [w] -> wSource
intercalate = mconcat .: intersperse
Strict implementation
Text for Read and Show operations
readIO :: Read a => Text -> IO aSource
The readIO function is similar to read except that it signals parse failure to the IO monad instead of terminating the program.
FilePath for file operations
readFile :: FilePath -> IO TextSource
Read a file and return the contents of the file as Text. The entire file is read strictly.
writeFile :: FilePath -> Text -> IO ()Source
Write Text to a file. The file is truncated to zero length before writing begins.
appendFile :: FilePath -> Text -> IO ()Source
Write Text to the end of a file.
Text exports
Text operations (Pure)
textToString :: Text -> StringSource
ltextToString :: LText -> StringSource
encodeUtf8 :: Text -> ByteString
Encode text using UTF-8 encoding.
decodeUtf8 :: ByteString -> TextSource
Note that this is not the standard Data.Text.Encoding.decodeUtf8
. That
function will throw impure exceptions on any decoding errors. This function
instead uses decodeLenient
.
Text operations (IO)
getContents :: IO Text
Lazily read all user input on stdin
as a single string.
interact :: (Text -> Text) -> IO ()
The interact
function takes a function of type Text -> Text
as its argument. The entire input from the standard input device is
passed (lazily) to this function as its argument, and the resulting
string is output on the standard output device.
Miscellaneous prelude re-exports
Math
Show and Read
showString :: String -> ShowS