@hackage placeholders0.1
Placeholders for use while developing Haskell code
Categories
License
BSD-3-Clause
Maintainer
Andreas Hammar <ahammar@gmail.com>
Links
Versions
- 0.1 Fri, 29 Apr 2011
Installation
Dependencies (2)
- base >=4 && <5
- template-haskell Show all…
Dependents (20)
@hackage/prologue, @hackage/focus, @hackage/bit-array, @hackage/remotion, @hackage/hashtables-plus, @hackage/acme-everything, Show all…
placeholders
While working on some Haskell code, it is often useful to develop
incrementally by inserting undefined as a placeholder for missing code.
This approach has a couple of drawbacks.
-
If you have several occurrences of
undefinedin your code, it can be hard to track down the one reponsible for the error at run-time. -
It is too easy to forget to replace
undefinedwith the proper code, which might cause unexpected errors.
This library provides placeholders that produce better messages when evaluated at run-time and also generate compile-time warnings so that they do not get forgotten so easily.
example
{-# LANGUAGE TemplateHaskell #-}
import Development.Placeholders
theUltimateAnswer :: Int
theUltimateAnswer = $notImplemented
main = do
putStrLn "The ultimate answer:"
print theUltimateAnswer
This will compile with a warning about the unimplemented function:
$ ghc --make Simple.hs
...
Simple.hs:6:21: Unimplemented feature
...
At runtime, an exception will be thrown when the placeholder is evaluated, indicating the location of the placeholder.
$ ./Simple
The ultimate answer:
Simple: PlaceholderExcption "Unimplemented feature at Simple.hs:6:21"
If compiled with the GHC flag -Werror, the warning will get turned into
an error and compilation will fail. -Werror can therefore be used to
verify that you haven't left any unintended placeholders behind.