Skip to content

Instantly share code, notes, and snippets.

@caiorss
Last active October 26, 2016 16:35
Show Gist options
  • Save caiorss/2d72fd2207ea8f180f51f618f84b323c to your computer and use it in GitHub Desktop.
Save caiorss/2d72fd2207ea8f180f51f618f84b323c to your computer and use it in GitHub Desktop.
Haskell configuration file ~/.ghc/ghic.conf for Haskell 8.0.1
-- Test of ghci.conf
--
> :{
- add :: Int -> Int -> Int
- add x y = x * y
- :}
add :: Int -> Int -> Int
> add 10 20
200
it :: Int
>
> :cd ~/Documents
> :cd ~/Documents/projects
> :ls .
.
..
boleto.fsharp
bookmarklet-maker.web
...
> :ls /
etc
proc
sys
lost+found
var
.manjaro-tools
.
sbin
mnt
tmp
root
usr
lib
opt
...
-- Pasting code in the repl
--
> :{
- maybeToEither :: err -> Maybe value -> Either err value
- maybeToEither e m =
- case m of
- Just v -> Right v
- Nothing -> Left e
- :}
maybeToEither :: err -> Maybe value -> Either err value
>
import System.Directory ( getCurrentDirectory, getDirectoryContents)
import System.Process (readProcess)
import Control.Monad (mapM_)
-- Set prompt to >
:set prompt "> "
:set prompt2 "- "
:def source readFile
:def hoogle \s -> return $ ":! hoogle --count=15 \"" ++ s ++ "\""
-- The command :pwd shows the current directory
--
:def pwd \_ -> getCurrentDirectory >>= putStrLn >> return ""
-- Show current directory
--
:def ls \input -> getDirectoryContents input >>= mapM_ putStrLn >> return ""
-- Print type after evaluation
:set +t
-- Allow multi-line command
:set +m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment