diff --git a/halfway-presentation/hei.svg b/halfway-presentation/hei.svg new file mode 100644 index 0000000..b34fcaa --- /dev/null +++ b/halfway-presentation/hei.svg @@ -0,0 +1,4000 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/halfway-presentation/langs.typ b/halfway-presentation/langs.typ new file mode 100644 index 0000000..fc26f5f --- /dev/null +++ b/halfway-presentation/langs.typ @@ -0,0 +1,107 @@ +#let translations = ( + fr: ( + _date-fmt: "[day] $month [year repr:full]", + title: "Midas: mieux typer Python", + subtitle: "Présentation intermédiaire", + short-title: "Midas", + "context": "Contexte", + problematic: "Problématique", + case-1: [Cas 1 -- Type != sémantique], + case-2: [Cas 2 -- Erreur de type _at runtime_], + goal: "Objectif", + gradual-typing: [Typage graduel (_gradual typing_)], + static-type-checking: [Vérification statique], + runtime-assertions: [Assertions _at runtime_], + example: "Exemple", + lat-lon-error: "Invalide, même si float+float est valide", + initial-planning: "Planification initiale", + week: "Semaine", + objectives: "Objectifs", + initial-week1: "Kickoff, setup projet, début de prototype de syntaxe", + initial-week2: [Prototype de syntaxe, _parser_ simple], + initial-week3-6: [Implémentation d'un _type checker_], + initial-week7-9: "Générateur de code, améliorations, rapport", + current-status: "État actuel", + current-week1: "Kickoff, setup projet, début de prototype de syntaxe", + current-week2: [Prototype de syntaxe, _parser_ simple], + current-week3: [_Type checker_ basique(assign., fonctions, opérations)], + current-week4: [Diagnostiques, _control flow_, améliorer l'architecture], + current-week5: "Types génériques, sous-typage", + current-week6: "Contraintes", + current-week7-9: "Générateur de code, améliorations, rapport", + demo: "Démo", + def-custom-types: "Définition de types", + write-program: "Écrire un programme", + valid: "Valide", + invalid: "Invalide", + ), + en: ( + _date-fmt: "$month [day], [year repr:full]", + title: "Midas: better type checking in Python", + subtitle: "Halfway presentation", + short-title: "Midas", + "context": "Context", + problematic: "Problematic", + case-1: [Case 1 -- Type != semantic], + case-2: [Case 2 -- Runtime type error], + goal: "Goal", + gradual-typing: "Gradual typing", + static-type-checking: "Static type checking", + runtime-assertions: "Runtime assertions", + example: "Example", + lat-lon-error: "Invalid, even though float+float is valid", + initial-planning: "Initial planning", + week: "Week", + objectives: "Objectives", + initial-week1: "Kickoff, setup project, start prototyping a syntax", + initial-week2: "Syntax prototype, simple parser", + initial-week3-6: "Implement a type checker", + initial-week7-9: "Code generator, refinements, report", + current-status: "Current status", + current-week1: "Kickoff, setup project, start prototyping a syntax", + current-week2: "Syntax prototype, simple parser", + current-week3: "Basic type checker (assignments, functions, operations)", + current-week4: "Diagnostics, type check control flow, refine architecture", + current-week5: "Generic types, subtyping", + current-week6: "Constraints", + current-week7-9: "Code generator, refinements, report", + demo: "Demo", + def-custom-types: "Defining custom types", + write-program: "Writing a program", + valid: "Valid", + invalid: "Invalid", + ) +) + +#let months = ( + fr: ( + "Janvier", "Février", "Mars", "Avril", + "Mai", "Juin", "Juillet", "Août", + "Septembre", "Octobre", "Novembre", "Décembre" + ), + en: ( + "January", "February", "March", "April", + "May", "June", "July", "August", + "September", "October", "November", "December" + ) +) + +#let i18n(lang, key) = { + let dict = translations.at(lang, default: (:)) + return dict.at( + key, + default: "[" + lang + ":" + key + "]" + ) +} + +#let i18n-date(lang, date) = { + let month = date.month() - 1 + let month-name = months.at(lang, default: ()).at( + month, + default: "[" + lang + ":month[" + str(month) + "]]" + ) + + let fmt = i18n(lang, "_date-fmt").replace("$month", month-name) + + return date.display(fmt) +} \ No newline at end of file diff --git a/halfway-presentation/logo_black.svg b/halfway-presentation/logo_black.svg new file mode 100644 index 0000000..aecdbf1 --- /dev/null +++ b/halfway-presentation/logo_black.svg @@ -0,0 +1,988 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/halfway-presentation/logo_symbol.svg b/halfway-presentation/logo_symbol.svg new file mode 100644 index 0000000..1aac1e0 --- /dev/null +++ b/halfway-presentation/logo_symbol.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/halfway-presentation/logo_white.svg b/halfway-presentation/logo_white.svg new file mode 100644 index 0000000..b71d2ee --- /dev/null +++ b/halfway-presentation/logo_white.svg @@ -0,0 +1,988 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/halfway-presentation/main.typ b/halfway-presentation/main.typ new file mode 100644 index 0000000..1811841 --- /dev/null +++ b/halfway-presentation/main.typ @@ -0,0 +1,219 @@ +#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]] +``` +] + diff --git a/halfway-presentation/midas.sublime-syntax b/halfway-presentation/midas.sublime-syntax new file mode 100644 index 0000000..42d7bc7 --- /dev/null +++ b/halfway-presentation/midas.sublime-syntax @@ -0,0 +1,15 @@ +--- +name: Midas +file_extensions: [midas] +scope: source.midas + +contexts: + main: + - match: \b(type|extend|op|predicate)\b + scope: keyword.control.midas + - match: // + scope: punctuation.definition.comment.midas + push: + - meta_scope: comment.line.midas + - match: $ + pop: true \ No newline at end of file diff --git a/halfway-presentation/midas.svg b/halfway-presentation/midas.svg new file mode 100644 index 0000000..56c81fa --- /dev/null +++ b/halfway-presentation/midas.svg @@ -0,0 +1,117 @@ + + + + + + + + + + + + + + + + + + + + + + + + + +