infix notation - How does Haskell know which function can operate first? -



infix notation - How does Haskell know which function can operate first? -

i'm writing custom language features functional elements. when stuck somewhere check how haskell it. time though, problem bit complicated me think of illustration give haskell.

here's how goes.

say have next line

a . b

in haskell. obviously, composing 2 functions, , b. if function took 2 functions parameters. what's stopping operating on . , b? can surround in brackets shouldn't create difference since look still evaluates function, prefix one, , prefix functions have precedence on infix functions.

if do

(+) 2 3 * 5

for example, output 25 instead of 17.

basically i'm asking is, mechanism haskell utilize when want infix function operate before preceding prefix function.

so. if "a" function takes 2 functions parameters. how stop haskell interpreting

a . b

as "apply . , b function a" , interpret "compose functions , b".

if don't set parens around operator, it's always parsed infix; i.e. operator, not operand. e.g. if have f g ? j, there no parens around ?, whole thing phone call (?) (parsed (f g) ? (i j), equivalent (?) (f g) (i j)).

haskell infix-notation

Comments

Popular posts from this blog

web services - java.lang.NoClassDefFoundError: Could not initialize class net.sf.cglib.proxy.Enhancer -

Accessing MATLAB's unicode strings from C -

javascript - mongodb won't find my schema method in nested container -