MWE for when AsSet breaks instances

Home   »   MWE for when AsSet breaks instances

{-# 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

Leave a Reply

Your email address will not be published. Required fields are marked *