{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE LambdaCase #-}
{-# language TemplateHaskell #-}
{-# options_ghc -Wno-unused-imports #-}
module Data.Generics.Encode.Internal.Prim (VP(..), vpInt, vpBool, vpFloat, vpDouble, vpScientific, vpChar, vpString, vpText, vpOneHot) where
import Data.Int (Int8, Int16, Int32, Int64)
import Data.Word (Word, Word8, Word16, Word32, Word64)
import qualified GHC.Generics as G
import Data.Hashable (Hashable(..))
import Lens.Micro.TH (makeLenses)
import Data.Scientific (Scientific)
import Data.Text (Text, unpack)
import Data.Generics.Encode.OneHot (OneHot, mkOH)
data VP =
VPInt { VP -> Int
_vpInt :: Int }
| VPInt8 Int8
| VPInt16 Int16
| VPInt32 Int32
| VPInt64 Int64
| VPWord Word
| VPWord8 Word8
| VPWord16 Word16
| VPWord32 Word32
| VPWord64 Word64
| VPBool { VP -> Bool
_vpBool :: Bool }
| VPFloat { VP -> Float
_vpFloat :: Float }
| VPDouble { VP -> Double
_vpDouble :: Double }
| VPScientific { VP -> Scientific
_vpScientific :: Scientific }
| VPChar { VP -> Char
_vpChar :: Char }
| VPString { VP -> String
_vpString :: String }
| VPText { VP -> Text
_vpText :: Text }
| VPOH { VP -> OneHot Int
_vpOneHot :: OneHot Int }
| VPUnit
deriving (VP -> VP -> Bool
(VP -> VP -> Bool) -> (VP -> VP -> Bool) -> Eq VP
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VP -> VP -> Bool
$c/= :: VP -> VP -> Bool
== :: VP -> VP -> Bool
$c== :: VP -> VP -> Bool
Eq, Eq VP
Eq VP
-> (VP -> VP -> Ordering)
-> (VP -> VP -> Bool)
-> (VP -> VP -> Bool)
-> (VP -> VP -> Bool)
-> (VP -> VP -> Bool)
-> (VP -> VP -> VP)
-> (VP -> VP -> VP)
-> Ord VP
VP -> VP -> Bool
VP -> VP -> Ordering
VP -> VP -> VP
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 :: VP -> VP -> VP
$cmin :: VP -> VP -> VP
max :: VP -> VP -> VP
$cmax :: VP -> VP -> VP
>= :: VP -> VP -> Bool
$c>= :: VP -> VP -> Bool
> :: VP -> VP -> Bool
$c> :: VP -> VP -> Bool
<= :: VP -> VP -> Bool
$c<= :: VP -> VP -> Bool
< :: VP -> VP -> Bool
$c< :: VP -> VP -> Bool
compare :: VP -> VP -> Ordering
$ccompare :: VP -> VP -> Ordering
$cp1Ord :: Eq VP
Ord, (forall x. VP -> Rep VP x)
-> (forall x. Rep VP x -> VP) -> Generic VP
forall x. Rep VP x -> VP
forall x. VP -> Rep VP x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VP x -> VP
$cfrom :: forall x. VP -> Rep VP x
G.Generic)
instance Hashable VP
makeLenses ''VP
instance Show VP where
show :: VP -> String
show = \case
VPInt Int
x -> Int -> String
forall a. Show a => a -> String
show Int
x
VPInt8 Int8
x -> Int8 -> String
forall a. Show a => a -> String
show Int8
x
VPInt16 Int16
x -> Int16 -> String
forall a. Show a => a -> String
show Int16
x
VPInt32 Int32
x -> Int32 -> String
forall a. Show a => a -> String
show Int32
x
VPInt64 Int64
x -> Int64 -> String
forall a. Show a => a -> String
show Int64
x
VPWord Word
x -> Word -> String
forall a. Show a => a -> String
show Word
x
VPWord8 Word8
x -> Word8 -> String
forall a. Show a => a -> String
show Word8
x
VPWord16 Word16
x -> Word16 -> String
forall a. Show a => a -> String
show Word16
x
VPWord32 Word32
x -> Word32 -> String
forall a. Show a => a -> String
show Word32
x
VPWord64 Word64
x -> Word64 -> String
forall a. Show a => a -> String
show Word64
x
VPBool Bool
b -> Bool -> String
forall a. Show a => a -> String
show Bool
b
VPFloat Float
f -> Float -> String
forall a. Show a => a -> String
show Float
f
VPDouble Double
d -> Double -> String
forall a. Show a => a -> String
show Double
d
VPScientific Scientific
s -> Scientific -> String
forall a. Show a => a -> String
show Scientific
s
VPChar Char
d -> Char -> String
forall (f :: * -> *) a. Applicative f => a -> f a
pure Char
d
VPString String
s -> String
s
VPText Text
t -> Text -> String
unpack Text
t
VPOH OneHot Int
oh -> OneHot Int -> String
forall a. Show a => a -> String
show OneHot Int
oh
VP
VPUnit -> () -> String
forall a. Show a => a -> String
show ()