
Hello all, I'm trying to figure out how 'data' and 'type'. I haven't read any documentation because I can't find any. Could someone point me to a document explaining these? I'm happy to RTFM, I just need to know where the FM is :) Cheers, Daniel. -- /\/`) http://oooauthors.org /\/_/ http://opendocumentfellowship.org /\/_/ \/_/ I am not over-weight, I am under-tall. /

Daniel Carrera
I'm trying to figure out how 'data' and 'type'.
How data and type...what? :-) Generally, 'type' introduces type synonyms, i.e. just gives a new name to an existing type, while 'data' defines new (algebraic) types. So you can use type Name = String in order to make your program (and, if you're lucky, the compiler error messages) more legible, or you can use data Name = Nick String | Initials Char (Maybe Char) Char | Full String String to deal with names in various forms (pronounce the '|' as 'or') Note that the initial words on the right side in the data declaration (i.e. "Nick","Initials", and "Full") are type constructors, not types (like "Name" and "String" are). Did that help? (There's also 'newtype', btw, which lets you add a constructor to a type synonym.) -k -- If I haven't seen further, it is by standing in the footprints of giants

Ketil Malde wrote:
I'm trying to figure out how 'data' and 'type'.
How data and type...what? :-)
oops... "work" :)
Generally, 'type' introduces type synonyms, i.e. just gives a new name to an existing type, while 'data' defines new (algebraic) types.
So you can use
type Name = String
Ah. Thanks.
Did that help?
Yes, a lot. :) Cheers, Daniel. -- /\/`) http://oooauthors.org /\/_/ http://opendocumentfellowship.org /\/_/ \/_/ I am not over-weight, I am under-tall. /

Daniel Carrera wrote:
Hello all,
I'm trying to figure out how 'data' and 'type'. I haven't read any documentation because I can't find any. Could someone point me to a document explaining these? I'm happy to RTFM, I just need to know where the FM is :)
http://www.isi.edu/~hdaume/htut/tutorial.pdf 4.5 Data Types 47 8 Advanced Types 103 8.1 Type Synonyms

Christian Maeder wrote:
http://www.isi.edu/~hdaume/htut/tutorial.pdf
4.5 Data Types 47
8 Advanced Types 103 8.1 Type Synonyms
Thanks! Daniel. -- /\/`) http://oooauthors.org /\/_/ http://opendocumentfellowship.org /\/_/ \/_/ I am not over-weight, I am under-tall. /
participants (3)
-
Christian Maeder
-
Daniel Carrera
-
Ketil Malde