[Haskell-cafe] an idea for modifiyng data/newtype syntax: use `::=` instead of `=`

MigMit miguelimo38 at yandex.ru
Sat Aug 8 21:14:40 UTC 2015


> On 08 Aug 2015, at 23:11, Tom Ellis <tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk> wrote:
> 
> On Sat, Aug 08, 2015 at 11:02:27PM +0200, MigMit wrote:
>> What you say is "if we don't use some perfectly legitimate language
>> constructs and never use third-party code, than 'data' and 'newtype' are
>> the same".
> 
> No, not at all.  I'm making a much stronger claim than that.  I'm claiming
> the functionality provided by newtype is completely subsumed by that
> provided by data.

Well, it's certainly unsupported by evidence. Because third-party code CAN distinguish between those.

>>> On Sat, Aug 08, 2015 at 10:43:39PM +0200, MigMit wrote:
>>>> Prelude> newtype A = A Int deriving Show
>>>> Prelude> data B = B !Int deriving Show
>>>> Prelude> let x = case x of A n -> A 1 in x
>>>> A 1
>>>> Prelude> let y = case y of B n -> B 1 in y
>>>> *** Exception: <<loop>>
>>> 
>>> Sure, they're not exactly the same thing but if you get the translations
>>> right you can use them for the same purposes:
>>> 
>>>   Prelude> let y = case y of b -> B 1 in y
>>>   B 1
>>> 
>>> I list the translations here
>>> 
>>>   http://stackoverflow.com/questions/21327740/strict-single-constructor-single-field-data-declaration-vs-newtype/21331284#21331284
> _______________________________________________
> Haskell-Cafe mailing list
> Haskell-Cafe at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe



More information about the Haskell-Cafe mailing list