blob: 9356d9028a2e80d1ffea32a3fbc9851b5670de7b (
plain)
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
|
#!/usr/bin/env bash
# Generate a module with N data types and instances
DEFS=10000
MATCHES=500
MODE=$1
echo "module Defs where" > Defs.hs;
for i in $(seq -w 1 $DEFS); do
echo "data T$i a = T$i a deriving Show" >> Defs.hs;
done
echo "{-# LANGUAGE TypeFamilies #-}" > Match.hs
echo "{-# LANGUAGE StandaloneDeriving #-}" >> Match.hs
echo "{-# LANGUAGE EmptyDataDecls #-}" >> Match.hs
echo "module Match where" >> Match.hs
echo "import Defs" >> Match.hs
if [ $MODE -eq 0 ]; then
for i in $(seq -w 1 $MATCHES); do
echo "type family F$i a where" >> Match.hs;
done
echo "data T a = T" >> Match.hs
for i in $(seq -w 1 $MATCHES); do
echo " (F$i a)" >> Match.hs;
done
echo "deriving instance Show (T a)" >> Match.hs;
fi
#elif [ $MODE -eq 1 ]; then
# echo "data T " >> Match.hs
# for i in $(seq -w 1 $MATCHES); do
# echo " a$i" >> Match.hs;
# done
# echo " = T " >> Match.hs
# for i in $(seq -w 1 $MATCHES); do
# echo " a$i" >> Match.hs;
# done
# echo "deriving instance Show (T" >> Match.hs
# for i in $(seq -w 1 $MATCHES); do
# echo " a$i" >> Match.hs;
# done
# echo " )" >> Match.hs;
#else
# for i in $(seq -w 1 $MATCHES); do
# echo "data F$i a" >> Match.hs;
# done
# echo "data T a = T" >> Match.hs
# for i in $(seq -w 1 $MATCHES); do
# echo " (F$i a)" >> Match.hs;
# done
# echo "deriving instance Show (T a)" >> Match.hs;
#
#fi
|