-
Notifications
You must be signed in to change notification settings - Fork 5
/
.ghci
58 lines (55 loc) · 2.14 KB
/
.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import Data.List
import Control.Lens
:{
:def test (\args ->
do let createPattern p = if (null p)
then "**"
else if "*" `isSuffixOf` p
then p
else "**" ++ p ++ "**"
pattern = createPattern args
cmd p = unlines [ ":reload"
, ":main --pattern " ++ p
, ":test " ++ p
]
putStrLn $ "Going to run: " ++ pattern
putStrLn "Press any key to run tests, q to stop, anything else changes the test pattern..."
x <- getLine
return $ if (x == "q")
then ""
else if null x
then cmd pattern
else createPattern x
)
:}
-- -*- mode: haskell; -*-
-- Begin copied material.
-- <http://www.cs.kent.ac.uk/people/staff/cr3/toolbox/haskell/dot-squashed.ghci641>
:{
:def redir \varcmd -> return $
case break Data.Char.isSpace varcmd of
(var,_:cmd) -> 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->Data.List.length t `seq` return t"
,var++" <- readFileNow f"
,"System.Directory.removeFile f"
]
_ -> "putStrLn \"usage: :redir <var> <cmd>\""
:}
--- Integration with the hlint code style tool
:{
:def hlint \extra -> return $ unlines
[":unset +t +s"
,":set -w"
,":redir hlintvar1 :show modules"
,":cmd return $ \":! hlint \" ++ unwords (map (takeWhile (/=',') . drop 2 . dropWhile (/= '(')) $ lines hlintvar1) ++ \" \" ++ " ++ show extra
,":set +t +s -Wall"
]
:}