-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTry.hs
41 lines (31 loc) · 950 Bytes
/
Try.hs
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
{-# LANGUAGE TemplateHaskell #-}
module Main where
import NowHs
import NowHsPrim
import Interface
import SchemaTH
import Language.Haskell.TH
import Language.Haskell.TH.Syntax
import Control.Applicative
import Control.Concurrent
import Control.Monad.IO.Class
import Data.Aeson
import Data.Aeson.TH
import Data.Set
data SomeData = SomeData { first :: Int, second :: Int }
$(deriveJSON id ''SomeData)
$(deriveSchema ''SomeData)
-- TODO write test that checks for asynchronousness superforking!
asd :: Int -> Int -> NowHs () Integer
asd i1 i2 = liftIO $ do
let i3 = fromIntegral $ i1 + i2
putStrLn $ show i1 ++ " + " ++ show i2 ++ " = " ++ show i3
let seconds = 1000000
liftIO $ threadDelay (5 * seconds)
return i3
afg :: SomeData -> NowHs () Int
afg d = return $ first d
interface :: Interface ()
interface = $(genInterface [ 'asd
, 'afg])
main = runNowHs "127.0.0.1" 8888 () . nowHs $ interface