Skip to content

Commit bb9bc17

Browse files
committed
server: -funroll-gadt
1 parent 960407b commit bb9bc17

File tree

1 file changed

+34
-28
lines changed
  • hnix-store-remote/src/System/Nix/Store/Remote

1 file changed

+34
-28
lines changed

hnix-store-remote/src/System/Nix/Store/Remote/Server.hs

Lines changed: 34 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import Control.Monad.IO.Class (MonadIO, liftIO)
1515
import Data.Default.Class (Default(def))
1616
import Data.Foldable (traverse_)
1717
import Data.IORef (IORef, atomicModifyIORef, newIORef)
18-
import Data.Some (Some(Some))
18+
--import Data.Some (Some(Some))
1919
import Data.Text (Text)
2020
import Data.Void (Void, absurd)
2121
import Data.Word (Word32)
@@ -33,8 +33,7 @@ import System.Nix.Store.Remote.Types.Handshake (ServerHandshakeInput(..), Server
3333
import System.Nix.Store.Remote.Types.WorkerMagic (WorkerMagic(..))
3434

3535
-- wip
36-
-- import Data.Some (traverseSome)
37-
import Data.Functor.Identity
36+
import Data.Some (withSome)
3837

3938
type WorkerHelper m
4039
= forall a
@@ -107,7 +106,7 @@ processConnection workerHelper sock = do
107106
, StoreReply a
108107
)
109108
=> StoreRequest a
110-
-> RemoteStoreT m (Identity a)
109+
-> RemoteStoreT m ()
111110
perform req = do
112111
resp <- bracketLogger tunnelLogger $ lift $ workerHelper req
113112
sockPutS
@@ -116,7 +115,6 @@ processConnection workerHelper sock = do
116115
$ getReplyS
117116
)
118117
resp
119-
pure (Identity resp)
120118

121119
-- Process client requests.
122120
let loop = do
@@ -126,26 +124,34 @@ processConnection workerHelper sock = do
126124
RemoteStoreError_SerializerRequest
127125
storeRequest
128126

129-
-- • Could not deduce (Show a) arising from a use of ‘perform’
130-
-- and also (StoreReply a)
131-
-- traverseSome perform someReq
132-
void $ do
133-
case someReq of
134-
Some req@(IsValidPath {}) -> do
135-
-- • Couldn't match type ‘a0’ with ‘Bool’
136-
-- Expected: StoreRequest a0
137-
-- Actual: StoreRequest a
138-
-- • ‘a0’ is untouchable
139-
-- inside the constraints: a ~ Bool
140-
-- bound by a pattern with constructor:
141-
-- IsValidPath :: StorePath -> StoreRequest Bool
142-
-- runIdentity <$> perform req
143-
144-
void $ perform req
145-
pure undefined
146-
147-
_ -> throwError unimplemented
148-
127+
-- have to be explicit here
128+
-- because otherwise GHC can't conjure Show a, StoreReply a
129+
-- out of thin air
130+
() <- withSome someReq $ \case
131+
r@AddToStore {} -> perform r
132+
r@AddTextToStore {} -> perform r
133+
r@AddSignatures {} -> perform r
134+
r@AddTempRoot {} -> perform r
135+
r@AddIndirectRoot {} -> perform r
136+
r@BuildDerivation {} -> perform r
137+
r@BuildPaths {} -> perform r
138+
r@CollectGarbage {} -> perform r
139+
r@EnsurePath {} -> perform r
140+
r@FindRoots {} -> perform r
141+
r@IsValidPath {} -> perform r
142+
r@QueryValidPaths {} -> perform r
143+
r@QueryAllValidPaths {} -> perform r
144+
r@QuerySubstitutablePaths {} -> perform r
145+
r@QueryPathInfo {} -> perform r
146+
r@QueryReferrers {} -> perform r
147+
r@QueryValidDerivers {} -> perform r
148+
r@QueryDerivationOutputs {} -> perform r
149+
r@QueryDerivationOutputNames {} -> perform r
150+
r@QueryPathFromHashPart {} -> perform r
151+
r@QueryMissing {} -> perform r
152+
r@OptimiseStore {} -> perform r
153+
r@SyncWithGC {} -> perform r
154+
r@VerifyStore {} -> perform r
149155
loop
150156
loop
151157

@@ -223,9 +229,9 @@ processConnection workerHelper sock = do
223229
, serverHandshakeOutputClientVersion = clientVersion
224230
}
225231

226-
{-# WARNING unimplemented "not yet implemented" #-}
227-
unimplemented :: RemoteStoreError
228-
unimplemented = RemoteStoreError_WorkerException $ WorkerException_Error $ WorkerError_NotYetImplemented
232+
{-# WARNING _unimplemented "not yet implemented" #-}
233+
_unimplemented :: RemoteStoreError
234+
_unimplemented = RemoteStoreError_WorkerException $ WorkerException_Error $ WorkerError_NotYetImplemented
229235

230236
bracketLogger
231237
:: MonadRemoteStore m

0 commit comments

Comments
 (0)