-- | This module re-exports common functions so that the other modules doesn't have to import them.
module Haxible.Prelude
  ( module Witch,
    module Data.Maybe,
    json,
    Vars,
    mkObj,
    quote,
    Text,
    LByteString,
    Data.Aeson.Value (..),
    Data.Aeson.Result (..),
    Data.Aeson.fromJSON,
    Data.Bifunctor.first,
    Data.List.nub,
    GHC.Generics.Generic,
    module Control.Monad.Reader,
    module Control.Monad.State,
    (&),
    (.~),
    (%~),
    Control.Lens.preview,
    Control.Lens.itoListOf,
    Debug.Trace.trace,
    System.Environment.lookupEnv,
    Data.List.NonEmpty.nonEmpty,
    Data.List.NonEmpty.NonEmpty,
    module Data.Aeson.Lens,
    module System.FilePath,
    module Control.Monad,
    module Control.Applicative,
    module Data.Foldable,
    module System.Directory,
  )
where

import Control.Applicative
import Control.Lens
import Control.Monad
import Control.Monad.Reader
import Control.Monad.State
import Data.Aeson qualified
import Data.Aeson.Key qualified
import Data.Aeson.KeyMap qualified
import Data.Aeson.Lens
import Data.Aeson.QQ
import Data.Bifunctor qualified
import Data.ByteString.Lazy qualified
import Data.Foldable
import Data.Generics.Labels ()
import Data.List qualified
import Data.List.NonEmpty qualified
import Data.Maybe
import Data.Text (Text)
import Data.Text qualified as Text
import Debug.Trace qualified
import GHC.Generics qualified
import Language.Haskell.TH.Quote qualified
import System.Directory
import System.Environment qualified
import System.FilePath
import Witch

type LByteString = Data.ByteString.Lazy.ByteString

type Vars = [(Text, Data.Aeson.Value)]

mkObj :: [(Text, Data.Aeson.Value)] -> Data.Aeson.Value
mkObj :: [(Text, Value)] -> Value
mkObj = Object -> Value
Data.Aeson.Object (Object -> Value)
-> ([(Text, Value)] -> Object) -> [(Text, Value)] -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [(Key, Value)] -> Object
forall v. [(Key, v)] -> KeyMap v
Data.Aeson.KeyMap.fromList ([(Key, Value)] -> Object)
-> ([(Text, Value)] -> [(Key, Value)]) -> [(Text, Value)] -> Object
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ((Text, Value) -> (Key, Value))
-> [(Text, Value)] -> [(Key, Value)]
forall a b. (a -> b) -> [a] -> [b]
map ((Text -> Key) -> (Text, Value) -> (Key, Value)
forall (p :: * -> * -> *) a b c.
Bifunctor p =>
(a -> b) -> p a c -> p b c
Data.Bifunctor.first Text -> Key
Data.Aeson.Key.fromText)

quote :: Text -> Text
quote :: Text -> Text
quote = Char -> Text -> Text
Text.cons Char
'"' (Text -> Text) -> (Text -> Text) -> Text -> Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Text -> Char -> Text) -> Char -> Text -> Text
forall a b c. (a -> b -> c) -> b -> a -> c
flip Text -> Char -> Text
Text.snoc Char
'"'

json :: Language.Haskell.TH.Quote.QuasiQuoter
json :: QuasiQuoter
json = QuasiQuoter
aesonQQ