parseWS xs -> all \Space xs
parseNumber [@xs] -> if (all digit? xs) then asBase 10 xs
parseSymbol [@xs] -> if (all alpha? xs) then asSymbol xs
parseRest x -> x.{[] => 'nil; [@!WS] => 'nil
[\Space @!WS e:!Sexp es:!Rest] => if es=='nil [e] [e@es]}
parseList xs -> parseRest [\Space @xs]
parseSexp x -> x.{[e:!Number]=>e; [e:!Symbol]=>e
[\( @!WS es:!List \)] => e}
Name:
Anonymous2010-12-29 3:12
when used in pattern matching like x::xs
If Haskell had real pattern matching, it would be possible to match things like
parseEnglish [v:!verb o:@Object as:@Adverbs] -> [[v as] o]
but no, Haskell forces you to monkey code everything, just like C/C++.