<commit_before>import BreveEval
import System.Environment

promptChanges :: IO [String]
promptChanges = putStrLn ">>Enter changes: (line, col) val (blank line when done)" >> changes []

changes :: [String] -> IO [String]
changes ts = do
    putStr "> "
    s <- getLine
    case s of
        [] -> return ts
        t -> changes (t:ts)

main = do
    [fname] <- getArgs
    file <- readFile fname
    let (prog, traces) = interp file
    run file
    putStrLn "\nSource:"
    putStrLn file
    putStrLn "Program:"
    putStrLn (show prog)
    putStrLn "\nTraces:"
    mapM_ (putStrLn . show) traces
    changes <- fmap (map words) promptChanges
    mapM_ (putStrLn . unwords) changes
<commit_msg>Extremely fragile, but it's there<commit_after>import BreveEval
import BreveLang
import BrevePrinter
import Synth
import System.Environment
import qualified Euterpea.Music.Note.Music as E

promptChanges :: IO [String]
promptChanges = putStrLn ">>Enter changes: (line, col) val (blank line when done)" >> changes []

changes :: [String] -> IO [String]
changes ts = do
    -- putStr "> "
    s <- getLine
    case s of
        [] -> return ts
        t -> changes (t:ts)

changesToTraces :: [String] -> Traces
changesToTraces = map parseTrace

parseTrace :: String -> Expr
parseTrace s = let [(loc,rem)] = readLoc s in
    if readPitchClass rem /= [] then (PitchClass (fst $ head $ readPitchClass rem) loc)
    else if readDuration rem /= [] then (Duration (fst $ head $ readDuration rem) loc)
    else if readOctave rem /= [] then (Octave (fst $ head $ readOctave rem) loc)
    else error "Badly formatted trace"

readLoc :: String -> [(Loc, String)]
readLoc = reads

readPitchClass :: String -> [(E.PitchClass, String)]
readPitchClass = reads

readOctave :: String -> [(E.Octave, String)]
readOctave = reads

readDuration :: String -> [(E.Dur, String)]
readDuration s = [(dur, rem)]
    where
        llex :: String -> [(String, String)]
        llex = lex
        [(s, rem)] = llex s
        dur = strToDur s

main = do
    [fname] <- getArgs
    file <- readFile fname
    let (prog, traces) = interp file
    run file
    putStrLn "\nSource:"
    putStrLn file
    putStrLn "Program:"
    putStrLn (show prog)
    putStrLn "\nTraces:"
    mapM_ (putStrLn . show) traces
    newTraces <- fmap changesToTraces promptChanges
    putStrLn (show newTraces)
    let newProg = updateProg prog traces newTraces
    let newP = unparse newProg
    run newP
    return ()

{'fraction_non_alphanumeric': 0.11504065040650406, 'fraction_numerical': 0.0, 'mean_word_length': 2.9565916398713825, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 26, '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': '4170639', 'n_tokens_mistral': 838, 'n_tokens_neox': 804, 'n_words': 269}