Lens: Using items << filtered leads to "missing constraint" compile error without Intellisense error
See original GitHub issuenamespace Test
open FSharpPlus.Lens
type Child = { Id: string }
type Parent = { Children: Child list }
module Test =
let inline _children f (p: Parent) =
f p.Children <&> fun v -> { p with Children = v }
let inline _child childId =
_children << items << filtered (fun c -> c.Id = childId)
The above does not produce an Intellisense error, but compilation fails with the following error on items
on the last line:
error FS0193: A type parameter is missing a constraint 'when (FSharpPlus.Control.Traverse or Test.Child Microsoft.FSharp.Collections.list or ^d) : (static member Traverse : Test.Child Microsoft.FSharp.Collections.list * (Test.Child -> ^a) * ^d * FSharpPlus.Control.Traverse -> ^d)'
I’m unable to get it to compile. What’s wrong with the code? And shouldn’t there be an Intellisense error, too?
Issue Analytics
- State:
- Created 3 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Error List with Filter "Build + IntelliSense" is empty but " ...
NET Framework 4.7.2. I have noticed that the CodeFix for implementing the abstract class on a subclass is missing on most of the...
Read more >Missing Constraint Autolayout Warning
I have a project and I used to add constraints with xcode interface builder. In a specific case I needed to add some...
Read more >Bad error message on missing type constraint · Issue ...
you'd just get an error for the field ( T is not a type). The compiler cannot reasonably know (or "guess") that you...
Read more >UGS Troubleshooting | Unreal Engine 4.27 Documentation
Some tips and procedures for correcting common problems with UGS · Can't detect Precompiled Binaries. · Can't connect. · **Failed sync or build...
Read more >Feature request: Filter/group items by type in the problems ...
I find it unfortunate to mix intellisense/lint errors and build errors/warnings in the "Problems" tab. I might have several multi-root ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@cmeeren Here’s a quick workaround:
Since
items
is just an alias fortraverse
, you can replace it but using a specific traverse for your case.So, for instance if you’re working with
list
Data provides additional types, but it also provides some generic extensions to existing types which I reckon it’s a bit confusing since we have also extensions in Extensions.fs
This is like this also for a technical reason, Extensions are used in Invokables, and Data uses Invokables, in this case to restrict to a less generic version.
We’ll need to re-think this for V2.
CC @adz