GHC has a feature, overloaded string literals, which lets you make
autoconversions from string literals to whatever types you want. You
can enable it with {-# LANGUAGE
OverloadedStrings #-}
, and it works for any type that is an
instance of the type class, IsString
. This
sounds like just the kind of wholesome, serious feature, for serious,
professional programmers to make their lives easier with. We
would never misuse this feature for evil, would we. Never.
Here's the factorial function, of type Double -> Double
:
"[dup [dup tor * swap 1 - 3 pick ap] [drop] ifte] 1 rot 3 pick ap"
More details here.
> "two billion one" - "negative fifty-nine thousand" 2000059001
You can write integers in word form. How useful!
This serves as an elementary example of using Parsec.