guard package:code-conjure

Provides a guard bound to the conjured function's return type. Guards are only alllowed at the root fo the RHS.
last' :: [Int] -> Int
last' [x]  =  x
last' [x,y]  =  y
last' [x,y,z]  =  z
> conjure "last" last'
>   [ unfun ([] :: [Int])
>   , fun ":" ((:) :: Int -> [Int] -> [Int])
>   , fun "null" (null :: [Int] -> Bool)
>   , guard
>   , fun "undefined" (undefined :: Int)
>   ]
last :: [Int] -> Int
-- 0.0s, testing 360 combinations of argument values
-- 0.0s, pruning with 5/5 rules
-- 0.0s, 1 candidates of size 1
-- 0.0s, 0 candidates of size 2
-- 0.0s, 0 candidates of size 3
-- 0.0s, 0 candidates of size 4
-- 0.0s, 0 candidates of size 5
-- 0.0s, 0 candidates of size 6
-- 0.0s, 4 candidates of size 7
-- 0.0s, tested 2 candidates
last []  =  undefined
last (x:xs)
| null xs  =  x
| otherwise  =  last xs
Creates an if Expr of the type argument of the given proxy. The expression is named as | as if to represent a guard.
> guardFor (undefined :: Int)
(|) :: Bool -> Int -> Int -> Int
In the future, maybe we display these differently in Conjure as guards. For now, this will signalize an if that can only appear as a root expression.
Conjures a guard at the return type of the given function.
Has this expression a non-root guard? This only checks the immediate sub-expressions, good enough for when enumerating. Guards at the root are still allowed.
Changes an if encoded as an Expr to a guard encoded as an Expr. This works for both the dangling symbol, or for a full application.
Is the expression a guard application?