Re:Automated reasoning in F#, Scala, Haskell, C++, and Julia
by stuhood on Monday August 03, 2015 @03:36PM
(#9999189)
In scala, the body of a match expression is a PartialFunction, and PartialFunctions compose similarly.
Re:Automated reasoning in F#, Scala, Haskell, C++, and Julia
by junkyarddog on Monday August 03, 2015 @11:17PM
(#10001451)
Have to agree that Active Patterns are an incredibly useful F# feature.
In the author's example, he matches on a few rules. A zero rule, an identity rule, an evaluation rule, and the default like so:
Active Patterns let you define these patterns as reusable blocks like so: It has the effect of making your pattern matching code more readable with a syntax that somewhat resembles a Prolog horn clause. As a bonus, you can mix and match these patterns when doing advanced reasoning.