-- |
-- Module      :  TLynx.TLynx
-- Description :  TLynx module
-- Copyright   :  (c) Dominik Schrempf 2021
-- License     :  GPL-3.0-or-later
--
-- Maintainer  :  dominik.schrempf@gmail.com
-- Stability   :  unstable
-- Portability :  portable
--
-- Creation date: Thu Apr 23 16:36:43 2020.
module TLynx.TLynx
  ( tlynx,
    rTLynx,
  )
where

import ELynx.Tools
import TLynx.Compare.Compare
import TLynx.Connect.Connect
import TLynx.Distance.Distance
import TLynx.Examine.Examine
import TLynx.Options
import TLynx.Shuffle.Shuffle
import TLynx.Simulate.Simulate

-- | Run TLynx with given arguments.
tlynx :: Arguments CommandArguments -> IO ()
tlynx :: Arguments CommandArguments -> IO ()
tlynx Arguments CommandArguments
c = case Arguments CommandArguments -> CommandArguments
forall a. Arguments a -> a
local Arguments CommandArguments
c of
  Compare CompareArguments
l -> GlobalArguments
-> CompareArguments
-> (CompareArguments -> CommandArguments)
-> ELynx CompareArguments ()
-> IO ()
forall a b.
(Eq a, Show a, Reproducible a, Reproducible b, ToJSON a) =>
GlobalArguments -> b -> (b -> a) -> ELynx b () -> IO ()
eLynxWrapper GlobalArguments
g CompareArguments
l CompareArguments -> CommandArguments
Compare ELynx CompareArguments ()
compareCmd
  Connect ConnectArguments
l -> GlobalArguments
-> ConnectArguments
-> (ConnectArguments -> CommandArguments)
-> ELynx ConnectArguments ()
-> IO ()
forall a b.
(Eq a, Show a, Reproducible a, Reproducible b, ToJSON a) =>
GlobalArguments -> b -> (b -> a) -> ELynx b () -> IO ()
eLynxWrapper GlobalArguments
g ConnectArguments
l ConnectArguments -> CommandArguments
Connect ELynx ConnectArguments ()
connectCmd
  Distance DistanceArguments
l -> GlobalArguments
-> DistanceArguments
-> (DistanceArguments -> CommandArguments)
-> ELynx DistanceArguments ()
-> IO ()
forall a b.
(Eq a, Show a, Reproducible a, Reproducible b, ToJSON a) =>
GlobalArguments -> b -> (b -> a) -> ELynx b () -> IO ()
eLynxWrapper GlobalArguments
g DistanceArguments
l DistanceArguments -> CommandArguments
Distance ELynx DistanceArguments ()
distance
  Examine ExamineArguments
l -> GlobalArguments
-> ExamineArguments
-> (ExamineArguments -> CommandArguments)
-> ELynx ExamineArguments ()
-> IO ()
forall a b.
(Eq a, Show a, Reproducible a, Reproducible b, ToJSON a) =>
GlobalArguments -> b -> (b -> a) -> ELynx b () -> IO ()
eLynxWrapper GlobalArguments
g ExamineArguments
l ExamineArguments -> CommandArguments
Examine ELynx ExamineArguments ()
examine
  Shuffle ShuffleArguments
l -> GlobalArguments
-> ShuffleArguments
-> (ShuffleArguments -> CommandArguments)
-> ELynx ShuffleArguments ()
-> IO ()
forall a b.
(Eq a, Show a, Reproducible a, Reproducible b, ToJSON a) =>
GlobalArguments -> b -> (b -> a) -> ELynx b () -> IO ()
eLynxWrapper GlobalArguments
g ShuffleArguments
l ShuffleArguments -> CommandArguments
Shuffle ELynx ShuffleArguments ()
shuffleCmd
  Simulate SimulateArguments
l -> GlobalArguments
-> SimulateArguments
-> (SimulateArguments -> CommandArguments)
-> ELynx SimulateArguments ()
-> IO ()
forall a b.
(Eq a, Show a, Reproducible a, Reproducible b, ToJSON a) =>
GlobalArguments -> b -> (b -> a) -> ELynx b () -> IO ()
eLynxWrapper GlobalArguments
g SimulateArguments
l SimulateArguments -> CommandArguments
Simulate ELynx SimulateArguments ()
simulate
  where
    g :: GlobalArguments
g = Arguments CommandArguments -> GlobalArguments
forall a. Arguments a -> GlobalArguments
global Arguments CommandArguments
c

-- | Run TLynx, parse arguments from command line.
rTLynx :: IO ()
rTLynx :: IO ()
rTLynx = IO (Arguments CommandArguments)
forall a. Reproducible a => IO (Arguments a)
parseArguments IO (Arguments CommandArguments)
-> (Arguments CommandArguments -> IO ()) -> IO ()
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= Arguments CommandArguments -> IO ()
tlynx