[Haskell-cafe] F# active patterns versus GHC's view

John Van Enk vanenkj at gmail.com
Fri Jan 16 11:16:10 EST 2009

I think that's correct. I would really love to be able to make alternate
constructors and views. I know we can make "specialized" constructors, but I
don't think there's a good way to pattern match on these. It would be pretty
sweet if we could.


On Fri, Jan 16, 2009 at 11:14 AM, Peter Verswyvelen <bugfact at gmail.com>wrote:

> As far as I understand, record syntax and data accessor only give access to
> the data, they don't provide alternate views / interpretations of the data,
> something that Active Patterns or view patterns in Haskell do?
> On Fri, Jan 16, 2009 at 4:27 PM, Henning Thielemann <
> lemming at henning-thielemann.de> wrote:
>> On Fri, 16 Jan 2009, John Van Enk wrote:
>>  2009/1/16 Peter Verswyvelen <bugfact at gmail.com>
>>>  [...]
>>>> After a while you decide that you need to change the Bla data type,
>>>> maybe
>>>> give Dog more fields, maybe completely redesign it, maybe not exposing
>>>> it,
>>>> but you want to keep existing code backwards compatible. With F# you can
>>>> write Active Patterns for the old Dog and Cat constructors, so all
>>>> existing
>>>> code remains compatible. At least that is the way I understand it, but I
>>>> have not actually worked yet with Active Patterns, will do so soon :)
>>>>  You get something similar with the record syntax (though, probably
>>> still not
>>> quite as powerful as the active patterns):
>> ... or use data-accessor package.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.haskell.org/pipermail/haskell-cafe/attachments/20090116/bd907161/attachment.htm

More information about the Haskell-Cafe mailing list