{-|
  Copyright   :  (C) 2024, Martijn Bastiaan
  License     :  BSD2 (see the file LICENSE)
  Maintainer  :  QBayLogic B.V. <devops@qbaylogic.com>
-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DeriveAnyClass #-}

module Clash.Driver.Bool where

import Control.DeepSeq (NFData)
import Data.Hashable (Hashable)
import GHC.Generics (Generic)

#if MIN_VERSION_ghc(9,4,0)
import qualified GHC.Data.Bool as Ghc
#elif MIN_VERSION_ghc(9,0,0)
import qualified GHC.Utils.Misc as Ghc
#else
import qualified Util as Ghc
#endif

data OverridingBool = Auto | Never | Always
  deriving (Int -> OverridingBool -> ShowS
[OverridingBool] -> ShowS
OverridingBool -> String
(Int -> OverridingBool -> ShowS)
-> (OverridingBool -> String)
-> ([OverridingBool] -> ShowS)
-> Show OverridingBool
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OverridingBool] -> ShowS
$cshowList :: [OverridingBool] -> ShowS
show :: OverridingBool -> String
$cshow :: OverridingBool -> String
showsPrec :: Int -> OverridingBool -> ShowS
$cshowsPrec :: Int -> OverridingBool -> ShowS
Show, ReadPrec [OverridingBool]
ReadPrec OverridingBool
Int -> ReadS OverridingBool
ReadS [OverridingBool]
(Int -> ReadS OverridingBool)
-> ReadS [OverridingBool]
-> ReadPrec OverridingBool
-> ReadPrec [OverridingBool]
-> Read OverridingBool
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OverridingBool]
$creadListPrec :: ReadPrec [OverridingBool]
readPrec :: ReadPrec OverridingBool
$creadPrec :: ReadPrec OverridingBool
readList :: ReadS [OverridingBool]
$creadList :: ReadS [OverridingBool]
readsPrec :: Int -> ReadS OverridingBool
$creadsPrec :: Int -> ReadS OverridingBool
Read, OverridingBool -> OverridingBool -> Bool
(OverridingBool -> OverridingBool -> Bool)
-> (OverridingBool -> OverridingBool -> Bool) -> Eq OverridingBool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OverridingBool -> OverridingBool -> Bool
$c/= :: OverridingBool -> OverridingBool -> Bool
== :: OverridingBool -> OverridingBool -> Bool
$c== :: OverridingBool -> OverridingBool -> Bool
Eq, Eq OverridingBool
Eq OverridingBool
-> (OverridingBool -> OverridingBool -> Ordering)
-> (OverridingBool -> OverridingBool -> Bool)
-> (OverridingBool -> OverridingBool -> Bool)
-> (OverridingBool -> OverridingBool -> Bool)
-> (OverridingBool -> OverridingBool -> Bool)
-> (OverridingBool -> OverridingBool -> OverridingBool)
-> (OverridingBool -> OverridingBool -> OverridingBool)
-> Ord OverridingBool
OverridingBool -> OverridingBool -> Bool
OverridingBool -> OverridingBool -> Ordering
OverridingBool -> OverridingBool -> OverridingBool
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: OverridingBool -> OverridingBool -> OverridingBool
$cmin :: OverridingBool -> OverridingBool -> OverridingBool
max :: OverridingBool -> OverridingBool -> OverridingBool
$cmax :: OverridingBool -> OverridingBool -> OverridingBool
>= :: OverridingBool -> OverridingBool -> Bool
$c>= :: OverridingBool -> OverridingBool -> Bool
> :: OverridingBool -> OverridingBool -> Bool
$c> :: OverridingBool -> OverridingBool -> Bool
<= :: OverridingBool -> OverridingBool -> Bool
$c<= :: OverridingBool -> OverridingBool -> Bool
< :: OverridingBool -> OverridingBool -> Bool
$c< :: OverridingBool -> OverridingBool -> Bool
compare :: OverridingBool -> OverridingBool -> Ordering
$ccompare :: OverridingBool -> OverridingBool -> Ordering
$cp1Ord :: Eq OverridingBool
Ord, Int -> OverridingBool
OverridingBool -> Int
OverridingBool -> [OverridingBool]
OverridingBool -> OverridingBool
OverridingBool -> OverridingBool -> [OverridingBool]
OverridingBool
-> OverridingBool -> OverridingBool -> [OverridingBool]
(OverridingBool -> OverridingBool)
-> (OverridingBool -> OverridingBool)
-> (Int -> OverridingBool)
-> (OverridingBool -> Int)
-> (OverridingBool -> [OverridingBool])
-> (OverridingBool -> OverridingBool -> [OverridingBool])
-> (OverridingBool -> OverridingBool -> [OverridingBool])
-> (OverridingBool
    -> OverridingBool -> OverridingBool -> [OverridingBool])
-> Enum OverridingBool
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
enumFromThenTo :: OverridingBool
-> OverridingBool -> OverridingBool -> [OverridingBool]
$cenumFromThenTo :: OverridingBool
-> OverridingBool -> OverridingBool -> [OverridingBool]
enumFromTo :: OverridingBool -> OverridingBool -> [OverridingBool]
$cenumFromTo :: OverridingBool -> OverridingBool -> [OverridingBool]
enumFromThen :: OverridingBool -> OverridingBool -> [OverridingBool]
$cenumFromThen :: OverridingBool -> OverridingBool -> [OverridingBool]
enumFrom :: OverridingBool -> [OverridingBool]
$cenumFrom :: OverridingBool -> [OverridingBool]
fromEnum :: OverridingBool -> Int
$cfromEnum :: OverridingBool -> Int
toEnum :: Int -> OverridingBool
$ctoEnum :: Int -> OverridingBool
pred :: OverridingBool -> OverridingBool
$cpred :: OverridingBool -> OverridingBool
succ :: OverridingBool -> OverridingBool
$csucc :: OverridingBool -> OverridingBool
Enum, OverridingBool
OverridingBool -> OverridingBool -> Bounded OverridingBool
forall a. a -> a -> Bounded a
maxBound :: OverridingBool
$cmaxBound :: OverridingBool
minBound :: OverridingBool
$cminBound :: OverridingBool
Bounded, Eq OverridingBool
Eq OverridingBool
-> (Int -> OverridingBool -> Int)
-> (OverridingBool -> Int)
-> Hashable OverridingBool
Int -> OverridingBool -> Int
OverridingBool -> Int
forall a. Eq a -> (Int -> a -> Int) -> (a -> Int) -> Hashable a
hash :: OverridingBool -> Int
$chash :: OverridingBool -> Int
hashWithSalt :: Int -> OverridingBool -> Int
$chashWithSalt :: Int -> OverridingBool -> Int
$cp1Hashable :: Eq OverridingBool
Hashable, (forall x. OverridingBool -> Rep OverridingBool x)
-> (forall x. Rep OverridingBool x -> OverridingBool)
-> Generic OverridingBool
forall x. Rep OverridingBool x -> OverridingBool
forall x. OverridingBool -> Rep OverridingBool x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OverridingBool x -> OverridingBool
$cfrom :: forall x. OverridingBool -> Rep OverridingBool x
Generic, OverridingBool -> ()
(OverridingBool -> ()) -> NFData OverridingBool
forall a. (a -> ()) -> NFData a
rnf :: OverridingBool -> ()
$crnf :: OverridingBool -> ()
NFData)

toGhcOverridingBool :: OverridingBool -> Ghc.OverridingBool
toGhcOverridingBool :: OverridingBool -> OverridingBool
toGhcOverridingBool OverridingBool
Auto = OverridingBool
Ghc.Auto
toGhcOverridingBool OverridingBool
Never = OverridingBool
Ghc.Never
toGhcOverridingBool OverridingBool
Always = OverridingBool
Ghc.Always

fromGhcOverridingBool :: Ghc.OverridingBool -> OverridingBool
fromGhcOverridingBool :: OverridingBool -> OverridingBool
fromGhcOverridingBool OverridingBool
Ghc.Auto = OverridingBool
Auto
fromGhcOverridingBool OverridingBool
Ghc.Never = OverridingBool
Never
fromGhcOverridingBool OverridingBool
Ghc.Always = OverridingBool
Always