function - Infix operator with missing argument -
is possible haskell have operator (infix function) working missing argument ? (rather -
meaning subtraction or negative sign)
for example, have operator :
data1 <*> data2
is possible make work default value if first argument omitted ?
<*> data2
not really, no. on other hand, define different operation provides default argument, e.g.
withdef data2 = {- default value -} <*> data2
if want use name otherwise operator, can still name partially applied function operator name:
($<*>) data2 = {- default value -} <*> data2
it can used prefix, in ($<*>) data2
, or postfix appropriate ghc extensions, in (data2 $<*>)
. parentheses not optional.
Comments
Post a Comment