Skip to content

Commit

Permalink
scala.io fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Krever committed Nov 7, 2024
1 parent 720320d commit 89a76fd
Showing 1 changed file with 46 additions and 32 deletions.
78 changes: 46 additions & 32 deletions 2024-11-scala-io/slides.html
Original file line number Diff line number Diff line change
Expand Up @@ -220,35 +220,6 @@ <h2>Higher-Kinded <br/> Data</h2>

++++

<span class="breadcrumb-data">Decisions4s » The What » Example</span>

### Visualize: markdown

```scala
val markdown = MarkdownRenderer.render(decisionTable)
```

```markdown
|(I) numOfApprovals|(I) isTargetBranchProtected|(I) authorIsAdmin|(O) allowMerging|(O) notifyUnusualAction|
|------------------|---------------------------|-----------------|----------------|-----------------------|
| > 0 | false | - | true | false |
| > 1 | true | - | true | false |
| - | - | true | true | true |
| - | - | - | false | false |
```

++++

### Visualize: DMN

```scala
val dmnXML = DmnRenderer.render(decisionTable).toXML
```

<img src="resources/PullRequestDecision-50329dacab102e3c924e247982d62948.png">

++++

### Evaluate

```scala [1-7|8-11]
Expand Down Expand Up @@ -293,14 +264,43 @@ <h2>Higher-Kinded <br/> Data</h2>

++++

<span class="breadcrumb-data">Decisions4s » The What » Example</span>

### Visualize: markdown

```scala
val markdown = MarkdownRenderer.render(decisionTable)
```

```markdown
|(I) numOfApprovals|(I) isTargetBranchProtected|(I) authorIsAdmin|(O) allowMerging|(O) notifyUnusualAction|
|------------------|---------------------------|-----------------|----------------|-----------------------|
| > 0 | false | - | true | false |
| > 1 | true | - | true | false |
| - | - | true | true | true |
| - | - | - | false | false |
```

++++

### Visualize: DMN

```scala
val dmnXML = DmnRenderer.render(decisionTable).toXML
```

<img src="resources/PullRequestDecision-50329dacab102e3c924e247982d62948.png">

++++

### Bonus: effectful inputs

Run the IO only when needed

```scala
val result: IO[...] = decisionTable.evaluateFirst(
Input[IO](
numOfApprovals = fetchFromApi(),
userIsAdmin = fetchFromApi(),
...
)
```
Expand Down Expand Up @@ -466,7 +466,7 @@ <h2>Higher-Kinded <br/> Data</h2>
}

val output: RuleOutput =
Input[Expr](a = Literal(1), b = Literal("hi"))
Output[Expr](a = Literal(1), b = Literal("hi"))
```

++++
Expand Down Expand Up @@ -505,7 +505,7 @@ <h2>Higher-Kinded <br/> Data</h2>

<span class="breadcrumb-data">Decisions4s » The how » Higher-Kinded Data</span>

### Can we just use maps?
### Can't we just use maps?

- hard to implement heterogeneous ones <!-- .element: class="fragment fade-in-then-semi-out " -->
- can't ensure the key set <!-- .element: class="fragment fade-in-then-semi-out " -->
Expand Down Expand Up @@ -699,6 +699,18 @@ <h2>Higher-Kinded <br/> Data</h2>
```
<span style="font-size: 0.7em;color: gray">Works only with wrapping</span>

++++

### HKD in the wild

* SQL
* `kubukoz/datas`
* `scalalandio/ocdquery`
* `com-lihaoyi/scalasql`
* Tapir (`RequestT` and uri presence)
* Validations
* Parsers

----

<span class="breadcrumb-data">Decisions4s » The how</span>
Expand Down Expand Up @@ -852,6 +864,8 @@ <h2>Higher-Kinded <br/> Data</h2>
### Remotely!
#### For good bucks!

<span style="font-size: 0.7em;color: gray">France is a bit tricky, ask me for details</span>

++++

<span class="breadcrumb-data">Decisions4s » Context</span>
Expand Down

0 comments on commit 89a76fd

Please sign in to comment.