Mercurial > repo
comparison interps/rhotor/Node.hs @ 996:859f9b4339e6
<Gregor> tar xf egobot.tar.xz
author | HackBot |
---|---|
date | Sun, 09 Dec 2012 19:30:08 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
995:6883f5911eb7 | 996:859f9b4339e6 |
---|---|
1 module Node ( | |
2 Node(Function,Application,Cons,Symbol,Nil,Break) | |
3 ) | |
4 where | |
5 | |
6 import Uniqs | |
7 | |
8 data Node = Function Node Node Node | | |
9 Application Node Node | | |
10 Cons Node Node | | |
11 Break Node | | |
12 Symbol Uniqs | | |
13 Nil | |
14 | |
15 | |
16 instance Eq Node where | |
17 (==) Nil Nil = True | |
18 (==) (Cons a1 d1) (Cons a2 d2) = (a1 == a2) && (d1 == d2) | |
19 (==) (Application a1 d1) (Application a2 d2) = (a1 == a2) && (d1 == d2) | |
20 (==) (Function a1 d1 c1) (Function a2 d2 c2) = (a1 == a2) && (d1 == d2) && (c1 == c2) | |
21 (==) (Symbol a) (Symbol b) = a == b | |
22 (==) a b = False | |
23 (/=) a b = not (a == b) | |
24 | |
25 instance Show Node where | |
26 show Nil = "Nil" | |
27 show (Cons a b) = "(Cons " ++ (show a) ++ " " ++ (show b) ++ ")" | |
28 show (Application a b) = "(Application " ++ (show a) ++ " " ++ (show b) ++ ")" | |
29 show (Function a b c) = "(Function " ++ (show a) ++ " " ++ (show b) ++ " " ++ (show c) ++ ")" | |
30 show (Break a) = "**" ++ (show a) | |
31 show (Symbol a) = "#" ++ (show a) |