-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basics for generating mermaid definitions for PolyMaps
- Loading branch information
1 parent
ecad5f5
commit 38f93c3
Showing
4 changed files
with
114 additions
and
17 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
49 changes: 49 additions & 0 deletions
49
modules/mermaid/shared/src/main/scala/polynomial/mermaid/Mermaid.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,49 @@ | ||
package polynomial.mermaid | ||
|
||
import polynomial.morphism.PolyMap | ||
import polynomial.`object`.{Monomial, Store} | ||
import scala.reflect.ClassTag | ||
|
||
trait Mermaid[P[_]]: | ||
def showGeneric: String | ||
def showSpecific: String | ||
|
||
object Mermaid: | ||
|
||
given moore[S, A, B](using | ||
S: ClassTag[S], | ||
A: ClassTag[A], | ||
B: ClassTag[B] | ||
): Mermaid[PolyMap[Store[S, _], Monomial[A, B, _], _]] = | ||
new Mermaid[PolyMap[Store[S, _], Monomial[A, B, _], _]]: | ||
|
||
def showGeneric: String = | ||
s"""|```mermaid | ||
|graph LR; | ||
| A:::hidden-->|A|S-->|B|B:::hidden; | ||
|```""".stripMargin | ||
|
||
def showSpecific: String = | ||
s"""|```mermaid | ||
|graph LR; | ||
| A[${A.toString}]:::hidden-->|${A.toString}|S[${S.toString}]-->|${B.toString}|B[${B.toString}]:::hidden; | ||
|```""".stripMargin | ||
|
||
given mealy[S, A, B](using | ||
S: ClassTag[S], | ||
A: ClassTag[A], | ||
B: ClassTag[B] | ||
): Mermaid[PolyMap[Store[S, _], Monomial[A, A => B, _], _]] = | ||
new Mermaid[PolyMap[Store[S, _], Monomial[A, A => B, _], _]]: | ||
|
||
def showGeneric: String = | ||
s"""|```mermaid | ||
|graph LR; | ||
| A:::hidden-->|A|S-->|B|B:::hidden; | ||
|```""".stripMargin | ||
|
||
def showSpecific: String = | ||
s"""|```mermaid | ||
|graph LR; | ||
| A[${A.toString}]:::hidden-->|${A.toString}|S[${S.toString}]-->|${A.toString} => ${B.toString}|B[${A.toString} => ${B.toString}]:::hidden; | ||
|```""".stripMargin |