view interps/rhotor/Node.hs @ 10776:b474172c9892

<b_jonas> slashlearn ance//Spelling of -ance/-ence words: advance, science, conference, experience, finance, insurance, licence, performance, reference, assistance, balance, defence, difference, distance, evidence, acceptance, appliance, audience, compliance, importance, influence, instance, intelligence, maintenance, preference, presence, sentence, sequence, substance, violence, absence, accordance, alliance, appearance, assurance, attendance, circumstance, clea
author HackBot
date Fri, 21 Apr 2017 18:06:38 +0000
parents 859f9b4339e6
children
line wrap: on
line source

module Node (
	Node(Function,Application,Cons,Symbol,Nil,Break)
)
where

import Uniqs

data Node	= 	Function Node Node Node	| 
				Application Node Node	|
				Cons Node Node			|
				Break Node				|
				Symbol Uniqs			|
				Nil


instance Eq Node where
	(==) Nil Nil									= True
	(==) (Cons a1 d1) (Cons a2 d2)					= (a1 == a2) && (d1 == d2)
	(==) (Application a1 d1) (Application a2 d2)	= (a1 == a2) && (d1 == d2)
	(==) (Function a1 d1 c1) (Function a2 d2 c2)	= (a1 == a2) && (d1 == d2) && (c1 == c2)
	(==) (Symbol a) (Symbol b)						= a == b
	(==) a b										= False
	(/=) a b = not (a == b)

instance Show Node where
	show Nil				= "Nil"
	show (Cons a b)			= "(Cons " ++ (show a) ++ " " ++  (show b) ++ ")"
	show (Application a b)	= "(Application " ++ (show a) ++ " " ++  (show b) ++ ")"
	show (Function a b c)	= "(Function " ++ (show a) ++ " " ++  (show b) ++ " " ++  (show c) ++ ")"
	show (Break a)			= "**" ++ (show a)
	show (Symbol a)			= "#" ++ (show a)