Skip to content

Instantly share code, notes, and snippets.

@zudov
Last active December 29, 2015 22:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zudov/e7adef0d7563bc615001 to your computer and use it in GitHub Desktop.
Save zudov/e7adef0d7563bc615001 to your computer and use it in GitHub Desktop.
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