unison-parser-typechecker-0.0.0
Safe HaskellSafe-Inferred
LanguageHaskell2010

Unison.PatternMatchCoverage.GrdTree

Synopsis

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

data GrdTreeF n l a Source #

Constructors

LeafF l

A successful match

GrdF n a

A constraint of some kind (structural pattern match, boolan guard, etc)

ForkF [a]

A list of alternative matches, tried in order

Instances

Instances details
Functor (GrdTreeF n l) Source # 
Instance details

Defined in Unison.PatternMatchCoverage.GrdTree

Methods

fmap :: (a -> b) -> GrdTreeF n l a -> GrdTreeF n l b #

(<$) :: a -> GrdTreeF n l b -> GrdTreeF n l a #

(Show l, Show n, Show a) => Show (GrdTreeF n l a) Source # 
Instance details

Defined in Unison.PatternMatchCoverage.GrdTree

Methods

showsPrec :: Int -> GrdTreeF n l a -> ShowS #

show :: GrdTreeF n l a -> String #

showList :: [GrdTreeF n l a] -> ShowS #

pattern Leaf :: l -> GrdTree n l Source #

pattern Grd :: n -> GrdTree n l -> GrdTree n l Source #

pattern Fork :: [GrdTree n l] -> GrdTree n l Source #

prettyGrdTree :: forall n l s. (ListLike s Char, IsString s) => (n -> Pretty s) -> (l -> Pretty s) -> GrdTree n l -> Pretty s Source #