WARNING pragmas in `Prelude.undefined` and `Prelude.error`

Vilem Liepelt vliepelt at futurefinance.com
Mon Dec 23 11:55:39 UTC 2019


I agree that `error`/`undefined` can be legitimate; however often this legitimacy rests on invariants that aren't necessary stable under change-types-and-fix-errors-until-things-type-check style refactoring! So after refactoring I'd like to switch on my `error`/`undefined` warnings temporarily.

> On 23 Dec 2019, at 13:36, Andreas Abel <andreas.abel at ifi.lmu.de> wrote:
> 
> I am missing some context of this discussion, but if this is the question of whether using `undefined` and `error` can be legitimate, yes they can.  If you know your invariants, you might want to write
> 
>  fromMaybe undefined $ lookup key map
> 
> or
> 
>  Map.findWithDefault undefined key map
> 
> knowing you put the key into the map and the lookup cannot fail.
> 
> On 2019-12-22 13:15, Zemyla wrote:
>> The most common legitimate usage for undefined I have is strictness:
>> func x y | x `seq` False = undefined
>> func x y = ...
>> There's nothing else that would go there, and when it's compiled, the reference to undefined disappears.
>> On Sun, Dec 22, 2019, 05:50 chessai . <chessai1996 at gmail.com <mailto:chessai1996 at gmail.com>> wrote:
>>    Right, it's been discussed before IIRC, and i know I've certainly
>>    given it passing thoughts. I think this isn't worth it because of
>>    breakage. Many people use -Wall -Werror, so I see this as a no-go.
>>    Thanka
>>    On Sun, Dec 22, 2019, 6:45 AM Vilem Liepelt
>>    <vliepelt at futurefinance.com <mailto:vliepelt at futurefinance.com>> wrote:
>>        Has there been any discussion about adding WARNING pragmas to
>>        `Prelude.undefined` and `Prelude.error`, as done in some custom
>>        preludes?
>>        I suppose this hasn't been done yet to avoid breaking existing
>>        code which makes "legitimate" use of those helpers?
>>        _______________________________________________
>>        Libraries mailing list
>>        Libraries at haskell.org <mailto:Libraries at haskell.org>
>>        http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>>    _______________________________________________
>>    Libraries mailing list
>>    Libraries at haskell.org <mailto:Libraries at haskell.org>
>>    http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
>> _______________________________________________
>> Libraries mailing list
>> Libraries at haskell.org
>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries
> _______________________________________________
> Libraries mailing list
> Libraries at haskell.org
> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries



More information about the Libraries mailing list