{-# LANGUAGE BangPatterns #-}
{-# OPTIONS_GHC -Wno-orphans #-}
module Distribution.Client.Compat.Orphans () where
import Control.Exception (SomeException)
import Data.Typeable (typeRep)
import Distribution.Compat.Binary (Binary (..))
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 [Char]
a Maybe URIAuth
b [Char]
c [Char]
d [Char]
e) = do [Char] -> Put
forall t. Binary t => t -> Put
put [Char]
a; Maybe URIAuth -> Put
forall t. Binary t => t -> Put
put Maybe URIAuth
b; [Char] -> Put
forall t. Binary t => t -> Put
put [Char]
c; [Char] -> Put
forall t. Binary t => t -> Put
put [Char]
d; [Char] -> Put
forall t. Binary t => t -> Put
put [Char]
e
get :: Get URI
get = do
!a <- Get [Char]
forall t. Binary t => Get t
get
!b <- get
!c <- get
!d <- get
!e <- get
return (URI a b c d e)
instance Structured URI where
structure :: Proxy URI -> Structure
structure Proxy URI
p = TypeRep -> Word32 -> [Char] -> [Structure] -> Structure
Nominal (Proxy URI -> TypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> TypeRep
typeRep Proxy URI
p) Word32
0 [Char]
"URI" []
instance Binary URIAuth where
put :: URIAuth -> Put
put (URIAuth [Char]
a [Char]
b [Char]
c) = do [Char] -> Put
forall t. Binary t => t -> Put
put [Char]
a; [Char] -> Put
forall t. Binary t => t -> Put
put [Char]
b; [Char] -> Put
forall t. Binary t => t -> Put
put [Char]
c
get :: Get URIAuth
get = do !a <- Get [Char]
forall t. Binary t => Get t
get; !b <- get; !c <- get; return (URIAuth a b c)
instance Binary SomeException where
put :: SomeException -> Put
put SomeException
_ = () -> Put
forall a. a -> PutM a
forall (m :: * -> *) a. Monad m => a -> m a
return ()
get :: Get SomeException
get = [Char] -> Get SomeException
forall a. HasCallStack => [Char] -> a
error [Char]
"cannot serialise exceptions"
instance Structured SomeException where
structure :: Proxy SomeException -> Structure
structure Proxy SomeException
p = TypeRep -> Word32 -> [Char] -> [Structure] -> Structure
Nominal (Proxy SomeException -> TypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> TypeRep
typeRep Proxy SomeException
p) Word32
0 [Char]
"SomeException" []