lean4-htt/Lake/Build/MonadBasic.lean
2021-11-11 00:10:52 -05:00

36 lines
940 B
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/-
Copyright (c) 2021 Mac Malone. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Mac Malone
-/
import Lake.Util.Task
import Lake.Build.Trace
import Lake.Build.MonadCore
import Lake.Config.InstallPath
import Lake.Config.OpaquePackage
open System
namespace Lake
structure BuildContext where
leanTrace : BuildTrace
leanInstall : LeanInstall
lakeInstall : LakeInstall
package : OpaquePackage
abbrev BuildM :=
ReaderT BuildContext BuildCoreM
/-- `Task` type for `BuildM`/`BuildCoreM`. -/
abbrev BuildTask :=
EIOTask PUnit
def BuildM.run (logMethods : LogMethods BaseIO) (ctx : BuildContext) (self : BuildM α) : IO α :=
self ctx |>.run logMethods
def failOnBuildCycle [ToString k] : Except (List k) α → BuildM α
| Except.ok a => a
| Except.error cycle => do
let cycle := cycle.map (s!" {·}")
logError s!"build cycle detected:\n{"\n".intercalate cycle}"
failure