Skip to content

Commit

Permalink
Split functions in CLI
Browse files Browse the repository at this point in the history
  • Loading branch information
owickstrom committed Jul 17, 2016
1 parent b256998 commit 72b1bb7
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions cli/Oden/CLI/Build.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,22 @@ resolvePkg :: CompileEnvironment -> TypedPackage -> CLI TypedPackage
resolvePkg compileEnv pkg' =
liftEither (resolveInPackage compileEnv pkg')

resolveImplsInFile :: SourceFile -> CLI (CompileEnvironment, TypedPackage)
resolveImplsInFile sourceFile = do
inferAndValidateFile :: SourceFile -> CLI TypedPackage
inferAndValidateFile sourceFile = do
inferredPkg <- snd <$> inferFile sourceFile
validateTypedPkg inferredPkg
return inferredPkg

resolveImplsInPackage :: TypedPackage -> CLI (CompileEnvironment, TypedPackage)
resolveImplsInPackage inferredPkg = do
let compileEnv = environmentFromPackage inferredPkg
resolvedPkg <- resolvePkg compileEnv inferredPkg
return (compileEnv, resolvedPkg)

compileFile :: SourceFile -> CLI MonomorphedPackage
compileFile sourceFile = do
(compileEnv, resolvedPkg) <- resolveImplsInFile sourceFile
inferredPkg <- inferAndValidateFile sourceFile
(compileEnv, resolvedPkg) <- resolveImplsInPackage inferredPkg
liftEither (compile compileEnv resolvedPkg)

codegenPkg :: MonomorphedPackage -> CLI [CompiledFile]
Expand Down

0 comments on commit 72b1bb7

Please sign in to comment.