Steven D'Aprano <ste...@remove.this.cybersource.com.au> writes: > How would Haskell coders write it? Something like this? > > def get_popular_name(url): > data = fetch url > names = parse data > name = choose name 1 > return name
The syntax and types would be different, but ok, something like that. > name = get_popular_name 'http://guessmyname.com' # call the function > f = decorate get_popular_name # treat the function as a 1st class object You wouldn't need "decorate". You'd just say f = get_popular_name "http://guessmyname.com" f is now an "I/O action" which when executed queries the guessmyname site. > but now how do I call the new function? > Is this where you say "Monads" and everyone's eyes glaze over? You'd say something like most_popular_name <- f to invoke the action. Yes, explaining the difference between "<-" and "=" involves monads. You might like the Haskell tutorial http://learnyouahaskell.com . -- http://mail.python.org/mailman/listinfo/python-list