-
Notifications
You must be signed in to change notification settings - Fork 11
/
fixHaskell.sh
executable file
·170 lines (147 loc) · 3.89 KB
/
fixHaskell.sh
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#!/usr/bin/env bash
mkdir -p $1
cmd="ghc $GHCFLAGS -j -O1 --make ./FixLits.hs"
echo $cmd
$cmd
echo "Fixing Literals"
for file in $(find $2 -maxdepth 1 -name "*.hs")
do
baseval=`basename $file`
./FixLits $file
mv $file $1
echo "$file fixed."
done
echo "Adding missing imports"
unameOut="$(uname -s)"
case "${unameOut}" in
Darwin*) SED=gsed;;
*) SED=sed
esac
for file in $(grep -l "CustomExtract" $1/*.hs)
do
grep -q "import qualified CustomExtract" $file
if [ $? -ne 0 ]
then
$SED -i -e '0,/^import/{s/^import/import qualified CustomExtract\nimport/}' $file
fi
done
for file in $(grep -l "Data\.Char" $1/*.hs)
do
grep -q "import qualified Data\.Char" $file
if [ $? -ne 0 ]
then
$SED -i -e '0,/^import/{s/^import/import qualified Data.Char\nimport/}' $file
fi
done
for file in $(grep -l "Data\.Bits" $1/*.hs)
do
grep -q "import qualified Data\.Bits" $file
if [ $? -ne 0 ]
then
$SED -i -e '0,/^import/{s/^import/import qualified Data.Bits\nimport/}' $file
fi
done
for file in $(grep -l "Data\.List" $1/*.hs)
do
grep -q "import qualified Data\.List" $file
if [ $? -ne 0 ]
then
$SED -i -e '0,/^import/{s/^import/import qualified Data.List\nimport/}' $file
fi
done
for file in $(grep -l "Data\.BitVector" $1/*.hs)
do
grep -q "import qualified Data\.BitVector" $file
if [ $? -ne 0 ]
then
$SED -i -e '0,/^import/{s/^import/import qualified Data.BitVector\nimport/}' $file
fi
done
for file in $(grep -l "Data\.Vector" $1/*.hs)
do
grep -q "import qualified Data\.Vector" $file
if [ $? -ne 0 ]
then
$SED -i -e '0,/^import/{s/^import/import qualified Data.Vector\nimport/}' $file
fi
done
for file in $(grep -l "System\.Exit" $1/*.hs)
do
grep -q "import qualified System\.Exit" $file
if [ $? -ne 0 ]
then
$SED -i -e '0,/^import/{s/^import/import qualified System.Exit\nimport/}' $file
fi
done
for file in $(grep -l "System\.IO" $1/*.hs)
do
grep -q "import qualified System\.IO" $file
if [ $? -ne 0 ]
then
$SED -i -e '0,/^import/{s/^import/import qualified System.IO\nimport/}' $file
fi
done
for file in $(grep -l "Data\.Map\.Strict" $1/*.hs)
do
grep -q "import qualified Data\.Map\.Strict" $file
if [ $? -ne 0 ]
then
$SED -i -e '0,/^import/{s/^import/import qualified Data.Map.Strict\nimport/}' $file
fi
done
for file in $(grep -l "ParseExtract" $1/*.hs)
do
grep -q "import qualified ParseExtract" $file
if [ $? -ne 0 ]
then
$SED -i -e '0,/^import/{s/^import/import qualified ParseExtract\nimport/}' $file
fi
done
for file in $(grep -l "Data\.Array.IO" $1/*.hs)
do
grep -q "import qualified Data\.Array.IO" $file
if [ $? -ne 0 ]
then
$SED -i -e '0,/^import/{s/^import/import qualified Data.Array.IO\nimport/}' $file
fi
done
for file in $(grep -l "Data\.Array\.MArray" $1/*.hs)
do
grep -q "import qualified Data\.Array\.MArray" $file
if [ $? -ne 0 ]
then
$SED -i -e '0,/^import/{s/^import/import qualified Data.Array.MArray\nimport/}' $file
fi
done
for file in $(grep -l "Control\.Monad" $1/*.hs)
do
grep -q "import qualified Control\.Monad" $file
if [ $? -ne 0 ]
then
$SED -i -e '0,/^import/{s/^import/import qualified Control.Monad\nimport/}' $file
fi
done
for file in $(grep -l "Control\.Monad\.Primitive" $1/*.hs)
do
grep -q "import qualified Control\.Monad\.Primitive" $file
if [ $? -ne 0 ]
then
$SED -i -e '0,/^import/{s/^import/import qualified Control.Monad.Primitive\nimport/}' $file
fi
done
for file in $(grep -l "Data\.Vector\.Mutable" $1/*.hs)
do
grep -q "import qualified Data\.Vector\.Mutable" $file
if [ $? -ne 0 ]
then
$SED -i -e '0,/^import/{s/^import/import qualified Data.Vector.Mutable\nimport/}' $file
fi
done
for file in $(grep -l "Data\.Vector\.Generic" $1/*.hs)
do
grep -q "import qualified Data\.Vector\.Generic" $file
if [ $? -ne 0 ]
then
$SED -i -e '0,/^import/{s/^import/import qualified Data.Vector.Generic\nimport/}' $file
fi
done