acme-omitted-3.0.0.0: A name for omitted definitions

Copyright(c) 2013-2016 Joachim Fasting
LicenseBSD3
Maintainerjoachifm@fastmail.fm
Stabilityprovisional
Portabilityportable
Safe HaskellSafe
LanguageHaskell2010

Acme.OmittedOrUndefined

Contents

Description

 

Synopsis

Usage

module AwesomeSauce where

import Prelude hiding (undefined)
import Acme.Omitted
import Acme.Undefined

tooLazyToDefine     = (...)

actuallyUndefinable = undefined

main = do
  merelyOmitted <- isOmitted tooLazyToDefine
  putStrLn "Definition was merely omitted"
  (...)
  trulyUndefined <- isUndefined actuallyUndefinable
  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
isOmitted undefined = return False
isOmitted omitted   = return True

isUndefined :: a -> IO Bool Source #

... or is it really undefined?

isUndefined 0           = return False
isUndefined undefined = return True
isUndefined omitted   = return False

isPreludeUndefined :: a -> IO Bool Source #

A version of isUndefined for "Prelude.undefined".