Skip to content

Instantly share code, notes, and snippets.

@parambirs
Last active October 6, 2016 22:15
Show Gist options
  • Select an option

  • Save parambirs/c1a29352e28e0856bace3ab0be4575c4 to your computer and use it in GitHub Desktop.

Select an option

Save parambirs/c1a29352e28e0856bace3ab0be4575c4 to your computer and use it in GitHub Desktop.
GHC
putStrLn
putStr
putChar
print
getChar
sequence
mapM
mapM_
Control.Monad:
when
forever
forM
-- FILES and STREAMS
getContents
interact
readFile
writeFile
appendFile
openFile
hGetContents
hClose
withFile
hGetLine
hGetChar
hPutStr
hPutStrLn
hSetBuffering
hFlush
openTempFile
removeFile
renameFile
getCurrentDirectory
doesFileExist
-- COMMAND LINE ARGUMENTS
import System.Environment
getArgs
getProgName
-- RANDOM
import System.Random
random
mkStdGen
randoms
randomR
randomRs
getStdGen
newStdGen
-- BYTESTRINGS
import qualified Data.ByteString.Lazy as B
import qualified Data.ByteString as S
pack
unpack
fromChunks
toChunks
cons
cons'
empty
readFile
-- EXCEPTIONS
import System.IO.Error
catchIOError
ioError
userError
isAlreadyExistsError
isDoesNotExistError
isAlreadyInUseError
isFullError
isEOFError
isIllegalOperation
isPermissionError
isUserError
ioeGetFileName
# Run a haskell file directly
$ runhaskell helloworld.hs
# Open GHCi (REPL)
$ ghci
# Compile file to binary
$ ghc --make helloworld
# GHCI: Get type of a function
:t toUpper
toUpper :: Char -> Char
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment