Score diverges to \$\infty\$
f=(:).(:)
g=f.f.f.f.f.f.f.f -- adding ".f" always results in better score
main=g+main g
Based on ASCII-only's construction, it is pretty easy to get ever-increasing score with longer and longer programs. Just posting to knock the challenge out of the unanswered list.
Given the following program form
f=(:).(:).(:) -- n copies of (:) composed
main=f+main f
the sizes of error messages are:
2 copies -> 2328
3 copies -> 8121 (x3.488)
4 copies -> 27121 (x3.339)
5 copies -> 103385 (x3.812)
6 copies -> 432486 (x4.183)
7 copies -> 1898125 (x4.388)
8 copies -> 8495224 (x4.475)
9 copies -> 39395094 (x4.637)
10 copies -> 198171503 (x5.030)
We can't know the exact formula of this because Haskell's error message pretty-printing is complicated, but we can at least know that adding one copy of .(:) consistently increases the error size by a factor of 4 or higher. In the top submission, adding two characters .f adds two copies of (:), multiplying the error size by at least 16 and therefore the score by
\$16 \div 4 = 4\$.
To roughly see what is going on, here's the full error for 1-copy (:) program: (those ��s are pretty quotes, which got somehow broken in my editor)
[1 of 1] Compiling Main ( Main.hs, Main.o )
Main.hs:2:1: error:
? Couldn't match expected type ��IO t0��
with actual type ��(a0 -> [a0] -> [a0])
-> (a0 -> [a0] -> [a0])
-> [a0 -> [a0] -> [a0]]
-> [a0 -> [a0] -> [a0]]��
? Probable cause: ��main�� is applied to too few arguments
In the expression: main
When checking the type of the IO action ��main��
|
2 | main=f+main f
| ^
Main.hs:2:6: error:
? Couldn't match type ��[a -> [a] -> [a]]�� with ��a -> [a] -> [a]��
Expected type: (a -> [a] -> [a])
-> (a -> [a] -> [a]) -> [a -> [a] -> [a]] -> [a -> [a] -> [a]]
Actual type: (a -> [a] -> [a])
-> [a -> [a] -> [a]] -> [a -> [a] -> [a]]
? Possible cause: ��(+)�� is applied to too many arguments
In the expression: f + main f
In an equation for ��main��: main = f + main f
? Relevant bindings include
main :: (a -> [a] -> [a])
-> (a -> [a] -> [a]) -> [a -> [a] -> [a]] -> [a -> [a] -> [a]]
(bound at Main.hs:2:1)
|
2 | main=f+main f
| ^^^^^^^^
and for 2-copy (:) program:
[1 of 1] Compiling Main ( Main.hs, Main.o )
Main.hs:2:1: error:
? Couldn't match expected type ��IO t0��
with actual type ��(a0 -> [[a0] -> [a0]] -> [[a0] -> [a0]])
-> (a0 -> [[a0] -> [a0]] -> [[a0] -> [a0]])
-> [[a0 -> [[a0] -> [a0]] -> [[a0] -> [a0]]]
-> [a0 -> [[a0] -> [a0]] -> [[a0] -> [a0]]]]
-> [[a0 -> [[a0] -> [a0]] -> [[a0] -> [a0]]]
-> [a0 -> [[a0] -> [a0]] -> [[a0] -> [a0]]]]��
? Probable cause: ��main�� is applied to too few arguments
In the expression: main
When checking the type of the IO action ��main��
|
2 | main=f+main f
| ^
Main.hs:2:6: error:
? Couldn't match type ��[[a -> [[a] -> [a]] -> [[a] -> [a]]]
-> [a -> [[a] -> [a]] -> [[a] -> [a]]]]��
with ��a -> [[a] -> [a]] -> [[a] -> [a]]��
Expected type: (a -> [[a] -> [a]] -> [[a] -> [a]])
-> (a -> [[a] -> [a]] -> [[a] -> [a]])
-> [[a -> [[a] -> [a]] -> [[a] -> [a]]]
-> [a -> [[a] -> [a]] -> [[a] -> [a]]]]
-> [[a -> [[a] -> [a]] -> [[a] -> [a]]]
-> [a -> [[a] -> [a]] -> [[a] -> [a]]]]
Actual type: (a -> [[a] -> [a]] -> [[a] -> [a]])
-> [[a -> [[a] -> [a]] -> [[a] -> [a]]]
-> [a -> [[a] -> [a]] -> [[a] -> [a]]]]
-> [[a -> [[a] -> [a]] -> [[a] -> [a]]]
-> [a -> [[a] -> [a]] -> [[a] -> [a]]]]
? Possible cause: ��(+)�� is applied to too many arguments
In the expression: f + main f
In an equation for ��main��: main = f + main f
? Relevant bindings include
main :: (a -> [[a] -> [a]] -> [[a] -> [a]])
-> (a -> [[a] -> [a]] -> [[a] -> [a]])
-> [[a -> [[a] -> [a]] -> [[a] -> [a]]]
-> [a -> [[a] -> [a]] -> [[a] -> [a]]]]
-> [[a -> [[a] -> [a]] -> [[a] -> [a]]]
-> [a -> [[a] -> [a]] -> [[a] -> [a]]]]
(bound at Main.hs:2:1)
|
2 | main=f+main f
| ^^^^^^^^
Basically the inferred type signature of main is blowing up by factor of >4. The type has the format of x -> y -> z -> w, where each of x, y, z, w contains the sub-structure p -> q -> r. When a copy of (:) is added, q and r parts are doubled and z and w are quadrupled.