Re: [Haskell-cafe] newbie problems

2004-07-05 Thread Mark Carroll
On Sat, 3 Jul 2004, paolo veronelli wrote:

> I'd like to have a simple definition of the meanings of 'type' and 'data'
> and maybe a clarifing example on their use.
(snip)

The way I see it, you use "type" for genuine synonyms where you don't care
about the distinction, "newtype" where you want to make a separate type
with a single constructor, and "data" where you want to make a separate
type with multiple constructors. My memory might be failing, though.

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


Re: [Haskell-cafe] newbie problems

2004-07-03 Thread paolo veronelli
On Sat, 3 Jul 2004 17:57:04 +0100 (BST), MR K P SCHUPKE 
<[EMAIL PROTECTED]> wrote:

The zipper should work on n-ary trees. all the zipper does is
store the tree as (Context,Subtree)
What is the meaning of storing in haskell?
Imagine I put numbers in the leaves...
you could do something like
data Context x = Root | Parent x (Context x) [Rose x] [Rose x]
data Rose x = Node x [Rose x]
Should the numbers be of type x ,right?? So x is Int.
   -5
   |
 -2-6
 |
1-3
 |
 -4
context of 1 is Root.Where do I store the 1?I Subtree?The name is 
misleading me...
context of 2 is Parent 1 Root .and then

To make it easy I don't mind siblings I just want sons

so at any given point in the tree the context is either Root,
or the Parent (with the value at that node, the parents context,
What do you mean with the parents context?Is it the substitution for the 
pointer?
Which is the tracker function?

tracker (context,???)
| (Root,???) = []  should be the node 1 where can I get it?
| (Parent p (Contetx c),???) = tracker (c,?!?):
I feel terrible    Paolino




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


Re: [Haskell-cafe] newbie problems

2004-07-03 Thread MR K P SCHUPKE
The zipper should work on n-ary trees. all the zipper does is
store the tree as (Context,Subtree) so you just need to
adapt that to a Rose-Tree. you could do something like
(and I am thinking out loud here as I havent written zipper code
for rose trees)...

data Context x = Root | Parent x (Context x) [Rose x] [Rose x]
data Rose x = Node x [Rose x]

so at any given point in the tree the context is either Root,
or the Parent (with the value at that node, the parents context, then 
the left siblings and right siblings as lists)


As to the difference between types and values, a type limits
the permitted values. For example

a :: [Int]

a is a list of integers. now

data IntList = Value Int | List [Int]

IntList can be a single int or a list of ints... 

data IntList = Value Int | List [IntList]

Now intlist can be a value or a list of IntLists... we are dealing
with the type of permitted data not the data itself. when we
define a value for example:

a :: IntList
a = Value 3

This must obey the construction rules given in the data type "IntList"
So you see when a data declaration refers to itself it is not a 
"pointer" but an inclusion of the type for example:

a :: IntList
a = List [Value 3,List [Value 2,Value 1],Value 4]

is a valid instance of IntList, but notice that although the 'type'
refers to itself the value is not self-referential. Thats not to
say self referential values are not possible - but lets avoid confusing
the issue with such things.

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


[Haskell-cafe] newbie problems

2004-07-03 Thread paolo veronelli
I'd like to have a simple definition of the meanings of 'type' and 'data' 
and maybe a clarifing example on their use.

I've read the Zipper doc on he wiki ,but I can't make it work on n-ary 
trees,and most of all they are not any clear the performance hits on using 
more complex 'data'

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