Created
May 4, 2021 08:51
-
-
Save olligobber/7acce0d7b8d02d587f609f7e4b0689a4 to your computer and use it in GitHub Desktop.
MWE for when AsSet breaks instances
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE DataKinds #-} | |
{-# LANGUAGE TypeOperators #-} | |
{-# LANGUAGE KindSignatures #-} | |
{-# LANGUAGE FlexibleContexts #-} | |
import Data.Type.Set (AsSet) | |
class GoodType t | |
data Type1 | |
data Type2 | |
instance GoodType Type1 | |
instance GoodType Type2 | |
class AllGood (t :: [*]) | |
instance AllGood '[] | |
instance (GoodType t, AllGood ts) => AllGood (t:ts) | |
-- f :: AllGood '[Type1, Type2] => Int -- works | |
-- f :: AllGood '[Type2, Type1] => Int -- works | |
-- f :: AllGood (AsSet '[Type1, Type2]) => Int -- error | |
-- f :: AllGood (AsSet '[Type2, Type1]) => Int -- error | |
-- f :: AllGood (AsSet '[Type1]) => Int -- works | |
-- f :: AllGood (AsSet '[Type2]) => Int -- works | |
f = 0 | |
main :: IO () | |
main = print f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solution was to use Symbols instead of Types, and have
type instance Cmp (a :: Symbol) (b :: Symbol) = CmpSymbol a b