The OverloadedLists language pragma in GHC 7.8 is quite attractive, so I decided to try it:
{-# LANGUAGE OverloadedLists #-}
import Data.Set (Set)
import qualified Data.Set as Set
mySet :: Set Int
mySet = [1,2,3]
And the compiler gives me:
No instance for (GHC.Exts.IsList (Set Int))
arising from an overloaded list
In the expression: [1, 2, 3]
In an equation for ‘mySet’: mySet = [1, 2, 3]
No instance for (Num (GHC.Exts.Item (Set Int)))
arising from the literal ‘1’
In the expression: 1
In the expression: [1, 2, 3]
In an equation for ‘mySet’: mySet = [1, 2, 3]
Failed, modules loaded: none.
Even the example from the release notes doesn't work:
> ['0' .. '9'] :: Set Char
<interactive>:5:1:
Couldn't match type ‘GHC.Exts.Item (Set Char)’ with ‘Char’
Expected type: [Char] -> Set Char
Actual type: [GHC.Exts.Item (Set Char)] -> Set Char
In the expression: ['0' .. '9'] :: Set Char
In an equation for ‘it’: it = ['0' .. '9'] :: Set Char
Does anyone know what's going on here?
No instance for (GHC.Exts.IsList (Set Int))
.Data.Set
doesn't define an instance forIsList
. You can write the instance yourself quite easily, here is the class: hackage.haskell.org/package/base-4.7.0.0/docs/… – Drews