Copyright | (c) Curran McConnell Levent Erkok |
---|---|
License | BSD3 |
Maintainer | erkokl@gmail.com |
Stability | experimental |
Safe Haskell | None |
Language | Haskell2010 |
Demonstrates how to create symbolic newtypes with the same behaviour as their wrapped type.
Synopsis
- newtype Metres = Metres Integer
- type SMetres = SBV Metres
- newtype HumanHeightInCm = HumanHeightInCm Word16
- type SHumanHeightInCm = SBV HumanHeightInCm
- tallestHumanEver :: SHumanHeightInCm
- ceilingHighEnoughForHuman :: SMetres -> SHumanHeightInCm -> SBool
- problem :: Predicate
Documentation
>>>
-- For doctest purposes only:
>>>
import Data.SBV
Instances
newtype HumanHeightInCm Source #
Similarly, we can create another newtype, this time wrapping over Word16
. As an example,
consider measuring the human height in centimetres? The tallest person in history,
Robert Wadlow, was 272 cm. We don't need negative values, so Word16
is the smallest type that
suits our needs.
Instances
type SHumanHeightInCm = SBV HumanHeightInCm Source #
Symbolic version of HumanHeightInCm
.
tallestHumanEver :: SHumanHeightInCm Source #
The tallest human ever was 272 cm. We can simply use literal
to lift it
to the symbolic space.
ceilingHighEnoughForHuman :: SMetres -> SHumanHeightInCm -> SBool Source #
Given a distance between a floor and a ceiling, we can see whether
the human can stand in that room. Comparison is expressed using sFromIntegral
.