module Clash.Hedgehog.Internal.Bias
( Bias(..)
) where
import Clash.Core.Subst (aeqType)
import Clash.Core.TyCon
import Clash.Core.Type
import Clash.Core.TysPrim
class Bias a where
biasOf :: a -> Int
instance Bias TyCon where
biasOf :: TyCon -> Int
biasOf tc :: TyCon
tc@PrimTyCon{}
| Type -> Type -> Bool
aeqType Type
ty Type
liftedTypeKind = Int -> Int
biasBy Int
3
| Type -> Type -> Bool
aeqType Type
ty Type
typeNatKind = Int -> Int
biasBy Int
2
| Type -> Type -> Bool
aeqType Type
ty Type
typeSymbolKind = Int -> Int
biasBy Int
1
| Type -> Type -> Bool
aeqType Type
ty Type
integerPrimTy = Int -> Int
biasBy Int
5
| Type -> Type -> Bool
aeqType Type
ty Type
naturalPrimTy = Int -> Int
biasBy Int
5
| Type -> Type -> Bool
aeqType Type
ty Type
intPrimTy = Int -> Int
biasBy Int
5
| Type -> Type -> Bool
aeqType Type
ty Type
wordPrimTy = Int -> Int
biasBy Int
5
| Type -> Type -> Bool
aeqType Type
ty Type
int64PrimTy = Int -> Int
biasBy Int
4
| Type -> Type -> Bool
aeqType Type
ty Type
word64PrimTy = Int -> Int
biasBy Int
4
| Type -> Type -> Bool
aeqType Type
ty Type
floatPrimTy = Int -> Int
biasBy Int
3
| Type -> Type -> Bool
aeqType Type
ty Type
doublePrimTy = Int -> Int
biasBy Int
3
| Type -> Type -> Bool
aeqType Type
ty Type
charPrimTy = Int -> Int
biasBy Int
2
| Type -> Type -> Bool
aeqType Type
ty Type
byteArrayPrimTy = Int -> Int
biasBy Int
2
| Type -> Type -> Bool
aeqType Type
ty Type
stringPrimTy = Int -> Int
biasBy Int
2
| Type -> Type -> Bool
aeqType Type
ty Type
voidPrimTy = Int -> Int
biasBy Int
1
| Bool
otherwise = Int
baseBias
where
baseBias :: Int
baseBias = Int
10
ty :: Type
ty = TyConName -> Type
mkTyConTy (TyCon -> TyConName
tyConName TyCon
tc)
biasBy :: Int -> Int
biasBy :: Int -> Int
biasBy Int
n = Int
baseBias Int -> Int -> Int
forall a b. (Num a, Integral b) => a -> b -> a
^ Int
n
biasOf AlgTyCon{} = Int
20 Int -> Int -> Int
forall a b. (Num a, Integral b) => a -> b -> a
^ (Int
4 :: Int)
biasOf PromotedDataCon{} = Int
20 Int -> Int -> Int
forall a b. (Num a, Integral b) => a -> b -> a
^ (Int
3 :: Int)
biasOf FunTyCon{} = Int
20 Int -> Int -> Int
forall a b. (Num a, Integral b) => a -> b -> a
^ (Int
3 :: Int)