compileBaseLib :: FilePath -> FilePath -> FilePath -> Value -> IO ()
compileBaseLib base_dir jcab jreg (String lib') = do
    b <- doesDirectoryExist dir
    unless b $ sh $ "cd " ++ base_dir ++ " && git clone " ++ lib
    fls <- getDirectoryContents dir
    if isJust $ find (isSuffixOf ".conf") fls
        then return ()
        else compile $ elem "ghc-prim.cabal" fls
    where lib = drop_git_suffix $ T.unpack lib'
          dir = base_dir ++ "/" ++ takeFileName lib
          cd = "cd " ++ dir ++ " && "
          compile b = do when b $ sh $ cd ++ "cabal configure"
                         sh $ cd ++ jcab ++ " configure && " ++ jcab ++ " build"
                         sh $ cd ++ jreg
          drop_git_suffix l = if isSuffixOf ".git" l then reverse $ drop 4 $ reverse l else l
compileBaseLib :: FilePath -> FilePath -> FilePath -> Value -> IO ()
compileBaseLib base_dir jcab jreg (String lib') = do
    b <- doesDirectoryExist dir
    unless b $ sh $ "cd " ++ base_dir ++ " && git clone " ++ lib
    fls <- getDirectoryContents dir
    if isJust $ find (isSuffixOf ".conf") fls
        then return ()
        else compile $ elem "ghc-prim.cabal" fls
    where lib = drop_git_suffix $ T.unpack lib'
          dir = base_dir ++ "/" ++ takeFileName lib
          cd = "cd " ++ dir ++ " && "
          compile b = do when b $ sh $ cd ++ "cabal configure"
                         sh $ cd ++ jcab ++ " configure && " ++ jcab ++ " build"
                         sh $ cd ++ jreg
          drop_git_suffix l = if isSuffixOf ".git" l then reverse $ drop 4 $ reverse l else l
compileBaseLib base_dir jcab jreg (String lib') = do
    b <- doesDirectoryExist dir
    unless b $ sh $ "cd " ++ base_dir ++ " && git clone " ++ lib
    fls <- getDirectoryContents dir
    if isJust $ find (isSuffixOf ".conf") fls
        then return ()
        else compile $ elem "ghc-prim.cabal" fls
    where lib = drop_git_suffix $ T.unpack lib'
          dir = base_dir ++ "/" ++ takeFileName lib
          cd = "cd " ++ dir ++ " && "
          compile b = do when b $ sh $ cd ++ "cabal configure"
                         sh $ cd ++ jcab ++ " configure && " ++ jcab ++ " build"
                         sh $ cd ++ jreg
          drop_git_suffix l = if isSuffixOf ".git" l then reverse $ drop 4 $ reverse l else l