Skip to content

AsyncSeqBuilder is not compatible with HtmlContainer #239

Closed

Description

@ThisFunctionalTom

I am trying to use Oxpecker + ViewEngine with datastar and for that I decided to use AsyncSeq for the views which are then rendered and sent to the Client via PatchElementsAsync.

When trying to create AsyncSeq of views with computation expression it does not work. I get the error: repro.fsx(10,38): error FS0193: The type 'AsyncSeq.AsyncSeqBuilder' is not compatible with the type 'HtmlContainer'.

Without the computation expression everything works as expected.

Do you know what could be the problem? Is there maybe a workaround so that I can still use asyncSeq CE?

Small repro.fsx:

#r "nuget: Oxpecker.ViewEngine"
#r "nuget: FSharp.Control.AsyncSeq"

open FSharp.Control
open Oxpecker.ViewEngine

let myView (name: string) : HtmlContainer =
    h1() { name }

let main : AsyncSeq<HtmlContainer> = asyncSeq {
    yield myView "Hello, world"
}

Activity

  1. dsyme commented on Feb 22, 2026

    @dsyme
    Contributor

    Yes that's a bit strange. Code looks like it should be fine

  2. dsyme commented on Feb 22, 2026

    @dsyme
    Contributor

    I think this highly generic constrained Run is causing grief - probably for any computation expressions.

        type HtmlContainerExtensions =
            [<Extension>]
            static member inline Run(this: #HtmlContainer, [<InlineIfLambda>] runExpr: HtmlContainerFun) =
                runExpr this
                this
    

    This could be onsidered an F# compiler bug but we'd have to check the spec - the compiler commits to using this Run before it knows the constraint check #HtmlContainer will fail.

  3. dsyme commented on Feb 22, 2026

    @dsyme
    Contributor

    But it's not AsyncSeq causing this as such - I think you'll get the same problem with many computation expressions (though it may vary on other details related to overloading, subtyping)

  4. dsyme commented on Feb 22, 2026

    @dsyme
    Contributor

    I'll close this one, thanks, though not sure what you should do to resolve the incompat

  5. dsyme commented on Feb 22, 2026

    @dsyme
    Contributor

    Not sure if using the less generic variant without # will help?

        type HtmlContainerExtensions =
            [<Extension>]
            static member inline Run(this: HtmlContainer, [<InlineIfLambda>] runExpr: HtmlContainerFun) =
                runExpr this
                this
    
  6. Lanayx commented on Feb 22, 2026

    @Lanayx
    Member

    This could be onsidered an F# compiler bug but we'd have to check the spec - the compiler commits to using this Run before it knows the constraint check #HtmlContainer will fail.

    It also feels like a compiler bug to me.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions