Comment on page
Roadmap
Derw is currently in a usable place, but there's a lot more planned. This page documents the current features, along with some ideas I have yet to implement.
- Arrays
[ ]
,[ 1, 2, 3 ]
,[ [ 1, 2, 3 ], [ 3, 2, 1 ] ]
- Booleans
true
,false
- Boolean equality
1 < 2
,1 <= 2
,1 == 2
,1 != 2
,1 > 2
,1 >= 2
- Boolean operations
true && false
,not true
,true || false
- Strings
""
,"hello world"
- Format strings
``
,`Hello ${name}`
- Numbers
-1
,0
,1
,-1.1
,1.1
- Addition
1 + 2
,"Hello" + name
- Subtraction
2 - 1
- Multiplication
2 * 1
- Division
2 / 1
- Pipe
[1, 2, 3] |> List.fold add
,List.fold add <| [1, 2, 3]
- Compose
>>
,<<
- Constants
hello = "hello world"
- Function definitions
- Lists
[ 1, 2, 3 ]
,[ "hello", "world" ]
- List ranges
[ 1..5 ]
,[ start..end ]
add : number -> number -> numberadd x y = x + y - Function callsthree = add 1 2
- Module referencesthree = List.map identity [ 1, 2, 3 ]
- Union typestype Result a b= Err { error: a }| Ok { value: b }
- Type variablestype Thing a = Thing a
- Type aliasestype alias User ={ name: string }
- Object literalsuser: Useruser = { name: "Noah" }
- Object literals updatesuser: Useruser = { ...noah, name: "Noah" }
- Importsimport Listimport Result exposing ( map )import something as banana
- Exportsexposing ( map )
- Let statementssayHiTo : User -> stringsayHiTo user =letname = user.namein"Hello " + namesayHelloTo : User -> stringsayHelloTo user =letgetName: User -> stringgetName user = user.namein"Hello" + getName user
- If statementstype Animal = Animal { age: number }sayHiTo : Animal -> stringsayHiTo animal =if animal.age == 1 of"Hello little one!"else"You're old"
- Case..oftype Animal = Dog | CatsayHiTo : Animal -> stringsayHiTo animal =case animal ofDog -> "Hi dog!"Cat -> "Hi cat!"
- Destructing in case..oftype User = User { name: string }sayHiTo : User -> stringsayHiTo user =case user ofUser { name } -> "Hi " + name + !"
- strings in case..of
- defaults in case..ofsayHiTo : string -> stringsayHiTo name =case name of"Noah" -> "Hi " + name + !"default: "I don't know you"
- List destructingsum: List number -> numbersum xs =case xs of[] -> 0y :: ys :: [] -> y + ysz :: zs -> z + sum zsdefault -> 0
- List destructing with string valuessum: List string -> numbersum xs =case xs of[] -> 0"1" :: ys :: [] -> 1 + 2"2" :: zs -> 2 + sum zsdefault -> 0
- List destructing with union types valuessum: List (Maybe number) -> numbersum xs =case xs of[] -> 0Just { value } :: rest -> value + sum restNothing :: rest -> sum restdefault -> 0
- Constructing union typestype User = User { name: string }noah = User { name: "Noah" }
- Accessorstype alias User = { name: string }names = List.map .name [ { name: "Noah" }, { name: "Dave" } ]
- Nested accessorstype alias Group = { person: { name: string } }names = List.map .person.name [ { person: { name: "Noah" } }, { person: { name: "Dave" } } ]
- Errors on type name collisonThe name `Person` has been used for different things.8 - 10:```type Person =Person { name: string }```11 - 14:```type alias Person = {name: string}```
- Errors on function name collisonThe name `isTrue` has been used for different things.0 - 3:```isTrue: boolean -> booleanisTrue x =x == true```4 - 7:```isTrue: boolean -> booleanisTrue x =x != true```
- Some form of basic type errorsFailed to parse examples/errors/mismatching_types.derw due to:Error on lines 0 - 3Expected `boolean` but got `number` in the body of the function:```isTrue: boolean -> booleanisTrue x =1 + 2```Error on lines 4 - 7Expected `List string` but got `List number`:```names: List stringnames =[1..2]```
- lambdas
\x -> x + 1
,\x y -> x + y
- Typescript output
- Javscript output
- Elm output
- Module resolution
- CLI
- Basic type checking
- Detect if types exist in current namespace
- Syntax highlighting for editors
- Collision detection for names in a module
- Importing of Derw filesimport "./other"import "./something" as bananaimport "./another" exposing ( isTrue, isFalse )import "./Maybe" as Maybe exposing (Maybe)
- Errors when failing to find relative importWarning! Failed to find `examples/derw_imports/banana` as either derw, ts or js
- Single line comments-- helloisTrue: boolean -> booleanisTrue x =x
- Single line comments in function or const bodiesisTrue: boolean -> booleanisTrue x =-- hellox
- Multiline comments{-helloworld-}isTrue: boolean -> booleanisTrue x =x
- Function argumentsmap: (a -> b) -> a -> bmap fn value =fn value
- GlobalsGlobals can be accessed through the
globalThis
module which is imported into every namespace. E.gglobalThis.console.log
- Constant if statementsname: stringname =if 1 == 1 then"Noah"else"James"
- Constant case statementsname: stringname =case person of"n" -> "Noah""j" -> "James"default -> "Other"
- List prependnumbers: List numbernumbers =1 :: [ 2, 3 ]
- An automatic formatter with no optionsderw format
- A standard library
- Write a file with
_test
as an extension (e.gList_test.derw
).import Test exposing (equals)testMath: boolean -> voidtestMath a? =equals 1 1Compile it, then run bach vianpx @eeue56/bach
- Type checking
- Async support
- Packaging
- Package initderw init
- Package testing# inside a package directoryderw test
- Compile a packagederw compile
- Install a packagederw install --name derw-lang/stdlib --version main
- An info command to find out stats about modulesderw init
- A replderw repl
- Bundlingderw bundle --entry src/Main.derw --output dist/index.js --watch --quiet
- English outputderw compile --target english
- Template generationderw template --path src/Main.derw --template web
- Do notationsayHi: string -> voidsayHi name =doglobalThis.console.log "Hello" namereturnundefined
- Time travelling debugger
- Type checking with interop with TypeScript
- Derw compiler is written in Derw
Last modified 1yr ago