Skip to content
This repository has been archived by the owner on Mar 24, 2020. It is now read-only.

stoft/baby-steps-elm

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Baby Steps Elm

Knowledge repository, guide and exercises for people beginning with Elm.

Exercises are found under: Exercises

Notes

Functions

Currying

All functions in Elm are curried into one argument functions. E.g. a 3 argument function foo: (foo x y z)

Is converted to: (((foo x) y) z)

A function foo that takes one argument x, and returns a function that in turn takes an argument y, which in turn returns a function that takes an argument z.

References:

Associativity

As noted in the Elm Syntax functions are left associative. This means functions take left precedence which in turn means functions take precedence over operators since operators are infix functions.

Example:

> f n = n * 2
<function> : number -> number
> f 3 + 3
9 : number
> f (3 + 3)
12 : number

Broken down, what's happening is:

f 3 + 3 becomes (((+) (f 3)) 3) whereas f (3 + 3) becomes (f((+)(3) 3))

Function Type Declarations

Unlike functions, their type declarations are right associative.

A type declaration such as: foo : Int -> Int -> Int

Will have the following precedence: (Int -> (Int -> Int))

If you want a different precedence you have to explicitly declare this in your declaration. See e.g. List.map

About

Getting Started with Elm

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages