Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCaml declare type as weak. It is not. #7782

Closed
vicuna opened this issue Apr 20, 2018 · 1 comment
Closed

OCaml declare type as weak. It is not. #7782

vicuna opened this issue Apr 20, 2018 · 1 comment
Assignees

Comments

@vicuna
Copy link

vicuna commented Apr 20, 2018

Original bug ID: 7782
Reporter: sagotch
Assigned to: @Octachron
Status: resolved (set by @Octachron on 2018-04-20T08:51:32Z)
Resolution: not a bug
Priority: normal
Severity: minor
Platform: Mac
OS: Mac OS
OS Version: 10.13.4
Version: 4.06.1
Category: typing

Bug description

let for_all =
let module IntSet =
Set.Make (struct type t = int let compare = Pervasives.compare end)
in
fun fn data ->
let maybe_update acc i v = if fn v then acc else IntSet.add i acc in
let init =
let rec fold i acc = function
| v :: tl -> fold (i + 1) (maybe_update acc i v) tl
| [] -> acc
in
fold 0 IntSet.empty
in
let update_idx_after i f acc =
IntSet.map (fun i' -> if i' >= i then f i' 1 else i') acc
in
let f = fun acc -> function
| Set x -> init x
| Patch updates ->
List.fold_left
(fun acc -> function
| X (i, i') ->
if IntSet.mem i acc = IntSet.mem i' acc
then acc
else if IntSet.mem i acc
then IntSet.add i' (IntSet.remove i acc)
else IntSet.add i (IntSet.remove i' acc)
| R i ->
let acc = update_idx_after i (-) acc in
IntSet.remove i acc
| I (i, v) ->
let acc = update_idx_after i (+) acc in
maybe_update acc i v
| U (i, v) ->
maybe_update (IntSet.remove i acc) i v)
acc
updates
in
React.S.fold f (init (value data)) (event data)
|> React.S.map IntSet.is_empty

Error: The implementation src/reactiveData.ml
does not match the interface src/reactiveData.cmi:
...
In module RList:
Values do not match:
val for_all : ('_weak1 -> bool) -> '_weak1 t -> bool React.signal
is not included in
val for_all : ('a -> bool) -> 'a t -> bool React.signal
File "src/reactiveData.mli", line 194, characters 2-54:
Expected declaration
File "src/reactiveData.ml", line 476, characters 6-13:
Actual declaration

Steps to reproduce

Try to compile ocsigen/reactiveData#23 but with

let for_all =
let module IntSet =
Set.Make (struct type t = int let compare = Pervasives.compare end)
in
fun fn data ->

instead of

let for_all fn data =

Additional information

Delaring the IntSet module at toplevel solved the issue.

Declaring it inside the function works as well.

i.e.:
let for_all fn data =
let module IntSet =
Set.Make (struct type t = int let compare = Pervasives.compare end)
in

@vicuna
Copy link
Author

vicuna commented Apr 20, 2018

Comment author: @Octachron

This is the intended behavior. "Set.Make(...)" is a functor application, therefore "let module M = Set.make() in fun ... -> ... " is not a value and the value restriction applies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants