Peter,
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.
/jve
On Fri, Jan 16, 2009 at 11:14 AM, Pete
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 <
lemm...@henning-thielemann.de>
On Fri, 16 Jan 2009, John Van Enk wrote:
2009/1/16 Peter Verswyvelen
[...]
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# yo
2009/1/16 Peter Verswyvelen
> [...]
>
> 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
Hi Luke,
On Fri, Jan 16, 2009 at 2:31 AM, Luke Palmer wrote:
> However, I think it is flawed, since the following
>>
>> case c of
>> Polar _ _ -> "it's polar!"
>> Rect _ _ -> "it's rect!"
>>
>> seems like valid code but does not make any sense.
>>
>
> I think it's okay, given that we u
2009/1/15 Peter Verswyvelen
> When I first read about active patterns in F#, I found it really cool idea,
> since it allows creating fake data constructors that can be used for pattern
> matching, giving many views to a single piece of data, and allowing
> backwards compatibility when you complet
If you don't mind using GHC extensions (which in a view pattern thread
probably isn't much of a stretch to assume :) ), there's always record
punning (-XNamedFieldPuns):
data Foo = { [snip] }
f (Foo { a, g }) = ...
2009/1/15 John Van Enk :
> I've often thought having constructor "views" w
I've often thought having constructor "views" would be handy.
data Foo = Foo A B C D E F G H I
view Bar = (Foo A _ C _ _ _ G _ I) => Bar A C G I
This does bring up problems with case alternatives though.
I think the correct answer for these kinds of views is with the record
pattern matching synt