-
Notifications
You must be signed in to change notification settings - Fork 380
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #247 from edwinb/evaluator-fix
More explicitness in evaluator return type
- Loading branch information
Showing
5 changed files
with
90 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import Data.Vect | ||
|
||
%default total | ||
|
||
infix 3 .<=. | ||
(.<=.) : Int -> Int -> Bool | ||
(.<=.) p q = case (p, q) of | ||
(0, _) => True | ||
_ => False | ||
|
||
countGreater : (thr : Int) -> (ctx : Vect n Int) -> Nat | ||
countGreater thr [] = Z | ||
countGreater thr (x :: xs) with (x .<=. thr) | ||
countGreater thr (x :: xs) | True = countGreater thr xs | ||
countGreater thr (x :: xs) | False = S $ countGreater thr xs | ||
|
||
-- map a variable from the old context to the erased context | ||
-- where we erase all bindings less than or equal to the threshold | ||
eraseVar : (thr : Int) -> (ctx : Vect n Int) -> Fin n -> Maybe (Fin (countGreater thr ctx)) | ||
eraseVar thr (x :: xs) j with (x .<=. thr) | ||
eraseVar thr (x :: xs) FZ | True = Nothing | ||
eraseVar thr (x :: xs) FZ | False = Just FZ | ||
eraseVar thr (x :: xs) (FS i) | True = FS <$> eraseVar thr xs i | ||
eraseVar thr (x :: xs) (FS i) | False = FS <$> eraseVar thr xs i | ||
|
||
boom : Maybe (Fin 1) | ||
boom = eraseVar 0 [0, 1] (FS FZ) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
1/1: Building boom (boom.idr) | ||
boom.idr:23:42--24:3:While processing right hand side of with block in eraseVar at boom.idr:23:3--24:3: | ||
Can't solve constraint between: | ||
S (countGreater thr xs) | ||
and | ||
countGreater thr xs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
$1 --check boom.idr | ||
|
||
rm -rf build |