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

Vilem Liepelt vliepelt at futurefinance.com
Mon Dec 23 21:05:00 UTC 2019


> On 23 Dec 2019, at 21:48, Daniel Díaz Casanueva <dhelta.diaz at gmail.com> wrote:
> 
> Oh, I see. Sorry. I totally misunderstood the proposal. I should have read more carefully.
> 
> I think undefined and error are useful functions to have, so why adding WARNING to them? For example, you can fold an infinite structure `xs` with `foldr f undefined xs` (for some proper `f`) without needing to define or look for an alternative to `Data.Foldable.foldr`.

Yes, as long as the structure really is infinite. However the types don't guarantee or even suggest this, so this can easily blow up after a refactor that doesn't take this unwritten rule into consideration. If `undefined` came with a WARNING, then that might encourage you to try to express your solution with a proper coinductive data structure. :)


More information about the Libraries mailing list