Re: ghc should be able to deduce correct use of partial functions and not give a warning in such cases
Henning Thielemann <[email protected]>
| Newsgroups | gmane.comp.lang.haskell.cafe |
|---|---|
| Message-ID | <[email protected]> |
On Fri, 19 Apr 2024, Ben via Haskell-Cafe wrote: > I'm not 100% sure what Safe.tailErr function you are using (Hoogle only > finds tailErr :: e -> [a] -> Either e [a], which doesn't appear > compatible with the way you're using it since it takes an "error > message" as first argument). I found this one: https://hackage.haskell.org/package/safe-0.3.21/docs/Safe.html#v:tailErr It is problematic in even more ways. First, the reader of the code does not know, which tailErr the programmer means. We must look it up. Even if there would be only one candidate, we must look up what it does. Second, the documentation says, tailErr is meant to suppress the new warning on 'tail' in GHC>=9.8, but is still partial. Not a good idea to suppress a warning that has a purpose. Third, the naming of the 'safe' package and 'Safe' module is misleading, because there is nothing unsafe in 'tail'&Co. in the sense of SafeHaskell or unsafePerformIO. 'tail' is partial, that is, for some inputs it is undefined, read: it may run into an infinite loop. But it will not cause memory corruption or ignite nukes while pretending to stay away from IO. _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post.