-
Notifications
You must be signed in to change notification settings - Fork 36
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
Add S combinator i.e. ap for (->) a #455
Comments
Indeed. I've tried defining such instances myself, but I didn't get very far. The purpose of this |
If overall name conflicts are OK, it could even be called |
One issue with this is that that module is intended to just be a promoted/singled version of |
I wonder if we should just wait until instance PApplicative ((~>) r) where
type (f <*> g) = Ap f g
type family Ap (f :: r ~> a ~> b) (g :: r ~> a) (x :: r) :: b where
Ap f g x = f x (g x) And all would be well. |
The S combinator is occasionally useful for writing stuff in point-free style, if you're defining a type alias over a composition of the standard defunctionalisation symbols instead of writing your own type family.
In regular Haskell this is
<*>
for the(->) a
instance ofApplicative
. However, for what I assume are hard technical reasons, neither(->) a
nor(~>) a
are instances ofPApplicative
/SApplicative
in singletons, or any of the other expected classes for that matter. Nevertheless, the function doesn't require these instances and can be defined straightforwardly by itself:singletons [d| ap :: (x -> y -> z) -> (x -> y) -> (x -> z) ap f g x = f x (g x) |]
which when promoted is essentially
plus its defunctionalisation symbols. However I'm not sure the best name for it,
ap
is of course taken already byMonad
.The text was updated successfully, but these errors were encountered: