| Copyright | (c) 2013-2016 Joachim Fasting |
|---|---|
| License | BSD3 |
| Maintainer | joachifm@fastmail.fm |
| Stability | provisional |
| Portability | portable |
| Safe Haskell | Safe |
| Language | Haskell2010 |
Acme.OmittedOrUndefined
Description
- isOmitted :: a -> IO Bool
- isUndefined :: a -> IO Bool
- isPreludeUndefined :: a -> IO Bool
Usage
module AwesomeSauce where import Prelude hiding (undefined) import Acme.Omitted import Acme.Undefined tooLazyToDefine = (...) actuallyUndefinable = undefined main = do merelyOmitted <-isOmittedtooLazyToDefine putStrLn "Definition was merely omitted" (...) trulyUndefined <-isUndefinedactuallyUndefinable putStrLn "Definition is truly undefinable"
Observing the difference between "omitted" and "undefined"
Consistent use of undefined and omitted can clarify the intent of the
programmer, but there is no way to statically prevent incorrect uses of
undefined (e.g., due to ignorance).
Consequently, isUndefined will return bogus results every now and then,
which is why it is modelled as an IO action and not a pure function.
Nevertheless, the user can identify incorrect uses of undefined more
easily than before.
To wit, if
isUndefined twoPlusTwo = return True
then, surely, something is amiss.
For backwards-compatibility, we also support detecting the standard implementation of undefined, about which we cannot infer anything except that its evaluation will terminate with no useful result.
isOmitted :: a -> IO Bool Source #
Answer the age-old question "was this definition omitted?"
isOmitted 0 = return False isOmittedundefined= return False isOmittedomitted= return True
isUndefined :: a -> IO Bool Source #
isPreludeUndefined :: a -> IO Bool Source #
A version of isUndefined for "Prelude.undefined".