Hi,

You're pretty close, actually.  In general, remember the following:

'type' introduces a type synonym, which means that you're just renaming an
existing type, not creating a new one.  this means that you don't need
constructors.

'data' means that you're defining a new type; in order to do this, you
need to specify constructors.

for instance:

> type Position = Int

here, we've just given Int a new name, Position.

> data Bool = True | False

here we've defined a new type (Bool) with two constructors, True and
False.

or, if the constructors take arguments:

> data PairOfInts = PairOfInts Int Int

here, the type is called PairOfInts and the constructor is called
PairOfInts; the constructor takes two ints as arguments.

HTH,

 - Hal

--
 Hal Daume III                                   | [EMAIL PROTECTED]
 "Arrest this man, he talks in maths."           | www.isi.edu/~hdaume

On Mon, 3 Nov 2003, Patty Fong wrote:

> 
> Hello, I'm fairly new to haskell and functional programming and i'm still
> trying to get my head around certain concepts.
> 
> I'm wondering if anyone can help me convert this abstract syntax into
> Haskel data and type declarations:
> 
> <prolog> ::= (<assertion> ".")*<?xml:namespace prefix = o ns =
> "urn:schemas-microsoft-com:office:office" />
> 
> <assertion> :: = <structure> | <rule>
> 
> <rule> ::= <structure> ":-" <structure>("," <structure>)*
> 
> <structure> ::= <name> [�(� <term> (�,� <term>)* �)�]
> 
> <term> ::= <number> | <variable> | <structure>
> 
> <variable> ::= <name>
> 
>  
> 
> <name> is simply a String and <number> an Int
> 
>  
> 
> This was my attempt feeble attempt but i ran into numerous errors... :
> 
>  
> 
> type Prolog = Assertion
> 
> data Assertion = Structure | Rule
> 
> type Rule = Structure Structure (Structure)
> 
> type Structure = Name [ Term (Term)]
> 
> data Term = Number | Variable | Structure
> 
> type Variable = String
> 
> type Name = String
> 
> type Number = Int
> 
>  
> 
> Any help would be appreciated
> 
> TIA
> 
> Patrick.
> 
> 
> ________________________________________________________________________________
> Hot chart ringtones and polyphonics. Click here.
> 

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

Reply via email to