In Haskell it is possible to define functions that will cause a compiler error unless they are called elsewhere in the program.
For example the following code causes a compiler error
r=sum.map(read.(:[])).show
main=putStr""
while the extremely similar
r=sum.map(read.(:[])).show
main=print$r 6
has no error.
The reason this occurs is the Haskell compiler fails to find the type signature of the first bit of code because of multiple instances of show
, however once you call it on a Num
elsewhere the compiler can figure out which instance of show
you mean.
The question is, should this type of function, that is functions that need to be called in order to work be considered valid entries to challenges that require a function?