Skip to content

Instantly share code, notes, and snippets.

@maoe
Created June 3, 2010 12:00
Show Gist options
  • Save maoe/423793 to your computer and use it in GitHub Desktop.
Save maoe/423793 to your computer and use it in GitHub Desktop.
:set -i./src -i./bin
-- Read GHCI commands from the file whose name is
-- in the GHCIRC environment variable
:def _load const(System.Environment.getEnvironment>>=maybe(return"")readFile.lookup"GHCIRC")
:_load
:undef _load
:def hoogle \str -> return $ ":! hoogle --count=15 \"" ++ str ++ "\""
-- <http://www.cs.kent.ac.uk/people/staff/cr3/toolbox/haskell/dot-squashed.ghci641>
let { redir varcmd = case break Data.Char.isSpace varcmd of { (var,_:cmd) -> return $ unlines [":set -fno-print-bind-result","tmp <- System.Directory.getTemporaryDirectory","(f,h) <- System.IO.openTempFile tmp \"ghci\"","sto <- GHC.Handle.hDuplicate System.IO.stdout","GHC.Handle.hDuplicateTo h System.IO.stdout","System.IO.hClose h",cmd,"GHC.Handle.hDuplicateTo sto System.IO.stdout","let readFileNow f = readFile f >>= \\t->length t `seq` return t",var++" <- readFileNow f","System.Directory.removeFile f"]; _ -> return "putStrLn \"usage: :redir <var> <cmd>\"" } }
:def redir redir
-- End copied material
-- Integration with the hlint code style tool
let hlint _ = return $ unlines [":set -w", ":redir hlintvar1 :show modules", ":cmd return (\":! hlint \" ++ (concat $ Data.List.intersperse \" \" (map (fst . break (==',') . drop 2 . snd . break (== '(')) $ lines hlintvar1)))", ":set -Wall"]
:def hlint hlint
:module + Control.Applicative
:module + Data.Time
let day y m d = return (fromGregorian y m d) :: IO Day
let now = getCurrentTime
let today = utctDay <$> now
:module - Data.Time
:set prompt "Prelude> "
:set +t
:set +s
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment