From 4f0c515a83c2ca54e5951fed2b7593273821ef2f Mon Sep 17 00:00:00 2001 From: Joe Crayne Date: Tue, 27 Nov 2018 22:40:09 -0500 Subject: Use Data.Functor.Compose from base instead of custom Composed type. --- src/Crypto/Tox.hs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'src/Crypto') diff --git a/src/Crypto/Tox.hs b/src/Crypto/Tox.hs index 4fc87f7c..ad246d4e 100644 --- a/src/Crypto/Tox.hs +++ b/src/Crypto/Tox.hs @@ -10,6 +10,7 @@ {-# LANGUAGE TypeOperators #-} {-# LANGUAGE MagicHash, UnboxedTuples, BangPatterns #-} {-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE PatternSynonyms #-} module Crypto.Tox ( PublicKey , publicKey @@ -24,7 +25,7 @@ module Crypto.Tox , newSecretsCache , Encrypted , Encrypted8(..) - , type (∘)(..) + , type (∘), uncomposed, pattern Composed -- type (∘)(..) , Asymm(..) , getAsymm , getAliasedAsymm @@ -108,6 +109,7 @@ import qualified Data.MinMaxPSQ as MM import Data.Time.Clock.POSIX import Data.Hashable import System.IO.Unsafe (unsafeDupablePerformIO) +import Data.Functor.Compose -- | A 16-byte mac and an arbitrary-length encrypted stream. newtype Encrypted a = Encrypted ByteString @@ -116,9 +118,11 @@ newtype Encrypted a = Encrypted ByteString newtype Encrypted8 a = E8 (Encrypted (a,Nonce8)) deriving (Serialize, Show) -newtype (f ∘ g) x = Composed { uncomposed :: f (g x) } - -infixr ∘ +-- Simulating: newtype (f ∘ g) x = Composed { uncomposed :: f (g x) } +pattern Composed x = Compose x +uncomposed = getCompose +type f ∘ g = f `Compose` g +infixr 9 ∘ newtype Auth = Auth Poly1305.Auth deriving (Eq, ByteArrayAccess) instance Ord Auth where @@ -498,7 +502,6 @@ data Asymm a = Asymm } deriving (Functor,Foldable,Traversable, Show, Eq, Ord) - instance Sized a => Sized (Asymm a) where size = case size of ConstSize a -> ConstSize $ a + 24 + 32 -- cgit v1.2.3