Skip to content

Instantly share code, notes, and snippets.

@dcastro
Created October 17, 2018 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dcastro/1d58617f2a87c83aeb4881b0de6a89f5 to your computer and use it in GitHub Desktop.
Save dcastro/1d58617f2a87c83aeb4881b0de6a89f5 to your computer and use it in GitHub Desktop.
Alias for empty constraint `* -> Constraint`
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE FunctionalDependencies #-}
module Playground4 where
import Data.Kind (Constraint)
import qualified Data.List as List
class GFunctor (c :: * -> Constraint) (f :: * -> *) | f -> c where
gfmap :: c b => (a -> b) -> (f a -> f b)
type EmptyConstraint a = ()
instance GFunctor EmptyConstraint [] where
gfmap = List.map
-- error:
-- • Expected kind ‘* -> Constraint’,
-- but ‘EmptyConstraint’ has kind ‘* -> *’
-- • In the first argument of ‘GFunctor’, namely ‘EmptyConstraint’
-- In the instance declaration for ‘GFunctor EmptyConstraint []’
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment