{-# LANGUAGE BlockArguments      #-}
{-# LANGUAGE ImportQualifiedPost #-}
{-# LANGUAGE OverloadedStrings   #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications    #-}
{-# LANGUAGE ViewPatterns        #-}

module Dovetail.Core.Data.Show.Generic where

import Data.Text (Text)
import Data.Text qualified as Text
import Data.Vector (Vector)
import Data.Vector qualified as Vector
import Dovetail
import Dovetail.Evaluate (builtIn)

env :: forall ctx. Env ctx
env :: Env ctx
env = do
  let _ModuleName :: ModuleName
_ModuleName = Text -> ModuleName
ModuleName Text
"Data.Show.Generic"

  -- intercalate :: String -> Array String -> String
  ModuleName
-> Text -> (Text -> Vector Text -> Eval ctx Text) -> Env ctx
forall ctx a. ToValue ctx a => ModuleName -> Text -> a -> Env ctx
builtIn @ctx @(Text -> Vector Text -> Eval ctx Text)
    ModuleName
_ModuleName Text
"intercalate"
    \Text
sep Vector Text
xs ->
      Text -> Eval ctx Text
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Text -> [Text] -> Text
Text.intercalate Text
sep (Vector Text -> [Text]
forall a. Vector a -> [a]
Vector.toList Vector Text
xs))