{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE PatternSynonyms #-}
{-# OPTIONS_GHC -Wall -fno-warn-tabs #-}

module Control.Moffy.Samples.Followbox.Run.Gtk3 (
	runFollowbox, runFollowbox' ) where

import Prelude hiding (break)

import Control.Arrow
import Control.Monad
import Control.Moffy
import Control.Moffy.Samples.Event.Delete
import Control.Moffy.Samples.Event.CalcTextExtents
import Control.Moffy.Samples.Handle.TChan
import Control.Moffy.Samples.Run.TChan
import Control.Concurrent
import Control.Concurrent.STM
import Data.Type.Set ((:-), (:+:), pattern Nil)
import Data.Type.Flip
import Data.Color
import System.Random

import Control.Moffy.Samples.Followbox.Event
import Control.Moffy.Samples.Followbox.Handle
import Control.Moffy.Samples.Followbox.TypeSynonym

import Control.Moffy.Samples.Run.Gtk3

import Control.Moffy.Samples.View

import Control.Moffy.Samples.Followbox.ViewType qualified as T
import Control.Moffy.Samples.Viewable.Text
import Control.Moffy.Samples.Viewable.Image
import Control.Moffy.Samples.Viewable.Shape
import Data.OneOfThem

import Data.Map qualified as M
import Control.Moffy.Samples.Event.Area qualified as A

runFollowbox :: String -> Sig s FollowboxEv T.View () -> IO ()
runFollowbox :: forall s. String -> Sig s FollowboxEv View () -> IO ()
runFollowbox String
brws Sig s FollowboxEv View ()
sig = String
-> Maybe GithubNameToken -> Sig s FollowboxEv View () -> IO ()
forall s.
String
-> Maybe GithubNameToken -> Sig s FollowboxEv View () -> IO ()
runFollowbox_ String
brws Maybe GithubNameToken
forall a. Maybe a
Nothing (Sig
   s
   (Browse
    ':~ (StoreRandomGen
         ':~ (Move
              ':~ (EndSleep
                   ':~ (Down
                        ':~ (Up
                             ':~ (Unlock
                                  ':~ (NewLockId
                                       ':~ (GetLock
                                            ':~ (GetArea
                                                 ':~ (CalcTextExtents
                                                      ':~ (DeleteEvent
                                                           ':~ (LoadRandomGen
                                                                ':~ (GetThreadId
                                                                     ':~ (HttpGet
                                                                          ':~ (RaiseError
                                                                               ':~ (StoreJsons
                                                                                    ':~ (SetArea
                                                                                         ':~ (LoadJsons
                                                                                              ':~ (GetTimeZone
                                                                                                   ':~ (BeginSleep
                                                                                                        ':~ 'Nil)))))))))))))))))))))
   View
   ()
 -> IO ())
-> (Sig
      s
      (Browse
       ':~ (StoreRandomGen
            ':~ (Move
                 ':~ (EndSleep
                      ':~ (Down
                           ':~ (Up
                                ':~ (Unlock
                                     ':~ (NewLockId
                                          ':~ (GetLock
                                               ':~ (GetArea
                                                    ':~ (CalcTextExtents
                                                         ':~ (DeleteEvent
                                                              ':~ (LoadRandomGen
                                                                   ':~ (GetThreadId
                                                                        ':~ (HttpGet
                                                                             ':~ (RaiseError
                                                                                  ':~ (StoreJsons
                                                                                       ':~ (SetArea
                                                                                            ':~ (LoadJsons
                                                                                                 ':~ (GetTimeZone
                                                                                                      ':~ (BeginSleep
                                                                                                           ':~ 'Nil)))))))))))))))))))))
      View
      (Either (Either () (Maybe View, ())) (Maybe View, ()))
    -> Sig
         s
         (Browse
          ':~ (StoreRandomGen
               ':~ (Move
                    ':~ (EndSleep
                         ':~ (Down
                              ':~ (Up
                                   ':~ (Unlock
                                        ':~ (NewLockId
                                             ':~ (GetLock
                                                  ':~ (GetArea
                                                       ':~ (CalcTextExtents
                                                            ':~ (DeleteEvent
                                                                 ':~ (LoadRandomGen
                                                                      ':~ (GetThreadId
                                                                           ':~ (HttpGet
                                                                                ':~ (RaiseError
                                                                                     ':~ (StoreJsons
                                                                                          ':~ (SetArea
                                                                                               ':~ (LoadJsons
                                                                                                    ':~ (GetTimeZone
                                                                                                         ':~ (BeginSleep
                                                                                                              ':~ 'Nil)))))))))))))))))))))
         View
         ())
-> Sig
     s
     (Browse
      ':~ (StoreRandomGen
           ':~ (Move
                ':~ (EndSleep
                     ':~ (Down
                          ':~ (Up
                               ':~ (Unlock
                                    ':~ (NewLockId
                                         ':~ (GetLock
                                              ':~ (GetArea
                                                   ':~ (CalcTextExtents
                                                        ':~ (DeleteEvent
                                                             ':~ (LoadRandomGen
                                                                  ':~ (GetThreadId
                                                                       ':~ (HttpGet
                                                                            ':~ (RaiseError
                                                                                 ':~ (StoreJsons
                                                                                      ':~ (SetArea
                                                                                           ':~ (LoadJsons
                                                                                                ':~ (GetTimeZone
                                                                                                     ':~ (BeginSleep
                                                                                                          ':~ 'Nil)))))))))))))))))))))
     View
     (Either (Either () (Maybe View, ())) (Maybe View, ()))
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Sig
  s
  (Browse
   ':~ (StoreRandomGen
        ':~ (Move
             ':~ (EndSleep
                  ':~ (Down
                       ':~ (Up
                            ':~ (Unlock
                                 ':~ (NewLockId
                                      ':~ (GetLock
                                           ':~ (GetArea
                                                ':~ (CalcTextExtents
                                                     ':~ (DeleteEvent
                                                          ':~ (LoadRandomGen
                                                               ':~ (GetThreadId
                                                                    ':~ (HttpGet
                                                                         ':~ (RaiseError
                                                                              ':~ (StoreJsons
                                                                                   ':~ (SetArea
                                                                                        ':~ (LoadJsons
                                                                                             ':~ (GetTimeZone
                                                                                                  ':~ (BeginSleep
                                                                                                       ':~ 'Nil)))))))))))))))))))))
  View
  (Either (Either () (Maybe View, ())) (Maybe View, ()))
-> Sig
     s
     (Browse
      ':~ (StoreRandomGen
           ':~ (Move
                ':~ (EndSleep
                     ':~ (Down
                          ':~ (Up
                               ':~ (Unlock
                                    ':~ (NewLockId
                                         ':~ (GetLock
                                              ':~ (GetArea
                                                   ':~ (CalcTextExtents
                                                        ':~ (DeleteEvent
                                                             ':~ (LoadRandomGen
                                                                  ':~ (GetThreadId
                                                                       ':~ (HttpGet
                                                                            ':~ (RaiseError
                                                                                 ':~ (StoreJsons
                                                                                      ':~ (SetArea
                                                                                           ':~ (LoadJsons
                                                                                                ':~ (GetTimeZone
                                                                                                     ':~ (BeginSleep
                                                                                                          ':~ 'Nil)))))))))))))))))))))
     View
     ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void
	(Sig
   s
   (Browse
    ':~ (StoreRandomGen
         ':~ (Move
              ':~ (EndSleep
                   ':~ (Down
                        ':~ (Up
                             ':~ (Unlock
                                  ':~ (NewLockId
                                       ':~ (GetLock
                                            ':~ (GetArea
                                                 ':~ (CalcTextExtents
                                                      ':~ (DeleteEvent
                                                           ':~ (LoadRandomGen
                                                                ':~ (GetThreadId
                                                                     ':~ (HttpGet
                                                                          ':~ (RaiseError
                                                                               ':~ (StoreJsons
                                                                                    ':~ (SetArea
                                                                                         ':~ (LoadJsons
                                                                                              ':~ (GetTimeZone
                                                                                                   ':~ (BeginSleep
                                                                                                        ':~ 'Nil)))))))))))))))))))))
   View
   (Either (Either () (Maybe View, ())) (Maybe View, ()))
 -> IO ())
-> Sig
     s
     (Browse
      ':~ (StoreRandomGen
           ':~ (Move
                ':~ (EndSleep
                     ':~ (Down
                          ':~ (Up
                               ':~ (Unlock
                                    ':~ (NewLockId
                                         ':~ (GetLock
                                              ':~ (GetArea
                                                   ':~ (CalcTextExtents
                                                        ':~ (DeleteEvent
                                                             ':~ (LoadRandomGen
                                                                  ':~ (GetThreadId
                                                                       ':~ (HttpGet
                                                                            ':~ (RaiseError
                                                                                 ':~ (StoreJsons
                                                                                      ':~ (SetArea
                                                                                           ':~ (LoadJsons
                                                                                                ':~ (GetTimeZone
                                                                                                     ':~ (BeginSleep
                                                                                                          ':~ 'Nil)))))))))))))))))))))
     View
     (Either (Either () (Maybe View, ())) (Maybe View, ()))
-> IO ()
forall a b. (a -> b) -> a -> b
$ View -> View
viewToView (View -> View)
-> Sig
     s
     (Browse
      ':~ (StoreRandomGen
           ':~ (Move
                ':~ (EndSleep
                     ':~ (Down
                          ':~ (Up
                               ':~ (Unlock
                                    ':~ (NewLockId
                                         ':~ (GetLock
                                              ':~ (GetArea
                                                   ':~ (CalcTextExtents
                                                        ':~ (DeleteEvent
                                                             ':~ (LoadRandomGen
                                                                  ':~ (GetThreadId
                                                                       ':~ (HttpGet
                                                                            ':~ (RaiseError
                                                                                 ':~ (StoreJsons
                                                                                      ':~ (SetArea
                                                                                           ':~ (LoadJsons
                                                                                                ':~ (GetTimeZone
                                                                                                     ':~ (BeginSleep
                                                                                                          ':~ 'Nil)))))))))))))))))))))
     View
     (Either (Either () (Maybe View, ())) (Maybe View, ()))
-> Sig
     s
     (Browse
      ':~ (StoreRandomGen
           ':~ (Move
                ':~ (EndSleep
                     ':~ (Down
                          ':~ (Up
                               ':~ (Unlock
                                    ':~ (NewLockId
                                         ':~ (GetLock
                                              ':~ (GetArea
                                                   ':~ (CalcTextExtents
                                                        ':~ (DeleteEvent
                                                             ':~ (LoadRandomGen
                                                                  ':~ (GetThreadId
                                                                       ':~ (HttpGet
                                                                            ':~ (RaiseError
                                                                                 ':~ (StoreJsons
                                                                                      ':~ (SetArea
                                                                                           ':~ (LoadJsons
                                                                                                ':~ (GetTimeZone
                                                                                                     ':~ (BeginSleep
                                                                                                          ':~ 'Nil)))))))))))))))))))))
     View
     (Either (Either () (Maybe View, ())) (Maybe View, ()))
forall (t :: * -> * -> *) c a b.
Functor (Flip t c) =>
(a -> b) -> t a c -> t b c
<$%> Sig s FollowboxEv View ()
Sig
  s
  (Browse
   ':~ (StoreRandomGen
        ':~ (Move
             ':~ (EndSleep
                  ':~ (Down
                       ':~ (Up
                            ':~ (Unlock
                                 ':~ (NewLockId
                                      ':~ (GetLock
                                           ':~ (GetArea
                                                ':~ (CalcTextExtents
                                                     ':~ (DeleteEvent
                                                          ':~ (LoadRandomGen
                                                               ':~ (GetThreadId
                                                                    ':~ (HttpGet
                                                                         ':~ (RaiseError
                                                                              ':~ (StoreJsons
                                                                                   ':~ (SetArea
                                                                                        ':~ (LoadJsons
                                                                                             ':~ (GetTimeZone
                                                                                                  ':~ (BeginSleep
                                                                                                       ':~ 'Nil)))))))))))))))))))))
  View
  ()
sig Sig
  s
  (Browse
   ':~ (StoreRandomGen
        ':~ (Move
             ':~ (EndSleep
                  ':~ (Down
                       ':~ (Up
                            ':~ (Unlock
                                 ':~ (NewLockId
                                      ':~ (GetLock
                                           ':~ (GetArea
                                                ':~ (CalcTextExtents
                                                     ':~ (DeleteEvent
                                                          ':~ (LoadRandomGen
                                                               ':~ (GetThreadId
                                                                    ':~ (HttpGet
                                                                         ':~ (RaiseError
                                                                              ':~ (StoreJsons
                                                                                   ':~ (SetArea
                                                                                        ':~ (LoadJsons
                                                                                             ':~ (GetTimeZone
                                                                                                  ':~ (BeginSleep
                                                                                                       ':~ 'Nil)))))))))))))))))))))
  View
  ()
-> React s (Singleton DeleteEvent) ()
-> Sig
     s
     (Merge
        (Browse
         ':~ (StoreRandomGen
              ':~ (Move
                   ':~ (EndSleep
                        ':~ (Down
                             ':~ (Up
                                  ':~ (Unlock
                                       ':~ (NewLockId
                                            ':~ (GetLock
                                                 ':~ (GetArea
                                                      ':~ (CalcTextExtents
                                                           ':~ (DeleteEvent
                                                                ':~ (LoadRandomGen
                                                                     ':~ (GetThreadId
                                                                          ':~ (HttpGet
                                                                               ':~ (RaiseError
                                                                                    ':~ (StoreJsons
                                                                                         ':~ (SetArea
                                                                                              ':~ (LoadJsons
                                                                                                   ':~ (GetTimeZone
                                                                                                        ':~ (BeginSleep
                                                                                                             ':~ 'Nil)))))))))))))))))))))
        (Singleton DeleteEvent))
     View
     (Either () (Maybe View, ()))
forall (es :: Set (*)) (es' :: Set (*)) s a r r'.
Firstable es es' (ISig s (es :+: es') a r) r' =>
Sig s es a r
-> React s es' r' -> Sig s (es :+: es') a (Either r (Maybe a, r'))
`break` React s (Singleton DeleteEvent) ()
forall s. React s (Singleton DeleteEvent) ()
deleteEvent Sig
  s
  (Merge
     (Browse
      ':~ (StoreRandomGen
           ':~ (Move
                ':~ (EndSleep
                     ':~ (Down
                          ':~ (Up
                               ':~ (Unlock
                                    ':~ (NewLockId
                                         ':~ (GetLock
                                              ':~ (GetArea
                                                   ':~ (CalcTextExtents
                                                        ':~ (DeleteEvent
                                                             ':~ (LoadRandomGen
                                                                  ':~ (GetThreadId
                                                                       ':~ (HttpGet
                                                                            ':~ (RaiseError
                                                                                 ':~ (StoreJsons
                                                                                      ':~ (SetArea
                                                                                           ':~ (LoadJsons
                                                                                                ':~ (GetTimeZone
                                                                                                     ':~ (BeginSleep
                                                                                                          ':~ 'Nil)))))))))))))))))))))
     (Singleton DeleteEvent))
  View
  (Either () (Maybe View, ()))
-> React s (Singleton RaiseError) ()
-> Sig
     s
     (Merge
        (Browse
         ':~ (StoreRandomGen
              ':~ (Move
                   ':~ (EndSleep
                        ':~ (Down
                             ':~ (Up
                                  ':~ (Unlock
                                       ':~ (NewLockId
                                            ':~ (GetLock
                                                 ':~ (GetArea
                                                      ':~ (CalcTextExtents
                                                           ':~ (DeleteEvent
                                                                ':~ (LoadRandomGen
                                                                     ':~ (GetThreadId
                                                                          ':~ (HttpGet
                                                                               ':~ (RaiseError
                                                                                    ':~ (StoreJsons
                                                                                         ':~ (SetArea
                                                                                              ':~ (LoadJsons
                                                                                                   ':~ (GetTimeZone
                                                                                                        ':~ (BeginSleep
                                                                                                             ':~ 'Nil)))))))))))))))))))))
        (Singleton DeleteEvent)
      :+: Singleton RaiseError)
     View
     (Either (Either () (Maybe View, ())) (Maybe View, ()))
forall (es :: Set (*)) (es' :: Set (*)) s a r r'.
Firstable es es' (ISig s (es :+: es') a r) r' =>
Sig s es a r
-> React s es' r' -> Sig s (es :+: es') a (Either r (Maybe a, r'))
`break` React s (Singleton RaiseError) ()
forall s. React s (Singleton RaiseError) ()
checkTerminate

runFollowbox' :: String -> Sig s FollowboxEv ([(Int, Maybe Area)], T.View) () -> IO ()
runFollowbox' :: forall s.
String -> Sig s FollowboxEv ([(Int, Maybe Area)], View) () -> IO ()
runFollowbox' String
brws Sig s FollowboxEv ([(Int, Maybe Area)], View) ()
sig = String
-> Maybe GithubNameToken
-> Sig s FollowboxEv ([(Int, Maybe Area)], View) ()
-> IO ()
forall s.
String
-> Maybe GithubNameToken
-> Sig s FollowboxEv ([(Int, Maybe Area)], View) ()
-> IO ()
runFollowbox_' String
brws Maybe GithubNameToken
forall a. Maybe a
Nothing (Sig s FollowboxEv ([(Int, Maybe Area)], View) () -> IO ())
-> Sig s FollowboxEv ([(Int, Maybe Area)], View) () -> IO ()
forall a b. (a -> b) -> a -> b
$ ((View -> View)
-> ([(Int, Maybe Area)], View) -> ([(Int, Maybe Area)], View)
forall b c d. (b -> c) -> (d, b) -> (d, c)
forall (a :: * -> * -> *) b c d.
Arrow a =>
a b c -> a (d, b) (d, c)
second View -> View
viewToView) (([(Int, Maybe Area)], View) -> ([(Int, Maybe Area)], View))
-> Sig
     s
     (Browse
      ':~ (StoreRandomGen
           ':~ (Move
                ':~ (EndSleep
                     ':~ (Down
                          ':~ (Up
                               ':~ (Unlock
                                    ':~ (NewLockId
                                         ':~ (GetLock
                                              ':~ (GetArea
                                                   ':~ (CalcTextExtents
                                                        ':~ (DeleteEvent
                                                             ':~ (LoadRandomGen
                                                                  ':~ (GetThreadId
                                                                       ':~ (HttpGet
                                                                            ':~ (RaiseError
                                                                                 ':~ (StoreJsons
                                                                                      ':~ (SetArea
                                                                                           ':~ (LoadJsons
                                                                                                ':~ (GetTimeZone
                                                                                                     ':~ (BeginSleep
                                                                                                          ':~ 'Nil)))))))))))))))))))))
     ([(Int, Maybe Area)], View)
     ()
-> Sig
     s
     (Browse
      ':~ (StoreRandomGen
           ':~ (Move
                ':~ (EndSleep
                     ':~ (Down
                          ':~ (Up
                               ':~ (Unlock
                                    ':~ (NewLockId
                                         ':~ (GetLock
                                              ':~ (GetArea
                                                   ':~ (CalcTextExtents
                                                        ':~ (DeleteEvent
                                                             ':~ (LoadRandomGen
                                                                  ':~ (GetThreadId
                                                                       ':~ (HttpGet
                                                                            ':~ (RaiseError
                                                                                 ':~ (StoreJsons
                                                                                      ':~ (SetArea
                                                                                           ':~ (LoadJsons
                                                                                                ':~ (GetTimeZone
                                                                                                     ':~ (BeginSleep
                                                                                                          ':~ 'Nil)))))))))))))))))))))
     ([(Int, Maybe Area)], View)
     ()
forall (t :: * -> * -> *) c a b.
Functor (Flip t c) =>
(a -> b) -> t a c -> t b c
<$%> Sig s FollowboxEv ([(Int, Maybe Area)], View) ()
Sig
  s
  (Browse
   ':~ (StoreRandomGen
        ':~ (Move
             ':~ (EndSleep
                  ':~ (Down
                       ':~ (Up
                            ':~ (Unlock
                                 ':~ (NewLockId
                                      ':~ (GetLock
                                           ':~ (GetArea
                                                ':~ (CalcTextExtents
                                                     ':~ (DeleteEvent
                                                          ':~ (LoadRandomGen
                                                               ':~ (GetThreadId
                                                                    ':~ (HttpGet
                                                                         ':~ (RaiseError
                                                                              ':~ (StoreJsons
                                                                                   ':~ (SetArea
                                                                                        ':~ (LoadJsons
                                                                                             ':~ (GetTimeZone
                                                                                                  ':~ (BeginSleep
                                                                                                       ':~ 'Nil)))))))))))))))))))))
  ([(Int, Maybe Area)], View)
  ()
sig

runFollowbox_ :: String -> Maybe GithubNameToken -> Sig s FollowboxEv View () -> IO ()
runFollowbox_ :: forall s.
String
-> Maybe GithubNameToken -> Sig s FollowboxEv View () -> IO ()
runFollowbox_ String
brws Maybe GithubNameToken
tkn Sig s FollowboxEv View ()
sig = do
	va <- STM (TVar (Map Int Area)) -> IO (TVar (Map Int Area))
forall a. STM a -> IO a
atomically (STM (TVar (Map Int Area)) -> IO (TVar (Map Int Area)))
-> STM (TVar (Map Int Area)) -> IO (TVar (Map Int Area))
forall a b. (a -> b) -> a -> b
$ Map Int Area -> STM (TVar (Map Int Area))
forall a. a -> STM (TVar a)
newTVar Map Int Area
forall k a. Map k a
M.empty
	(cer, ceo, cv) <- atomically $
		(,,) <$> newTChan <*> newTChan <*> newTChan
	_ <- forkIO $ runFollowboxGen cer ceo va brws tkn cv (sig >> emit Stopped)
	runSingleWin cer ceo cv

runFollowbox_' :: String -> Maybe GithubNameToken -> Sig s FollowboxEv ([(Int, Maybe Area)], View) () -> IO ()
runFollowbox_' :: forall s.
String
-> Maybe GithubNameToken
-> Sig s FollowboxEv ([(Int, Maybe Area)], View) ()
-> IO ()
runFollowbox_' String
brws Maybe GithubNameToken
tkn Sig s FollowboxEv ([(Int, Maybe Area)], View) ()
sig = do
	va <- STM (TVar (Map Int Area)) -> IO (TVar (Map Int Area))
forall a. STM a -> IO a
atomically (STM (TVar (Map Int Area)) -> IO (TVar (Map Int Area)))
-> STM (TVar (Map Int Area)) -> IO (TVar (Map Int Area))
forall a b. (a -> b) -> a -> b
$ Map Int Area -> STM (TVar (Map Int Area))
forall a. a -> STM (TVar a)
newTVar Map Int Area
forall k a. Map k a
M.empty
	(cer, ceo, cv) <- atomically $
		(,,) <$> newTChan <*> newTChan <*> newTChan
	_ <- forkIO $ runFollowboxGen' cer ceo va brws tkn cv (sig >> emit ([], Stopped))
	runSingleWin cer ceo cv

runFollowboxGen ::
	TChan (EvReqs (CalcTextExtents :- GuiEv)) -> TChan (EvOccs (CalcTextExtents :- GuiEv)) ->
	TVar (M.Map Int (A.Point, A.Point)) -> String ->
	Maybe GithubNameToken -> TChan x -> Sig s FollowboxEv x r -> IO r
runFollowboxGen :: forall x s r.
TChan (EvReqs (CalcTextExtents :- GuiEv))
-> TChan (EvOccs (CalcTextExtents :- GuiEv))
-> TVar (Map Int Area)
-> String
-> Maybe GithubNameToken
-> TChan x
-> Sig s FollowboxEv x r
-> IO r
runFollowboxGen TChan (EvReqs (CalcTextExtents :- GuiEv))
cr TChan (EvOccs (CalcTextExtents :- GuiEv))
c TVar (Map Int Area)
va String
brs Maybe GithubNameToken
mgnt TChan x
c' Sig s FollowboxEv x r
s = do
	(r, _) <- HandleSt
  FollowboxState
  IO
  (Browse
   ':~ (StoreRandomGen
        ':~ (Move
             ':~ (EndSleep
                  ':~ (Down
                       ':~ (Up
                            ':~ (Unlock
                                 ':~ (NewLockId
                                      ':~ (GetLock
                                           ':~ (GetArea
                                                ':~ (CalcTextExtents
                                                     ':~ (DeleteEvent
                                                          ':~ (LoadRandomGen
                                                               ':~ (GetThreadId
                                                                    ':~ (HttpGet
                                                                         ':~ (RaiseError
                                                                              ':~ (StoreJsons
                                                                                   ':~ (SetArea
                                                                                        ':~ (LoadJsons
                                                                                             ':~ (GetTimeZone
                                                                                                  ':~ (BeginSleep
                                                                                                       ':~ 'Nil)))))))))))))))))))))
-> TChan x
-> Sig
     s
     (Browse
      ':~ (StoreRandomGen
           ':~ (Move
                ':~ (EndSleep
                     ':~ (Down
                          ':~ (Up
                               ':~ (Unlock
                                    ':~ (NewLockId
                                         ':~ (GetLock
                                              ':~ (GetArea
                                                   ':~ (CalcTextExtents
                                                        ':~ (DeleteEvent
                                                             ':~ (LoadRandomGen
                                                                  ':~ (GetThreadId
                                                                       ':~ (HttpGet
                                                                            ':~ (RaiseError
                                                                                 ':~ (StoreJsons
                                                                                      ':~ (SetArea
                                                                                           ':~ (LoadJsons
                                                                                                ':~ (GetTimeZone
                                                                                                     ':~ (BeginSleep
                                                                                                          ':~ 'Nil)))))))))))))))))))))
     x
     r
-> St FollowboxState IO r
forall (m :: * -> *) (es :: Set (*)) (es' :: Set (*)) st a s r.
(MonadIO m, Adjustable es es') =>
HandleSt st m es' -> TChan a -> Sig s es a r -> St st m r
interpretSt (TVar (Map Int Area)
-> (TChan (EvReqs (CalcTextExtents :- GuiEv)),
    TChan (EvOccs (CalcTextExtents :- GuiEv)))
-> String
-> Maybe GithubNameToken
-> HandleF IO (CalcTextExtents :- (GuiEv :+: FollowboxEv))
handleFollowbox TVar (Map Int Area)
va (TChan (EvReqs (CalcTextExtents :- GuiEv))
cr, TChan (EvOccs (CalcTextExtents :- GuiEv))
c) String
brs Maybe GithubNameToken
mgnt) TChan x
c' Sig s FollowboxEv x r
Sig
  s
  (Browse
   ':~ (StoreRandomGen
        ':~ (Move
             ':~ (EndSleep
                  ':~ (Down
                       ':~ (Up
                            ':~ (Unlock
                                 ':~ (NewLockId
                                      ':~ (GetLock
                                           ':~ (GetArea
                                                ':~ (CalcTextExtents
                                                     ':~ (DeleteEvent
                                                          ':~ (LoadRandomGen
                                                               ':~ (GetThreadId
                                                                    ':~ (HttpGet
                                                                         ':~ (RaiseError
                                                                              ':~ (StoreJsons
                                                                                   ':~ (SetArea
                                                                                        ':~ (LoadJsons
                                                                                             ':~ (GetTimeZone
                                                                                                  ':~ (BeginSleep
                                                                                                       ':~ 'Nil)))))))))))))))))))))
  x
  r
s (StdGen -> FollowboxState
initialFollowboxState (StdGen -> FollowboxState) -> StdGen -> FollowboxState
forall a b. (a -> b) -> a -> b
$ Int -> StdGen
mkStdGen Int
8)
	pure r

type Area = (Point, Point)

runFollowboxGen' ::
	TChan (EvReqs (CalcTextExtents :- GuiEv)) -> TChan (EvOccs (CalcTextExtents :- GuiEv)) ->
	TVar (M.Map Int (A.Point, A.Point)) -> String ->
	Maybe GithubNameToken -> TChan x ->
	Sig s FollowboxEv ([(Int, Maybe Area)], x) r -> IO r
runFollowboxGen' :: forall x s r.
TChan (EvReqs (CalcTextExtents :- GuiEv))
-> TChan (EvOccs (CalcTextExtents :- GuiEv))
-> TVar (Map Int Area)
-> String
-> Maybe GithubNameToken
-> TChan x
-> Sig s FollowboxEv ([(Int, Maybe Area)], x) r
-> IO r
runFollowboxGen' TChan (EvReqs (CalcTextExtents :- GuiEv))
cr TChan (EvOccs (CalcTextExtents :- GuiEv))
c TVar (Map Int Area)
va String
brs Maybe GithubNameToken
mgnt TChan x
c' Sig s FollowboxEv ([(Int, Maybe Area)], x) r
s = do
	(r, _) <- HandleSt
  FollowboxState
  IO
  (Browse
   ':~ (StoreRandomGen
        ':~ (Move
             ':~ (EndSleep
                  ':~ (Down
                       ':~ (Up
                            ':~ (Unlock
                                 ':~ (NewLockId
                                      ':~ (GetLock
                                           ':~ (GetArea
                                                ':~ (CalcTextExtents
                                                     ':~ (DeleteEvent
                                                          ':~ (LoadRandomGen
                                                               ':~ (GetThreadId
                                                                    ':~ (HttpGet
                                                                         ':~ (RaiseError
                                                                              ':~ (StoreJsons
                                                                                   ':~ (SetArea
                                                                                        ':~ (LoadJsons
                                                                                             ':~ (GetTimeZone
                                                                                                  ':~ (BeginSleep
                                                                                                       ':~ 'Nil)))))))))))))))))))))
-> TVar (Map Int Area)
-> TChan x
-> Sig
     s
     (Browse
      ':~ (StoreRandomGen
           ':~ (Move
                ':~ (EndSleep
                     ':~ (Down
                          ':~ (Up
                               ':~ (Unlock
                                    ':~ (NewLockId
                                         ':~ (GetLock
                                              ':~ (GetArea
                                                   ':~ (CalcTextExtents
                                                        ':~ (DeleteEvent
                                                             ':~ (LoadRandomGen
                                                                  ':~ (GetThreadId
                                                                       ':~ (HttpGet
                                                                            ':~ (RaiseError
                                                                                 ':~ (StoreJsons
                                                                                      ':~ (SetArea
                                                                                           ':~ (LoadJsons
                                                                                                ':~ (GetTimeZone
                                                                                                     ':~ (BeginSleep
                                                                                                          ':~ 'Nil)))))))))))))))))))))
     ([(Int, Maybe Area)], x)
     r
-> St FollowboxState IO r
forall (m :: * -> *) (es :: Set (*)) (es' :: Set (*)) k st v a s r.
(MonadIO m, Adjustable es es', Ord k) =>
HandleSt st m es'
-> TVar (Map k v)
-> TChan a
-> Sig s es ([(k, Maybe v)], a) r
-> St st m r
interpretSt' (TVar (Map Int Area)
-> (TChan (EvReqs (CalcTextExtents :- GuiEv)),
    TChan (EvOccs (CalcTextExtents :- GuiEv)))
-> String
-> Maybe GithubNameToken
-> HandleF IO (CalcTextExtents :- (GuiEv :+: FollowboxEv))
handleFollowbox TVar (Map Int Area)
va (TChan (EvReqs (CalcTextExtents :- GuiEv))
cr, TChan (EvOccs (CalcTextExtents :- GuiEv))
c) String
brs Maybe GithubNameToken
mgnt) TVar (Map Int Area)
va TChan x
c' Sig s FollowboxEv ([(Int, Maybe Area)], x) r
Sig
  s
  (Browse
   ':~ (StoreRandomGen
        ':~ (Move
             ':~ (EndSleep
                  ':~ (Down
                       ':~ (Up
                            ':~ (Unlock
                                 ':~ (NewLockId
                                      ':~ (GetLock
                                           ':~ (GetArea
                                                ':~ (CalcTextExtents
                                                     ':~ (DeleteEvent
                                                          ':~ (LoadRandomGen
                                                               ':~ (GetThreadId
                                                                    ':~ (HttpGet
                                                                         ':~ (RaiseError
                                                                              ':~ (StoreJsons
                                                                                   ':~ (SetArea
                                                                                        ':~ (LoadJsons
                                                                                             ':~ (GetTimeZone
                                                                                                  ':~ (BeginSleep
                                                                                                       ':~ 'Nil)))))))))))))))))))))
  ([(Int, Maybe Area)], x)
  r
s (StdGen -> FollowboxState
initialFollowboxState (StdGen -> FollowboxState) -> StdGen -> FollowboxState
forall a b. (a -> b) -> a -> b
$ Int -> StdGen
mkStdGen Int
8)
	pure r

handleFollowbox :: TVar (M.Map Int (A.Point, A.Point)) ->
	(TChan (EvReqs (CalcTextExtents :- GuiEv)), TChan (EvOccs (CalcTextExtents :- GuiEv))) -> Browser ->
	Maybe GithubNameToken -> HandleF IO (CalcTextExtents :- GuiEv :+: FollowboxEv)
handleFollowbox :: TVar (Map Int Area)
-> (TChan (EvReqs (CalcTextExtents :- GuiEv)),
    TChan (EvOccs (CalcTextExtents :- GuiEv)))
-> String
-> Maybe GithubNameToken
-> HandleF IO (CalcTextExtents :- (GuiEv :+: FollowboxEv))
handleFollowbox TVar (Map Int Area)
va (TChan (EvReqs (CalcTextExtents :- GuiEv)),
 TChan (EvOccs (CalcTextExtents :- GuiEv)))
f = (Maybe DiffTime
 -> (TChan
       (EvReqs
          (Move
           ':~ (Down
                ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent))))),
     TChan
       (OneOrMoreApp
          ('SetApp
             Occurred
             (Map
                Occurred
                (Move
                 ':~ (Down
                      ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent))))))))
 -> Handle' IO (CalcTextExtents :- GuiEv))
-> (TChan
      (EvReqs
         (Move
          ':~ (Down
               ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent))))),
    TChan
      (OneOrMoreApp
         ('SetApp
            Occurred
            (Map
               Occurred
               (Move
                ':~ (Down
                     ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent))))))))
-> TVar (Map Int Area)
-> String
-> Maybe GithubNameToken
-> HandleF IO (GuiEv :+: FollowboxEv)
forall f.
(Maybe DiffTime -> f -> Handle' IO (CalcTextExtents :- GuiEv))
-> f
-> TVar (Map Int Area)
-> String
-> Maybe GithubNameToken
-> HandleF IO (GuiEv :+: FollowboxEv)
handleFollowboxWith ((TChan
   (EvReqs
      (Move
       ':~ (Down
            ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent)))))
 -> TChan
      (OneOrMoreApp
         ('SetApp
            Occurred
            (Map
               Occurred
               (Move
                ':~ (Down
                     ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent)))))))
 -> EvReqs
      (Move
       ':~ (Down
            ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent))))
 -> IO
      (Maybe
         (OneOrMoreApp
            ('SetApp
               Occurred
               (Occurred Move
                ':~ (Occurred Down
                     ':~ (Occurred Up
                          ':~ (Occurred CalcTextExtents
                               ':~ (Occurred DeleteEvent ':~ 'Nil)))))))))
-> (TChan
      (EvReqs
         (Move
          ':~ (Down
               ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent))))),
    TChan
      (OneOrMoreApp
         ('SetApp
            Occurred
            (Map
               Occurred
               (Move
                ':~ (Down
                     ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent))))))))
-> EvReqs
     (Move
      ':~ (Down
           ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent))))
-> IO
     (Maybe
        (OneOrMoreApp
           ('SetApp
              Occurred
              (Occurred Move
               ':~ (Occurred Down
                    ':~ (Occurred Up
                         ':~ (Occurred CalcTextExtents
                              ':~ (Occurred DeleteEvent ':~ 'Nil))))))))
forall a b c. (a -> b -> c) -> (a, b) -> c
uncurry ((TChan
    (EvReqs
       (Move
        ':~ (Down
             ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent)))))
  -> TChan
       (OneOrMoreApp
          ('SetApp
             Occurred
             (Map
                Occurred
                (Move
                 ':~ (Down
                      ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent)))))))
  -> EvReqs
       (Move
        ':~ (Down
             ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent))))
  -> IO
       (Maybe
          (OneOrMoreApp
             ('SetApp
                Occurred
                (Occurred Move
                 ':~ (Occurred Down
                      ':~ (Occurred Up
                           ':~ (Occurred CalcTextExtents
                                ':~ (Occurred DeleteEvent ':~ 'Nil)))))))))
 -> (TChan
       (EvReqs
          (Move
           ':~ (Down
                ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent))))),
     TChan
       (OneOrMoreApp
          ('SetApp
             Occurred
             (Map
                Occurred
                (Move
                 ':~ (Down
                      ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent))))))))
 -> EvReqs
      (Move
       ':~ (Down
            ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent))))
 -> IO
      (Maybe
         (OneOrMoreApp
            ('SetApp
               Occurred
               (Occurred Move
                ':~ (Occurred Down
                     ':~ (Occurred Up
                          ':~ (Occurred CalcTextExtents
                               ':~ (Occurred DeleteEvent ':~ 'Nil)))))))))
-> (Maybe DiffTime
    -> TChan
         (EvReqs
            (Move
             ':~ (Down
                  ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent)))))
    -> TChan
         (OneOrMoreApp
            ('SetApp
               Occurred
               (Map
                  Occurred
                  (Move
                   ':~ (Down
                        ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent)))))))
    -> EvReqs
         (Move
          ':~ (Down
               ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent))))
    -> IO
         (Maybe
            (OneOrMoreApp
               ('SetApp
                  Occurred
                  (Occurred Move
                   ':~ (Occurred Down
                        ':~ (Occurred Up
                             ':~ (Occurred CalcTextExtents
                                  ':~ (Occurred DeleteEvent ':~ 'Nil)))))))))
-> Maybe DiffTime
-> (TChan
      (EvReqs
         (Move
          ':~ (Down
               ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent))))),
    TChan
      (OneOrMoreApp
         ('SetApp
            Occurred
            (Map
               Occurred
               (Move
                ':~ (Down
                     ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent))))))))
-> EvReqs
     (Move
      ':~ (Down
           ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent))))
-> IO
     (Maybe
        (OneOrMoreApp
           ('SetApp
              Occurred
              (Occurred Move
               ':~ (Occurred Down
                    ':~ (Occurred Up
                         ':~ (Occurred CalcTextExtents
                              ':~ (Occurred DeleteEvent ':~ 'Nil))))))))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe DiffTime
-> TChan
     (EvReqs
        (Move
         ':~ (Down
              ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent)))))
-> TChan
     (OneOrMoreApp
        ('SetApp
           Occurred
           (Map
              Occurred
              (Move
               ':~ (Down
                    ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent)))))))
-> Handle'
     IO
     (Move
      ':~ (Down
           ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent))))
Maybe DiffTime
-> TChan
     (EvReqs
        (Move
         ':~ (Down
              ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent)))))
-> TChan
     (OneOrMoreApp
        ('SetApp
           Occurred
           (Map
              Occurred
              (Move
               ':~ (Down
                    ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent)))))))
-> EvReqs
     (Move
      ':~ (Down
           ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent))))
-> IO
     (Maybe
        (OneOrMoreApp
           ('SetApp
              Occurred
              (Occurred Move
               ':~ (Occurred Down
                    ':~ (Occurred Up
                         ':~ (Occurred CalcTextExtents
                              ':~ (Occurred DeleteEvent ':~ 'Nil))))))))
forall (es :: Set (*)).
Maybe DiffTime
-> TChan (EvReqs es) -> TChan (EvOccs es) -> Handle' IO es
handle) (TChan (EvReqs (CalcTextExtents :- GuiEv)),
 TChan (EvOccs (CalcTextExtents :- GuiEv)))
(TChan
   (EvReqs
      (Move
       ':~ (Down
            ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent))))),
 TChan
   (OneOrMoreApp
      ('SetApp
         Occurred
         (Map
            Occurred
            (Move
             ':~ (Down
                  ':~ (Up ':~ (CalcTextExtents ':~ Singleton DeleteEvent))))))))
f TVar (Map Int Area)
va

viewToView :: T.View -> View
viewToView :: View -> View
viewToView (T.View [View1]
vs) = [View1] -> View
View ([View1] -> View) -> [View1] -> View
forall a b. (a -> b) -> a -> b
$ (OneOfThemFun (VText :- (Line :- (Image :- 'Nil))) View1
OneOfThemFun (Line ':~ (VText ':~ (Image ':~ 'Nil))) View1
view1ToView1 OneOfThemFun (Line ':~ (VText ':~ (Image ':~ 'Nil))) View1
-> OneOfThem (Line ':~ (VText ':~ (Image ':~ 'Nil))) -> View1
forall b.
OneOfThemFun (Line ':~ (VText ':~ (Image ':~ 'Nil))) b
-> OneOfThem (Line ':~ (VText ':~ (Image ':~ 'Nil))) -> b
forall (as :: Set (*)) b.
Applyable as =>
OneOfThemFun as b -> OneOfThem as -> b
`apply`) (OneOfThem (Line ':~ (VText ':~ (Image ':~ 'Nil))) -> View1)
-> [OneOfThem (Line ':~ (VText ':~ (Image ':~ 'Nil)))] -> [View1]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [View1]
[OneOfThem (Line ':~ (VText ':~ (Image ':~ 'Nil)))]
vs

view1ToView1 :: OneOfThemFun (VText :- Line :- Image :- 'Nil) View1
view1ToView1 :: OneOfThemFun (VText :- (Line :- (Image :- 'Nil))) View1
view1ToView1 =
	(\(Line' (T.Color Word8
r Word8
g Word8
b) Double
lw Position
p0 Position
p1) ->
		Rgb Double -> Double -> Position -> Position -> View1
VLine (Word8 -> Word8 -> Word8 -> Rgb Double
forall d. RealFrac d => Word8 -> Word8 -> Word8 -> Rgb d
RgbWord8 Word8
r Word8
g Word8
b) Double
lw Position
p0 Position
p1) (Line -> View1)
-> OneOfThemFun (VText ':~ (Image ':~ 'Nil)) View1
-> OneOfThemFun (Line :- (VText ':~ (Image ':~ 'Nil))) View1
forall a (as :: Set (*)) b.
InsertableFun a as (a :- as) =>
(a -> b) -> OneOfThemFun as b -> OneOfThemFun (a :- as) b
>--
	(\(T.Text' (T.Color Word8
r Word8
g Word8
b) String
fn Double
fs Position
p Text
txt) ->
		Rgb Double -> String -> Double -> Position -> Text -> View1
VText (Word8 -> Word8 -> Word8 -> Rgb Double
forall d. RealFrac d => Word8 -> Word8 -> Word8 -> Rgb d
RgbWord8 Word8
r Word8
g Word8
b) String
fn Double
fs Position
p Text
txt) (VText -> View1)
-> OneOfThemFun (Image ':~ 'Nil) View1
-> OneOfThemFun (VText :- (Image ':~ 'Nil)) View1
forall a (as :: Set (*)) b.
InsertableFun a as (a :- as) =>
(a -> b) -> OneOfThemFun as b -> OneOfThemFun (a :- as) b
>-- (Image -> View1) -> OneOfThemFun (Image ':~ 'Nil) View1
forall a b. (a -> b) -> OneOfThemFun (Singleton a) b
SingletonFun
	(\(T.Image' Position
p (T.Png Double
w Double
h ByteString
dt)) -> Position -> Double -> Double -> ByteString -> View1
VImage Position
p Double
w Double
h ByteString
dt)