Monads Schmonads: Functional Input without tears (PYFL) | Bill Wadge's Blog

submited by
Style Pass
2021-05-22 17:30:02

As I already explained, I’ve invented and implemented a simple functional language (PYFL) with a few interesting twists. Including a promising but simple approach to input.

The basic language itself is pretty standard, except that it uses infix operators and conventional mathematical notation for function calling; e.g. f(h,a+2*y). It also has a wide range of variable binding operators; as in the following program

valof    subsets(s,i) =  // the set of all i-element subsets of set s                            if i==0 then {{}}                               i==1 then collectfor x in s all {% x %} end                              else                                    unionfor x in s all                                      valof                                        sminusx = s – {% x %};           //  {% x %} is singleton x                                       withoutx = subsets(sminusx,i);  // subsets without x                                       withx = collectfor u in subsets(sminusx,i-1) all //those  with x                                                      {% x %} ++ u                                                 end;                                      result = withx ++ withoutx;    // disjoint union                                     end                                    end                            fi;     result = subsets({tom dick harry chris pat},3);  end

Haskell uses the seriously complex machinery of monads to do I/O, supposedly without side effects (I don’t accept this). And you end up writing stuff like

Leave a Comment