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 of Applicative. However, for what I assume are hard technical reasons, neither (->) a nor (~>) a are instances of PApplicative / 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
type instance Apply (Ap f g) a = Apply (Apply f a) (Apply g a)
plus its defunctionalisation symbols. However I'm not sure the best name for it, ap is of course taken already by Monad.
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(->) ainstance ofApplicative. However, for what I assume are hard technical reasons, neither(->) anor(~>) aare instances ofPApplicative/SApplicativein 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,
apis of course taken already byMonad.