[Haskell-cafe] Re: [Haskell] View patterns in GHC: Request for feedback

Stefan O'Rear stefanor at cox.net
Fri Jul 27 11:05:39 EDT 2007


On Fri, Jul 27, 2007 at 05:22:37AM -0400, Dan Licata wrote:
> On Jul26, Stefan O'Rear wrote:
> > > So, this syntax affects a lot of code, existing or otherwise, that
> > > doesn't use view patterns, which is something we're trying to avoid.
> > 
> > Eh?  I *think* the typing rules are the same for the no-view case.  If
> > the auto-deriving hack isn't implemented, you only need a
> > deriving(View), otherwise there should be no change at all...
> 
> Assuming you don't have the functional dependency: "affects" in the
> sense that any code you write has a generalized type, so you have to
> explain view patterns to beginners right out of the gate, etc.  If you
> write 
> 
> length [] = []
> length (h : t) = 1 + length t
> 
> we don't want to have to explain to beginners why it has type
> 
> length :: forall a,b,c. View a [b] -> a -> Num c

Right, which is why I think the functional dependency is good.  If we
have it, and the auto-deriving hack, what breaks?

length [] = []
length (h : t) = 1 + length t

length :: forall a b c. (View a [b], Num c) => a -> c

==> (one of the FD rules)

length :: forall a b c. (View [a] [b], Num c) => [a] -> c

==> (plain context reduction, the first constraint is tautological)

length :: forall a c. Num c => [a] -> c

Stefan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://www.haskell.org/pipermail/haskell-cafe/attachments/20070727/ceeee438/attachment.bin


More information about the Haskell-Cafe mailing list