question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lens: Using items << filtered leads to "missing constraint" compile error without Intellisense error

See original GitHub issue
namespace 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:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
gustycommented, Sep 25, 2020

@cmeeren Here’s a quick workaround:

Since items is just an alias for traverse, you can replace it but using a specific traverse for your case.

So, for instance if you’re working with list

let inline _child childId =
    _children << List.traverse << filtered (fun c -> c.Id = childId)
0reactions
gustycommented, Sep 25, 2020

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found