Is it possible with Haskell to have an operator (infix function) working with a missing argument ? (rather like -
meaning a subtraction or a negative sign)
For example, I have this operator :
data1 <*> data2
Is it possible to make it work with a default value if first argument is omitted ?
<*> data2
Not really, no. On the other hand, you could perfectly well define a different operation that provides the default argument, e.g.
If you really want to use a name that would otherwise be an operator, you can still name this partially applied function with an operator name:
It can be used prefix, as in
($<*>) data2
, or postfix with appropriate GHC extensions, as in(data2 $<*>)
. The parentheses are not optional.