{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE UndecidableInstances #-}
module Language.Haskell.Liquid.Types.Generics where
import GHC.Generics
import Data.Hashable
import Data.Binary
import Data.Hashable.Generic
import Data.Function
newtype Generically a = Generically a deriving (forall x. Generically a -> Rep (Generically a) x)
-> (forall x. Rep (Generically a) x -> Generically a)
-> Generic (Generically a)
forall x. Rep (Generically a) x -> Generically a
forall x. Generically a -> Rep (Generically a) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall a x. Rep (Generically a) x -> Generically a
forall a x. Generically a -> Rep (Generically a) x
$cto :: forall a x. Rep (Generically a) x -> Generically a
$cfrom :: forall a x. Generically a -> Rep (Generically a) x
Generic
instance (Generic a, GHashable Zero (Rep a)) => Hashable (Generically a) where
hashWithSalt :: Int -> Generically a -> Int
hashWithSalt Int
s (Generically a
a) = Int -> a -> Int
forall a. (Generic a, GHashable Zero (Rep a)) => Int -> a -> Int
genericHashWithSalt Int
s a
a
instance (Generic a, GBinaryPut (Rep a), GBinaryGet (Rep a)) => Binary (Generically a) where
get :: Get (Generically a)
get = a -> Generically a
forall a. a -> Generically a
Generically (a -> Generically a)
-> (Rep a () -> a) -> Rep a () -> Generically a
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Rep a () -> a
forall a. Generic a => Rep a () -> a
to' (Rep a () -> Generically a)
-> Get (Rep a ()) -> Get (Generically a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Get (Rep a ())
forall k (f :: k -> *) (t :: k). GBinaryGet f => Get (f t)
gget
put :: Generically a -> Put
put (Generically a
a) = Rep a () -> Put
forall k (f :: k -> *) (t :: k). GBinaryPut f => f t -> Put
gput (a -> Rep a ()
forall a. Generic a => a -> Rep a ()
from' a
a)
geq :: (Generic a, Eq (Rep a ())) => a -> a -> Bool
geq :: a -> a -> Bool
geq = Rep a () -> Rep a () -> Bool
forall a. Eq a => a -> a -> Bool
(==) (Rep a () -> Rep a () -> Bool) -> (a -> Rep a ()) -> a -> a -> Bool
forall b c a. (b -> b -> c) -> (a -> b) -> a -> a -> c
`on` a -> Rep a ()
forall a. Generic a => a -> Rep a ()
from'
instance (Generic a, Eq (Rep a ())) => Eq (Generically a) where
(Generically a
a) == :: Generically a -> Generically a -> Bool
== (Generically a
b) = a -> a -> Bool
forall a. (Generic a, Eq (Rep a ())) => a -> a -> Bool
geq a
a a
b
from' :: Generic a => a -> Rep a ()
from' :: a -> Rep a ()
from' = a -> Rep a ()
forall a x. Generic a => a -> Rep a x
from
to' :: Generic a => Rep a () -> a
to' :: Rep a () -> a
to' = Rep a () -> a
forall a x. Generic a => Rep a x -> a
to