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> ".")*

<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.