-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make bosatsu.tool package, move some items from MainModule (#1321)
- Loading branch information
Showing
11 changed files
with
121 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package org.bykn.bosatsu.tool | ||
|
||
sealed abstract class FileKind(val name: String) | ||
object FileKind { | ||
case object Source extends FileKind("source") | ||
case object Iface extends FileKind("interface") | ||
case object Pack extends FileKind("package") | ||
} |
21 changes: 21 additions & 0 deletions
21
core/src/main/scala/org/bykn/bosatsu/tool/GraphOutput.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.bykn.bosatsu.tool | ||
|
||
import cats.data.Validated | ||
import com.monovore.decline.Opts | ||
|
||
sealed abstract class GraphOutput | ||
object GraphOutput { | ||
case object Dot extends GraphOutput | ||
case object Json extends GraphOutput | ||
|
||
val jsonOrDot: Opts[GraphOutput] = | ||
Opts | ||
.option[String]("graph_format", "format of graph, either json or dot") | ||
.mapValidated { | ||
case "json" => Validated.valid(Json) | ||
case "dot" => Validated.valid(Dot) | ||
case other => | ||
Validated.invalidNel(s"\"$other\" invalid, expected json or dot") | ||
} | ||
.withDefault(Json) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.bykn.bosatsu.tool | ||
|
||
import cats.Eval | ||
import cats.data.NonEmptyList | ||
import org.bykn.bosatsu.{Json, Package, PackageName, Test, Value, rankn} | ||
import org.typelevel.paiges.Doc | ||
import org.bykn.bosatsu.LocationMap.Colorize | ||
|
||
sealed abstract class Output[+Path] | ||
object Output { | ||
case class TestOutput( | ||
tests: List[(PackageName, Option[Eval[Test]])], | ||
colorize: Colorize | ||
) extends Output[Nothing] | ||
|
||
case class EvaluationResult( | ||
value: Eval[Value], | ||
tpe: rankn.Type, | ||
doc: Eval[Doc] | ||
) extends Output[Nothing] | ||
|
||
case class JsonOutput[Path](json: Json, output: Option[Path]) extends Output[Path] | ||
|
||
case class CompileOut[Path]( | ||
packList: List[Package.Typed[Any]], | ||
ifout: Option[Path], | ||
output: Option[Path] | ||
) extends Output[Path] | ||
|
||
case class TranspileOut[Path](outs: List[(NonEmptyList[String], Doc)], base: Path) | ||
extends Output[Path] | ||
|
||
case class ShowOutput[Path]( | ||
packages: List[Package.Typed[Any]], | ||
ifaces: List[Package.Interface], | ||
output: Option[Path] | ||
) extends Output[Path] | ||
|
||
case class DepsOutput[Path]( | ||
depinfo: List[(Path, PackageName, FileKind, List[PackageName])], | ||
output: Option[Path], | ||
style: GraphOutput | ||
) extends Output[Path] | ||
} |
Oops, something went wrong.