Re: Another query (-:

2001-08-01 Thread Mark Carroll

On Wed, 1 Aug 2001, Yao Guo wrote:
(snip)
> What "add list" does is adding a True to the end of the list,
> however, "grow list" will ignore the first element of the result,
> change it to False
(snip)

That makes a lot of sense. Thank you very much! I think I understand it
now. (-:

-- Mark


___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: Another query (-:

2001-08-01 Thread Yao Guo

- Original Message -
From: "Mark Carroll" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, August 01, 2001 5:03 PM
Subject: Another query (-:


> I've made a bizarre little program that I don't understand the behaviour
of.
> It's:
>
>
> data BoolList = End | Node Bool BoolList
>
> instance Show BoolList where
> show (Node False rest) = "F " ++ show rest
> show (Node True rest) = "T " ++ show rest
> show End = "<>"
>
> grow list = (Node False rest)
> where
> (Node _ rest) = add list
> add End = (Node True End)
> add (Node truth rest) = (Node truth (add rest))
>
What "add list" does is adding a True to the end of the list,
however, "grow list" will ignore the first element of the result,
change it to False

Main> Node True (Node False ( Node False (Node True End)))
T F F T <>
Main> grow(Node True (Node False ( Node False (Node True End
F F F T T <>

in the example above, "add list" will return T F F T T <>, and then,
"grow list" changes the first element to F.

Hope this helps,
Yao


___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Another query (-:

2001-08-01 Thread Mark Carroll

I've made a bizarre little program that I don't understand the behaviour of. 
It's:


data BoolList = End | Node Bool BoolList

instance Show BoolList where
show (Node False rest) = "F " ++ show rest
show (Node True rest) = "T " ++ show rest
show End = "<>"

grow list = (Node False rest)
where 
(Node _ rest) = add list
add End = (Node True End)
add (Node truth rest) = (Node truth (add rest))


The show is fine; it's the add that's confusing me. Where we have,

grow list = (Node False rest)
where
(Node _ rest) = add list

I don't really understand what's going on with this binding and matching
using "where", so I'm not seeing how the True and False values are
managing to propagate up to being results of grow as they do, e.g.:

> grow End
F <>
> grow (grow End)
F T <>

I have Hudak, Peterson, Fasel's gentle introduction to Haskell 98, and
Thompson's "Craft of Functional Programming" book - maybe I just missed
something in them? Is it easy to explain what's going on with this "where"
behaviour so that I could figure out what "grow"'s results are without
evaluating examples?

-- Mark


___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: Novice Haskell query

2001-08-01 Thread Mark Carroll

Thanks to everyone who responded. (-:

On Tue, 31 Jul 2001, Ashley Yakeley wrote:
(snip)
> Clearly the type 'Tree a' is only Show if 'a' is. It's irrelevant that 
> the 'Leaf' part of the definition doesn't need 'a' to be Show: the 
> 'Branch' part does, so the type has to be restricted to 'Show a => Tree 
> a' if it is going to be Show.
(snip)

Ah, right. Yes, I guess partly I was indeed confused because the 'Leaf'
part of the definition doesn't need 'a' to be Show - I'd been hoping to be
able to define that bit without the "Show a =>" requirement. I see now
that this reminds me of a previous thing I'd asked where, say, I define:

test [a,b] = a>b
test _ = False

...and am then surprised at it complaining when I ask the value of test []

I guess the lesson is that I can't just look at a definition and see that
it should be easy for Haskell to evaluate something; it still insists on
having enough type information for bits of code that aren't being used,
and no doubt I'll get used to it in time and figure out when this extra
type information is needed. (-: Thanks!

-- Mark


___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: newbie conceptual question [from haskell list]

2001-08-01 Thread Steinitz, Dominic J

Alex,

The code isn't ready to go public but you can try out a web interface at 
http://r341-02.king.ac.uk/cgi-bin/ldap.cgi. If you use the search filter 
objectClass=top you will get the whole tree on our test server. You shouldn't be able 
to add, modify or delete (let me know if you can!). The web code isn't very resilient. 
If you specifiy a non-existent attribute or use the wild card character (*), you will 
get an uninformative error message. Or you can try searching any public ldap server.

Dominic.




[EMAIL PROTECTED] on 01/08/2001 13:30:00
To: Dominic Steinitz
cc: hdaume
franka
haskell-cafe
bcc:
Subject:Re: newbie conceptual question [from haskell list]

Is the LDAP client available somewhere?

-Alex-

On 1 Aug 2001, Steinitz, Dominic J wrote:

> I don't know about functional dependencies but using an existential type
 turned out to be very useful in writing an LDAP protocol handler. The protocol
 is specified at an abstract level using ASN.1 and could, in theory, be encoded
 using any set of encoding rules. It happens to use the Basic Encoding Rules. We
 used an existential type to "encode" the protocol at an abstract level and the
 encoding rules take this type and produce a concrete representation ready to
 send over a transport mechanism. Thus we get a good separation between the
 abstract protocol and the concrete encoding. So the next time we implement a
 protocol handler we can re-use the encoding code or we could encode LDAP with a
 different set of encoding rules without having to touch the LDAP code itself.
>
> We are presenting a paper which includes this at the Scottish Functional
 Programming workshop.
>
> Dominic.
>
>
>
>
> [EMAIL PROTECTED] on 31/07/2001 22:29:00
> To:   franka
> cc:   haskell-cafe
> bcc:  Dominic Steinitz
> Subject:  Re: newbie conceptual question [from haskell list]
>
> Hi,
>
> Frank Atanassow wrote:
> > D. Tweed wrote:
> > > I've never written a Haskell program using functional dependencies, or
> > > existential classes, ...
> >
> > I find them indispensible, and I know for a fact that I am not the only one
> > around our office who feels that way. Though, the people around here
> > (Utrecht's software technology group) are not exactly typical programmers...
> > :)
>
> I've been recently experimenting quite a bit with existential classes
> and somewhat less with functional dependencies, primarily to help my
> understanding of the concepts.  However, I've yet to be able to think of
> an appropriate place to use them in the "real world".  That is, in
> something more than a toy thought-experiment.  Could you give some
> examples of what you are using them for?
>
> --
> Hal Daume III
>
>  "Computer science is no more about computers| [EMAIL PROTECTED]
>   than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume
>
> ___
> Haskell-Cafe mailing list
> [EMAIL PROTECTED]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
>
>
>
 ---
--
> 21st century air travel http://www.britishairways.com
>
> ___
> Haskell-Cafe mailing list
> [EMAIL PROTECTED]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>

___
S. Alexander Jacobson   Shop.Com
1-646-638-2300 voiceThe Easiest Way To Shop (sm)





-
21st century air travel http://www.britishairways.com

___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe



Re: newbie conceptual question [from haskell list]

2001-08-01 Thread S. Alexander Jacobson

Is the LDAP client available somewhere?

-Alex-

On 1 Aug 2001, Steinitz, Dominic J wrote:

> I don't know about functional dependencies but using an existential type turned out 
>to be very useful in writing an LDAP protocol handler. The protocol is specified at 
>an abstract level using ASN.1 and could, in theory, be encoded using any set of 
>encoding rules. It happens to use the Basic Encoding Rules. We used an existential 
>type to "encode" the protocol at an abstract level and the encoding rules take this 
>type and produce a concrete representation ready to send over a transport mechanism. 
>Thus we get a good separation between the abstract protocol and the concrete 
>encoding. So the next time we implement a protocol handler we can re-use the encoding 
>code or we could encode LDAP with a different set of encoding rules without having to 
>touch the LDAP code itself.
>
> We are presenting a paper which includes this at the Scottish Functional Programming 
>workshop.
>
> Dominic.
>
>
>
>
> [EMAIL PROTECTED] on 31/07/2001 22:29:00
> To:   franka
> cc:   haskell-cafe
> bcc:  Dominic Steinitz
> Subject:  Re: newbie conceptual question [from haskell list]
>
> Hi,
>
> Frank Atanassow wrote:
> > D. Tweed wrote:
> > > I've never written a Haskell program using functional dependencies, or
> > > existential classes, ...
> >
> > I find them indispensible, and I know for a fact that I am not the only one
> > around our office who feels that way. Though, the people around here
> > (Utrecht's software technology group) are not exactly typical programmers...
> > :)
>
> I've been recently experimenting quite a bit with existential classes
> and somewhat less with functional dependencies, primarily to help my
> understanding of the concepts.  However, I've yet to be able to think of
> an appropriate place to use them in the "real world".  That is, in
> something more than a toy thought-experiment.  Could you give some
> examples of what you are using them for?
>
> --
> Hal Daume III
>
>  "Computer science is no more about computers| [EMAIL PROTECTED]
>   than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume
>
> ___
> Haskell-Cafe mailing list
> [EMAIL PROTECTED]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>
>
>
>
> 
>-
> 21st century air travel http://www.britishairways.com
>
> ___
> Haskell-Cafe mailing list
> [EMAIL PROTECTED]
> http://www.haskell.org/mailman/listinfo/haskell-cafe
>

___
S. Alexander Jacobson   Shop.Com
1-646-638-2300 voiceThe Easiest Way To Shop (sm)


___
Haskell-Cafe mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/haskell-cafe