never executed always true always false
    1 {-# language CPP #-}
    2 {-# language MultiParamTypeClasses #-}
    3 
    4 #ifndef ENABLE_INTERNAL_DOCUMENTATION
    5 {-# OPTIONS_HADDOCK hide #-}
    6 #endif
    7 
    8 module OpenCV.Internal.Core.Types.Mat.Depth
    9     ( Depth(..)
   10     , ToDepth(toDepth)
   11     , ToDepthDS(toDepthDS)
   12     , DepthT
   13     , StaticDepthT
   14     ) where
   15 
   16 import "base" Data.Int
   17 import "base" Data.Proxy
   18 import "base" Data.Word
   19 import "this" OpenCV.TypeLevel
   20 
   21 --------------------------------------------------------------------------------
   22 
   23 data Depth =
   24      Depth_8U
   25    | Depth_8S
   26    | Depth_16U
   27    | Depth_16S
   28    | Depth_32S
   29    | Depth_32F
   30    | Depth_64F
   31    | Depth_USRTYPE1
   32      deriving (Bounded, Enum, Eq, Show)
   33 
   34 --------------------------------------------------------------------------------
   35 
   36 class ToDepth a where
   37     toDepth :: a -> Depth
   38 
   39 instance ToDepth Depth where toDepth = id
   40 instance ToDepth (proxy Word8 ) where toDepth _proxy = Depth_8U
   41 instance ToDepth (proxy Int8  ) where toDepth _proxy = Depth_8S
   42 instance ToDepth (proxy Word16) where toDepth _proxy = Depth_16U
   43 instance ToDepth (proxy Int16 ) where toDepth _proxy = Depth_16S
   44 instance ToDepth (proxy Int32 ) where toDepth _proxy = Depth_32S
   45 instance ToDepth (proxy Float ) where toDepth _proxy = Depth_32F
   46 instance ToDepth (proxy Double) where toDepth _proxy = Depth_64F
   47 -- TODO (BvD): instance ToDepth ? where toDepth = const Depth_USRTYPE1
   48 -- RvD: perhaps ByteString? Or a fixed size (statically) vector of bytes
   49 
   50 --------------------------------------------------------------------------------
   51 
   52 class ToDepthDS a where
   53     toDepthDS :: a -> DS Depth
   54 
   55 instance ToDepthDS Depth      where toDepthDS _depth = D
   56 instance ToDepthDS (proxy 'D) where toDepthDS _proxy = D
   57 
   58 instance ToDepthDS (proxy ('S Word8 )) where toDepthDS _proxy = S $ toDepth (Proxy :: Proxy Word8 )
   59 instance ToDepthDS (proxy ('S Int8  )) where toDepthDS _proxy = S $ toDepth (Proxy :: Proxy Int8  )
   60 instance ToDepthDS (proxy ('S Word16)) where toDepthDS _proxy = S $ toDepth (Proxy :: Proxy Word16)
   61 instance ToDepthDS (proxy ('S Int16 )) where toDepthDS _proxy = S $ toDepth (Proxy :: Proxy Int16 )
   62 instance ToDepthDS (proxy ('S Int32 )) where toDepthDS _proxy = S $ toDepth (Proxy :: Proxy Int32 )
   63 instance ToDepthDS (proxy ('S Float )) where toDepthDS _proxy = S $ toDepth (Proxy :: Proxy Float )
   64 instance ToDepthDS (proxy ('S Double)) where toDepthDS _proxy = S $ toDepth (Proxy :: Proxy Double)
   65 
   66 --------------------------------------------------------------------------------
   67 
   68 type family DepthT a :: DS * where
   69     DepthT Depth     = 'D
   70     DepthT (proxy d) = 'S d
   71 
   72 type family StaticDepthT a :: * where
   73     StaticDepthT (proxy d) = d
   74     StaticDepthT d         = d