What is the difference between . (dot) and $ (dollar sign)?

后端 未结 13 2153
庸人自扰
庸人自扰 2020-11-22 04:57

What is the difference between the dot (.) and the dollar sign ($)?

As I understand it, they are both syntactic sugar for not needing to us

13条回答
  •  面向向阳花
    2020-11-22 05:18

    I think a short example of where you would use . and not $ would help clarify things.

    double x = x * 2
    triple x = x * 3
    times6 = double . triple
    
    :i times6
    times6 :: Num c => c -> c
    

    Note that times6 is a function that is created from function composition.

提交回复
热议问题