diff options
Diffstat (limited to 'compiler/GHC/Data/Bag.hs')
-rw-r--r-- | compiler/GHC/Data/Bag.hs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/GHC/Data/Bag.hs b/compiler/GHC/Data/Bag.hs index aa18bec5e1..75e7927a6b 100644 --- a/compiler/GHC/Data/Bag.hs +++ b/compiler/GHC/Data/Bag.hs @@ -6,7 +6,7 @@ Bag: an unordered collection with duplicates -} -{-# LANGUAGE ScopedTypeVariables, CPP, DeriveFunctor #-} +{-# LANGUAGE ScopedTypeVariables, CPP, DeriveFunctor, TypeFamilies #-} module GHC.Data.Bag ( Bag, -- abstract type @@ -27,9 +27,9 @@ module GHC.Data.Bag ( import GHC.Prelude +import GHC.Exts ( IsList(..) ) import GHC.Utils.Outputable import GHC.Utils.Misc - import GHC.Utils.Monad import Control.Monad import Data.Data @@ -333,3 +333,8 @@ instance Traversable Bag where traverse f (UnitBag x) = UnitBag <$> f x traverse f (TwoBags b1 b2) = TwoBags <$> traverse f b1 <*> traverse f b2 traverse f (ListBag xs) = ListBag <$> traverse f xs + +instance IsList (Bag a) where + type Item (Bag a) = a + fromList = listToBag + toList = bagToList |