Skip to content

Lazy tuple workaround #456

@treeowl

Description

@treeowl

Due to a serious shortcoming in the GHC linearity system, which seems likely to require some research to fix, it's currently impossible to use laziness in any nontrivial way in linear code. I suggest we add some functions to work around the problem until someone with the requisite skills has time to address the underlying problem.

lazyUncurry :: (a %p -> b %p -> c) %q-> (a, b) %p-> c
lazyUncurry = \f -> Unsafe.toLinear (\ ~(a, b) -> f a b)

This can be extended to tuples of various sizes. Another approach that can be used in parallel is

ensure2 :: (a, b) %p -> (a, b)
ensure2 = Unsafe.toLinear $ \ ~(a, b) -> (a, b)

we can easily offer a Generic version of the latter that works with all sorts of Generic records.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions