Skip to content

Instantly share code, notes, and snippets.

@chadaustin
Created February 29, 2016 15:28
Show Gist options
  • Select an option

  • Save chadaustin/5f534171b3e40a250bf0 to your computer and use it in GitHub Desktop.

Select an option

Save chadaustin/5f534171b3e40a250bf0 to your computer and use it in GitHub Desktop.
type ModuleLoader = AST.ModuleName -> IO (Either Error.Error AST.ParsedModule)
newChainedModuleLoader :: [ModuleLoader] -> ModuleLoader
newChainedModuleLoader [] moduleName = return $ Left $ Error.ModuleNotFound moduleName
newChainedModuleLoader (loader:rest) moduleName = do
loader moduleName >>= \case
Left (Error.ModuleNotFound _) -> newChainedModuleLoader rest moduleName
Left e -> return $ Left e
Right m -> return $ Right m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment