You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Conceptually, a LazyList<'T> contains a head of type 'T and a tail of type Lazy<LazyList<'T>>. Strangely, there is no direct way to construct such a lazy list using the current API. The best can be done is LazyList.consDelayed head (fun () -> tail.Value), which is unnecessarily wasteful.
I suggest a new function for creating such a list: LazyList.consLazy (head : <'T>) (tail : Lazy<LazyList<'T>>).
For bonus points, also provide an infix operator that can be used for clarity. I suggest something like (@).
Desired result
I should be able to create an infinite list of 1's like this: let rec ones = 1 @ lazy ones.
Known workarounds
consDelayed can be used but it is inelegant and wasteful.
LazyList.consLazy is now on main (src/FSharpx.Collections/LazyList.fsi, with tests in LazyListTests.fs), so the original request looks fulfilled.
On the follow-up about @: in F# (@) is a fixed list-only function rather than an overloadable operator. A type can't override it, and shadowing it globally would break list append. A custom infix operator such as @@ is the practical route, if one is wanted.
Unless an operator is still wanted, this issue could probably be closed.
Generated by 🌈 Repo Assist, see workflow run. Learn more. Comment /repo-assist to run again
Add this agentic workflow to your repo
To install this agentic workflow, run
gh aw add githubnext/agentics/workflows/repo-assist.md@b4e175bab6674279e0fe158f7dc877b77bc9d92f
Activity
gdziadkiewicz commentedon Oct 13, 2019
In F#
@is the list concatenation operator. To make it more aligned with the language shouldn't it be something along the lines of cons::?feat: add LazyList.consLazy for constructing from Lazy<LazyList<'T>>
github-actions commentedon Mar 13, 2026
gdziadkiewicz commentedon May 16, 2026
@copilot Add override for the
@operator that doesconsLazygithub-actions commentedon Oct 22, 2026
🤖 This is an automated response from Repo Assist.
LazyList.consLazyis now onmain(src/FSharpx.Collections/LazyList.fsi, with tests inLazyListTests.fs), so the original request looks fulfilled.On the follow-up about
@: in F#(@)is a fixed list-only function rather than an overloadable operator. A type can't override it, and shadowing it globally would break list append. A custom infix operator such as@@is the practical route, if one is wanted.Unless an operator is still wanted, this issue could probably be closed.
Add this agentic workflow to your repo
To install this agentic workflow, run