File tree 3 files changed +27
-1
lines changed 3 files changed +27
-1
lines changed Original file line number Diff line number Diff line change 5
5
6
6
# Answers
7
7
answers /
8
+
9
+ # Temporary build files generated, say, by `make o`
10
+ out /
Original file line number Diff line number Diff line change 1
1
default : example
2
2
3
- .PHONY : example read run test watch verify
3
+ .PHONY : example read run test watch verify o clean
4
4
5
5
example :
6
6
@n=` ls -t * .hs | head -1 | cut -f1 -d.` ; \
@@ -43,3 +43,17 @@ verify:
43
43
cat $$in | runghc $$hs && \
44
44
echo "(` cat answers/$$ n-a ` ,` cat answers/$$ n-b ` )" ;\
45
45
done
46
+
47
+ o :
48
+ @n=` ls -t * .hs | head -1 | cut -f1 -d.` ; \
49
+ in=" inputs/$$ n" ; \
50
+ hs=` ls -t * .hs | head -1` ; \
51
+ mkdir -p out && \
52
+ echo " ghc -O -outputdir out -o out/$$ n $$ hs" && \
53
+ echo " cat $$ in | time ./out/$$ n" && \
54
+ ghc -O -outputdir out -o out/$$ n $$ hs && \
55
+ cat $$ in | time -h ./out/$$ n && \
56
+ echo " (` cat answers/$$ n-a` ,` cat answers/$$ n-b` )"
57
+
58
+ clean :
59
+ rm -rf out
Original file line number Diff line number Diff line change @@ -18,7 +18,16 @@ Other commands:
18
18
- ` make watch ` – same as ` make ` , but start a fswatch to automatically re-run
19
19
it whenever the .hs file is changed.
20
20
- ` make verify ` - Run ` make test ` , but for all days so far, in reverse.
21
+ - ` make o ` - same as ` make test ` , but first compile the .hs file using GHC
22
+ with optimizations enabled, and also print timings. To remove these, use
23
+ ` make clean ` .
21
24
22
25
All of these are wrappers around the basic pattern of
23
26
24
27
cat somefile | runghc xx.hs
28
+
29
+ Some of the solutions are done in shell scripts. To run these, the filename
30
+ needs to be passed to the script instead of passing the input via stdin (this is
31
+ to keep the scripts simple – reading stdin in a script isn't a snap):
32
+
33
+ ./xx.sh somefile
You can’t perform that action at this time.
0 commit comments