• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

msakai / toysolver / 496

10 Nov 2024 11:05AM UTC coverage: 69.994% (-1.1%) from 71.113%
496

push

github

web-flow
Merge pull request #117 from msakai/update-coveralls-and-haddock

GitHub Actions: Update coveralls and haddock configuration

9872 of 14104 relevant lines covered (69.99%)

0.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

57.89
/src/ToySolver/Data/LBool.hs
1
-----------------------------------------------------------------------------
2
-- |
3
-- Module      :  ToySolver.Data.LBool
4
-- Copyright   :  (c) Masahiro Sakai 2012
5
-- License     :  BSD-style
6
--
7
-- Maintainer  :  masahiro.sakai@gmail.com
8
-- Stability   :  provisional
9
-- Portability :  portable
10
--
11
-- Lifted boolean type.
12
--
13
-----------------------------------------------------------------------------
14
module ToySolver.Data.LBool
15
  ( LBool (..)
16
  , lTrue
17
  , lFalse
18
  , lUndef
19
  , lnot
20
  , liftBool
21
  , unliftBool
22
  ) where
23

24
import Data.Int
25

26
-- | Lifted Bool type. It has three values 'lTrue', 'lFalse', 'lUndef'.
27
newtype LBool = LBool Int8 deriving Eq
1✔
28

29
-- | lifted true value
30
{-# INLINE lTrue #-}
31
lTrue :: LBool
32
lTrue = LBool 1
1✔
33

34
-- | lifted false value
35
{-# INLINE lFalse #-}
36
lFalse :: LBool
37
lFalse = LBool (-1)
1✔
38

39
-- | undefined truth value
40
{-# INLINE lUndef #-}
41
lUndef :: LBool
42
lUndef = LBool 0
1✔
43

44
-- |
45
-- @
46
--   lnot lTrue == lFalse
47
--   lnot lFalse == lTrue
48
--   lnot lUndef == lUndef
49
-- @
50
{-# INLINE lnot #-}
51
lnot :: LBool -> LBool
52
lnot x
1✔
53
  | x == lTrue  = lFalse
1✔
54
  | x == lFalse = lTrue
1✔
55
  | otherwise   = lUndef
×
56

57
-- |
58
-- @
59
--   liftBool True == lTrue
60
--   liftBool False == lFalse
61
-- @
62
{-# INLINE liftBool #-}
63
liftBool :: Bool -> LBool
64
liftBool True  = lTrue
1✔
65
liftBool False = lFalse
1✔
66

67
-- |
68
-- @
69
--   unliftBool lTrue == Just True
70
--   unliftBool lFalse == Just False
71
--   unliftBool lUndef == Nothing
72
-- @
73
{-# INLINE unliftBool #-}
74
unliftBool :: LBool -> Maybe Bool
75
unliftBool x
1✔
76
  | x == lTrue  = Just True
1✔
77
  | x == lFalse = Just False
×
78
  | otherwise   = Nothing
×
79

80
instance Show LBool where
×
81
  show x
×
82
    | x == lTrue  = "lTrue"
×
83
    | x == lFalse = "lFalse"
×
84
    | otherwise   = "lUndef"
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc