From 283eacd9a552b2473e39ebeb40915e9e5f104869 Mon Sep 17 00:00:00 2001 From: Evgeny Poberezkin <2769109+epoberezkin@users.noreply.github.com> Date: Fri, 10 Jul 2020 14:50:52 +0100 Subject: [PATCH] stricter Enabled --- definitions/package.yaml | 1 + definitions/src/Simplex/Messaging/Protocol.hs | 11 ++++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/definitions/package.yaml b/definitions/package.yaml index f858a433d2..bebd528553 100644 --- a/definitions/package.yaml +++ b/definitions/package.yaml @@ -17,6 +17,7 @@ ghc-options: - -Wredundant-constraints - -Wincomplete-record-updates - -Wincomplete-uni-patterns + - -Wunused-type-patterns dependencies: - aeson diff --git a/definitions/src/Simplex/Messaging/Protocol.hs b/definitions/src/Simplex/Messaging/Protocol.hs index ecc677dff3..b9a108938e 100644 --- a/definitions/src/Simplex/Messaging/Protocol.hs +++ b/definitions/src/Simplex/Messaging/Protocol.hs @@ -45,7 +45,7 @@ $( singletons ) type family HasState (p :: Party) (s :: ConnState) :: Constraint where - HasState Recipient s = () + HasState Recipient _ = () HasState Broker None = () HasState Broker New = () HasState Broker Secured = () @@ -55,10 +55,11 @@ type family HasState (p :: Party) (s :: ConnState) :: Constraint where HasState Sender Confirmed = () HasState Sender Secured = () -type Enabled rs bs = - ( (rs == New || rs == Pending || rs == Confirmed || rs == Secured) ~ True, - (bs == New || bs == Secured) ~ True - ) +type family Enabled (rs :: ConnState) (bs :: ConnState) :: Constraint where + Enabled New New = () + Enabled Pending New = () + Enabled Confirmed New = () + Enabled Secured Secured = () type PartyCmd = (Party, ConnState, ConnState)