[Haskell-cafe] Eta Reduction

malcolm.wallace malcolm.wallace at me.com
Wed Apr 2 13:55:45 UTC 2014


In early Haskell (up until 1.2 I think), your "Seq" class existed, and was called "Eval".
Regards,
    Malcolm

On 02 Apr, 2014,at 01:52 PM, Edward Kmett <ekmett at gmail.com> wrote:

Consider something like 

data Foo a = Foo !Int !a

The data constructor Foo needs to be strict in its arguments, so it'd need Seq Int and Seq a. Seq Int would be resolved by the environment, but Seq a would need to come from somewhere.

data Seq a => Foo a = Foo !Int !a

gives you

Foo :: Seq a => Int -> a -> Foo a

so it is available when evaluating the constructor.

We're not storing the instance as a slot in the constructor, so this isn't.

data Foo a where
   Foo :: Seq a => Int -> a -> Foo a

or equivalently

data Foo a = Seq a => Foo !Int !a

This is where the data type contexts came from. They were originally motivated by the needs of the no-longer existent Seq class, and then subverted to make Complex less useful than it otherwise could be. ;)

-Edward



On Wed, Apr 2, 2014 at 3:08 AM, Tom Ellis <tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk> wrote:
On Tue, Apr 01, 2014 at 05:32:45PM -0400, Edward Kmett wrote:
> Unfortunately the old class based solution also carries other baggage,
> like the old data type contexts being needed in the language for bang
> patterns.  :(

Can you explain why that is so?  I don't understand.

Tom

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe at haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe

_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe at haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.haskell.org/pipermail/haskell-cafe/attachments/20140402/cc694aad/attachment.html>


More information about the Haskell-Cafe mailing list