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

module Dovetail.Core.Data.String.CodePoints where

import Data.Foldable (fold)
import Data.Text (Text)
import Data.Vector (Vector)
import Dovetail
import Dovetail.Evaluate (builtIn)

type CodePoint = Integer

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

  [Env ctx] -> Env ctx
forall (t :: * -> *) m. (Foldable t, Monoid m) => t m -> m
fold
    [ -- _singleton
      --   :: (CodePoint -> String)
      --   -> CodePoint
      --   -> String
      ModuleName
-> Text
-> ((CodePoint -> Eval ctx Text) -> CodePoint -> Eval ctx Text)
-> Env ctx
forall ctx a. ToValue ctx a => ModuleName -> Text -> a -> Env ctx
builtIn @ctx @((CodePoint -> Eval ctx Text) -> CodePoint -> Eval ctx Text)
        ModuleName
_ModuleName Text
"_singleton" 
        \CodePoint -> Eval ctx Text
fallback -> CodePoint -> Eval ctx Text
fallback
      -- _fromCodePointArray
      --   :: (CodePoint -> String)
      --   -> Array CodePoint
      --   -> String
    , ModuleName
-> Text
-> ((Vector CodePoint -> Eval ctx Text)
    -> Vector CodePoint -> Eval ctx Text)
-> Env ctx
forall ctx a. ToValue ctx a => ModuleName -> Text -> a -> Env ctx
builtIn @ctx @((Vector CodePoint -> Eval ctx Text) -> Vector CodePoint -> Eval ctx Text)
        ModuleName
_ModuleName Text
"_fromCodePointArray" 
        \Vector CodePoint -> Eval ctx Text
fallback -> Vector CodePoint -> Eval ctx Text
fallback
      -- _toCodePointArray
      --   :: (String -> Array CodePoint)
      --   -> (String -> CodePoint)
      --   -> String
      --   -> Array CodePoint
    , ModuleName
-> Text
-> ((Text -> Eval ctx (Vector CodePoint))
    -> (Text -> Eval ctx CodePoint)
    -> Text
    -> Eval ctx (Vector CodePoint))
-> Env ctx
forall ctx a. ToValue ctx a => ModuleName -> Text -> a -> Env ctx
builtIn @ctx @((Text -> Eval ctx (Vector CodePoint)) -> (Text -> Eval ctx CodePoint) -> Text -> Eval ctx (Vector CodePoint))
        ModuleName
_ModuleName Text
"_toCodePointArray" 
        \Text -> Eval ctx (Vector CodePoint)
fallback Text -> Eval ctx CodePoint
_ -> Text -> Eval ctx (Vector CodePoint)
fallback
      -- _codePointAt
      --   :: (Int -> String -> Maybe CodePoint)
      --   -> (forall a. a -> Maybe a)
      --   -> (forall a. Maybe a)
      --   -> (String -> CodePoint)
      --   -> Int
      --   -> String
      --   -> Maybe CodePoint
    , ModuleName
-> Text
-> ((CodePoint -> Text -> Eval ctx (Value ctx))
    -> (Value ctx -> Eval ctx (Value ctx))
    -> Value ctx
    -> (Text -> Eval ctx CodePoint)
    -> CodePoint
    -> Text
    -> Eval ctx (Value ctx))
-> Env ctx
forall ctx a. ToValue ctx a => ModuleName -> Text -> a -> Env ctx
builtIn @ctx @((Integer -> Text -> Eval ctx (Value ctx)) -> (Value ctx -> Eval ctx (Value ctx)) -> Value ctx -> (Text -> Eval ctx CodePoint) -> Integer -> Text -> Eval ctx (Value ctx))
        ModuleName
_ModuleName Text
"_codePointAt" 
        \CodePoint -> Text -> Eval ctx (Value ctx)
fallback Value ctx -> Eval ctx (Value ctx)
_ Value ctx
_ Text -> Eval ctx CodePoint
_ -> CodePoint -> Text -> Eval ctx (Value ctx)
fallback
      -- _countPrefix
      --   :: ((CodePoint -> Boolean) -> String -> Int)
      --   -> (String -> CodePoint)
      --   -> (CodePoint -> Boolean)
      --   -> String
      --   -> Int
    , ModuleName
-> Text
-> (((CodePoint -> Eval ctx Bool) -> Text -> Eval ctx CodePoint)
    -> (Text -> Eval ctx CodePoint)
    -> (CodePoint -> Eval ctx Bool)
    -> Text
    -> Eval ctx CodePoint)
-> Env ctx
forall ctx a. ToValue ctx a => ModuleName -> Text -> a -> Env ctx
builtIn @ctx @(((CodePoint -> Eval ctx Bool) -> Text -> Eval ctx Integer) -> (Text -> Eval ctx CodePoint) -> (CodePoint -> Eval ctx Bool) -> Text -> Eval ctx Integer)
        ModuleName
_ModuleName Text
"_countPrefix" 
        \(CodePoint -> Eval ctx Bool) -> Text -> Eval ctx CodePoint
fallback Text -> Eval ctx CodePoint
_ -> (CodePoint -> Eval ctx Bool) -> Text -> Eval ctx CodePoint
fallback
      -- _take
      --   :: (Int -> String -> String)
      --   -> Int 
      --   -> String 
      --   -> String
    , ModuleName
-> Text
-> ((CodePoint -> Text -> Eval ctx Text)
    -> CodePoint -> Text -> Eval ctx Text)
-> Env ctx
forall ctx a. ToValue ctx a => ModuleName -> Text -> a -> Env ctx
builtIn @ctx @((Integer -> Text -> Eval ctx Text) -> Integer -> Text -> Eval ctx Text)
        ModuleName
_ModuleName Text
"_take" 
        \CodePoint -> Text -> Eval ctx Text
fallback -> CodePoint -> Text -> Eval ctx Text
fallback
      -- _unsafeCodePointAt0
      --   :: (String -> CodePoint)
      --   -> String
      --   -> CodePoint
    , ModuleName
-> Text
-> ((Text -> Eval ctx CodePoint) -> Text -> Eval ctx CodePoint)
-> Env ctx
forall ctx a. ToValue ctx a => ModuleName -> Text -> a -> Env ctx
builtIn @ctx @((Text -> Eval ctx CodePoint) -> Text -> Eval ctx CodePoint)
        ModuleName
_ModuleName Text
"_unsafeCodePointAt0" 
        \Text -> Eval ctx CodePoint
fallback -> Text -> Eval ctx CodePoint
fallback
    ]