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

2009-01-16 Thread John Van Enk
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

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

2009-01-16 Thread Peter Verswyvelen
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>

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

2009-01-16 Thread Henning Thielemann
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

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

2009-01-16 Thread John Van Enk
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

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

2009-01-16 Thread Peter Verswyvelen
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

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

2009-01-15 Thread Luke Palmer
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

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

2009-01-15 Thread andy morris
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

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

2009-01-15 Thread John Van Enk
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