| Safe Haskell | Safe-Inferred |
|---|---|
| Language | Haskell2010 |
Unison.PatternMatchCoverage.GrdTree
Synopsis
- type GrdTree n l = Fix (GrdTreeF n l)
- data GrdTreeF n l a
- pattern Leaf :: l -> GrdTree n l
- pattern Grd :: n -> GrdTree n l -> GrdTree n l
- pattern Fork :: [GrdTree n l] -> GrdTree n l
- prettyGrdTree :: forall n l s. (ListLike s Char, IsString s) => (n -> Pretty s) -> (l -> Pretty s) -> GrdTree n l -> Pretty s
Documentation
type GrdTree n l = Fix (GrdTreeF n l) Source #
A GrdTree is the simple language to desugar matches into. All
pattern matching constructs (e.g. structural pattern matching,
boolean guards, pattern guards, view patterns, etc) are desugared
into this simpler structure.
It is parameterized by the values at guard nodes, n, and the
values at the leaves, l. When desugaring, n is
PmGrd and l is the source
location. After annotating the GrdTree, n is a refinement type
representing matching values and the l is pairs of the
aforementioned refinement type and source location.
For example:
example : Optional Nat -> Nat
example = cases
None -> 0
Some x
| isEven x -> 0
| otherwise -> 1
is desugared into
──┬─ None <- v0 ── srcloc ├─ Some ( v1 :: ##Nat ) <- v0 ── let v2 = isEven v1 ── True <- v2 ── srcloc └─ Some ( v3 :: ##Nat ) <- v0 ── srcloc