Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007782OCamltypingpublic2018-04-20 10:432018-04-20 10:51
Reportersagotch 
Assigned Tooctachron 
PrioritynormalSeverityminorReproducibilityalways
StatusresolvedResolutionno change required 
PlatformMacOSMac OSOS Version10.13.4
Product Version4.06.1 
Target VersionFixed in Version 
Summary0007782: OCaml declare type as weak. It is not.
Descriptionlet 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 ReproduceTry to compile https://github.com/ocsigen/reactiveData/pull/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 InformationDelaring 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
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0019043)
octachron (developer)
2018-04-20 10:50

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.

- Issue History
Date Modified Username Field Change
2018-04-20 10:43 sagotch New Issue
2018-04-20 10:50 octachron Note Added: 0019043
2018-04-20 10:51 octachron Status new => resolved
2018-04-20 10:51 octachron Resolution open => no change required
2018-04-20 10:51 octachron Assigned To => octachron


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker