01
Erste Schritte
Hello World
PureScript nutzt Haskell-ähnliche Syntax.
purescript
module Main where
import Effect.Console (log)
main = log "Hello, World!"Funktionen
Typsignaturen verwenden :: und ->.
purescript
add :: Int -> Int -> Int
add a b = a + bDaten
Algebraische Datentypen mit dem data-Schlüsselwort.
purescript
data Maybe a = Nothing | Just a
data Either a b = Left a | Right b02
Features
Records
Records mit Row-Polymorphismus.
purescript
type Person = { name :: String, age :: Int }
p :: Person
p = { name: "Alice", age: 30 }Type Classes
Type Classes für Ad-hoc-Polymorphismus.
purescript
class Show a where
show :: a -> String
instance showInt :: Show Int where
show n = showIntImpl nDo-Notation
Do-Notation für monadischen Code.
purescript
main = do
log "First"
log "Second"Was this helpful?