Copyright | (c) 2021-2024 Rudy Matela |
---|---|
License | 3-Clause BSD (see the file LICENSE) |
Maintainer | Rudy Matela <rudy@matela.com.br> |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
This module is part of Conjure.
This defines functions that deal with recursive descent and deconstructions
Synopsis
- conjureIsDeconstruction :: Conjurable f => f -> Int -> Expr -> Bool
- descends :: (Expr -> Expr -> Bool) -> Expr -> Expr -> Bool
- candidateDeconstructionsFrom :: Expr -> [Expr]
- candidateDeconstructionsFromHoled :: Expr -> [Expr]
Documentation
conjureIsDeconstruction :: Conjurable f => f -> Int -> Expr -> Bool Source #
Checks if an expression is a deconstruction.
There should be a single hole
in the expression.
It should decrease the size of all arguments that have a size greater than 0.
descends :: (Expr -> Expr -> Bool) -> Expr -> Expr -> Bool Source #
Returns whether a non-empty subset of arguments descends arguments by deconstruction.
> descends isDec (xxs -++- yys) (xxs -++- tail' yys) True
> descends isDec (xxs -++- yys) (xxs -++- yys) False
> descends isDec (xxs -++- yys) (head' xxs -:- tail xxs -++- head' yys -:- tail yys) False
candidateDeconstructionsFrom :: Expr -> [Expr] Source #
Compute candidate deconstructions from an Expr
.
This is used in the implementation of candidateDefnsC
followed by conjureIsDeconstruction
.
> candidateDeconstructionsFrom (xx `mod'` yy) [ _ `mod` y , x `mod` _ ]
To be constrasted with candidateDeconstructionsFromHoled
.
candidateDeconstructionsFromHoled :: Expr -> [Expr] Source #
Compute candidate deconstructions from an Expr
.
This is used in the implementation of candidateExprs
followed by conjureIsDeconstruction
.
This is similar to canonicalVariations
but always leaves a hole
of the same return type as the given expression.
> candidateDeconstructionsFrom (i_ `mod'` i_) [ _ `mod` x , x `mod` _ ]
To be contrasted with candidateDeconstructionsFrom