Return to Answer

added 86 characters in body
flawr
• 42.4k
• 37
• 40

These kinds of functions are valid answers in a code golf challenge by default (based on this meta question):

Added the results of three meta discussions concerning Haskell
Laikoni
• 24.8k
• 14
• 14
1. A named function (here f) with arguments:

 f x=x++map g x
g n=div n 2*div n 3

2. A named function (here f) without arguments:

 f=(++)=<<map g
g n=div n 2*div n 3

3. An unnamed function (here, the first line) without arguments:

 (++)=<<map g
g n=div n 2*div n 3

4. Binary functions can be defined as infix operators (here !):

 x!y=x++map g y
g n=div n 2*div n 3

5. For challenges where some output should be produced with out taking any input, the object itself counts as function which does not take any argument due to lazy evaluation (see this meta question):

 ['a'..'z']++['A'..'Z']++['0'..'9']


Haskell has no concept of mutable values, so all functions must return their result instead of modifying the arguments in place.

The type of a function can be more general than the challenge requires, e.g. when the challenge asks to reverse a string, which in Haskell is a list of characters, then a function reversing a list with elements of any type is acceptable. If the type of a function can not be inferred without the function being called with an argument of the correct type, you can assume such a call exists (see this meta question).

Functions are allowed to wrap their return value in the Maybe Monad (see this meta question).

replaced http://codegolf.stackexchange.com/ with https://codegolf.stackexchange.com/

###Tips Tips for golfing in Haskell are collected herehere.

added link to tips question
Laikoni
• 24.8k
• 14
• 14
Loading
Added part about default compiler. Please review whether this makes sense and is indeed the current best-practice.
Laikoni
• 24.8k
• 14
• 14
Loading
Zgarb
• 41.8k
• 1
• 19
• 26
Loading
Post Made Community Wiki by Zgarb