1
Fork 0
solar-conflux/purescript/factorio-throughput/src/Main.purs

35 lines
1.1 KiB
Plaintext
Raw Normal View History

2021-04-01 18:29:27 +02:00
module Main where
import Prelude
import Data.Either (Either(..))
import Data.Tuple (Tuple(..))
import Data.Tuple.Nested ((/\))
import Effect (Effect)
import Effect.Console (log)
2021-04-03 23:37:14 +02:00
import Moontorio.Render (RenderFn, renderFactory)
import RealFunction (PortSide(..), RealFunction, SolveM, collectConstraints, myFactory, runSolveM, tryFindBoundSolveM)
2021-04-01 18:29:27 +02:00
p :: SolveM (Array RealFunction)
p = do
collectConstraints
2021-04-03 23:37:14 +02:00
a <- tryFindBoundSolveM (0 /\ Input)
b <- tryFindBoundSolveM (0 /\ Output)
c <- tryFindBoundSolveM (1 /\ Input)
d <- tryFindBoundSolveM (1 /\ Output)
e <- tryFindBoundSolveM (2 /\ Input)
f <- tryFindBoundSolveM (2 /\ Output)
g <- tryFindBoundSolveM (4 /\ Input)
h <- tryFindBoundSolveM (4 /\ Output)
pure [a, b, c, d, e, f, g, h]
2021-04-01 18:29:27 +02:00
2021-04-03 23:37:14 +02:00
main :: RenderFn -> Effect Unit
main render = do
-- for_ (HashMap.toArrayBy Tuple myFactory) \(Tuple key value) -> log $ show key <> ": " <> show value
2021-04-01 18:29:27 +02:00
case runSolveM myFactory p of
Left err -> log err
Right (Tuple s f) -> do
2021-04-03 23:37:14 +02:00
renderFactory render myFactory s.constraints
-- log $ joinWith "\n" $ show <$> s.constraints
-- logShow $ f <*> pure 0.0