Skip to content

Instantly share code, notes, and snippets.

@zudov
Last active Dec 29, 2015
Embed
What would you like to do?
ConstraintKinds, Functor, Set
-- | https://jeltsch.wordpress.com/2013/02/14/the-constraint-kind/
{-# LANGUAGE ConstraintKinds, TypeFamilies #-}
import Prelude hiding (Functor(..))
import Data.Set (Set)
import qualified Data.Set as Set
import GHC.Exts (Constraint)
class Functor f where
type Object f a :: Constraint
type Object f a = ()
fmap :: (Object f a, Object f b) => (a -> b) -> f a -> f b
instance Functor Set where
type Object Set a = Ord a
fmap = Set.map
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment