On this page
Functions
Functions are the primary building blocks in Halyard. They are first-class values, meaning they can be passed as arguments, returned from other functions, and stored in variables.
Defining Functions
Functions are defined using the fn keyword with a type signature followed by the implementation:
fn greet : String -> String
fn greet name =
"Hello, " ++ name ++ "!"
greet "Alice" -- "Hello, Alice!"
Compiled
Forward References
Both fn declarations and let-bound lambdas can be used before their own definition
appears in the file, as long as the reference happens inside another function or
lambda's body (not in an eagerly-evaluated top-level expression):
let useHelper = |n : Int| helper n
let helper : Int -> Int = |n| n + 1
useHelper 5
The compiler pre-registers every top-level function-shaped name — whether written as
fn or as a let-bound lambda — before checking any function body, so you can write
your script in whatever order reads best. A let-bound lambda used this way needs its
own type signature (let helper : Int -> Int = ...) rather than relying only on an
annotated lambda parameter, so its full type is known at every forward-reference site.
Type Signatures
Type signatures declare the function's input and output types:
fn add : Int -> Int -> Int
fn add x y =
x + y
add 3 4 -- 7
Compiled
Read Int -> Int -> Int as "takes an Int, returns a function that takes an Int and returns an Int" (currying).
Effect Rows on the Arrow
An arrow can carry an effect row — the set of effects performed when that arrow is applied. The row is written in braces immediately after the arrow:
fn readFile : Path ->{IO} String
fn fetch : Url ->{Net, IO} Body
Each arrow carries its own row, so a curried signature can say where an effect happens:
fn logTo : Path -> String ->{IO} Unit
logTo takes a Path purely and returns a function that performs IO when it
is given the String.
A row can be polymorphic — ->{| e} reads "these effects, plus whatever the
caller's are". This is what lets a higher-order function pass its argument's
effects through instead of fixing them:
fn map : (a ->{| e} b) -> [a] ->{| e} [b]
An arrow with no row keeps its row inferred: Int -> Int stays bare (never
rewritten to Int ->{} Int), and for a fn's own arrow that inferred row is
compared against nothing — there is nothing written to compare it with.
A row written on a callback SLOT is different, and the difference matters. A written, closed row is a DEMAND on the argument, checked at each call site:
fn takes : (Int ->{} Int) ->{} Int
takes demands a pure callback: passing one whose own arrow carries a row is an
EffectRowMismatch. A bare arrow in the same position — (Int -> Int) ->{} Int —
makes no claim about the argument, because a bare arrow means "whatever this
performs". So write the ->{} when you mean to require purity.
Effects are declared, rendered and CHECKED. Rows are parsed, kept through type inference, and shown by the editor, the formatter and the REPL; a function whose body performs an effect outside its declared row is a compile-time EffectRowMismatch, and an undeclared row label is an UndeclaredEffect. The effects guide states the guarantee in one place: what the effect row guarantees.
Tuple Types as Arguments
Function signatures can use tuple types directly as arguments:
fn fst : (Int, String) -> Int
fn fst pair =
case pair of
(x, _) -> x
fst (42, "hello")
Compiled
fn swap : (a, b) -> (b, a)
fn swap pair =
case pair of
(x, y) -> (y, x)
swap (1, "hello")
Compiled
Anonymous Functions (Lambdas)
Create functions without names using pipe syntax:
let addOne = |x : Int| x + 1
let addTwo = |x : Int y : Int| x + y
let addTuple = |(x : Int, y : Int)| x + y
addOne 5
Compiled
Lambda parameters can have type annotations:
let f1 = |x : Int| x + 1
let f2 = |x : Int y : Int| x + y
let f3 = |(x : Int, y : Int)| x + y
let f4 = |f : Int -> Int| f 1
f4 (|x : Int| x * 2)
Compiled
Multi-line lambdas:
let compute =
|x : Int|
let y = 3
x + y
compute 7
Compiled
Lambda Patterns
Lambdas support irrefutable patterns (patterns that always match):
let addPair = |(x : Int, y : Int)| x + y
addPair (3, 4)
Compiled
As-patterns (bind both the value and destructured parts):
let withAlias = |x : Int as m| (x, m)
withAlias 42
Compiled
Typed Record Fields in Lambdas
Record fields in lambda patterns can have type annotations. This works standalone — no pipe context needed:
let describe = |{ name: String, age: Int }| name
describe { name = "Alice", age = 30 }
Compiled
-- Mixed typed and untyped fields (untyped inferred from context)
{ x = 1, y = 2 } |> |{ x: Int, y }| x + y
Compiled
let getName = |{ name: String, .. }| name
getName { name = "Alice", age = 30 }
Compiled
Note: Lambdas only accept irrefutable patterns. Refutable patterns like |Just x|, |5|, or |[a, b]| are rejected at parse time with a clear error message.
Lambda Type Inference
Lambda parameter types can be inferred from context:
-- Pipe operator provides context from the left operand
5 |> |x| x + 1
Compiled
Higher-order function context:
module M exposing ..
fn apply : (Int -> Int) -> Int -> Int
fn apply f x =
f x
M.apply (|y| y + 1) 5
-- y inferred as Int, result: 6
Compiled
When the lambda body constrains the parameter type, the annotation is optional even without an outer context:
-- When the body constrains the parameter type, the annotation is optional.
-- Here x must be Int because x + 1 requires Int.
let f = |x| x + 1
f 1
Compiled
A parameter nothing constrains takes any type: |x| x is the identity function, written in place or bound by name.
let pair = |x| x -- nothing constrains x: the identity function, at any type
(pair 1, pair "a")
Compiled
A parameter that only a trait constrains is different: show x needs some type with a show, and nothing says which. Such a lambda needs an annotation or an outer context:
|x| show x -- only `show` constrains x, and nothing says which type it shows
Compiled
let f = |x : Int| x + 1
f 1
Compiled
Use lambdas with higher-order functions:
import List
[1, 2, 3] |> List.map (|x| x * 2)
Compiled
Stdlib Higher-Order Function Inference
Lambda parameter types are automatically inferred when passed to stdlib higher-order functions. The compiler examines the higher-order function's type signature and unifies type variables with concrete types from the call site.
For example, List.map has the signature (a -> b) -> List a -> List b. When called with a List Int, the type variable a unifies with Int, so the lambda parameter x is inferred to be Int:
import List
-- Lambda parameter type inferred from List.map signature
List.map (|x| x * 2) [1, 2, 3]
-- [2, 4, 6]
Compiled
import List
-- Lambda parameter type inferred from List.filter signature
List.filter (|x| x > 2) [1, 2, 3, 4, 5]
-- [3, 4, 5]
Compiled
Fold Functions
Fold functions infer both the accumulator and element types:
import List
-- Accumulator and element types inferred from List.foldl signature
-- foldl : (b -> a -> b) -> b -> List a -> b
-- With initial value 0 (Int) and List Int, acc : Int and x : Int
List.foldl (|acc x| acc + x) 0 [1, 2, 3, 4]
-- 10
Compiled
Multi-Parameter Inference
Functions like zipWith that take multiple parameters infer all parameter types:
import List
-- Both parameters inferred from List.zipWith signature
-- zipWith : (a -> b -> c) -> List a -> List b -> List c
-- With List Int and List Int, both x : Int and y : Int
List.zipWith (|x y| x * y) [1, 2, 3] [4, 5, 6]
-- [4, 10, 18]
Compiled
Chained Operations
Type inference flows through pipelines. Each lambda's parameter type is inferred from the result of the previous operation:
import List
-- Type inference flows through chained operations
-- Each lambda's parameter type is inferred from the previous result
[1, 2, 3, 4, 5]
|> List.filter (|x| x > 2)
|> List.map (|x| x * 2)
|> List.foldl (|acc x| acc + x) 0
-- acc : Int, x : Int
-- Result: 24
Compiled
Supported stdlib functions: map, filter, foldl, foldr, zipWith, any, all, find, partition, sortBy
See also: Generic Functions for how type variables work in function signatures.
Currying
All functions in Halyard are curried by default:
fn add : Int -> Int -> Int
fn add x y =
x + y
let add5 = add 5
add5 3
Compiled
Currying enables powerful function composition patterns.
Function Overloading
Functions can have the same name but different type signatures. The correct function is selected at compile time based on argument types:
module CustomMath exposing ..
fn double : Int -> Int
fn double x =
x * 2
fn double : String -> String
fn double s =
s ++ s
CustomMath.double 5
-- 10
Compiled
module CustomMath exposing ..
fn double : Int -> Int
fn double x =
x * 2
fn double : String -> String
fn double s =
s ++ s
CustomMath.double "hi"
-- "hihi"
Compiled
Overloading also works at the top level:
fn inc : Int -> Int
fn inc x =
x + 1
fn inc : Float -> Float
fn inc x =
x + 1.0
inc 5 -- 6
Compiled
Different Arity Overloading
Functions with the same name but different numbers of parameters are supported:
module CustomMath exposing ..
fn add : Int -> Int
fn add x =
x + 1
fn add : Int -> Int -> Int
fn add x y =
x + y
CustomMath.add 5
-- 6 (uses single-arg overload)
Compiled
module CustomMath exposing ..
fn add : Int -> Int
fn add x =
x + 1
fn add : Int -> Int -> Int
fn add x y =
x + y
CustomMath.add 5 3
-- 8 (uses two-arg overload)
Compiled
Overloaded Higher-Order Functions
When passing lambdas to overloaded higher-order functions, parameter types are automatically inferred:
module Apply exposing ..
fn apply : (Int -> Int) -> Int -> Int
fn apply f x =
f x
fn apply : (String -> String) -> String -> String
fn apply f s =
f s
Apply.apply (|x| x + 1) 5
-- 6: x inferred as Int
Compiled
Shadowing a Function in a Nested Scope
A fn declared inside another function's body hides an outer declaration of the same name and the same profile — that is, the same parameter type. Calls in the inner scope reach the nested declaration:
fn helper : Int -> Int
fn helper x =
x + 100
fn outer : Int -> Int
fn outer n =
fn helper : Int -> Int
fn helper x =
x + 1
helper n
outer 5 -- 6, the nested helper wins
Compiled
Hiding applies only to the same profile. An outer overload taking a different parameter type stays visible, so shadowing never silently removes an overload you did not mean to replace:
fn helper : Bool -> String
fn helper b =
"outerbool"
fn outer : Bool -> String
fn outer n =
fn helper : Int -> String
fn helper x =
"nestedint"
helper n
outer True -- outerbool, the Int overload does not hide the Bool one
Compiled
Trait method names are reserved — for top-level functions
Declaring a top-level fn whose name is a method of a trait the program
implements or derives — show, eq, compare, hash, toRational, fromInt,
or a user trait's method — is a compile error at the declaration, whether the
impl was written (trait Show for Int) or brought in by a deriving (Show)
clause. A clause inside a module body or in a module file is a trigger as
well: a module body is a compilation unit in its own right, so an impl written
there is as real as one written at a file's top level. Only a clause nested
inside a block — a let body, a function body — reserves nothing anywhere. A
fn inside a module is covered by the same rule, but only where the
method's name is called bare somewhere that could reach it — in the module's own
file, or in a file that writes import M exposing show; the paragraphs on
modules below say why, and which bare names do not count. The rule applies at
any type and any arity, and a program with no trait and no deriving clause is
unaffected.
Where a clause reserves is settled per program. A program is a root — the
file you run, or a run target — together with every module it imports,
transitively: exactly the set one compilation puts into one trait registry. A
clause reserves its trait's method names in every unit of every program it
belongs to, and in every program spawned below one of those through run. It
never reserves back across a run boundary, because a child inherits its
caller's registry and contributes nothing back to it. Two consequences worth
knowing:
- A module file's clause reserves in the files that import it. The module is
part of their program, so a top-level
fn showin an importing file collides with aderiving (Show)written in the module — otherwise the module's impl would silently displace the importer's own function. - Two
runchildren that share a module file do not reserve in each other. They are two programs that happen to import the same module, and the module is compiled once into each registry. A clause in one child reaches neither its caller nor its siblings.
This is the same rule Ada uses for homographs, and it is what makes overloading and shadowing composable: an inner declaration replaces the one it genuinely conflicts with, and nothing else.
A binding, though, shadows a trait method exactly as it shadows a function. A
let, a nested fn, a parameter, a lambda parameter and a case binder named
like a method all bind, and the reference means the binding — the same rule that
applies when you shadow any other name.
A task expecting field is the exception, and it is a bug rather than a rule — in
two ways. A field named like a method of a trait the program derives is
displaced by the method, and the program fails at run time instead of using
the value you passed in. And if the same file also declares a module member of
that name, the program is rejected instead, with the error pointing at the
member rather than at the field. Rename the field until both are fixed.
fn f : Int -> Int
fn f x = x * 10
fn viaParam : (Int -> Int) -> Int
fn viaParam f = f 2 -- the parameter f, not the function f
fn viaLet : Int -> Int
fn viaLet n =
let f = |x| x + 1 -- the local f, not the function f
f n
[viaParam (|x| x + 1), viaLet 5]
Compiled
So let eq = 1 == 1 is the Bool it looks like, even in a file that derives
Eq. One thing to know when you do this: the method you shadowed has no other
name to call it by, so inside that scope it is unreachable. Pick a different
binder name if you still need the method there.
A top-level let binds for the top-level code that follows it, and a fn
body is not that code. A fn written above such a let still means the method;
a fn written below it cannot see the binding at all and reports "a fn cannot
use the outer value" — the same capture rule as for any other top-level value.
Inside a function, then, shadow with something the function itself binds: a
parameter, or a let in its own body.
A module member is not reserved either, when its only use form is qualified:
a module exposing show keeps compiling in a program that derives Show,
because M.show and a bare show are different names. What reserves it is a
bare show anywhere in the member's own file — in the member's body, in
another member, or in a top-level function beside the module block — because
there the bare name is the one dispatch would claim. The unit is the file, not the
module block: an inline module shares its file's, so a bare show elsewhere in
that file reserves the member even though nothing can reach it except M.show.
One other file CAN reserve it, and only one way: by importing the name. import M exposing show makes the member callable as a bare show in the importing
file, so that import is itself the bare use dispatch would claim, and the member
is reserved as if its own file had written it. import M exposing .. does the
same for every name the module actually exports, and for no other — a member the
module keeps private stays unreserved, because no bare name can reach it.
Both forms count only when the importing file is one the clause's own unit
reaches. A file that writes import M exposing show but sits outside that reach
— a sibling the deriving file never imports or runs — reserves nothing, since
nothing there could be hijacked by that clause's impl.
A plain import M reserves nothing either: M.show is still the only spelling.
Nor does another file's own bare show, which reaches that file's trait impl and
never the member.
A bare name a binding owns is not such a call. A module whose function writes
let f = |show| show + 1, or case n of show -> …, has named no dispatch site —
show there is the binding, by the shadowing rule above — so the member stays
unreserved, and renaming that binder changes nothing. What is reserved is a bare
show that would reach the method: the call, not the binder.
Using an Overloaded Function as a Value
A call picks its overload by the argument. A function that is referenced rather than called has no argument, so something else has to say which overload is meant. Three things do. An annotation on the binding:
fn scale : Int -> Int
fn scale n = n * 10
fn scale : Float -> Float
fn scale x = x * 2.0
let f : Float -> Float = scale -- the annotation picks the Float overload
f 2.0
Compiled
The parameter type of the function it is passed to:
fn scale : Int -> Int
fn scale n = n * 10
fn scale : Float -> Float
fn scale x = x * 2.0
fn applyTwice : (Int -> Int) -> Int -> Int
fn applyTwice f x = f (f x)
applyTwice scale 3 -- the parameter type picks the Int overload
Compiled
And, in a composition, the other operand or the composed function's use. The function applied second is chosen by the first one's return type; the function applied first is chosen by what the composed function is applied to:
fn scale : Int -> Int
fn scale n = n * 10
fn scale : Float -> Float
fn scale x = x * 2.0
fn inc : Int -> Int
fn inc n = n + 1
let h = scale >> inc -- h's use below gives scale an Int: the Int overload
let k = inc >> scale -- inc's Int result picks scale's Int overload
[h 3, k 3]
Compiled
Where nothing ever says which overload is meant, the reference is ambiguous and the compiler says so:
fn scale : Int -> Int
fn scale n = n * 10
fn scale : Float -> Float
fn scale x = x * 2.0
let pair = (scale, 1) -- nothing here says which scale is meant
pair
Compiled
An annotation on an enclosing expression reaches the references inside it, so let k : Float -> Float = if c then scale else scale and let h : Int -> Int = scale >> inc each pick one overload. A module-qualified reference such as M.scale follows the same rule as a plain name.
How a Call Chooses Its Overload
A call is chosen by all of its arguments together, not by the first one alone:
fn d : Int -> Int -> Int
fn d a b = a + b
fn d : Float -> Float -> Float
fn d a b = a - b
d 1 2.5 -- both arguments choose: the Float overload, with 1 widened
Compiled
When several overloads fit, the one that needs fewer conversions wins (an Int meeting a Float parameter is one conversion), then one whose parameters name no type variable. When none fits, the error names the overload set and the type it was used at. When two still fit equally, the call is ambiguous.
A call that applies an overloaded name to fewer arguments than the overloads take is decided where it is bound. With h over two and three Int arguments, let g = h 2 fits both, and a later use of g does not decide it. The binding's type does:
fn h : Int -> Int -> Int
fn h a b = a * b
fn h : Int -> Int -> Int -> Int
fn h a b c = a + b + c
let g : Int -> Int = h 2 -- the binding's type says which partial application is meant
g 3
Compiled
fn h : Int -> Int -> Int
fn h a b = a * b
fn h : Int -> Int -> Int -> Int
fn h a b c = a + b + c
let g = h 2 -- two overloads take 2 and want more: decided here, not by g's later use
g 3
Compiled
A lambda that passes its unannotated parameter to such a name is decided at its own binding too. With area over one and two Float arguments, let circ = |r| area r is ambiguous: the later circ 2.0 does not decide it. Annotate the parameter:
fn area : Float -> Float
fn area r = r * 3.0
fn area : Float -> Float -> Float
fn area w h = w * h
let circ = |r: Float| area r -- without `: Float`, r could still be either overload's
circ 2.0
Compiled
If annotating the parameter still leaves two partly applied overloads, as with |y: Int| h y for the h above, annotate the binding's whole type instead: let k : Int -> Int -> Int -> Int = |y: Int| h y. The error message says which remedy applies. Inside a trait-impl method or a fn with constraints, the binding's type is already fixed by the trait or the signature, so the remedy is to decide the argument (write w 2.0, or annotate the binding w comes from).
An overload that takes every argument given always wins over one that would be partly applied, and an annotation cannot override that: with d over Float -> Float and Int -> Int -> Int, let g : Int -> Int = d 2 chooses the one-argument overload, and its Float result does not match Int -> Int. To reach the two-argument overload, write both arguments:
fn d : Float -> Float
fn d x = x * 10.0
fn d : Int -> Int -> Int
fn d a b = a * b
let g = |x| d 2 x -- writing both arguments reaches the two-argument overload
g 3
Compiled
Duplicate Signature Detection
Functions with the same name AND same type signature are rejected:
fn add : Int -> Int
fn add x = x + 1
fn add : Int -> Int
fn add x = x + 2
Compiled
Recursive Functions
Use if-then-else or case expressions for recursion:
module CustomMath exposing factorial
fn factorial : Int -> Int
fn factorial n =
if n <= 1 then
1
else
n * factorial (n - 1)
CustomMath.factorial 5
Compiled
module CustomMath exposing fibonacci
fn fibonacci : Int -> Int
fn fibonacci n =
if n <= 1 then
n
else
fibonacci (n - 1) + fibonacci (n - 2)
CustomMath.fibonacci 10
Compiled
Using case expressions:
fn factorial : Int -> Int
fn factorial n =
case n of
0 -> 1
1 -> 1
_ -> n * factorial (n - 1)
factorial 6 -- 720
Compiled
Pattern Matching in Functions
Match on argument structure using case expressions:
fn length : [a] -> Int
fn length list =
case list of
[] -> 0
x :: xs -> 1 + length xs
length [1, 2, 3, 4]
Compiled
List types can be written as List a or [a] — both are equivalent.
Higher-Order Functions
Functions that take or return functions:
-- Takes a function as argument
fn applyTwice : (Int -> Int) -> Int -> Int
fn applyTwice f x =
f (f x)
applyTwice (|x : Int| x + 1) 5 -- 7
Compiled
fn makeAdder : Int -> (Int -> Int)
fn makeAdder n =
|x : Int| x + n
makeAdder 10 5
Compiled
Common Higher-Order Functions
import List
-- map: transform each element
[1, 2, 3] |> List.map (|x| x * 2)
Compiled
import List
-- filter: keep matching elements
[1, 2, 3, 4] |> List.filter (|x| x > 2)
Compiled
import List
-- fold: reduce to single value
[1, 2, 3, 4] |> List.foldl (|acc x| acc + x) 0
Compiled
Pipe Operators
Chain function calls elegantly:
fn double : Int -> Int
fn double x =
x * 2
fn addOne : Int -> Int
fn addOne x =
x + 1
-- Forward pipe
5
|> double
|> addOne -- Same as: addOne (double 5) = 11
Compiled
import List
[1, 2, 3, 4, 5]
|> List.filter (|x| x > 2)
|> List.map (|x| x * 2)
Compiled
Native Functions in Pipes
Standard library native functions work directly with pipes and composition:
import List
import Math
import String
let a =
"hello"
|> String.toUpper
|> String.length
let b =
"hello"
|> String.slice 0 3
|> String.toUpper
let c =
[1, 2, 3]
|> List.reverse
|> List.length
let d = 0 - 5
d |> Math.abs
Compiled
Assigning Generic Results to Variables
Results of generic stdlib functions can be assigned to variables with proper type inference:
import List
let doubled = List.map (|x| x * 2) [1, 2, 3]
let result =
[1, 2, 3, 4, 5]
|> List.map (|x| x * 2)
|> List.filter (|x| x > 4)
result
Compiled
Function Composition
Compose functions into new functions:
fn double : Int -> Int
fn double x =
x * 2
fn addOne : Int -> Int
fn addOne x =
x + 1
let transform = double >> addOne
transform 5
Compiled
Generic Functions
Functions can work with any type using type variables:
fn identity : a -> a
fn identity x =
x
identity 42
Compiled
fn swap : (a, b) -> (b, a)
fn swap pair =
case pair of
(x, y) -> (y, x)
swap (1, "hello")
Compiled
fn compose : (b -> c) -> (a -> b) -> a -> c
fn compose g f x =
g (f x)
let double = |x : Int| x * 2
let addOne = |x : Int| x + 1
compose double addOne 5
Compiled
Local Bindings
Define helper bindings within a function:
import Math
fn quadraticFormula : Float -> Float -> Float -> (Float, Float)
fn quadraticFormula a b c =
let discriminant = b * b - 4.0 * a * c
let sqrtDisc =
case Math.sqrt discriminant of
Just v -> v
Nothing -> 0.0
let root1 = (0.0 - b + sqrtDisc) / (2.0 * a)
let root2 = (0.0 - b - sqrtDisc) / (2.0 * a)
(root1, root2)
quadraticFormula 1.0 0.0 (0.0 - 4.0)
Compiled
A Function Sees Only Its Parameters
A fn may use its own parameters, the bindings it makes in its own body, and other
DECLARATIONS — functions, enums, constructors, modules, effect operations, trait
methods. It may not use a VALUE from outside its body:
let rate = 0.2
fn scaled : Float -> Float
fn scaled x = x * rate
scaled 10.0
Compiled
Pass it in instead, which also makes the dependency visible in the signature:
fn scaled : Float -> Float -> Float
fn scaled rate x = x * rate
scaled 0.2 10.0
Compiled
The rule covers an enclosing function's parameters and locals, a top-level or
module-level let, a task's expecting fields, and an earlier REPL cell's binding. A
lambda is the exception and the tool for the job — it is the closure form, and captures
what is around it:
let rate = 0.2
let scaled = |x| x * rate
scaled 10.0
Compiled
This is Rust's rule for fn items rather than Haskell's or Elm's. The point is that a
fn's signature is the whole of its contract: everything it depends on is in the
parameter list, so reading the signature tells you what the function can touch.
Declaration Order
Functions are visible to the whole file, so two of them may call each other and one may use a function written below it:
fn isEven : Int -> Bool
fn isEven n = if n == 0 then True else isOdd (n - 1)
fn isOdd : Int -> Bool
fn isOdd n = if n == 0 then False else isEven (n - 1)
isEven 4
Compiled
A let is different: it binds from its own line onward, so a let that names one
written below it is an undeclared name:
let b = a + 1
let a = 1
b
Compiled
Declarations are order-free, statements are not — the same split Rust and Haskell make.
Best Practices
- Write type signatures for all top-level functions
- Keep functions small and focused on one task
- Use descriptive names —
calculateTaxnotcalc - Prefer pure functions without side effects
- Use case expressions for pattern matching
Next Steps
Learn about control flow for conditional logic.