_loadController :: (HasEnvironment m) => CodeType -> CodeMap -> CodeLocation -> [Arg] -> FilePath -> m CodeMap
_loadController ct cmap cl args fp = do
    debugM ("_load : " ++ (show ct) ++ " : " ++ (fst cl) ++ " : " ++ (snd cl))
    ls <- liftIO $ load_ fp [compiledDir] (snd cl)
    case ls of
            LoadFailure err -> do debugM ("LoadFailure : " ++ (show err))
                                  return (insert cl (CodeLoadFailure $ unlines err) cmap)
            LoadSuccess m f -> do debugM ("LoadSuccess : " ++ fst cl )
                                  liftIO $ unload m
                                  t <- liftIO $ getCurrentTime
                                  case ct of
                                    CTController          -> return (insert cl (CodeLoadController f t) cmap)
                                    CTComponentController -> return (insert cl (CodeLoadComponentController f t) cmap)
                                    _                     -> error $ "_loadController: passed an invalid CodeType (" ++ (show ct) ++ ")"


-------------------------------------------------------------------------------------------------
-- Utility functions
-------------------------------------------------------------------------------------------------
-- | Custom merge function because I don't want to have to use a custom
-- version of Plugins (with HSX enabled)
_loadController :: (HasEnvironment m) => CodeType -> CodeMap -> CodeLocation -> [Arg] -> FilePath -> m CodeMap
_loadController ct cmap cl args fp = do
    debugM ("_load : " ++ (show ct) ++ " : " ++ (fst cl) ++ " : " ++ (snd cl))
    ls <- liftIO $ load_ fp [compiledDir] (snd cl)
    case ls of
            LoadFailure err -> do debugM ("LoadFailure : " ++ (show err))
                                  return (insert cl (CodeLoadFailure $ unlines err) cmap)
            LoadSuccess m f -> do debugM ("LoadSuccess : " ++ fst cl )
                                  liftIO $ unload m
                                  t <- liftIO $ getCurrentTime
                                  case ct of
                                    CTController          -> return (insert cl (CodeLoadController f t) cmap)
                                    CTComponentController -> return (insert cl (CodeLoadComponentController f t) cmap)
                                    _                     -> error $ "_loadController: passed an invalid CodeType (" ++ (show ct) ++ ")"


-------------------------------------------------------------------------------------------------
-- Utility functions
-------------------------------------------------------------------------------------------------
-- | Custom merge function because I don't want to have to use a custom
-- version of Plugins (with HSX enabled)
_loadController ct cmap cl args fp = do
    debugM ("_load : " ++ (show ct) ++ " : " ++ (fst cl) ++ " : " ++ (snd cl))
    ls <- liftIO $ load_ fp [compiledDir] (snd cl)
    case ls of
            LoadFailure err -> do debugM ("LoadFailure : " ++ (show err))
                                  return (insert cl (CodeLoadFailure $ unlines err) cmap)
            LoadSuccess m f -> do debugM ("LoadSuccess : " ++ fst cl )
                                  liftIO $ unload m
                                  t <- liftIO $ getCurrentTime
                                  case ct of
                                    CTController          -> return (insert cl (CodeLoadController f t) cmap)
                                    CTComponentController -> return (insert cl (CodeLoadComponentController f t) cmap)
                                    _                     -> error $ "_loadController: passed an invalid CodeType (" ++ (show ct) ++ ")"


-------------------------------------------------------------------------------------------------
-- Utility functions
-------------------------------------------------------------------------------------------------
-- | Custom merge function because I don't want to have to use a custom
-- version of Plugins (with HSX enabled)