module Ribosome.Host.Data.ChannelId where
import Ribosome.Host.Class.Msgpack.Decode (MsgpackDecode (fromMsgpack))

newtype ChannelId =
  ChannelId { ChannelId -> Int64
unChannelId :: Int64 }
  deriving stock (ChannelId -> ChannelId -> Bool
(ChannelId -> ChannelId -> Bool)
-> (ChannelId -> ChannelId -> Bool) -> Eq ChannelId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ChannelId -> ChannelId -> Bool
$c/= :: ChannelId -> ChannelId -> Bool
== :: ChannelId -> ChannelId -> Bool
$c== :: ChannelId -> ChannelId -> Bool
Eq, Int -> ChannelId -> ShowS
[ChannelId] -> ShowS
ChannelId -> String
(Int -> ChannelId -> ShowS)
-> (ChannelId -> String)
-> ([ChannelId] -> ShowS)
-> Show ChannelId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ChannelId] -> ShowS
$cshowList :: [ChannelId] -> ShowS
show :: ChannelId -> String
$cshow :: ChannelId -> String
showsPrec :: Int -> ChannelId -> ShowS
$cshowsPrec :: Int -> ChannelId -> ShowS
Show)
  deriving newtype (Integer -> ChannelId
ChannelId -> ChannelId
ChannelId -> ChannelId -> ChannelId
(ChannelId -> ChannelId -> ChannelId)
-> (ChannelId -> ChannelId -> ChannelId)
-> (ChannelId -> ChannelId -> ChannelId)
-> (ChannelId -> ChannelId)
-> (ChannelId -> ChannelId)
-> (ChannelId -> ChannelId)
-> (Integer -> ChannelId)
-> Num ChannelId
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
fromInteger :: Integer -> ChannelId
$cfromInteger :: Integer -> ChannelId
signum :: ChannelId -> ChannelId
$csignum :: ChannelId -> ChannelId
abs :: ChannelId -> ChannelId
$cabs :: ChannelId -> ChannelId
negate :: ChannelId -> ChannelId
$cnegate :: ChannelId -> ChannelId
* :: ChannelId -> ChannelId -> ChannelId
$c* :: ChannelId -> ChannelId -> ChannelId
- :: ChannelId -> ChannelId -> ChannelId
$c- :: ChannelId -> ChannelId -> ChannelId
+ :: ChannelId -> ChannelId -> ChannelId
$c+ :: ChannelId -> ChannelId -> ChannelId
Num, Num ChannelId
Ord ChannelId
Num ChannelId
-> Ord ChannelId -> (ChannelId -> Rational) -> Real ChannelId
ChannelId -> Rational
forall a. Num a -> Ord a -> (a -> Rational) -> Real a
toRational :: ChannelId -> Rational
$ctoRational :: ChannelId -> Rational
Real, Int -> ChannelId
ChannelId -> Int
ChannelId -> [ChannelId]
ChannelId -> ChannelId
ChannelId -> ChannelId -> [ChannelId]
ChannelId -> ChannelId -> ChannelId -> [ChannelId]
(ChannelId -> ChannelId)
-> (ChannelId -> ChannelId)
-> (Int -> ChannelId)
-> (ChannelId -> Int)
-> (ChannelId -> [ChannelId])
-> (ChannelId -> ChannelId -> [ChannelId])
-> (ChannelId -> ChannelId -> [ChannelId])
-> (ChannelId -> ChannelId -> ChannelId -> [ChannelId])
-> Enum ChannelId
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 :: ChannelId -> ChannelId -> ChannelId -> [ChannelId]
$cenumFromThenTo :: ChannelId -> ChannelId -> ChannelId -> [ChannelId]
enumFromTo :: ChannelId -> ChannelId -> [ChannelId]
$cenumFromTo :: ChannelId -> ChannelId -> [ChannelId]
enumFromThen :: ChannelId -> ChannelId -> [ChannelId]
$cenumFromThen :: ChannelId -> ChannelId -> [ChannelId]
enumFrom :: ChannelId -> [ChannelId]
$cenumFrom :: ChannelId -> [ChannelId]
fromEnum :: ChannelId -> Int
$cfromEnum :: ChannelId -> Int
toEnum :: Int -> ChannelId
$ctoEnum :: Int -> ChannelId
pred :: ChannelId -> ChannelId
$cpred :: ChannelId -> ChannelId
succ :: ChannelId -> ChannelId
$csucc :: ChannelId -> ChannelId
Enum, Enum ChannelId
Real ChannelId
Real ChannelId
-> Enum ChannelId
-> (ChannelId -> ChannelId -> ChannelId)
-> (ChannelId -> ChannelId -> ChannelId)
-> (ChannelId -> ChannelId -> ChannelId)
-> (ChannelId -> ChannelId -> ChannelId)
-> (ChannelId -> ChannelId -> (ChannelId, ChannelId))
-> (ChannelId -> ChannelId -> (ChannelId, ChannelId))
-> (ChannelId -> Integer)
-> Integral ChannelId
ChannelId -> Integer
ChannelId -> ChannelId -> (ChannelId, ChannelId)
ChannelId -> ChannelId -> ChannelId
forall a.
Real a
-> Enum a
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> (a, a))
-> (a -> a -> (a, a))
-> (a -> Integer)
-> Integral a
toInteger :: ChannelId -> Integer
$ctoInteger :: ChannelId -> Integer
divMod :: ChannelId -> ChannelId -> (ChannelId, ChannelId)
$cdivMod :: ChannelId -> ChannelId -> (ChannelId, ChannelId)
quotRem :: ChannelId -> ChannelId -> (ChannelId, ChannelId)
$cquotRem :: ChannelId -> ChannelId -> (ChannelId, ChannelId)
mod :: ChannelId -> ChannelId -> ChannelId
$cmod :: ChannelId -> ChannelId -> ChannelId
div :: ChannelId -> ChannelId -> ChannelId
$cdiv :: ChannelId -> ChannelId -> ChannelId
rem :: ChannelId -> ChannelId -> ChannelId
$crem :: ChannelId -> ChannelId -> ChannelId
quot :: ChannelId -> ChannelId -> ChannelId
$cquot :: ChannelId -> ChannelId -> ChannelId
Integral, Eq ChannelId
Eq ChannelId
-> (ChannelId -> ChannelId -> Ordering)
-> (ChannelId -> ChannelId -> Bool)
-> (ChannelId -> ChannelId -> Bool)
-> (ChannelId -> ChannelId -> Bool)
-> (ChannelId -> ChannelId -> Bool)
-> (ChannelId -> ChannelId -> ChannelId)
-> (ChannelId -> ChannelId -> ChannelId)
-> Ord ChannelId
ChannelId -> ChannelId -> Bool
ChannelId -> ChannelId -> Ordering
ChannelId -> ChannelId -> ChannelId
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 :: ChannelId -> ChannelId -> ChannelId
$cmin :: ChannelId -> ChannelId -> ChannelId
max :: ChannelId -> ChannelId -> ChannelId
$cmax :: ChannelId -> ChannelId -> ChannelId
>= :: ChannelId -> ChannelId -> Bool
$c>= :: ChannelId -> ChannelId -> Bool
> :: ChannelId -> ChannelId -> Bool
$c> :: ChannelId -> ChannelId -> Bool
<= :: ChannelId -> ChannelId -> Bool
$c<= :: ChannelId -> ChannelId -> Bool
< :: ChannelId -> ChannelId -> Bool
$c< :: ChannelId -> ChannelId -> Bool
compare :: ChannelId -> ChannelId -> Ordering
$ccompare :: ChannelId -> ChannelId -> Ordering
Ord)

instance MsgpackDecode ChannelId where
  fromMsgpack :: Object -> Either DecodeError ChannelId
fromMsgpack =
    (Int64 -> ChannelId)
-> Either DecodeError Int64 -> Either DecodeError ChannelId
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int64 -> ChannelId
ChannelId (Either DecodeError Int64 -> Either DecodeError ChannelId)
-> (Object -> Either DecodeError Int64)
-> Object
-> Either DecodeError ChannelId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Object -> Either DecodeError Int64
forall a. MsgpackDecode a => Object -> Either DecodeError a
fromMsgpack