Re: Design Patterns and Functional programming



S Perryman wrote:
No problem, on the understanding that "lots of useful opportunities" is
not equivalent to 'all usage scenarios' (although a type system could give
warnings etc for such scenarios as opposed to reporting nothing) .

Yes. Same for a pattern matcher:

# function 0 -> 1 | n -> 3 | 3 -> 4;;
Warning U: this match case is unused.
- : int -> int = <fun>

# function 0 -> 1;;
Warning P: this pattern-matching is not exhaustive.
Here is an example of a value that is not matched:
1
- : int -> int = <fun>

The art is in working out how powerful you can make your patterns and type
system without sacrificing such tests. ML chooses linear patterns over
closed sum types, which works very well in practice.

--
Dr Jon D Harrop, Flying Frog Consultancy
The OCaml Journal
http://www.ffconsultancy.com/products/ocaml_journal/?usenet
.



Relevant Pages

  • Re: Creating framework for singleton pattern?
    ... was presented to base an article warning off of. ... > harmful (and you don't seem opposed to that notion, and if Singletons can ... > misused by allowing the creation of global variables in an OO context, ... patterns beyond the OO purists point of view. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Gedankenexperiment on method duck type safety
    ... I like your warning in the readme: http://people.freebsd.org/~eivind/ruby/types/README ... considering though if a less verbose approach would be more rubyish ... usual type system, but just how to make method declarations more ... haven't really needed it yet, too much, but there are just some odd, ...
    (comp.lang.ruby)
  • Re: 10.2 iso download
    ... selections to patterns, openSUSEdvd might not work as expected. ... adviced to first test on a re-writabel DVD or CD first." ... The warning ...
    (alt.os.linux.suse)
  • Re: 10.2 iso download
    ... selections to patterns, openSUSEdvd might not work as expected. ... adviced to first test on a re-writabel DVD or CD first." ... Maybe you should modify the warning to tell people to make sure that they use the latest version ...
    (alt.os.linux.suse)