-
Notifications
You must be signed in to change notification settings - Fork 0
/
.ghci
36 lines (29 loc) · 948 Bytes
/
.ghci
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
-- @see https://github.com/nathanic/dotfiles/blob/master/config/ghci
-- things i always want
:m + Control.Applicative
:m + Control.Monad
:m + Data.List
:m + Data.Maybe
:m + Debug.Trace
:m + System.IO.Unsafe
:m + Text.Printf
-- @see http://www.haskell.org/haskellwiki/Hoogle#Using_Hoogle_from_GHCi
--
-- Example:
-- :hoogle map
-- :hoogle (a -> b) -> [a] -> [b]
-- :hoogle con map
-- :hoogle a -> a
-- :hoogle id :: a -> a
:def hoogle \x -> return $ ":!hoogle \"" ++ x ++ "\""
-- :doc map
-- :doc (a -> b) -> [a] -> [b]
:def doc \x -> return $ ":!hoogle --info \"" ++ x ++ "\""
-- too many modules for the default prompt.
:set prompt "ghci> "
-- for debug
let tracify x = (trace $ "<pop "++show x++">") x
-- binary string to integer
let b2i xs = foldl (\x y -> 2 * x + y) 0 $ map (\x -> read [x]) xs
-- integer to binary string
let i2b = concat . (map show) . reverse . i2b' where i2b' 0 = []; i2b' n = mod n 2 : i2b' (div n 2)