<commit_before>{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
module Incremental
    ( ElementOptions
    , Incremental
    , noKey
    , key
    , keyAndStatics
    , elementOpen
    , elementOpenStart
    , attr
    , elementOpenEnd
    , elementClose
    , element
    , elementVoid
    , text
    , patch
    , Patcher
    , makePatcher
    , callPatcher
    , releasePatcher
    , js_elementOpen
    , js_elementOpenStart
    , js_attr
    , js_elementOpenEnd
    , js_elementClose
    , js_elementVoid
    , js_text
    , js_patch
    ) where

import Control.Applicative
import Control.Monad
import Control.Monad.Base
import Control.Monad.Trans
import Data.JSString
import Data.Typeable
import GHC.TypeLits
import GHCJS.DOM.Element
import GHCJS.DOM.Node
import GHCJS.DOM.Text
import GHCJS.Foreign ()
import GHCJS.Foreign.Callback
import GHCJS.Foreign.Export
import GHCJS.Marshal
import GHCJS.Prim (JSVal)
import GHCJS.Types
import JavaScript.Array
import Unsafe.Coerce

-- TODO flip this around
import Attributes hiding (Text)

{-
newtype ElementOpen a = ElementOpen (IO a)
-}

newtype Incremental a = Incremental (IO a)
  deriving (Applicative, Functor, Monad, MonadIO)

instance MonadBase Incremental Incremental where
  liftBase = id

{-
open :: String -> Maybe String -> ElementOpen () -> Incremental ()
-}

newtype StaticAttributes (e :: Symbol) = StaticAttributes JSArray

incremental :: Incremental a -> IO a
incremental (Incremental m) = m

data ElementOptions (e :: Symbol)
  = NoKey
  | Key {-# UNPACK #-} !JSString
  | KeyAndStatics {-# UNPACK #-} !JSString
                  {-# UNPACK #-} !(StaticAttributes e)

noKey :: ElementOptions e
noKey = NoKey

key :: JSString -> ElementOptions e
key = Key<commit_msg>Add vaguely useful IsString instance to Incremental<commit_after>{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE FlexibleInstances #-}
module Incremental
    ( ElementOptions
    , Incremental
    , noKey
    , key
    , keyAndStatics
    , elementOpen
    , elementOpenStart
    , attr
    , elementOpenEnd
    , elementClose
    , element
    , elementVoid
    , text
    , patch
    , Patcher
    , makePatcher
    , callPatcher
    , releasePatcher
    , js_elementOpen
    , js_elementOpenStart
    , js_attr
    , js_elementOpenEnd
    , js_elementClose
    , js_elementVoid
    , js_text
    , js_patch
    ) where

import Control.Applicative
import Control.Monad
import Control.Monad.Base
import Control.Monad.Trans
import Data.JSString
import Data.String
import Data.Typeable
import GHC.TypeLits
import GHCJS.DOM.Element
import GHCJS.DOM.Node
import GHCJS.DOM.Text
import GHCJS.Foreign ()
import GHCJS.Foreign.Callback
import GHCJS.Foreign.Export
import GHCJS.Marshal
import GHCJS.Prim (JSVal)
import GHCJS.Types
import JavaScript.Array
import Unsafe.Coerce

-- TODO flip this around
import Attributes hiding (Text)

{-
newtype ElementOpen a = ElementOpen (IO a)
-}

newtype Incremental a = Incremental (IO a)
  deriving (Applicative, Functor, Monad, MonadIO)

instance MonadBase Incremental Incremental where
  liftBase = id

instance IsString (Incremental Text) where
  fromString = text . pack

{-
open :: String -> Maybe String -> ElementOpen () -> Incremental ()
-}

newtype StaticAttributes (e :: Symbol) = StaticAttributes JSArray

incremental :: Incremental a -> IO a
incremental (Incremental m) = m

data ElementOptions (e :: Symbol)
  = NoKey
  | Key {-# UNPACK #-} !JSString
  | KeyAndStatics {-# UNPACK #-} !JSString
                  {-# UNPACK #-} !(StaticAttributes e)

noKey :: ElementOptions e
noKey = NoKey

key :: JSString -> ElementOptions e
key = Key
{'fraction_non_alphanumeric': 0.09445429222587996, 'fraction_numerical': 0.0, 'mean_word_length': 3.438202247191011, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '722619', 'n_tokens_mistral': 1322, 'n_tokens_neox': 1282, 'n_words': 331}