<commit_before>{-# LANGUAGE Arrows #-}
-- {-# LANGUAGE DeriveAnyClass #-} -- this breaks deriving Num for trivial newtypes
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE UnicodeSyntax #-}

module Types
    (
    -- Simulation
      SimTime, SimWire
    , Sim(..)

    -- Model
    , Totality(..)
    , ElementAPI(..), Element(..)
    , Category(..), EngiName(..), Engine(..)
    , Graph(..), Dag(..), Set(..)
    , Controls(..), initial_controls
    , Selector(..)
    , Selection(..)
    , Engi(..), Viewport(..), Boundary(..)
    , ViewArgs(..), MinSize(..), Granularity(..)
    , View(..)

    -- Rendering
    , RenderContext(..)

    -- Engis
    , SideGraph(..)
    , DownGraph(..)
    , DagList(..)
    , DagGrid(..)
    , DagSpace(..)
    , Carousel(..)
    , Grid(..)
    , List(..)
    ) where

import Control.Monad (forM_)
import Control.Wire hiding (Category)
import qualified SDL

import GHC.Prim (Constraint)
import Data.Hashable
import qualified Data.HashSet      as HS
import qualified Data.HashMap.Lazy as HM
import Data.List (find)

import qualified Data.Time.Clock as Time

import Linear hiding (trace)
import Linear.Affine

import Text.Printf (printf)

import Data.Typeable (cast)



-- Local imports
import Ground



-- | Simulation
type SimTime     = (Timed NominalDiffTime ())
type SimWire a b = Wire SimTime String IO a b

class Sim w i | w → i, i → w where
    inputsOf        ∷ w → i
    --
    trackKeyDown    ∷ i → SDL.Scancode → i
    trackKeyUp      ∷ i → SDL.Scancode → i
    someKeyDown     ∷ i → Bool
    keyDown         ∷ SDL.Scancode → i → Bool



-- | Model
newtype Totality
    = Totality [String]

class ElementAPI e where

-- data Element = ∀ e . ElementAPI e ⇒ Element e -- equivalent to the below:
data Element where
    Element ∷ (ElementAPI e, Hashable e) ⇒ e → Element
instance (Hashable Element) where
    hashWithSalt s (Element e)  = s `hashWithSalt` (hash e)<commit_msg>imports:  indent<commit_after>{-# LANGUAGE Arrows #-}
-- {-# LANGUAGE DeriveAnyClass #-} -- this breaks deriving Num for trivial newtypes
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeSynonymInstances #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE UndecidableInstances #-}
{-# LANGUAGE UnicodeSyntax #-}

module Types
    (
    -- Simulation
      SimTime, SimWire
    , Sim(..)

    -- Model
    , Totality(..)
    , ElementAPI(..), Element(..)
    , Category(..), EngiName(..), Engine(..)
    , Graph(..), Dag(..), Set(..)
    , Controls(..), initial_controls
    , Selector(..)
    , Selection(..)
    , Engi(..), Viewport(..), Boundary(..)
    , ViewArgs(..), MinSize(..), Granularity(..)
    , View(..)

    -- Rendering
    , RenderContext(..)

    -- Engis
    , SideGraph(..)
    , DownGraph(..)
    , DagList(..)
    , DagGrid(..)
    , DagSpace(..)
    , Carousel(..)
    , Grid(..)
    , List(..)
    ) where

import           Control.Monad (forM_)
import           Control.Wire hiding (Category)
import qualified SDL

import           GHC.Prim (Constraint)
import           Data.Hashable
import qualified Data.HashSet as HS
import qualified Data.HashMap.Lazy as HM
import           Data.List (find)

import qualified Data.Time.Clock as Time

import           Linear hiding (trace)
import           Linear.Affine

import           Text.Printf (printf)

import           Data.Typeable (cast)



-- Local imports
import           Ground



-- | Simulation
type SimTime     = (Timed NominalDiffTime ())
type SimWire a b = Wire SimTime String IO a b

class Sim w i | w → i, i → w where
    inputsOf        ∷ w → i
    --
    trackKeyDown    ∷ i → SDL.Scancode → i
    trackKeyUp      ∷ i → SDL.Scancode → i
    someKeyDown     ∷ i → Bool
    keyDown         ∷ SDL.Scancode → i → Bool



-- | Model
newtype Totality
    = Totality [String]

class ElementAPI e where

-- data Element = ∀ e . ElementAPI e ⇒ Element e -- equivalent to the below:
data Element where
    Element ∷ (ElementAPI e, Hashable e) ⇒ e → Element
instance (Hashable Element) where
    hashWithSalt s (Element e)  = s `hashWithSalt` (hash e)
{'fraction_non_alphanumeric': 0.14823008849557523, 'fraction_numerical': 0.0, 'mean_word_length': 2.5070521861777153, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3544223', 'n_tokens_mistral': 1836, 'n_tokens_neox': 1741, 'n_words': 476}