Skip to content

Latest commit

 

History

History
83 lines (63 loc) · 2 KB

non-Haskell.md

File metadata and controls

83 lines (63 loc) · 2 KB

Einige Unterschiede zu Haskell

Syntax

  • keine list comprehensions
  • nur let, kein where
  • pattern-matching fast nur mit case, entsprechend nur eine Definitionsgleichung per Funktion
  • kein explizites Layout mit { ; }
Haskell
:
::
[Int]
type
data
newtype
...
Elm
::
:
List Int
type alias
type
existiert nicht ...

Standardtypen und -funktionen

  • Strings sind nicht Listen von Chars
  • Sets, Dicts, Arrays
  • record types with subtyping
Haskell
id
const
.
...
Elm
identity
always
<<
...

Sprachfeatures

Keine Typklassen!

Aber Array.map, Dict.map, Json.Decode.map, List.map, Maybe.map, ...

Und überladene Typen für einige spezifische Zwecke:

(+) : number -> number -> number

sort : List comparable -> List comparable

(++) : appendable -> appendable -> appendable

lexicographic : (comparable, comparable') -> (comparable, comparable') -> Bool
lexicographic (a,b) (x,y) = a < x || a == x && b <= y

Modul-import per Default immer qualifizert. Explizite Abweichung mittels etwa import List exposing (map).

Keine IO-Monade, da anderes Interaktionskonzept. Aber Task-Typkonstruktor spielt eine ähnliche Rolle.

Semantik

Strikte Auswertung!