disco-0.2: Functional programming language for teaching discrete math.
Copyrightdisco team and contributors
LicenseBSD-3-Clause
Maintainerbyorgey@gmail.com
Safe HaskellSafe-Inferred
LanguageHaskell2010

Disco.Exhaustiveness.Constraint

Description

The heart of the Lower Your Guards algorithm. Functions for converting constraints detailing pattern matches into a normalized description of everything that is left uncovered.

Synopsis

Documentation

alistLookup :: Eq a => a -> [(a, b)] -> [b] Source #

breakIf :: Alternative f => Bool -> f () Source #

conflictsWith :: Constraint -> Constraint -> Bool Source #

Returns a predicate that returns true if another constraint conflicts with the one given. This alone is not sufficient to test if a constraint can be added, but it filters out the easy negatives early on

getConstructorArgs :: DataCon -> [Constraint] -> Maybe [TypedVar] Source #

Search for a MatchDataCon that is matching on k specifically (there should be at most one, see I4 in section 3.4) and if it exists, return the variable ids of its arguments

substituteVarIDs :: TypedVar -> TypedVar -> [ConstraintFor] -> [ConstraintFor] Source #

substituting y *for* x ie replace the second with the first, replace x with y

inhabited :: Members '[Fresh, Reader TyDefCtx] r => NormRefType -> TypedVar -> Sem r Bool Source #

Deals with I2 from section 3.4 if a variable in the context has a resolvable type, there must be at least one constructor which can be instantiated without contradiction of the refinement type This function tests if this is true

instantiate :: Members '[Fresh, Reader TyDefCtx] r => NormRefType -> TypedVar -> DataCon -> Sem r Bool Source #

Attempts to "instantiate" a match of the dataconstructor k on x If we can add the MatchDataCon constraint to the normalized refinement type without contradiction (a Nothing value), then x is inhabited by k and we return true