data TF = T | F | If (TF,TF,TF) parse::[String]->(TF,[String]) parse("true":xs) =(T,xs) parse("false":xs)=(F,xs) parse("if":xs)=(If (a,b,c),cs) where (a,as)=parse xs (b,bs)=parse as (c,cs)=parse bs parse(_:xs)=parse xs exec::[String]->TF exec=fst.parse instance Show TF where show T="true" show F="false" show(If (a,b,c))= case(show a)of "true"->show b _->show c main=do c<-getContents;mapM_ putStrLn$(lines c)>>=(return.show.exec.words)
Note that non-ascii characters in the above source code will be escaped (such as \x9f).