Hi,
 
Thanks; so I imported Data.Set and copied the function
 
splitLookup :: Ord a => a -> Set a -> (Set a,Maybe a,Set a)
splitLookup _ Tip = (Tip,Nothing,Tip)
splitLookup x (Bin _ y l r)
   = case compare x y of
       LT -> let (lt,found,gt) = splitLookup x l in (lt,found,join y gt r)
       GT -> let (lt,found,gt) = splitLookup x r in (join y l lt,found,gt)
       EQ -> (l,Just y,r)

 

When compiling it says:

 

src\Main.hs:70:15: Not in scope: data constructor `Tip'

src\Main.hs:70:22: Not in scope: data constructor `Tip'

src\Main.hs:70:34: Not in scope: data constructor `Tip'

src\Main.hs:71:16: Not in scope: data constructor `Bin'

src\Main.hs:73:63: Not in scope: `join'

src\Main.hs:74:54: Not in scope: `join'

 

And I think this makes sense as neither the data constructors, nor the function ‘join’ are exported. Is there any other way you could think of?


In terms of the maintainers of the containers or Data.Set, how do I find out who could make a decision to include splitLookup in the export list?

 

 

In terms of the use case, I’d like to find an element in a set. If the element is there, I’d like to get it back (not just the fact that it exists). If it is not in the set, I’d like to get the next higher and the next lower one (according to the sort order). This is almost exactly what splitLookup does, however, splitLookup gives me both the trees, whereas I only would need the elements of the set.


Thanks a lot!

Christoph

 

--------------------------------------------------------------------------
Christoph Bussler
ChBussler@aol.com
www.real-programmer.com
www.linkedin.com/in/chbussler
www.google.com/search?hl=en&q=Christoph+Bussler
www.google.com/search?hl=en&q=Christoph%20Bussler&btnI=I%27m+Feeling+Lucky
--------------------------------------------------------------------------


From: Ozgur Akgun [mailto:ozgurakgun@gmail.com]
Sent: Wednesday, June 01, 2011 3:25 PM
To: Christoph Bussler
Cc: beginners@haskell.org
Subject: Re: [Haskell-beginners] How to access non-exported function from Data.Set?

 

Hi Christoph,

On 1 June 2011 21:56, Christoph Bussler <chbussler@aol.com> wrote:

splitLookup :: Ord a => a -> Set a -> (Set a,Maybe a,Set a)

Not sure why it is not exported, but is there a way to use it?

 

I am afraid you'll have to define the exact same function yourself, if you really want to use it. As you probably already know, you can copy it from: http://hackage.haskell.org/packages/archive/containers/0.4.0.0/doc/html/src/Data-Set.html#splitLookup

 

I am not sure as to why it was not exported though. If you describe your use case, maybe you can convince people to make a change, or people can suggest you some other function which fulfils your requirements in some other way.

HTH,

Ozgur