Next Functional Programming in Perl 21

Syntactic Difficulties

           char list -> 'a * char list
        fun digit (in1::ins) =
          if in1 = '0' then (0, ins) else
          if in1 = '1' then (1, ins) else
          ...
          if in1 = '9' then (9, ins) else
          raise "Parse error..."
        fun nothing input = ((), input);
        fun concat p1 p2 input =
          let val (v1, i1) = p1 input in
          let val (v2, i2) = p2 i1    in
            ((v1, v2), i2)
          end end
        fun star p1 input =
          alternates(concat(p1, star p1), nothing);

Next Copyright 2005 M. J. Dominus