mergeCode :: (HasEnvironment m) => CodeType -> CodeMap -> CodeLocation -> m CodeMap
mergeCode ct cmap cl = do
    debugM $ "\tMerging " ++ (fst cl)
    ms <- customMergeToDir (joinPath [normalise $ getStub ct]) (fst cl) compiledDir
    case ms of
        MergeFailure err            -> do debugM ("\tMerge error : " ++ (show err))
                                          return $ insert cl (CodeLoadFailure $ unlines err) cmap
        MergeSuccess NotReq _    _  -> do debugM ("\tMerge success (No recompilation required) : " ++ (fst cl)) 
                                          return cmap
        MergeSuccess _      args fp -> do debugM ("\tMerge success : " ++ (fst cl)) 
                                          makeCode ct cmap cl args fp


-- | Attempt to make the code, then call the loader appropriate for the 'CodeType' (e.g. @View@ -> '_loadView').
mergeCode :: (HasEnvironment m) => CodeType -> CodeMap -> CodeLocation -> m CodeMap
mergeCode ct cmap cl = do
    debugM $ "\tMerging " ++ (fst cl)
    ms <- customMergeToDir (joinPath [normalise $ getStub ct]) (fst cl) compiledDir
    case ms of
        MergeFailure err            -> do debugM ("\tMerge error : " ++ (show err))
                                          return $ insert cl (CodeLoadFailure $ unlines err) cmap
        MergeSuccess NotReq _    _  -> do debugM ("\tMerge success (No recompilation required) : " ++ (fst cl)) 
                                          return cmap
        MergeSuccess _      args fp -> do debugM ("\tMerge success : " ++ (fst cl)) 
                                          makeCode ct cmap cl args fp


-- | Attempt to make the code, then call the loader appropriate for the 'CodeType' (e.g. @View@ -> '_loadView').
mergeCode ct cmap cl = do
    debugM $ "\tMerging " ++ (fst cl)
    ms <- customMergeToDir (joinPath [normalise $ getStub ct]) (fst cl) compiledDir
    case ms of
        MergeFailure err            -> do debugM ("\tMerge error : " ++ (show err))
                                          return $ insert cl (CodeLoadFailure $ unlines err) cmap
        MergeSuccess NotReq _    _  -> do debugM ("\tMerge success (No recompilation required) : " ++ (fst cl)) 
                                          return cmap
        MergeSuccess _      args fp -> do debugM ("\tMerge success : " ++ (fst cl)) 
                                          makeCode ct cmap cl args fp


-- | Attempt to make the code, then call the loader appropriate for the 'CodeType' (e.g. @View@ -> '_loadView').