mgold / elm-repl

A REPL for Elm

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Elm REPL Build Status

This tool lets you interact with values and functions directly.

Install

Install Elm Platform to get elm-repl. Then make sure you have node.js installed because it is needed to evaluate the generated JS.

Use

You can type in expressions, definitions, ADTs, and module imports using normal Elm syntax.

> 1 + 1
2 : number

> "hello" ++ "world"
"helloworld" : String

The same can be done with definitions and ADTs:

> fortyTwo = 42
42 : number

> f n = n + 1
<function> : number -> number

> f 41
42 : number

> factorial n = \
|   if n < 1 then 1 \
|            else n * factorial (n-1)
<function> : number -> number

> factorial 5   
120 : number

> type Either a b = Left a | Right b

> case Left 32 of \
|   Left n -> 2 * n \
|   Right m -> m + 1
64 : number

You can import standard libraries and any library reachable from the directory where elm-repl is running:

> import String

> String.length "hello"
5 : Int

> String.reverse "flow"
"wolf" : String

About

A REPL for Elm

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Haskell 100.0%