on master help sign in
tiny cleanup
da4b071Mark Wotton
src/Roboservant/StateMachine.hs+3−3
@@ -66,7 +66,7 @@ callEndpoint staticRoutes =
66 options :: [(ApiOffset, [[Var (Opaque (IORef Dynamic)) Symbolic]])]
66 options :: [(ApiOffset, [[Var (Opaque (IORef Dynamic)) Symbolic]])]
67 options =
67 options =
68 mapMaybe
68 mapMaybe
69− ( \(offset, argreps, _retType, _dynCall) -> (offset,) <$> do
69+ ( \(offset, (argreps, _retType, _dynCall)) -> (offset,) <$> do
70 mapM fillableWith argreps
70 mapM fillableWith argreps
71 )
71 )
72 staticRoutes
72 staticRoutes
@@ -82,7 +82,7 @@ callEndpoint staticRoutes =
82 execute (Op (ApiOffset offset) args) = do
82 execute (Op (ApiOffset offset) args) = do
83 fmap Opaque . liftIO $ do
83 fmap Opaque . liftIO $ do
84 realArgs <- mapM (readIORef . opaque) args
84 realArgs <- mapM (readIORef . opaque) args
85− let (_offset, _staticArgs, _ret, endpoint) = staticRoutes !! offset
85+ let (_offset, (_staticArgs, _ret, endpoint)) = staticRoutes !! offset
86 -- now, magic happens: we apply some dynamic arguments to a dynamic
86 -- now, magic happens: we apply some dynamic arguments to a dynamic
87 -- function and hopefully something useful pops out the end.
87 -- function and hopefully something useful pops out the end.
88 func = foldr (\arg curr -> flip dynApply arg =<< curr) (Just endpoint) realArgs
88 func = foldr (\arg curr -> flip dynApply arg =<< curr) (Just endpoint) realArgs
@@ -110,7 +110,7 @@ callEndpoint staticRoutes =
110 (Op (ApiOffset offset) _args) ->
110 (Op (ApiOffset offset) _args) ->
111 s
111 s
112 { stateRefs =
112 { stateRefs =
113− let (_, _, tr, _) = staticRoutes !! offset
113+ let (_, (_, tr, _)) = staticRoutes !! offset
114 in Map.insertWith
114 in Map.insertWith
115 (<>)
115 (<>)
116 tr
116 tr
src/Roboservant/Types/ReifiedApi.hs+3−5
@@ -33,7 +33,7 @@ newtype ApiOffset = ApiOffset Int
33
33
34type ReifiedEndpoint = ([TypeRep], TypeRep, Dynamic)
34type ReifiedEndpoint = ([TypeRep], TypeRep, Dynamic)
35
35
36−type ReifiedApi = [(ApiOffset, [TypeRep], TypeRep, Dynamic)]
36+type ReifiedApi = [(ApiOffset, ReifiedEndpoint)]
37
37
38
38
39class ToReifiedApi (endpoints :: [*]) where
39class ToReifiedApi (endpoints :: [*]) where
@@ -50,12 +50,10 @@ instance
50 ToReifiedApi (endpoint : endpoints)
50 ToReifiedApi (endpoint : endpoints)
51 where
51 where
52 toReifiedApi (endpoint `AnEndpoint` endpoints) _ =
52 toReifiedApi (endpoint `AnEndpoint` endpoints) _ =
53− withOffset (toReifiedEndpoint (toDyn (normalize endpoint)) (Proxy @endpoint))
53+ (0,) (toReifiedEndpoint (toDyn (normalize endpoint)) (Proxy @endpoint))
54 : map
54 : map
55− (\(n, x, y, z) -> (n + 1, x, y, z))
55+ (\(n, x) -> (n + 1, x))
56 (toReifiedApi endpoints (Proxy @endpoints))
56 (toReifiedApi endpoints (Proxy @endpoints))
57− where
58− withOffset (x, y, z) = (0, x, y, z)
59
57
60class NormalizeFunction m where
58class NormalizeFunction m where
61 type Normal m
59 type Normal m