Reputation: 2684
Is SF
already defined anywhere, or does it at least have a name?
data SF a f x = SF a (f x)
instance Functor f => Functor (SF a f) where
fmap g (SF a fx) = SF a (fmap g fx)
Upvotes: 6
Views: 1173
Reputation: 74334
You could just define functor products
data (f :* g) a = P (f a) (g a) deriving Functor
and then write it directly
type SF a f = Const a :* f
Upvotes: 1
Reputation: 116139
Your functor looks like
type SF a f = (,) a :. f
using functor-combo notation.
(I somehow prefer to look at it using composition, rather than using product and Const
.)
Upvotes: 4