summaryrefslogtreecommitdiff
path: root/haskell/app/Main.hs
blob: 1b2ccecc374a99559fb9bb67a1cdcb666938db69 (plain)
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
{-# LANGUAGE OverloadedStrings #-}

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
  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'
  ships <- runSpaceTradersT listShips env
  case ships of
    Left e -> throwIO e
    Right s' -> print $ s'
  deinitST env