-
Notifications
You must be signed in to change notification settings - Fork 40
Open
Labels
Description
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.