stringlike-0.0.0: Transformations to several string-like types

Safe HaskellNone

Data.String.Like

Synopsis

Documentation

class StringLike a whereSource

This type class can be used to transform any string like from lazy Text, there is no default implementation for String consciously, beacause we don't want to incite String using.

Methods

fromLazyText :: Text -> aSource

string :: (ToString a, StringLike b) => a -> bSource

Transform any ToString type to any StringLike type, it can be inferred or should be explicitly defined.

text :: ToString a => a -> TextSource

Transform any ToString type to strict Text

ltext :: ToString a => a -> TextSource

Transform any ToString type to lazy Text

bs :: ToString a => a -> ByteStringSource

Transform any ToString type to strict ByteString

lbs :: ToString a => a -> ByteStringSource

Transform any ToString type to lazy ByteString

readFile :: FilePath -> IO String

The readFile function reads a file and returns the contents of the file as a string. The file is read lazily, on demand, as with getContents.

writeFile :: FilePath -> String -> IO ()

The computation writeFile file str function writes the string str, to the file file.

appendFile :: FilePath -> String -> IO ()

The computation appendFile file str function appends the string str, to the file file.

Note that writeFile and appendFile write a literal string to a file. To write a value of any printable type, as with print, use the show function to convert the value to a string first.

 main = appendFile "squares" (show [(x,x*x) | x <- [0,0.1..2]])