1.2 KiB
1.2 KiB
Ava R2
This document specifies the second revision of the Ava programming language, started 2024-07-18.
Example
- TODO: Disambiguate
fn
with and without implementation.
fn not: Boolean -> Boolean
λ false => true
λ true => false
end fn
given A
given B
class Eq
fn eq: A -> B -> Boolean
fn neq: A -> B -> Boolean
λ x y => not (eq x y)
end fn
infix =: A -> B -> Boolean
λ x y => eq x y
end infix
infix !=: A -> B -> Boolean
λ x y => neq x y
end infix
end class
given F *
class Functor
--- Transform some wrapped data from one type to another, preserving the
--- wrapper.
---
--- @tparam A The type of input data.
--- @tparam B The type of output data.
given A
given B
fn map: F A -> (A -> B) -> F B
end class
given A
class Semigroup
fn combine: A -> A -> A
end class
given A :: Semigroup
class Monoid
fn empty: A
end class
fn silly_string: String -> Int32
λ "foo" => 1
λ "bar" => 2
λ baz =>
-- No reason to do this, but demonstrates the syntax.
baz match
case "baz" => 3
case _ => 4
end match
end fn