{-# LANGUAGE AllowAmbiguousTypes #-}

module Mischief.Live
  ( -- * Mischief Live
    -- $intro

    -- * Project Structure
    -- $structure

    -- * How to Run
    -- $run

    -- * How to Use
    -- $how

    -- * Extensions
    -- $extensions

    -- * Preparing for Release
    -- $release
    attachLive,
    live,
    LiveExtensions (..),
    Extension,
    OnLiveLoad,
    liveIfChanged,
    ghc2024Extensions,
  )
where

import Control.Concurrent
import Control.Concurrent.STM
import Control.Monad
import Data.Data (Proxy (Proxy), TypeRep, Typeable, typeRep)
import Data.Foldable (for_)
import Data.Map (Map)
import Data.Map qualified as Map
import Language.Haskell.Interpreter
import Mischief.ECS
import Mischief.ECS.App (App (..))
import Mischief.ECS.Resources (modifyRes')
import Mischief.ECS.World (SystemAny (systemAny), World (..), runSystem)
import Mischief.Live.Interpreter
import System.Directory
import System.FSNotify
import Unsafe.Coerce

newtype LiveExtensions = LiveExtensions [Extension] deriving newtype (NonEmpty LiveExtensions -> LiveExtensions
LiveExtensions -> LiveExtensions -> LiveExtensions
(LiveExtensions -> LiveExtensions -> LiveExtensions)
-> (NonEmpty LiveExtensions -> LiveExtensions)
-> (forall b. Integral b => b -> LiveExtensions -> LiveExtensions)
-> Semigroup LiveExtensions
forall b. Integral b => b -> LiveExtensions -> LiveExtensions
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
$c<> :: LiveExtensions -> LiveExtensions -> LiveExtensions
<> :: LiveExtensions -> LiveExtensions -> LiveExtensions
$csconcat :: NonEmpty LiveExtensions -> LiveExtensions
sconcat :: NonEmpty LiveExtensions -> LiveExtensions
$cstimes :: forall b. Integral b => b -> LiveExtensions -> LiveExtensions
stimes :: forall b. Integral b => b -> LiveExtensions -> LiveExtensions
Semigroup)

instance Default LiveExtensions where
  def :: LiveExtensions
def =
    LiveExtensions
ghc2024Extensions
      LiveExtensions -> LiveExtensions -> LiveExtensions
forall a. Semigroup a => a -> a -> a
<> [Extension] -> LiveExtensions
LiveExtensions
        [ Extension
DeriveAnyClass,
          String -> Extension
UnknownExtension String
"DerivingStrategies",
          Extension
DuplicateRecordFields,
          String -> Extension
UnknownExtension String
"ImportQualifiedPost",
          Extension
MultiWayIf,
          String -> Extension
UnknownExtension String
"NoFieldSelectors",
          String -> Extension
UnknownExtension String
"OverloadedRecordDot",
          Extension
OverloadedStrings,
          Extension
QuasiQuotes,
          Extension
TypeFamilyDependencies
        ]

ghc2024Extensions :: LiveExtensions
ghc2024Extensions :: LiveExtensions
ghc2024Extensions =
  [Extension] -> LiveExtensions
LiveExtensions
    [ Extension
BangPatterns,
      Extension
BinaryLiterals,
      Extension
ConstrainedClassMethods,
      Extension
ConstraintKinds,
      Extension
DataKinds,
      Extension
DeriveDataTypeable,
      Extension
DeriveFoldable,
      Extension
DeriveFunctor,
      Extension
DeriveGeneric,
      Extension
DeriveLift,
      Extension
DeriveTraversable,
      String -> Extension
UnknownExtension String
"DerivingStrategies",
      Extension
DisambiguateRecordFields,
      Extension
DoAndIfThenElse,
      Extension
EmptyCase,
      Extension
EmptyDataDecls,
      String -> Extension
UnknownExtension String
"EmptyDataDeriving",
      Extension
ExistentialQuantification,
      Extension
ExplicitForAll,
      Extension
ExplicitNamespaces,
      String -> Extension
UnknownExtension String
"FieldSelectors",
      Extension
FlexibleContexts,
      Extension
FlexibleInstances,
      Extension
ForeignFunctionInterface,
      Extension
GADTs,
      Extension
GADTSyntax,
      String -> Extension
UnknownExtension String
"GeneralisedNewtypeDeriving",
      String -> Extension
UnknownExtension String
"HexFloatLiterals",
      Extension
ImplicitPrelude,
      String -> Extension
UnknownExtension String
"ImportQualifiedPost",
      Extension
InstanceSigs,
      Extension
KindSignatures,
      Extension
LambdaCase,
      Extension
MonoLocalBinds,
      Extension
MonomorphismRestriction,
      Extension
MultiParamTypeClasses,
      Extension
NamedFieldPuns,
      Extension
NamedWildCards,
      String -> Extension
UnknownExtension String
"NumericUnderscores",
      Extension
PatternGuards,
      Extension
PolyKinds,
      Extension
PostfixOperators,
      Extension
RankNTypes,
      Extension
RelaxedPolyRec,
      Extension
RoleAnnotations,
      Extension
ScopedTypeVariables,
      Extension
StandaloneDeriving,
      String -> Extension
UnknownExtension String
"StandaloneKindSignatures",
      String -> Extension
UnknownExtension String
"StarIsType",
      Extension
TraditionalRecordSyntax,
      Extension
TupleSections,
      Extension
TypeApplications,
      Extension
TypeOperators,
      Extension
TypeSynonymInstances
    ]

attachLive :: FilePath -> [FilePath] -> LiveExtensions -> App -> IO ()
attachLive :: String -> [String] -> LiveExtensions -> App -> IO ()
attachLive String
path [String]
files (LiveExtensions [Extension]
ext) App
app = do
  path <- String -> IO String
makeAbsolute String
path
  -- paths <- getFilesRecursively path
  chanReq <- newBroadcastTChanIO

  chanReqRead <- atomically $ dupTChan chanReq

  runSystem (insertRes $ InterpreterChan chanReq) app.world
  -- runSystem (insertRes $ LivePaths $ path :| paths) app.world

  runSystem (insertRes $ LiveRegistry Map.empty) app.world

  void $ forkIO $ withCurrentDirectory path $ interpreterInit files ext chanReqRead
  void $ forkIO $ withManager $ watcher app.world path

watcher :: World -> FilePath -> WatchManager -> IO ()
watcher :: World -> String -> WatchManager -> IO ()
watcher World {TVar [System ()]
deferredAsync :: TVar [System ()]
deferredAsync :: World -> TVar [System ()]
deferredAsync} String
dir WatchManager
mgr = do
  IO (IO ()) -> IO ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (IO (IO ()) -> IO ()) -> IO (IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ WatchManager -> String -> ActionPredicate -> Action -> IO (IO ())
watchTree WatchManager
mgr String
dir (Bool -> ActionPredicate
forall a b. a -> b -> a
const Bool
True) (Action -> IO (IO ())) -> Action -> IO (IO ())
forall a b. (a -> b) -> a -> b
$ IO () -> Action
forall a b. a -> b -> a
const (IO () -> Action) -> IO () -> Action
forall a b. (a -> b) -> a -> b
$ STM () -> IO ()
forall a. STM a -> IO a
atomically (STM () -> IO ()) -> STM () -> IO ()
forall a b. (a -> b) -> a -> b
$ do
    TVar [System ()] -> ([System ()] -> [System ()]) -> STM ()
forall a. TVar a -> (a -> a) -> STM ()
modifyTVar' TVar [System ()]
deferredAsync ([System ()] -> [System ()] -> [System ()]
forall a. [a] -> [a] -> [a]
++ [System ()
resetLiveCode])

  IO () -> IO ()
forall (f :: * -> *) a b. Applicative f => f a -> f b
forever (IO () -> IO ()) -> IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ Int -> IO ()
threadDelay Int
10000000000000000

resetLiveCode :: System ()
resetLiveCode :: System ()
resetLiveCode = do
  Just (InterpreterChan chanReq) <- System (Maybe InterpreterChan)
forall c (m :: * -> *) w.
(MonadSystem w m, Component c) =>
m (Maybe c)
res
  -- reset <- liftIO $ atomically $ do
  --   p <- peekTChan chanReq
  --   case p of
  --     Reset -> pure False
  --     _ -> True <$ writeTChan chanReq Reset

  -- when reset $ do
  liftIO $ atomically $ writeTChan chanReq Reset
  insertRes $ LiveRegistry Map.empty
  trigger OnLiveLoad

data LiveKey = LiveKey
  { LiveKey -> String
moduleName :: String,
    LiveKey -> String
valName :: String,
    LiveKey -> TypeRep
valType :: TypeRep
  }
  deriving (LiveKey -> LiveKey -> Bool
(LiveKey -> LiveKey -> Bool)
-> (LiveKey -> LiveKey -> Bool) -> Eq LiveKey
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LiveKey -> LiveKey -> Bool
== :: LiveKey -> LiveKey -> Bool
$c/= :: LiveKey -> LiveKey -> Bool
/= :: LiveKey -> LiveKey -> Bool
Eq, Eq LiveKey
Eq LiveKey =>
(LiveKey -> LiveKey -> Ordering)
-> (LiveKey -> LiveKey -> Bool)
-> (LiveKey -> LiveKey -> Bool)
-> (LiveKey -> LiveKey -> Bool)
-> (LiveKey -> LiveKey -> Bool)
-> (LiveKey -> LiveKey -> LiveKey)
-> (LiveKey -> LiveKey -> LiveKey)
-> Ord LiveKey
LiveKey -> LiveKey -> Bool
LiveKey -> LiveKey -> Ordering
LiveKey -> LiveKey -> LiveKey
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: LiveKey -> LiveKey -> Ordering
compare :: LiveKey -> LiveKey -> Ordering
$c< :: LiveKey -> LiveKey -> Bool
< :: LiveKey -> LiveKey -> Bool
$c<= :: LiveKey -> LiveKey -> Bool
<= :: LiveKey -> LiveKey -> Bool
$c> :: LiveKey -> LiveKey -> Bool
> :: LiveKey -> LiveKey -> Bool
$c>= :: LiveKey -> LiveKey -> Bool
>= :: LiveKey -> LiveKey -> Bool
$cmax :: LiveKey -> LiveKey -> LiveKey
max :: LiveKey -> LiveKey -> LiveKey
$cmin :: LiveKey -> LiveKey -> LiveKey
min :: LiveKey -> LiveKey -> LiveKey
Ord)

data LiveValue where
  LiveValue :: (Typeable a) => a -> LiveValue

newtype LiveRegistry = LiveRegistry (Map LiveKey LiveValue) deriving anyclass (Typeable LiveRegistry
[HookRel LiveRegistry]
[Hook LiveRegistry]
Set DefaultComponentType
IsExclusive (IsExclusiveRel LiveRegistry)
(Typeable LiveRegistry,
 IsExclusive (IsExclusiveRel LiveRegistry)) =>
Set DefaultComponentType
-> [Hook LiveRegistry]
-> [Hook LiveRegistry]
-> [Hook LiveRegistry]
-> [HookRel LiveRegistry]
-> [HookRel LiveRegistry]
-> [HookRel LiveRegistry]
-> Component LiveRegistry
forall c.
(Typeable c, IsExclusive (IsExclusiveRel c)) =>
Set DefaultComponentType
-> [Hook c]
-> [Hook c]
-> [Hook c]
-> [HookRel c]
-> [HookRel c]
-> [HookRel c]
-> Component c
$crequired :: Set DefaultComponentType
required :: Set DefaultComponentType
$conAdd :: [Hook LiveRegistry]
onAdd :: [Hook LiveRegistry]
$conSet :: [Hook LiveRegistry]
onSet :: [Hook LiveRegistry]
$conRemove :: [Hook LiveRegistry]
onRemove :: [Hook LiveRegistry]
$conAddRel :: [HookRel LiveRegistry]
onAddRel :: [HookRel LiveRegistry]
$conSetRel :: [HookRel LiveRegistry]
onSetRel :: [HookRel LiveRegistry]
$conRemoveRel :: [HookRel LiveRegistry]
onRemoveRel :: [HookRel LiveRegistry]
Component)

live :: forall a m w. (Typeable a, MonadSystem w m) => ModuleName -> String -> m (Maybe a)
live :: forall a (m :: * -> *) w.
(Typeable a, MonadSystem w m) =>
String -> String -> m (Maybe a)
live String
m String
f = do
  Just (InterpreterChan chanReq) <- m (Maybe InterpreterChan)
forall c (m :: * -> *) w.
(MonadSystem w m, Component c) =>
m (Maybe c)
res

  Just (LiveRegistry reg) <- res

  let key = LiveKey {moduleName :: String
moduleName = String
m, valName :: String
valName = String
f, valType :: TypeRep
valType = Proxy a -> TypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> TypeRep
typeRep (Proxy a -> TypeRep) -> Proxy a -> TypeRep
forall a b. (a -> b) -> a -> b
$ forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @a}

  case Map.lookup key reg of
    Just (LiveValue a
val) -> Maybe a -> m (Maybe a)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe a -> m (Maybe a)) -> Maybe a -> m (Maybe a)
forall a b. (a -> b) -> a -> b
$ a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> a -> Maybe a
forall a b. (a -> b) -> a -> b
$ a -> a
forall a b. a -> b
unsafeCoerce a
val
    Maybe LiveValue
Nothing -> do
      a <- IO (Maybe a) -> m (Maybe a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe a) -> m (Maybe a)) -> IO (Maybe a) -> m (Maybe a)
forall a b. (a -> b) -> a -> b
$ do
        t <- Result a -> IO (TMVar (Result a))
forall a. a -> IO (TMVar a)
newTMVarIO Result a
forall a. Result a
AwaitingResult
        atomically $ writeTChan chanReq (Request m f t)
        waitForResult t

      for_ a $ \a
a -> do
        let s :: System ()
s = (LiveRegistry -> LiveRegistry) -> System ()
forall r. (Component r, Bundle r) => (r -> r) -> System ()
modifyRes' ((LiveRegistry -> LiveRegistry) -> System ())
-> (LiveRegistry -> LiveRegistry) -> System ()
forall a b. (a -> b) -> a -> b
$ \(LiveRegistry Map LiveKey LiveValue
m) -> Map LiveKey LiveValue -> LiveRegistry
LiveRegistry (Map LiveKey LiveValue -> LiveRegistry)
-> Map LiveKey LiveValue -> LiveRegistry
forall a b. (a -> b) -> a -> b
$ LiveKey
-> LiveValue -> Map LiveKey LiveValue -> Map LiveKey LiveValue
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert LiveKey
key (a -> LiveValue
forall a. Typeable a => a -> LiveValue
LiveValue a
a) Map LiveKey LiveValue
m
        System () -> ParSystem () -> m ()
forall a. System a -> ParSystem a -> m a
forall (m :: * -> *) a.
SystemAny m =>
System a -> ParSystem a -> m a
systemAny System ()
s (System () -> ParSystem ()
forall w (m :: * -> *) a. MonadSystem w m => System a -> m ()
defer System ()
s)

      pure a

liveIfChanged :: forall a m w. (Typeable a, MonadSystem w m) => ModuleName -> String -> m (Maybe a)
liveIfChanged :: forall a (m :: * -> *) w.
(Typeable a, MonadSystem w m) =>
String -> String -> m (Maybe a)
liveIfChanged String
m String
f = do
  Just (InterpreterChan chanReq) <- m (Maybe InterpreterChan)
forall c (m :: * -> *) w.
(MonadSystem w m, Component c) =>
m (Maybe c)
res

  Just (LiveRegistry reg) <- res

  let key = LiveKey {moduleName :: String
moduleName = String
m, valName :: String
valName = String
f, valType :: TypeRep
valType = Proxy a -> TypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> TypeRep
typeRep (Proxy a -> TypeRep) -> Proxy a -> TypeRep
forall a b. (a -> b) -> a -> b
$ forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @a}

  case Map.lookup key reg of
    Just LiveValue
_ -> Maybe a -> m (Maybe a)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe a
forall a. Maybe a
Nothing
    Maybe LiveValue
Nothing -> do
      a <- IO (Maybe a) -> m (Maybe a)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe a) -> m (Maybe a)) -> IO (Maybe a) -> m (Maybe a)
forall a b. (a -> b) -> a -> b
$ do
        t <- Result a -> IO (TMVar (Result a))
forall a. a -> IO (TMVar a)
newTMVarIO Result a
forall a. Result a
AwaitingResult
        atomically $ writeTChan chanReq (Request m f t)
        waitForResult t

      for_ a $ \a
a -> do
        let s :: System ()
s = (LiveRegistry -> LiveRegistry) -> System ()
forall r. (Component r, Bundle r) => (r -> r) -> System ()
modifyRes' ((LiveRegistry -> LiveRegistry) -> System ())
-> (LiveRegistry -> LiveRegistry) -> System ()
forall a b. (a -> b) -> a -> b
$ \(LiveRegistry Map LiveKey LiveValue
m) -> Map LiveKey LiveValue -> LiveRegistry
LiveRegistry (Map LiveKey LiveValue -> LiveRegistry)
-> Map LiveKey LiveValue -> LiveRegistry
forall a b. (a -> b) -> a -> b
$ LiveKey
-> LiveValue -> Map LiveKey LiveValue -> Map LiveKey LiveValue
forall k a. Ord k => k -> a -> Map k a -> Map k a
Map.insert LiveKey
key (a -> LiveValue
forall a. Typeable a => a -> LiveValue
LiveValue a
a) Map LiveKey LiveValue
m
        System () -> ParSystem () -> m ()
forall a. System a -> ParSystem a -> m a
forall (m :: * -> *) a.
SystemAny m =>
System a -> ParSystem a -> m a
systemAny System ()
s (System () -> ParSystem ()
forall w (m :: * -> *) a. MonadSystem w m => System a -> m ()
defer System ()
s)

      pure a

waitForResult :: TMVar (Result a) -> IO (Maybe a)
waitForResult :: forall a. TMVar (Result a) -> IO (Maybe a)
waitForResult TMVar (Result a)
t = do
  x <- STM (Result a) -> IO (Result a)
forall a. STM a -> IO a
atomically (STM (Result a) -> IO (Result a))
-> STM (Result a) -> IO (Result a)
forall a b. (a -> b) -> a -> b
$ TMVar (Result a) -> STM (Result a)
forall a. TMVar a -> STM a
readTMVar TMVar (Result a)
t
  case x of
    Result a
a -> Maybe a -> IO (Maybe a)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe a -> IO (Maybe a)) -> Maybe a -> IO (Maybe a)
forall a b. (a -> b) -> a -> b
$ a -> Maybe a
forall a. a -> Maybe a
Just (a -> Maybe a) -> a -> Maybe a
forall a b. (a -> b) -> a -> b
$ a -> a
forall a b. a -> b
unsafeCoerce a
a
    Result a
NoResult -> Maybe a -> IO (Maybe a)
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe a
forall a. Maybe a
Nothing
    Result a
AwaitingResult -> TMVar (Result a) -> IO (Maybe a)
forall a. TMVar (Result a) -> IO (Maybe a)
waitForResult TMVar (Result a)
t

data OnLiveLoad = OnLiveLoad deriving (Typeable OnLiveLoad
Typeable OnLiveLoad =>
(OnLiveLoad -> ErasedEvent) -> Event OnLiveLoad
OnLiveLoad -> ErasedEvent
forall e. Typeable e => (e -> ErasedEvent) -> Event e
$ceraseEvent :: OnLiveLoad -> ErasedEvent
eraseEvent :: OnLiveLoad -> ErasedEvent
Mischief.ECS.Event)

-- $intro
-- This library is a lightweight, yet powerful, addition to the core ECS library. It enables a form of live coding
-- by running a background interpreter over the code from a chosen target, letting you modify the functions from it
-- during the runtime of your main compiled library.

-- $structure
-- I will be describing the general recommended structure of a mischief app that uses this library. It is also recommended to
-- look at or clone one of the @-live@ branches in the [template repository](https://codeberg.org/mischief/template) for a more concrete example
-- or starting point.
--
-- In order to properly use this library, you will need at least one library besides your executable (the main \"library\" that you're running). You can define
-- it in your @.cabal@ file. In the template, this library is generally named @live@, with it's starting point in a @Live.hs@ module.
--
-- In this live library you can write any code that you wish to be able to freely change at runtime. Systems, shaders, and so on.
--
-- Your executable cannot depend on the live library, and the live library cannot depend on your executable. Because of this restriction, it is
-- recommended to create a third library, containing the /common/ logic and definitions that you wish both the executable and the live library to see.
-- You'll generally define types, such as components and materials in this common library.

-- $run
-- In order to run your executable, you should use the following command:
--
-- @
-- cabal run --write-ghc-environment-files=always --enable-shared --enable-executable-dynamic
-- @
--
-- The first flag will write an environment file which the interpreter can read to see all dependencies. The other two
-- ensure your local libraries are compiled dynamically so that the interpreter can access them. These are very important! GHC
-- is likely to be stuck in the linking phase if you depend on @mischief-live@ and don't compile your code dynamically!
--
-- On windows you may also need to add the @-fthreaded@ flag, as this library uses [fsnotify](https://hackage.haskell.org/package/fsnotify) for reacting to file changes.

-- $how
-- This library's API is really simple! It only has two functions you need to be aware of.
--
-- First, you need to use @attachLive@ to attach the interpreter to your app before running it:
--
-- @
-- app <- 'newApp'
-- 'attachLive' \".\/live\/" [\"Live.hs\"] 'def' app
-- @
--
-- The first parameter is the directory where your live library is located. The second is a list of
-- files to load when initializing the interpreter, relative to the previous path. There is also
-- a list of extensions you need to pass, but more on that later, @def@ is usually enough.
--
-- Second, there is the main primitive introduces by this library, @live@:
--
-- @
-- x <- 'live' \@'Int' \"Live\" \"myInt\"
-- @
--
-- The @live@ function takes a module name and a top-level function from that module, and produces its latest value. In this case,
-- the @Live@ module is expected to look something like this:
--
-- @
-- module Live where
--
--   myInt :: 'Int'
--   myInt = 3
-- @
--
-- The @\@Int@ type hint is optional, @live@ usually infers the value.
--
-- This function is smart. It caches the functions you've already requested, so it only interprets them the first time you ask for them, at the
-- start of the app or after you made a change to the live library.
--
-- There is also the @'liveIfChanged'@ function which will return a value only if this is the first time you're asking for it since the last change in the live library.
--
-- The @'OnLiveLoad'@ event is triggered each time a change in the live library is detected and the interpreter is reset.

-- $extensions
-- A list of language extensions that are applied when interpreting the live library need to be provided. The Default instance
-- adds all the extensions enabled by default by @ghc2024@, as well as the set of extensions recommended by Mischief. You can see
-- the exact list in the source of this file!
--
-- In order to customize the list of extensions, you can use the 'ghc2024Extensions' and the 'def' as a starting point, adding more extensions on top. For instance:
--
-- @
-- myExtensions :: 'LiveExtensions'
-- myExtensions = 'ghc2024Extensions' <> LiveExtensions ['UndecidableInstances']
-- @
--
-- You should set these to match the extensions listed under your live library in the @.cabal@ file.

-- $release
-- When releasing your app, you'll want to comment out the @mischief-live@ dependencies in your @.cabal@ file, and compile your
-- app normally, without the dynamic flags.
--
-- The simplest approach to ensure your app still works as expected with minimal refactoring is to have your executable depend on the
-- live library and import it, replacing all the @live@ calls with actual calls to the relevant functions.
--
-- Options are being considered for streamlining this process, such as a macro that can smartly switch between @live@ and the
-- direct calls. Your feedback and ideas are appreciated!