- Compiles to JavaScript
- Haskell-inspired type system (with some improvements!)
- No runtime (unlike Elm, GHCJS, etc)
- A focus on readable and debuggable JavaScript
npm i -g purescript pulp
- psc
- psci
- ...
pulp init
pulp build
pulp test
pulp docs
pulp server
Atom via psc-ide, ide-purescript, and language-purescript
git clone https://github.com/kRITZCREEK/psc-ide.git
cd psc-ide
stack install
apm install ide-purescript purescript-language
Vim and Emacs plugins too!
x :: Number
x = 5.0
y :: Int
y = 5
import Prelude ((+))
add :: Number -> Number -> Number
add x y = x + y
import Prelude ((+))
add :: Int -> Int -> Int
add x y = x + y
data Maybe a = Nothing | Maybe a
data Maybe a = Nothing | Maybe a
greeting :: Maybe String
greeting = Just "hello."
silence :: Maybe String
silence = Nothing
type User = { name :: String
, email :: String
}
type Userish a = { name :: String
, email :: String
| a
}
import Prelude
import Control.Monad.Eff
import Control.Monad.Eff.Console
sayHi :: forall eff. Eff (console :: CONSOLE | eff) Unit
sayHi = log "hello world."
main = sayHi
data Direction
= North
| South
| East
| West
class Reversible a where
reverse :: a -> a
instance reversibleDirection :: Reversible Direction where
reverse North = South
reverse South = North
reverse East = West
reverse West = East
mirror :: forall a. (Reversible a) => a -> Tuple a a
mirror a = Tuple a (reverse a)
Completed Main.purs (don't cheat!)
- PureScript by Example (ebook by Phil Freeman)
- IRC Channel
- Pursuit -- "google (hoogle) for PureScript types and libraries"
- Recommended libraries
- Halogen and routing in PureScript
- 4 part Elm vs PureScript comparison (this eventually turns into "using the Elm Architecture in PureScript")
- PureScript Wiki - Learn
- PureScript subreddit
- QuickCheck your JavaScript!
- Haskell Programming -- great intro to FP, Haskell, and all this 'type' stuff