Elm (programming language)

This is an old revision of this page, as edited by 2620:0:1000:1c01:b6b5:2fff:feb8:1476 (talk) at 02:39, 29 November 2012 (Syntax and Semantics). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

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
Paradigmfunctional reactive
Designed byEvan Czaplicki
First appeared2011
Stable release2.5.8 (August 18, 2005; 20 years ago (2005-08-18)) [±]
Filename extensions.elm
Websiteelm-lang.org

Description

The primary implementation of Elm compiles to HTML, CSS, and JavaScript. 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

  1. ^ Wan, Zhanyong; Taha, Walid; Hudak, Paul (2002). "Event-Driven FRP". Proceedings of the 4th International Symposium on Practical Aspects of Declarative Languages: 155–172.
  2. ^ 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.