3

This statement in the update:

let update m msg =
  match msg with
  | SetEncounterMsg encounter ->
      match encounter with   
      | None -> init() , Cmd.none
      | Some s ->
          init () |> (fun q -> {q with Encounter = Some s}),
          Cmd.ofMsg (RequestPrescriptionsForEncounterMsg s)   

runs/works correctly to request an asynchronous operation.

However, the "RequestPrescriptionsForEnconterMsg" is giving the warning that "This construct causes code to be less generic than indicated by the type annotations. The type vairable 'a has been constrained to be type 'Msg'

Why? This is of type Msg. How do I fix this? (I think I'm missing something here :( )

Any help is most appreciated.

Edit #1: The model, m, is initialized in the above with:

let init () : Model = .....

which is then being further updated by the function, fun.

Lyndon Gingerich
  • 604
  • 7
  • 17
Alan Wayne
  • 5,122
  • 10
  • 52
  • 95
  • Where do you use the variable `m`? – phoog Jul 14 '22 at 22:33
  • @phoog Plese see above edit. The Model, m, is initialized with init(). – Alan Wayne Jul 15 '22 at 02:12
  • 1
    Please share a link to a GitHub repository with code that exhibits this problem. – Tyson Williams Jul 15 '22 at 02:35
  • There's no type annotation (type variable `'a`) in the code you've shown, so I suspect you haven't given us enough information to answer your question. – Brian Berns Jul 15 '22 at 13:06
  • @BrianBerns I aggree! However, I have used this exact same pattern in Elmish.wpf before without any warning messages--and this particular warning message gives me no idea where to look for the problem. I am curious to find out that maybe if I redefine init() to take the current Model, m, as a parameter as opposed to recreating the Model as it is currently defined, if that may not fix the error. I will try this in a bit to see if it makes a difference. Anyway, it does run fine without error--so I'm tempted just to ignore it. – Alan Wayne Jul 15 '22 at 17:54

0 Answers0