Elm is a functional programming language for declaratively creating graphical user interfaces. Elm uses the Functional Reactive Programming style and purely functional graphical layout to build user interface without any destructive updates.
Elm | |
---|---|
Paradigm | functional reactive |
Designed by | Evan Czaplicki |
First appeared | 2011 |
Stable release | 2.5.8 (August 18, 2005[±] | )
Filename extensions | .elm |
Website | elm-lang.org |
Description
The primary implementation of Elm compiles to HTML, CSS, and JavaScript. In Elm, Functional Reactive Programming takes the place of event handlers and callbacks; it also manages all screen updates automatically. Purely functional graphical layout takes the place of working with the DOM.
Elm allows Markdown to be embedded directly, so users can create text content in a familiar and natural way.
Syntax and Semantics
Elm's version of Functional Reactive Programming is event-driven, meaning that updates are only performed as necessary. It shares the closest resemblance to Event-Driven FRP [1] and Arrowized FRP [2].
The following program displays the position of the mouse as it moves around the screen, automatically updating the screen in real-time.
main = lift asText Mouse.position
The value of main is displayed on screen. Function asText turns any value into a displayable textual representation. Mouse.position is a value that changes over time, called a signal. Function lift ensures that asText is applied to Mouse.position every time the mouse moves.
Elm has a small but expressive set of language constructs, including if-expressions, let-expressions, case-expressions, anonymous functions, and list interpolation.
Elm also has both a module system and a foreign function interface for JavaScript.
References
- ^ Wan, Zhanyong; Taha, Walid; Hudak, Paul (2002). "Event-Driven FRP". Proceedings of the 4th International Symposium on Practical Aspects of Declarative Languages: 155–172.
- ^ Attention: This template ({{cite doi}}) is deprecated. To cite the publication identified by doi:10.1145/581690.581695, please use {{cite journal}} (if it was published in a bona fide academic journal, otherwise {{cite report}} with
|doi=10.1145/581690.581695
instead.