-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtmp.hs
More file actions
76 lines (51 loc) · 2.21 KB
/
tmp.hs
File metadata and controls
76 lines (51 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
{-# LANGUAGE DeriveGeneric, ExistentialQuantification, MultiParamTypeClasses, OverlappingInstances, FlexibleInstances, UndecidableInstances, TypeFamilies, DataKinds, PolyKinds, EmptyDataDecls, FunctionalDependencies, ScopedTypeVariables, GeneralizedNewtypeDeriving, ConstraintKinds #-}
module Tmp where
import JSON hiding (Proxy)
import Data.Dynamic
import qualified Data.Aeson as Aeson
import qualified Data.Set as Set
import qualified Data.IntMap as Map
import Control.Monad.State
import Control.Monad.Error
import Internal.Internal
type FunctionName = String
data NowHs a b
data Function
data AnySchema
-- asyncClient :: Client a -> Server ()
-- syncClient :: Client a -> Server a
-- doClientAdd :: (Int -> Int -> Client Int) -> Server Int
-- doClientAdd clAdd = syncClient (clAdd 1 2)
-- handleAddResult :: Int -> Server ()
-- doClientAsyncAdd :: (Int -> Int -> (Int -> Server ()) -> Client ()) -> Server ()
-- doClientAsyncAdd clAdd = asyncClient $ clAdd 1 2 handleAddResult
data Proxy k = Proxy
class Schema a
data Interface s
= Interface { interfaceInternal :: (FunctionName, [Aeson.Value]) -> NowHs s Aeson.Value
, interfaceExternal :: ([Function], Set.Set AnySchema) }
hey :: Int -> Int -> Server Int
hey a b = return (a + b)
lol :: (Int -> Int -> Server Int) -> Server Int
lol f = f 1 2
hah :: ((Int -> Int -> Server Int) -> Server Int) -> Server Int
hah f = f hey
lal :: (((Int -> Server Int) -> Server Int) -> Server Int) -> Server Int
lal = lal
whatever :: (Int -> Client Int) -> Server Int
whatever = undefined
whatever2 :: Server Int
whatever2 = undefined
main :: IO ()
main = do
let internalState = InternalState (Map.fromList [ (0, ServerFunCall hey)
, (1, ServerFunCall hah)
, (2, ServerFunCall whatever)])
print . flip evalState internalState . runErrorT . unInternal $ do
callServer lol [toJSON (0 :: Int)]
-- data ServerFunCxt cxt = forall a. cxt a => ServerFunCxt a
-- type ServerFunDyn = ServerFunCxt ServerCallDyn
data CallContext
= CallContext { inArguments :: [Aeson.Value]
, clientArgs :: [Aeson.Value]
, serverArgs :: [Dynamic] }