<commit_before>-- This file compiles all library and runtime code 
-- into elm-runtime.js. Run it with following command:
--
--     runHaskell Build.hs
--
-- Note: This does NOT compile the compiler! Run `cabal install`
-- from the compiler/ directory to do that.

import System.Cmd
import System.Directory
import System.Exit
import System.FilePath
import System.IO
import Language.Elm

getFiles ext dir = do
  contents <- map (dir </>) `fmap` getDirectoryContents dir
  let files = filter (\f -> takeExtension f == ext) contents
      dirs  = filter (not . hasExtension) contents
  filess <- mapM (getFiles ext) dirs
  return (files ++ concat filess)
  
appendJS file = do
  putStrLn (dropExtension file)
  str <- readFile file
  length str `seq` return ()
  appendFile "elm-runtime.js" str

appendElm file = do
  system ("elm --only-js " ++ file)
  let jsFile = replaceExtension file ".js"
  appendJS jsFile
  removeFile jsFile

main = do
  writeFile "elm-runtime.js" "Elm = {}; Elm.Native = {};\n"
  mapM_ appendJS  =<< getFiles ".js"  "libraries"
  mapM_ appendElm =<< getFiles ".elm" "libraries"
  mapM_ appendJS  =<< getFiles ".js"  "runtime"
  exitSuccess<commit_msg>Add success message that makes it clearer that the compiler is built separately.<commit_after>-- This file compiles all library and runtime code 
-- into elm-runtime.js. Run it with following command:
--
--     runHaskell Build.hs
--
-- Note: This does NOT compile the compiler! Run `cabal install`
-- from the compiler/ directory to do that.

import System.Cmd
import System.Directory
import System.Exit
import System.FilePath
import System.IO
import Language.Elm

getFiles ext dir = do
  contents <- map (dir </>) `fmap` getDirectoryContents dir
  let files = filter (\f -> takeExtension f == ext) contents
      dirs  = filter (not . hasExtension) contents
  filess <- mapM (getFiles ext) dirs
  return (files ++ concat filess)
  
appendJS file = do
  putStrLn (dropExtension file)
  str <- readFile file
  length str `seq` return ()
  appendFile "elm-runtime.js" str

appendElm file = do
  system ("elm --only-js " ++ file)
  let jsFile = replaceExtension file ".js"
  appendJS jsFile
  removeFile jsFile

main = do
  writeFile "elm-runtime.js" "Elm = {}; Elm.Native = {}; Elm.Native.Graphics = {}; Elm.Graphics = {};\n"
  mapM_ appendJS  =<< getFiles ".js"  "libraries"
  mapM_ appendElm =<< getFiles ".elm" "libraries"
  mapM_ appendJS  =<< getFiles ".js"  "runtime"
  putStrLn "Success building runtime and libraries!"
  exitSuccess
{'fraction_non_alphanumeric': 0.11102268205332272, 'fraction_numerical': 0.0, 'mean_word_length': 3.4653641207815276, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 7, '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': '7066922', 'n_tokens_mistral': 795, 'n_tokens_neox': 785, 'n_words': 287}