Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Haskell Qualified Imports (Creating an Empty Set)

Tags:

haskell

set

I am attempting to pass back a Node type from this function, but I get the error that empty is out of scope:

import Data.Set (Set)  
import qualified Data.Set as Set

data Node = Vertex String (Set Node)  
    deriving Show

toNode :: String -> Node  
toNode x = Vertex x empty

What am I doing wrong?

like image 801
Mantas Vidutis Avatar asked Oct 27 '25 15:10

Mantas Vidutis


1 Answers

import qualified Data.Set as Set means that when you want to use something from Data.Set, you have to qualify it with Set.. So to use empty write Set.empty.

like image 163
sepp2k Avatar answered Oct 29 '25 05:10

sepp2k