mirror of
https://github.com/GaloisInc/cryptol.git
synced 2024-12-30 11:23:56 +03:00
284338c938
When `:set mono-binds=on`, any local definitions lacking type signatures will not be generalized (i.e., will be monomorphic). This reduces what is in most cases unnecessary polymorphism that can give rise to constraints that are difficult to solve. This also improves the performance of the Cryptol interpreter by lifting many polymorphic type applications out of the inner loops that are commonly defined as bindings in `where` clauses. The flag is on by default in the Cryptol REPL, and in most cases makes it possible to leave out more type signatures in `where` clauses than before. However, some programs really do rely on inferring polymorphic types for local variables; in this case adding an explicit polymorphic type signature to the local binding in question will make the program typecheck.
33 lines
882 B
Plaintext
33 lines
882 B
Plaintext
Loading module Cryptol
|
|
Loading module Cryptol
|
|
Loading module test04
|
|
module test04
|
|
import Cryptol
|
|
/* Not recursive */
|
|
test04::test : {a, b} (b >= 4, fin b) => a -> ((a, ()), (a, [b]))
|
|
test04::test = \{a, b} (b >= 4, fin b) (a : a) ->
|
|
(f () (), f [b] (demote 10 b <> <> <>))
|
|
where
|
|
/* Not recursive */
|
|
f : {c} c -> (a, c)
|
|
f = \{c} (x : c) -> (a, x)
|
|
|
|
|
|
|
|
Loading module Cryptol
|
|
Loading module test04
|
|
[warning] at test04.cry:1:1--5:14:
|
|
Defaulting type parameter 'bits'
|
|
of literal or demoted expression
|
|
at test04.cry:3:19--3:21
|
|
to 4
|
|
|
|
[error] at test04.cry:3:17--3:21:
|
|
Type mismatch:
|
|
Expected type: [?b3]
|
|
Inferred type: ()
|
|
where
|
|
?b3 is type parameter 'bits'
|
|
of literal or demoted expression
|
|
at test04.cry:3:19--3:21
|