Re: Design Patterns and Functional programming
- From: Jon Harrop <jon@xxxxxxxxxxxxxxxxx>
- Date: Mon, 16 Jul 2007 19:39:12 +0100
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
.
- References:
- Design Patterns and Functional programming
- From: Jon Harrop
- Re: Design Patterns and Functional programming
- From: Dmitry A. Kazakov
- Re: Design Patterns and Functional programming
- From: Jon Harrop
- Re: Design Patterns and Functional programming
- From: Dmitry A. Kazakov
- Re: Design Patterns and Functional programming
- From: Jon Harrop
- Re: Design Patterns and Functional programming
- From: Dmitry A. Kazakov
- Re: Design Patterns and Functional programming
- From: Jon Harrop
- Re: Design Patterns and Functional programming
- From: Dmitry A. Kazakov
- Re: Design Patterns and Functional programming
- From: Jon Harrop
- Re: Design Patterns and Functional programming
- From: Dmitry A. Kazakov
- Re: Design Patterns and Functional programming
- From: Jon Harrop
- Re: Design Patterns and Functional programming
- From: Dmitry A. Kazakov
- Re: Design Patterns and Functional programming
- From: Jon Harrop
- Re: Design Patterns and Functional programming
- From: Dmitry A. Kazakov
- Re: Design Patterns and Functional programming
- From: Dmitry A. Kazakov
- Re: Design Patterns and Functional programming
- From: Jon Harrop
- Re: Design Patterns and Functional programming
- From: Dmitry A. Kazakov
- Re: Design Patterns and Functional programming
- From: Jon Harrop
- Re: Design Patterns and Functional programming
- From: S Perryman
- Design Patterns and Functional programming
- Prev by Date: Re: Design Patterns and Functional programming
- Next by Date: Re: Design Patterns and Functional programming
- Previous by thread: Re: Design Patterns and Functional programming
- Next by thread: Re: Design Patterns and Functional programming
- Index(es):
Relevant Pages
|