Misleading strictness annotations in Data.List.NonEmpty

Keith keith.wygant at gmail.com
Fri Jan 8 18:36:58 UTC 2021


Thanks, will do.

On January 8, 2021 5:07:25 PM UTC, David Feuer <david.feuer at gmail.com> wrote:
>The first one. Neither twiddles nor bangs are useful or add clarity.
>
>On Fri, Jan 8, 2021, 11:53 AM Keith <keith.wygant at gmail.com> wrote:
>
>> Currently:
>>
>> head ~(a :| _) = a
>> tail ~(_ :| as) = as
>>
>> But head and tail are both strict. At best the '~'s have no effect.
>>
>> Should I open a PR to change it to
>>
>> head (a :| _) = a
>> tail (_ :| as) = as
>>
>> or maybe even more clearly
>>
>> head !(a :l _) = a
>> tail !(_ :| as) = as
>>
>> ?
>> --Keith
>> Sent from my phone with K-9 Mail. 


Good to know! Wasn't aware that that was in the works.

And sorry for accidentally threading this onto something unrelated.

-- Keith
Sent from my phone with K-9 Mail.

On January 8, 2021 5:13:31 PM UTC, Henning Thielemann <lemming at henning-thielemann.de> wrote:
>
>On Fri, 8 Jan 2021, Keith wrote:
>
>> Currently:
>> 
>> head ~(a :| _) = a
>> tail ~(_ :| as) = as
>> 
>> But head and tail are both strict. At best the '~'s have no effect.
>> 
>> Should I open a PR to change it to
>> 
>> head (a :| _) = a
>> tail (_ :| as) = as
>> 
>> or maybe even more clearly
>> 
>> head !(a :l _) = a
>> tail !(_ :| as) = as
>> 
>> ?
>
>The last one would trigger the "redundant bang pattern" warning that is 
>going to be implemented/released:
>    https://gitlab.haskell.org/ghc/ghc/issues/17340


More information about the Libraries mailing list