-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0a3a2e1
commit c00c9e5
Showing
4 changed files
with
76 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
enum Maybe a = Nothing | Just a | ||
|
||
maybeEqual : {a} (Eq a) => Maybe a -> Maybe a -> Bit | ||
maybeEqual m1 m2 = | ||
case m1 of | ||
Just x1 -> | ||
case m2 of | ||
Just x2 -> x1 == x2 | ||
Nothing -> False | ||
Nothing -> | ||
case m2 of | ||
Just x2 -> False | ||
Nothing -> True | ||
|
||
maybeMapBad1 : {a, b} (a -> b) -> Maybe a -> Maybe b | ||
maybeMapBad1 f m = | ||
case m of | ||
Just x -> Just (f x) | ||
|
||
maybeMapBad2 : {a, b} (a -> b) -> Maybe a -> Maybe b | ||
maybeMapBad2 f m = | ||
case m of | ||
Nothing -> Nothing | ||
|
||
maybeMapBad1Prop : Maybe [8] -> Bit | ||
property maybeMapBad1Prop m = | ||
maybeEqual | ||
(maybeMapBad1 (\x -> x + 1) (maybeMapBad1 (\x -> x + 1) m)) | ||
(maybeMapBad1 (\x -> x + 2) m) | ||
|
||
maybeMapBad2Prop : Maybe [8] -> Bit | ||
property maybeMapBad2Prop m = | ||
maybeEqual | ||
(maybeMapBad2 (\x -> x + 1) (maybeMapBad2 (\x -> x + 1) m)) | ||
(maybeMapBad2 (\x -> x + 2) m) |
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 @@ | ||
:l CheckEnumPartialError.cry | ||
:set-seed 42 | ||
:check |
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,23 @@ | ||
Loading module Cryptol | ||
Loading module Cryptol | ||
Loading module Main | ||
property maybeMapBad1Prop Using random testing. | ||
Testing... ERROR for the following inputs: | ||
maybeMapBad1Prop Nothing ~> ERROR | ||
Missing `case` alternative for constructor `Nothing`. | ||
-- Backtrace -- | ||
Main::maybeMapBad1 called at CheckEnumPartialError.cry:28:34--28:46 | ||
Main::maybeMapBad1 called at CheckEnumPartialError.cry:28:6--28:18 | ||
Main::maybeEqual called at CheckEnumPartialError.cry:27:3--27:13 | ||
Main::maybeMapBad1Prop | ||
<interactive>::it | ||
property maybeMapBad2Prop Using random testing. | ||
Testing... ERROR for the following inputs: | ||
maybeMapBad2Prop Just 0xa6 ~> ERROR | ||
Missing `case` alternative for constructor `Just`. | ||
-- Backtrace -- | ||
Main::maybeMapBad2 called at CheckEnumPartialError.cry:34:34--34:46 | ||
Main::maybeMapBad2 called at CheckEnumPartialError.cry:34:6--34:18 | ||
Main::maybeEqual called at CheckEnumPartialError.cry:33:3--33:13 | ||
Main::maybeMapBad2Prop | ||
<interactive>::it |