-- Warning: do not add anything here that might conflict with a developer's
-- local `.ghci` configuration. As a rule of thumb, defining new commands using
-- `:new` should be safe, but using `:set` to set configuration options is
-- probably not.

import Prelude

-- Making a list out of all library modules in the `.cabal` file, so we have
-- access to everything from the REPL. I don't know of a better way to do this.
-- As new modules get added to the codebase, this list will become incomplete.
-- This shouldn't be a big deal, new modules can be added as the need arises.
:{
let gargantextModules = [ "Gargantext"
                        , "Gargantext.API"
                        , "Gargantext.API.Admin.Auth.Types"
                        , "Gargantext.API.Admin.EnvTypes"
                        , "Gargantext.API.Admin.Orchestrator.Types"
                        , "Gargantext.API.Admin.Settings"
                        , "Gargantext.API.Auth.PolicyCheck"
                        , "Gargantext.API.Count.Types"
                        , "Gargantext.API.Dev"
                        , "Gargantext.API.Errors"
                        , "Gargantext.API.Errors.Class"
                        , "Gargantext.API.Errors.TH"
                        , "Gargantext.API.Errors.Types"
                        , "Gargantext.API.Errors.Types.Backend"
                        , "Gargantext.API.HashedResponse"
                        , "Gargantext.API.Middleware"
                        , "Gargantext.API.Ngrams"
                        , "Gargantext.API.Ngrams.List"
                        , "Gargantext.API.Ngrams.List.Types"
                        , "Gargantext.API.Ngrams.Prelude"
                        , "Gargantext.API.Ngrams.Tools"
                        , "Gargantext.API.Ngrams.Types"
                        , "Gargantext.API.Node"
                        , "Gargantext.API.Node.Contact.Types"
                        , "Gargantext.API.Node.Corpus.Annuaire"
                        , "Gargantext.API.Node.Corpus.Export.Types"
                        , "Gargantext.API.Node.Corpus.Export.Utils"
                        , "Gargantext.API.Node.Corpus.New"
                        , "Gargantext.API.Node.Corpus.New.Types"
                        , "Gargantext.API.Node.Corpus.Types"
                        , "Gargantext.API.Node.Corpus.Update"
                        , "Gargantext.API.Node.DocumentsFromWriteNodes.Types"
                        , "Gargantext.API.Node.DocumentUpload.Types"
                        , "Gargantext.API.Node.File"
                        , "Gargantext.API.Node.File.Types"
                        , "Gargantext.API.Node.FrameCalcUpload.Types"
                        , "Gargantext.API.Node.Get"
                        , "Gargantext.API.Node.New.Types"
                        , "Gargantext.API.Node.Share"
                        , "Gargantext.API.Node.Share.Types"
                        , "Gargantext.API.Node.ShareURL"
                        , "Gargantext.API.Node.Types"
                        , "Gargantext.API.Node.Update"
                        , "Gargantext.API.Node.Update.Types"
                        , "Gargantext.API.Prelude"
                        , "Gargantext.API.Public.Types"
                        , "Gargantext.API.Routes"
                        , "Gargantext.API.Routes.Client"
                        , "Gargantext.API.Routes.Named"
                        , "Gargantext.API.Routes.Named.Annuaire"
                        , "Gargantext.API.Routes.Named.Contact"
                        , "Gargantext.API.Routes.Named.Context"
                        , "Gargantext.API.Routes.Named.Corpus"
                        , "Gargantext.API.Routes.Named.Count"
                        , "Gargantext.API.Routes.Named.Document"
                        , "Gargantext.API.Routes.Named.EKG"
                        , "Gargantext.API.Routes.Named.File"
                        , "Gargantext.API.Routes.Named.FrameCalc"
                        , "Gargantext.API.Routes.Named.List"
                        , "Gargantext.API.Routes.Named.Metrics"
                        , "Gargantext.API.Routes.Named.Node"
                        , "Gargantext.API.Routes.Named.Private"
                        , "Gargantext.API.Routes.Named.Public"
                        , "Gargantext.API.Routes.Named.Publish"
                        , "Gargantext.API.Routes.Named.Remote"
                        , "Gargantext.API.Routes.Named.Search"
                        , "Gargantext.API.Routes.Named.Share"
                        , "Gargantext.API.Routes.Named.Table"
                        , "Gargantext.API.Routes.Named.Tree"
                        , "Gargantext.API.Routes.Named.Viz"
                        , "Gargantext.API.Routes.Types"
                        , "Gargantext.API.Search.Types"
                        , "Gargantext.API.Table.Types"
                        , "Gargantext.API.Types"
                        , "Gargantext.API.Viz.Types"
                        , "Gargantext.API.Worker"
                        , "Gargantext.Core"
                        , "Gargantext.Core.Config"
                        , "Gargantext.Core.Config.Ini.Ini"
                        , "Gargantext.Core.Config.Ini.Mail"
                        , "Gargantext.Core.Config.Ini.NLP"
                        , "Gargantext.Core.Config.Mail"
                        , "Gargantext.Core.Config.NLP"
                        , "Gargantext.Core.Config.Types"
                        , "Gargantext.Core.Config.Utils"
                        , "Gargantext.Core.Config.Worker"
                        , "Gargantext.Core.LinearAlgebra"
                        , "Gargantext.Core.LinearAlgebra.Distributional"
                        , "Gargantext.Core.LinearAlgebra.Operations"
                        , "Gargantext.Core.Mail"
                        , "Gargantext.Core.Mail.Types"
                        , "Gargantext.Core.Methods.Matrix.Accelerate.Utils"
                        , "Gargantext.Core.Methods.Similarities"
                        , "Gargantext.Core.Methods.Similarities.Accelerate.Distributional"
                        , "Gargantext.Core.Methods.Similarities.Conditional"
                        , "Gargantext.Core.NLP"
                        , "Gargantext.Core.NodeStory"
                        , "Gargantext.Core.NodeStory.DB"
                        , "Gargantext.Core.NodeStory.Types"
                        , "Gargantext.Core.Notifications"
                        , "Gargantext.Core.Notifications.CentralExchange"
                        , "Gargantext.Core.Notifications.CentralExchange.Types"
                        , "Gargantext.Core.Notifications.Dispatcher"
                        , "Gargantext.Core.Notifications.Dispatcher.Subscriptions"
                        , "Gargantext.Core.Notifications.Dispatcher.Types"
                        , "Gargantext.Core.Notifications.Dispatcher.WebSocket"
                        , "Gargantext.Core.Notifications.Nanomsg"
                        , "Gargantext.Core.Text"
                        , "Gargantext.Core.Text.Context"
                        , "Gargantext.Core.Text.Corpus.API"
                        , "Gargantext.Core.Text.Corpus.API.Arxiv"
                        , "Gargantext.Core.Text.Corpus.API.EPO"
                        , "Gargantext.Core.Text.Corpus.API.OpenAlex"
                        , "Gargantext.Core.Text.Corpus.API.Pubmed"
                        , "Gargantext.Core.Text.Corpus.Parsers"
                        , "Gargantext.Core.Text.Corpus.Parsers.Types"
                        , "Gargantext.Core.Text.Corpus.Parsers.Date"
                        , "Gargantext.Core.Text.Corpus.Parsers.TSV"
                        , "Gargantext.Core.Text.Corpus.Query"
                        , "Gargantext.Core.Text.List"
                        , "Gargantext.Core.Text.List.Formats.TSV"
                        , "Gargantext.Core.Text.List.Group.WithStem"
                        , "Gargantext.Core.Text.List.Social"
                        , "Gargantext.Core.Text.Metrics"
                        , "Gargantext.Core.Text.Metrics.CharByChar"
                        , "Gargantext.Core.Text.Metrics.Count"
                        , "Gargantext.Core.Text.Metrics.TFICF"
                        , "Gargantext.Core.Text.Ngrams"
                        , "Gargantext.Core.Text.Terms"
                        , "Gargantext.Core.Text.Terms.Eleve"
                        , "Gargantext.Core.Text.Terms.Mono"
                        , "Gargantext.Core.Text.Terms.Mono.Stem"
                        , "Gargantext.Core.Text.Terms.Mono.Stem.Internal.GargPorter"
                        , "Gargantext.Core.Text.Terms.Mono.Stem.Internal.Lancaster"
                        , "Gargantext.Core.Text.Terms.Mono.Stem.Internal.Porter"
                        , "Gargantext.Core.Text.Terms.Multi"
                        , "Gargantext.Core.Text.Terms.Multi.Lang.En"
                        , "Gargantext.Core.Text.Terms.Multi.Lang.Fr"
                        , "Gargantext.Core.Text.Terms.Multi.RAKE"
                        , "Gargantext.Core.Text.Terms.WithList"
                        , "Gargantext.Core.Types"
                        , "Gargantext.Core.Types.Individu"
                        , "Gargantext.Core.Types.Main"
                        , "Gargantext.Core.Types.Phylo"
                        , "Gargantext.Core.Types.Query"
                        , "Gargantext.Core.Utils"
                        , "Gargantext.Core.Utils.Aeson"
                        , "Gargantext.Core.Utils.Prefix"
                        , "Gargantext.Core.Viz.Graph.Index"
                        , "Gargantext.Core.Viz.Graph.Tools"
                        , "Gargantext.Core.Viz.Graph.Tools.IGraph"
                        , "Gargantext.Core.Viz.Graph.Types"
                        , "Gargantext.Core.Viz.Phylo"
                        , "Gargantext.Core.Viz.Phylo.API"
                        , "Gargantext.Core.Viz.Phylo.API.Tools"
                        , "Gargantext.Core.Viz.Phylo.Example"
                        , "Gargantext.Core.Viz.Phylo.PhyloExport"
                        , "Gargantext.Core.Viz.Phylo.PhyloMaker"
                        , "Gargantext.Core.Viz.Phylo.PhyloTools"
                        , "Gargantext.Core.Viz.Phylo.SynchronicClustering"
                        , "Gargantext.Core.Viz.Types"
                        , "Gargantext.Core.Worker"
                        , "Gargantext.Core.Worker.Broker"
                        , "Gargantext.Core.Worker.Env"
                        , "Gargantext.Core.Worker.Jobs"
                        , "Gargantext.Core.Worker.Jobs.Types"
                        , "Gargantext.Core.Worker.PGMQTypes"
                        , "Gargantext.Core.Worker.Types"
                        , "Gargantext.Database.Action.Flow"
                        , "Gargantext.Database.Action.Flow.Types"
                        , "Gargantext.Database.Action.Flow.Utils"
                        , "Gargantext.Database.Action.Metrics.NgramsByContext"
                        , "Gargantext.Database.Action.Metrics.TFICF"
                        , "Gargantext.Database.Action.Search"
                        , "Gargantext.Database.Action.User"
                        , "Gargantext.Database.Action.User.New"
                        , "Gargantext.Database.Admin.Config"
                        , "Gargantext.Database.Admin.Trigger.Init"
                        , "Gargantext.Database.Admin.Types.Hyperdata"
                        , "Gargantext.Database.Admin.Types.Hyperdata.Corpus"
                        , "Gargantext.Database.Admin.Types.Hyperdata.Document"
                        , "Gargantext.Database.Admin.Types.Hyperdata.Folder"
                        , "Gargantext.Database.Admin.Types.Node"
                        , "Gargantext.Database.Class"
                        , "Gargantext.Database.Prelude"
                        , "Gargantext.Database.Query.Facet"
                        , "Gargantext.Database.Query.Table.Ngrams"
                        , "Gargantext.Database.Query.Table.NgramsPostag"
                        , "Gargantext.Database.Query.Table.Node"
                        , "Gargantext.Database.Query.Table.Node.Error"
                        , "Gargantext.Database.Query.Table.Node.UpdateOpaleye"
                        , "Gargantext.Database.Query.Table.Node.User"
                        , "Gargantext.Database.Query.Table.NodeContext"
                        , "Gargantext.Database.Query.Table.NodeNode"
                        , "Gargantext.Database.Query.Table.User"
                        , "Gargantext.Database.Query.Tree.Root"
                        , "Gargantext.Database.Schema.Context"
                        , "Gargantext.Database.Schema.Ngrams"
                        , "Gargantext.Database.Schema.Node"
                        , "Gargantext.Database.Schema.Prelude"
                        , "Gargantext.Database.Schema.User"
                        , "Gargantext.Database.Transactional"
                        , "Gargantext.Database.Transactional.Example"
                        , "Gargantext.Defaults"
                        , "Gargantext.MicroServices.ReverseProxy"
                        , "Gargantext.Orphans"
                        , "Gargantext.Orphans.Accelerate"
                        , "Gargantext.Orphans.OpenAPI"
                        , "Gargantext.System.Logging"
                        , "Gargantext.System.Logging.Loggers"
                        , "Gargantext.System.Logging.Types"
                        , "Gargantext.Utils.Dict"
                        , "Gargantext.Utils.Jobs.Error"
                        , "Gargantext.Utils.Jobs.Monad"
                        , "Gargantext.Utils.SpacyNLP"
                        , "Gargantext.Utils.SpacyNLP.Types"
                        , "Gargantext.Utils.Tuple"
                        , "Gargantext.Utils.Zip"
                        , "Paths_gargantext"
                        ]
:}

-- Define a command that loads all modules from the above list:
:def ggload const $ pure $ foldMap (\m -> "import " <> m <> "\n") gargantextModules
