Files
TB-Docs/halfway-presentation/main.typ

220 lines
4.0 KiB
Typst

#import "@preview/touying:0.7.3": *
#import "@preview/touying-unistra-pristine:1.4.3": *
#import "@preview/codly:1.3.0": codly, codly-init
#import "@preview/codly-languages:0.1.10": codly-languages
#import "langs.typ": i18n, i18n-date
#let langs = (
fr: ("fr", "ch"),
en: ("en", "gb")
)
#let (lang, region) = langs.en
#let i18n = i18n.with(lang)
#let i18n-date = i18n-date.with(lang)
#show raw.where(lang: "midas"): set raw(syntaxes: "midas.sublime-syntax")
#show: codly-init
#codly(languages: codly-languages + (
midas: (
name: "Midas",
color: rgb("#000000"),
icon: box(
image(
"midas.svg",
height: 130%,
fit: "contain",
),
),
)
))
#let regexp = regex(`\[\[(.*?)\]\]`.text)
#show raw: it => {
show regexp: m => {
let key = m.text.slice(2, -2)
return i18n(key)
}
it
}
#pdfpc.config(
duration-minutes: 15,
start-time: datetime(hour: 9, minute: 30, second: 0),
end-time: datetime(hour: 9, minute: 45, second: 0),
last-minutes: 2,
note-font-size: 12,
disable-markdown: false
)
#set text(lang: lang, region: region)
#show: unistra-theme.with(
aspect-ratio: "16-9",
config-common(
enable-pdfpc: true
),
config-info(
title: i18n("title"),
subtitle: i18n("subtitle"),
short-title: i18n("short-title"),
author: [Louis Heredero],
date: i18n-date(datetime(day: 3, month: 6, year: 2026)),
institution: [ISC \@ HEI Sion],
logo: stack(
dir: ltr,
spacing: 1em,
image("logo_symbol.svg", height: 100%),
image("hei.svg", height: 80%),
),
),
config-store(
font: "Source Sans 3",
),
)
#title-slide(
logo: image("logo_white.svg", height: 3em)
)
== #i18n("context")
==== #i18n("case-1")
#[
#set text(size: .8em)
```python
df = pd.read_csv()
value = df["distance"] / df["time"]
...
value += df["age"]
```
]
==== #i18n("case-2")
#[
#set text(size: .8em)
```sh
louis@powerful-server:$ ./start.sh
99%|██████████| 5410/5432 [90:10:06<22:33, 60.00s/it]
TypeError: unsupported operand type(s) for +: 'int' and 'NoneType'
```
]
== #i18n("goal")
- #i18n("gradual-typing")
- #i18n("static-type-checking")
- #i18n("runtime-assertions")
#let wah = place(
right + horizon,
dx: (
-.4em // inset
-100% // width
),
box(
inset: .4em,
text(
fill: std.red,
weight: "bold",
$->$
)
)
)
== #i18n("example")
#[
#set text(size: .8em)
```python
df: Frame[
verified: bool,
birth_date: date,
height: float & (0 < _ < 250),
name: Optional[str],
home: GeoLocation,
] = pd.read_csv(...)
lat = df["home"].lat
lon = df["home"].lon
invalid = lat + lon # [[lat-lon-error]]
```
]
== #i18n("initial-planning")
#table(
columns: (auto, 1fr),
align: (center, left + horizon),
inset: (x: .4em, y: .25em),
table.header[*#i18n("week")*][*#i18n("objectives")*],
[*1*], i18n("initial-week1"),
[*2*], i18n("initial-week2"),
[*3*], table.cell(rowspan: 4, i18n("initial-week3-6")),
[*4*#wah],
[*5*],
[*6*],
[*7*], table.cell(rowspan: 3, i18n("initial-week7-9")),
[*8*],
[*9*],
)
== #i18n("current-status")
#table(
columns: (auto, 1fr),
align: (center, left + horizon),
inset: (x: .4em, y: .25em),
table.header[*#i18n("week")*][*#i18n("objectives")*],
[*1*], i18n("current-week1"),
[*2*], i18n("current-week2"),
[*3*], i18n("current-week3"),
[*4*#wah], i18n("current-week4"),
[*5*], i18n("current-week5"),
[*6*], i18n("current-week6"),
[*7*], table.cell(rowspan: 3, i18n("current-week7-9")),
[*8*],
[*9*],
)
== #i18n("demo")
=== #i18n("def-custom-types")
#[
#set text(size: .8em)
```midas
type Meter = float
type Second = float
type MeterPerSecond = float
extend Meter {
op __add__(Meter) -> Meter
op __truediv__(Second) -> MeterPerSecond
}
extend Second {
op __add__(Second) -> Second
}
```
]
---
=== #i18n("write-program")
#[
#set text(size: .8em)
```python
distance: Meter = 123.45
time: Second = 6.7
time += time # [[valid]]
speed = distance / time # speed: MeterPerSecond
speed += time # [[invalid]]
```
]