Send Beginners mailing list submissions to
        [email protected]

To subscribe or unsubscribe via the World Wide Web, visit
        http://www.haskell.org/mailman/listinfo/beginners
or, via email, send a message with subject or body 'help' to
        [email protected]

You can reach the person managing the list at
        [email protected]

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Beginners digest..."


Today's Topics:

   1. Re:  How to access non-exported function from     Data.Set?
      (Christoph Bussler)
   2. Re:  How to access non-exported function from     Data.Set?
      (aditya siram)


----------------------------------------------------------------------

Message: 1
Date: Wed, 1 Jun 2011 18:06:38 -0700
From: "Christoph Bussler" <[email protected]>
Subject: Re: [Haskell-beginners] How to access non-exported function
        from    Data.Set?
To: <[email protected]>
Message-ID: <18E6CC35A1624C88881BFDCD8C3FCB04@REDPOWER>
Content-Type: text/plain; charset="us-ascii"

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
[email protected]
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:[email protected]] 
Sent: Wednesday, June 01, 2011 3:25 PM
To: Christoph Bussler
Cc: [email protected]
Subject: Re: [Haskell-beginners] How to access non-exported function from
Data.Set?

 

Hi Christoph,

On 1 June 2011 21:56, Christoph Bussler <[email protected]> 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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: 
<http://www.haskell.org/pipermail/beginners/attachments/20110601/f9c8b44e/attachment-0001.htm>

------------------------------

Message: 2
Date: Wed, 1 Jun 2011 20:18:23 -0500
From: aditya siram <[email protected]>
Subject: Re: [Haskell-beginners] How to access non-exported function
        from    Data.Set?
To: Christoph Bussler <[email protected]>
Cc: [email protected]
Message-ID: <[email protected]>
Content-Type: text/plain; charset=windows-1252

I've run into this with other modules although I can't think of any
specific examples off the top of my head.

I think if would be a great language feature if modules had three
levels of exported functions and datatypes,
1. normally API functions that are available using the usual "import
Some.Module"
2. functions that must be imported specifically because they are not
recommended for general use by maybe useful like the OP's example.
This functionality could just piggyback on the existing explicit
import syntax, eg. "import Some.Module (someSemiPrivateFunction).
3. Functions or datatypes that are not exported at all.


-deech

On Wed, Jun 1, 2011 at 8:06 PM, Christoph Bussler <[email protected]> wrote:
> 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
> [email protected]
> 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:[email protected]]
> Sent: Wednesday, June 01, 2011 3:25 PM
> To: Christoph Bussler
> Cc: [email protected]
> Subject: Re: [Haskell-beginners] How to access non-exported function from
> Data.Set?
>
>
>
> Hi Christoph,
>
> On 1 June 2011 21:56, Christoph Bussler <[email protected]> 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
>
> _______________________________________________
> Beginners mailing list
> [email protected]
> http://www.haskell.org/mailman/listinfo/beginners
>
>



------------------------------

_______________________________________________
Beginners mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/beginners


End of Beginners Digest, Vol 36, Issue 4
****************************************

Reply via email to