-
Notifications
You must be signed in to change notification settings - Fork 19
Open
Milestone
Description
For some usage patterns it's beneficial to produce universe stream on the fly, without memoising it. As it's a CAF it's get memoised by default:
For example with:
consumerExample :: Property
consumerExample = once $ a .&&. b
where
a = (universe !! 10000001) === (5000001 :: Integer)
b = (universe !! 10000001) === (5000001 :: Integer)maximal residency get out of hands:
272,054,848 bytes maximum residency (13 sample(s))
One solution would be to change Universe class to be
class Universe a where
{-# DEPRECATED universe "Consider using churchUniverse" #-}
universe = build churchEncoding
churchUniverse :: forall b. (a -> b -> b) -> b -> b
churchUniverse = churchUiverseDef
{-# DEPRECATED universeDef "Consider using churchUniverseDef" #-}
universeDef :: (Enum a, Bounded a) => [a]
universeDef = [minBound..maxBound]
churchUniverseDef :: (Enum a, Bounded a) => forall b. (a -> b -> b) -> b -> b
churchUniverseDef c n = foldr c n [minBound..maxBound]I could try to make this change, if it's a problem you think is worth solving. My gut feeling is that using church encoding is probably the best way to prevent sharing.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels