Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to create an instance of the Costrong class #46

Open
yukikurage opened this issue Oct 18, 2022 · 0 comments
Open

Impossible to create an instance of the Costrong class #46

yukikurage opened this issue Oct 18, 2022 · 0 comments

Comments

@yukikurage
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant