Skip to content

Instantly share code, notes, and snippets.

@kcsongor
Created December 28, 2017 00:18
Show Gist options
  • Save kcsongor/a2d03704cd27eafdbcc824648e317740 to your computer and use it in GitHub Desktop.
Save kcsongor/a2d03704cd27eafdbcc824648e317740 to your computer and use it in GitHub Desktop.
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE TypeFamilies #-}
module Stuck where
data Tag = Tag
type family Fam :: k -> Tag -> k
type family IsTagged (a :: k) :: Bool where
IsTagged (a 'Tag) = 'True
IsTagged (a _) = 'False
-- These two cases work perfectly:
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
-- >>> :kind! IsTagged (Maybe Int)
-- IsTagged (Maybe Int) :: Bool
-- = 'False
--
-- >>> :kind! IsTagged (Fam Int 'Tag)
-- IsTagged (Fam Int 'Tag) :: Bool
-- = 'True
-- But this one doesn't reduce... why?
-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
--
-- >>> :kind! IsTagged (Fam Maybe 'Tag Int)
-- IsTagged (Fam Maybe 'Tag Int) :: Bool
-- = IsTagged (Fam Maybe 'Tag Int)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment