[haskell] Refactored everything with a ReaderT pattern
This commit is contained in:
parent
9f75243ada
commit
4af96da567
14 changed files with 213 additions and 119 deletions
|
@ -3,19 +3,34 @@
|
|||
module Main (main) where
|
||||
|
||||
import Control.Exception
|
||||
import System.Environment
|
||||
import System.Posix.Process
|
||||
|
||||
import SpaceTraders
|
||||
import SpaceTraders.Automation.Init
|
||||
import SpaceTraders.APIClient.Agent(myAgent)
|
||||
import SpaceTraders.APIClient.Client
|
||||
import SpaceTraders.APIClient.Ships
|
||||
import SpaceTraders.APIClient.Systems
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
config <- initST
|
||||
ma <- runSpaceTradersT myAgent config
|
||||
print ma
|
||||
s <- listSystems (token config) (conn config)
|
||||
env <- initST
|
||||
ma <- runSpaceTradersT myAgent env
|
||||
case ma of
|
||||
Left (APIResetHappened _) -> do
|
||||
p <- getExecutablePath
|
||||
a <- getArgs
|
||||
e <- getEnvironment
|
||||
executeFile p False a (Just e)
|
||||
Left e -> throwIO e
|
||||
Right ma' -> print ma'
|
||||
s <- runSpaceTradersT listSystems env
|
||||
case s of
|
||||
Left e -> throwIO e
|
||||
Right s' -> print $ length s'
|
||||
deinitST config
|
||||
ships <- runSpaceTradersT listShips env
|
||||
case ships of
|
||||
Left e -> throwIO e
|
||||
Right s' -> print $ s'
|
||||
deinitST env
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue