Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
08ee7c4
typed-protocols: new API
coot Jul 25, 2024
81f2fbe
typed-protocols: Peer pattern synonyms
coot Jul 25, 2024
fe36759
typed-protocols-examples: updated
coot Jul 25, 2024
88d246f
typed-protocols: ActiveAgency
coot Sep 6, 2021
b121a80
typed-protocols: simplify runPeerWithDriver
coot Mar 27, 2022
bdf8100
typed-protocols: internal lemmas module
coot May 23, 2022
564da48
typed-protocols: provide ReflRelativeAgency type aliases
coot Jul 13, 2022
6f5ce41
typed-protocols-examples: socketAsChannel
coot Sep 4, 2021
c69993a
typed-protocols-examples: ReqResp2 example
coot Sep 17, 2021
e4bcf98
typed-protocols-examples: Wedge
coot Sep 18, 2021
86d007a
typed-protocols-examples: requestOnce
coot Sep 28, 2021
b4070d4
typed-protocols-examples: fixed cborg tests
coot Oct 2, 2021
74a64f2
typed-protocols-examples: pipelined tests
coot Oct 2, 2021
5ef5f2d
typed-protocols-examples: unbounded buffered channel
coot Mar 27, 2022
ce833a9
typed-protocols-examples: added runConnectedPeersAsymetric
coot Mar 27, 2022
1ca4aa7
typed-protocols: simplify evidence of termination in a terminal state
coot May 13, 2022
558a9fc
typed-protocols: added StateToken type family to Protocol type class
coot Jun 23, 2022
03270e4
typed-protocols: renamed Pipelined kind to IsPipelined
coot Jul 13, 2022
6b6118d
typed-protocols: added AnyMessageAndAgency pattern synonym
coot Sep 8, 2023
abecdaf
typed-protocols: added application specific singletons for protocol s…
coot Sep 26, 2023
a81caa1
typed-protocols-examples: relaxed constraint in PingPong client
coot Jul 1, 2022
166f5af
typed-protocols-examples: fixed a socket test on macos
coot Aug 17, 2022
f5ccedd
typed-protocols: bump version to `0.2.0.0`
coot Aug 25, 2023
148a91b
Added CHANGELOG and bumped versions of the packages
coot May 17, 2022
6c6a8ce
typed-protocols: moved outstanding counter into IsPipelined kind
coot Jul 23, 2024
d2f1e74
typed-protocols-stateful: non-pipelined stateful Peer
coot Jul 24, 2024
0d9cb77
typed-protocols: moved types to `Core` module
coot Jul 24, 2024
5ec9a8c
typed-protocols: connectPipelined type signature
coot Jul 24, 2024
8d31814
typed-protocols: added PeerPipelined newtype wrapper
coot Jul 24, 2024
b3ba779
Support io-classes-1.7
coot Jul 26, 2024
b23f327
typed-protocols: added haddocks
coot Aug 19, 2024
72a799c
disabled `typed-protocols-doc` in GHA
coot Aug 22, 2024
5cf79f3
stylish-haskell: fixes
coot Aug 22, 2024
b9e71bb
typed-protocols: removed unused extensions
coot Aug 23, 2024
20aa2fe
Improved haddocks, removed unused pragmas (extensions)
coot Aug 23, 2024
bdcf30a
Core module cannot be checked with stylish-haskell
coot Aug 23, 2024
0042b72
Removed Stateful PingPong example
coot Sep 4, 2024
b195c92
Stateful RPC example
coot Sep 5, 2024
f451040
typed-protocols: fixed typos
coot Sep 14, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
typed-protocols: simplify evidence of termination in a terminal state
The simplest solution seem to add `StateAgency st ~ NobodyAgency` to the
`Done` constructor.  Which can be carried over to `TerminalStates`.
  • Loading branch information
coot committed Sep 16, 2024
commit 1ca4aa7597d71720d924645917891c90ea4be5a7
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ module Network.TypedProtocol.PingPong.Tests

import Network.TypedProtocol.Channel
import Network.TypedProtocol.Codec
import Network.TypedProtocol.Core
import Network.TypedProtocol.Driver.Simple
import Network.TypedProtocol.Proofs

Expand Down Expand Up @@ -196,11 +195,7 @@ prop_connect (NonNegative n) =
(pingPongClientPeer (pingPongClientCount n))
(pingPongServerPeer pingPongServerCount))

of ((), n', TerminalStates SingDone
ReflNobodyAgency
SingDone
ReflNobodyAgency) ->
n == n'
of ((), n', TerminalStates SingDone SingDone) -> n == n'


--
Expand All @@ -219,11 +214,7 @@ connect_pipelined client cs =
(connectPipelined cs []
(pingPongClientPeerPipelined client)
(promoteToPipelined $ pingPongServerPeer pingPongServerCount))

of (reqResps, n, TerminalStates SingDone
ReflNobodyAgency
SingDone
ReflNobodyAgency) ->
of (reqResps, n, TerminalStates SingDone SingDone) ->
(n, reqResps)


Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneKindSignatures #-}
{-# LANGUAGE TupleSections #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeOperators #-}

-- orphaned arbitrary instances
{-# OPTIONS_GHC -Wno-orphans #-}
Expand All @@ -19,7 +15,6 @@ module Network.TypedProtocol.ReqResp.Tests (tests) where

import Network.TypedProtocol.Channel
import Network.TypedProtocol.Codec
import Network.TypedProtocol.Core
import Network.TypedProtocol.Driver.Simple
import Network.TypedProtocol.Proofs

Expand Down Expand Up @@ -163,10 +158,7 @@ prop_connect f xs =
(reqRespClientPeer (reqRespClientMap xs))
(reqRespServerPeer (reqRespServerMapAccumL (\a -> pure . f a) 0)))

of (c, s, TerminalStates SingDone
ReflNobodyAgency
SingDone
ReflNobodyAgency) ->
of (c, s, TerminalStates SingDone SingDone) ->
(s, c) == mapAccumL f 0 xs


Expand All @@ -178,10 +170,7 @@ prop_connectPipelined cs f xs =
(promoteToPipelined $ reqRespServerPeer
(reqRespServerMapAccumL (\a -> pure . f a) 0)))

of (c, s, TerminalStates SingDone
ReflNobodyAgency
SingDone
ReflNobodyAgency) ->
of (c, s, TerminalStates SingDone SingDone) ->
(s, c) == mapAccumL f 0 xs


Expand Down
4 changes: 3 additions & 1 deletion typed-protocols/src/Network/TypedProtocol/Peer.hs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,9 @@ data Peer ps pr pl n st m a where
--
Done
:: forall ps pr pl (st :: ps) m a.
SingI st
( SingI st
, StateAgency st ~ NobodyAgency
)
=> NobodyHasAgencyProof pr st
-- ^ (no) agency proof
-> a
Expand Down
32 changes: 14 additions & 18 deletions typed-protocols/src/Network/TypedProtocol/Proofs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}


-- This is already implied by the -Wall in the .cabal file, but lets just be
Expand Down Expand Up @@ -82,7 +83,7 @@ connect
(Monad m, SingI pr)
=> Peer ps pr NonPipelined Z initSt m a
-> Peer ps (FlipAgency pr) NonPipelined Z initSt m b
-> m (a, b, TerminalStates ps pr)
-> m (a, b, TerminalStates ps)
connect = go
where
singPeerRole :: Sing pr
Expand All @@ -91,14 +92,14 @@ connect = go
go :: forall (st :: ps).
Peer ps pr NonPipelined Z st m a
-> Peer ps (FlipAgency pr) NonPipelined Z st m b
-> m (a, b, TerminalStates ps pr)
go (Done reflA a) (Done reflB b) = return (a, b, terminals)
-> m (a, b, TerminalStates ps)
go (Done ReflNobodyAgency a) (Done ReflNobodyAgency b) =
return (a, b, terminals)
where
terminals :: TerminalStates ps pr
terminals :: TerminalStates ps
terminals = TerminalStates (sing :: Sing st)
reflA
(sing :: Sing st)
reflB

go (Effect a ) b = a >>= \a' -> go a' b
go a (Effect b) = b >>= \b' -> go a b'
go (Yield _ msg a) (Await _ b) = go a (b msg)
Expand Down Expand Up @@ -134,18 +135,13 @@ connect = go
-- | The terminal states for the protocol. Used in 'connect' and
-- 'connectPipelined' to return the states in which the peers terminated.
--
data TerminalStates ps (pr :: PeerRole) where
data TerminalStates ps where
TerminalStates
:: forall ps pr (st :: ps) (st' :: ps).
Sing st
-> ReflRelativeAgency (StateAgency st)
NobodyHasAgency
(Relative pr (StateAgency st))
-> Sing st'
-> ReflRelativeAgency (StateAgency st')
NobodyHasAgency
(Relative (FlipAgency pr) (StateAgency st'))
-> TerminalStates ps pr
:: forall ps (st :: ps).
(StateAgency st ~ NobodyAgency)
=> Sing st
-> Sing st
-> TerminalStates ps

--
-- Remove Pipelining
Expand Down Expand Up @@ -248,7 +244,7 @@ connectPipelined
-> [Bool]
-> Peer ps pr ('Pipelined c) Z st m a
-> Peer ps (FlipAgency pr) ('Pipelined c') Z st m b
-> m (a, b, TerminalStates ps pr)
-> m (a, b, TerminalStates ps)
connectPipelined csA csB a b =
connect (forgetPipelined csA a)
(forgetPipelined csB b)
Expand Down