purescript-profunctor
purescript-profunctor copied to clipboard
Impossible to create an instance of the Costrong class
The reason that Function and other types cannot be an instance of Costrong is that PureScript is a strict evaluation.
unfirst :: forall a b c. p (Tuple a c) (Tuple b c) -> p a b
That is, when we want to loop over c, it is impossible to set the initial value of c
How to modify it may be debatable, but I found the following solution
unfirstLazy :: forall a b c. Lazy c => p (Tuple a c) (Tuple b c) -> p a b
unfirstLazy f a = fst $ f $ Tuple a $ go
where
go = snd $ f $ Tuple a $ defer \_ -> go
Also, since this is not "Co" Strong, it might be better to name the class differently, for example CostrongLazy
, or create a new library.
Thanks to natefaubion for sharing this issue on PureScript discord server.