01
Getting Started
Hello World
PureScript uses Haskell-like syntax.
purescript
module Main where
import Effect.Console (log)
main = log "Hello, World!"Functions
Type signatures use :: and ->.
purescript
add :: Int -> Int -> Int
add a b = a + bData
Algebraic data types with data keyword.
purescript
data Maybe a = Nothing | Just a
data Either a b = Left a | Right b02
Features
Records
Records with row polymorphism.
purescript
type Person = { name :: String, age :: Int }
p :: Person
p = { name: "Alice", age: 30 }Type Classes
Type classes for ad-hoc polymorphism.
purescript
class Show a where
show :: a -> String
instance showInt :: Show Int where
show n = showIntImpl nDo Notation
Do notation for monadic code.
purescript
main = do
log "First"
log "Second"Was this helpful?