<commit_before>{-# LANGUAGE OverloadedStrings #-}
module GHCiManager (
        GHCiHandle,
        newGHCi,
        killGHCi,
        queryGHCi
    ) where

import CJail.System.Process
import Control.Exception
import Control.Monad
import Data.Text (Text)
import qualified Data.Text as T
import qualified Data.Text.IO as T
import System.IO

import GHCiParser

type GHCiHandle = ProcessHandle

cjailConf :: CJailConf
cjailConf = CJailConf Nothing Nothing "/home/hs15/cjail/ghci-online-jail/"

ghciPath :: FilePath
ghciPath = "/home/ghc/bin/ghci-safe"

ghciArgs :: [String]
ghciArgs = ["-XSafe", "-fpackage-trust", "-distrust-all-packages", "-trust base"]

stdoutSentinel, stderrSentinel :: Text
stdoutSentinel = "01234568909876543210"
stderrSentinel = "oopsthisisnotavariable"

newGHCi :: IO GHCiHandle
newGHCi = do
    phandle@(ProcessHandle hin hout herr _) <-
      createProcess cjailConf (proc ghciPath ghciArgs)
    -- TODO: check this actually worked...
    hSetBuffering hin NoBuffering<commit_msg>update ghc paths (yes hacky)<commit_after>{-# LANGUAGE OverloadedStrings #-}
module GHCiManager (
        GHCiHandle,
        newGHCi,
        killGHCi,
        queryGHCi
    ) where

import CJail.System.Process
import Control.Exception
import Control.Monad
import Data.Text (Text)
import qualified Data.Text as T
import qualified Data.Text.IO as T
import System.IO

import GHCiParser

type GHCiHandle = ProcessHandle

cjailConf :: CJailConf
cjailConf = CJailConf Nothing Nothing "/opt/ghc-online/jail/"

ghciPath :: FilePath
ghciPath = "/usr/bin/ghci-safe"

ghciArgs :: [String]
ghciArgs = ["-XSafe", "-fpackage-trust", "-distrust-all-packages", "-trust base"]

stdoutSentinel, stderrSentinel :: Text
stdoutSentinel = "01234568909876543210"
stderrSentinel = "oopsthisisnotavariable"

newGHCi :: IO GHCiHandle
newGHCi = do
    phandle@(ProcessHandle hin hout herr _) <-
      createProcess cjailConf (proc ghciPath ghciArgs)
    -- TODO: check this actually worked...
    hSetBuffering hin NoBuffering
{'fraction_non_alphanumeric': 0.09725685785536159, 'fraction_numerical': 0.020947630922693267, 'mean_word_length': 4.015, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, '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': '6843149', 'n_tokens_mistral': 736, 'n_tokens_neox': 686, 'n_words': 171}