diff --git a/lib/Cryptol.cry b/lib/Cryptol.cry index e756bef3..52a891cd 100644 --- a/lib/Cryptol.cry +++ b/lib/Cryptol.cry @@ -94,10 +94,16 @@ primitive False : Bit primitive negate : {a} (Arith a) => a -> a /** - * Binary complement + * Binary complement. */ primitive complement : {a} a -> a +/** + * Operator form of binary complement. + */ +(~) : {a} a -> a +(~) = complement + /** * Less-than. Only works on comparable arguments. */ diff --git a/src/Cryptol/Parser.y b/src/Cryptol/Parser.y index 8b6f4ab6..8a0dbbce 100644 --- a/src/Cryptol/Parser.y +++ b/src/Cryptol/Parser.y @@ -267,7 +267,8 @@ mbDoc :: { Maybe (Located String) } decl :: { Decl PName } : vars_comma ':' schema { at (head $1,$3) $ DSignature (reverse $1) $3 } | ipat '=' expr { at ($1,$3) $ DPatBind $1 $3 } - | name apats '=' expr { at ($1,$4) $ + | '(' op ')' '=' expr { at ($1,$5) $ DPatBind (PVar $2) $5 } + | var apats '=' expr { at ($1,$4) $ DBind $ Bind { bName = $1 , bParams = reverse $2 , bDef = at $4 (Located emptyRange (DExpr $4)) diff --git a/tests/issues/issue148.icry.stdout b/tests/issues/issue148.icry.stdout index 0c6ab086..6ab9f110 100644 --- a/tests/issues/issue148.icry.stdout +++ b/tests/issues/issue148.icry.stdout @@ -5,12 +5,12 @@ Loading module Main Defaulting type parameter 'bits' of literal or demoted expression at ./issue148.cry:4:34--4:35 - to max 2 (width a`193) + to max 2 (width a`195) [warning] at ./issue148.cry:2:1--9:10: Defaulting 2nd type parameter of expression take at ./issue148.cry:6:10--6:14 - to 16 * a`193 + to 16 * a`195 [warning] at :1:1--1:36: Defaulting type parameter 'bits' of finite enumeration diff --git a/tests/issues/issue198.icry.stdout b/tests/issues/issue198.icry.stdout index 72c9e6f9..22f9833b 100644 --- a/tests/issues/issue198.icry.stdout +++ b/tests/issues/issue198.icry.stdout @@ -5,15 +5,15 @@ Loading module Main Defaulting type parameter 'bits' of literal or demoted expression at ./simon.cry2:87:34--87:35 - to max 3 (width a`569) + to max 3 (width a`571) [warning] at ./simon.cry2:83:1--92:15: Defaulting type parameter 'bits' of literal or demoted expression at ./simon.cry2:90:29--90:31 - to width a`571 + to width a`573 [warning] at ./simon.cry2:83:1--92:15: Defaulting type parameter 'bits' of literal or demoted expression at ./simon.cry2:89:36--89:38 - to max 6 (max (width a`569) (width (a`570 - 1))) + to max 6 (max (width a`571) (width (a`572 - 1))) True diff --git a/tests/issues/issue214.icry.stdout b/tests/issues/issue214.icry.stdout index 54f013cf..3105f434 100644 --- a/tests/issues/issue214.icry.stdout +++ b/tests/issues/issue214.icry.stdout @@ -5,9 +5,9 @@ Loading module Main Defaulting type parameter 'bits' of finite enumeration at ./issue214.cry:2:14--2:26 - to max 2 (width (2 * a`193 - 2)) + to max 2 (width (2 * a`195 - 2)) [warning] at ./issue214.cry:2:1--2:49: Defaulting type parameter 'bits' of finite enumeration at ./issue214.cry:2:36--2:48 - to max 2 (width (2 * a`193 - 1)) + to max 2 (width (2 * a`195 - 1)) diff --git a/tests/issues/issue226.icry.stdout b/tests/issues/issue226.icry.stdout index f5885a56..d47acfc9 100644 --- a/tests/issues/issue226.icry.stdout +++ b/tests/issues/issue226.icry.stdout @@ -86,4 +86,5 @@ Symbols bits >= width len) => [len]elem -> [bits] zero : {a} a (||) : {a} a -> a -> a + (~) : {a} a -> a diff --git a/tests/issues/issue296.icry b/tests/issues/issue296.icry new file mode 100644 index 00000000..19a03962 --- /dev/null +++ b/tests/issues/issue296.icry @@ -0,0 +1 @@ +:t (~) diff --git a/tests/issues/issue296.icry.stdout b/tests/issues/issue296.icry.stdout new file mode 100644 index 00000000..3651f584 --- /dev/null +++ b/tests/issues/issue296.icry.stdout @@ -0,0 +1,2 @@ +Loading module Cryptol +(~) : {a} a -> a