Elm (programming language): Difference between revisions

Content deleted Content added
Adds Rust to the languages it inspired.
m Features: Fixed typo
Tags: canned edit summary Mobile edit Mobile app edit Android app edit
Line 37:
Types can refer to other types, for example a <code>List Int</code>. Types are always capitalized; lowercase names are type variables. For example, a <code>List a</code> is a list of values of unknown type. It is the type of the empty list and of the argument to <code>List.length</code>, which is agnostic to the list's elements. There are a few special types that programmers create to interact with the Elm runtime. For example, <code>Html Msg</code> represents a (virtual) DOM tree whose event handlers all produce messages of type <code>Msg</code>.
 
Rather than allow any value to be implicitly nullable (such aas JavaScript's <code>undefined</code> or a [[null pointer]]), Elm's standard library defines a <code>Maybe a</code> type. Code that produces or handles an optional value does so explicitly using this type, and all other code is guaranteed a value of the claimed type is actually present.
 
Elm provides a limited number of built-in [[Type class|type classes]]: <code>number</code> which includes <code>Int</code> and <code>Float</code> to facilitate the use of numeric operators such as <code>(+)</code> or <code>(*)</code>, <code>comparable</code> which includes numbers, characters, strings, lists of comparable things, and tuples of comparable things to facilitate the use of comparison operators, and <code>appendable</code> which includes strings and lists to facilitate concatenation with <code>(++)</code>. Elm does not provide a mechanism to include custom types into these type classes or create new type classes (see Limitations section).