Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A name for a product of `Const` and a functor?

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)
like image 244
Artyom Avatar asked Oct 02 '14 19:10

Artyom


Video Answer


2 Answers

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.)

like image 78
chi Avatar answered Oct 08 '22 18:10

chi


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
like image 37
J. Abrahamson Avatar answered Oct 08 '22 16:10

J. Abrahamson