{-# LANGUAGE BangPatterns #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Distribution.Client.Compat.Orphans () where
import Control.Exception (SomeException)
import Distribution.Compat.Binary (Binary (..))
import Distribution.Compat.Typeable (typeRep)
import Distribution.Utils.Structured (Structure (Nominal), Structured (..))
import Network.URI (URI (..), URIAuth (..))
import Prelude (error, return)
instance Binary URI where
put :: URI -> Put
put (URI String
a Maybe URIAuth
b String
c String
d String
e) = do String -> Put
forall t. Binary t => t -> Put
put String
a; Maybe URIAuth -> Put
forall t. Binary t => t -> Put
put Maybe URIAuth
b; String -> Put
forall t. Binary t => t -> Put
put String
c; String -> Put
forall t. Binary t => t -> Put
put String
d; String -> Put
forall t. Binary t => t -> Put
put String
e
get :: Get URI
get = do !String
a <- Get String
forall t. Binary t => Get t
get; !Maybe URIAuth
b <- Get (Maybe URIAuth)
forall t. Binary t => Get t
get; !String
c <- Get String
forall t. Binary t => Get t
get; !String
d <- Get String
forall t. Binary t => Get t
get; !String
e <- Get String
forall t. Binary t => Get t
get
URI -> Get URI
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> Maybe URIAuth -> String -> String -> String -> URI
URI String
a Maybe URIAuth
b String
c String
d String
e)
instance Structured URI where
structure :: Proxy URI -> Structure
structure Proxy URI
p = TypeRep -> TypeVersion -> String -> [Structure] -> Structure
Nominal (Proxy URI -> TypeRep
forall k (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> TypeRep
typeRep Proxy URI
p) TypeVersion
0 String
"URI" []
instance Binary URIAuth where
put :: URIAuth -> Put
put (URIAuth String
a String
b String
c) = do String -> Put
forall t. Binary t => t -> Put
put String
a; String -> Put
forall t. Binary t => t -> Put
put String
b; String -> Put
forall t. Binary t => t -> Put
put String
c
get :: Get URIAuth
get = do !String
a <- Get String
forall t. Binary t => Get t
get; !String
b <- Get String
forall t. Binary t => Get t
get; !String
c <- Get String
forall t. Binary t => Get t
get; URIAuth -> Get URIAuth
forall (m :: * -> *) a. Monad m => a -> m a
return (String -> String -> String -> URIAuth
URIAuth String
a String
b String
c)
instance Binary SomeException where
put :: SomeException -> Put
put SomeException
_ = () -> Put
forall (m :: * -> *) a. Monad m => a -> m a
return ()
get :: Get SomeException
get = String -> Get SomeException
forall a. HasCallStack => String -> a
error String
"cannot serialise exceptions"
instance Structured SomeException where
structure :: Proxy SomeException -> Structure
structure Proxy SomeException
p = TypeRep -> TypeVersion -> String -> [Structure] -> Structure
Nominal (Proxy SomeException -> TypeRep
forall k (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> TypeRep
typeRep Proxy SomeException
p) TypeVersion
0 String
"SomeException" []