This file contains hidden or 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
| // コンパイルできる | |
| flix> def applyTwice(f: a -> a, x: a, y: a): (a, a) = (f(x), f(y)) | |
| Ok. | |
| // コンパイルできない: 関数 needsRankN は a について多相だが、引数 f は単相である(そして多相にする手段が現状ない)ため | |
| flix> def needsRankN(f: a -> a): (Int32, String) = (f(1), f("hello")) | |
| -- Type Error [E7796] ------------------------------------------------------- $3 | |
| >> Unexpected type: expected 'Int32 -> a', found 'a -> a'. | |
| 1 | def needsRankN(f: a -> a): (Int32, String) = (f(1), f("hello")) |
This file contains hidden or 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
| flix> let {name | _} = {name = "Peter", age = 58}; name | |
| Peter | |
| flix> (p -> p#name)({name = "Peter", age = 58}) | |
| Peter | |
| flix> ((p: {name = String | _}) -> p#name)({name = "Peter", age = 58}) | |
| -- Type Error [E7796] ------------------------------------------- __SHELL__.flix | |
| >> Unexpected type: expected '{ age = Int32, name = String } -> String', found '{ name = String | _ } -> String'. | |
| 2 | def _f() = { println(((p: {name = String | _}) -> p#name)({name = "Peter", age = 58})) }; |
This file contains hidden or 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
| slides: | |
| charset: utf-8 | |
| theme: night | |
| highlight_theme: monokai-sublime | |
| separator_vertical: ^\s*----\s*$ | |
| revealjs: | |
| transition: convex | |
| plugins: | |
| - extra_css: | |
| - https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css |
This file contains hidden or 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
| // expressions as a type class | |
| trait Expr[repr: Type -> Type] { | |
| pub def int(n: Int32): repr[Int32] | |
| pub def bool(b: Bool): repr[Bool] | |
| pub def add(e1: repr[Int32], e2: repr[Int32]): repr[Int32] | |
| pub def mul(e1: repr[Int32], e2: repr[Int32]): repr[Int32] | |
| pub def eq(e1: repr[a], e2: repr[a]): repr[Bool] with Eq[a] | |
| } | |
| // an evaluator |
This file contains hidden or 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
| enum Person({ name = String, age = Int32 }) | |
| instance ToString[Person] { | |
| pub def toString(p: Person): String = match p { | |
| case Person.Person({ name, age }) => | |
| "Person(name = ${name}, age = ${age})" | |
| } | |
| } | |
| def example(): Unit \ IO = |
This file contains hidden or 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
| slides: | |
| charset: utf-8 | |
| theme: night | |
| highlight_theme: monokai-sublime | |
| separator_vertical: ^\s*----\s*$ | |
| revealjs: | |
| transition: convex | |
| plugins: | |
| - extra_css: | |
| - https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css |
This file contains hidden or 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
| use Sys.Process | |
| // The main entry point. | |
| def main(): Unit \ {Process, Abort, IO} = | |
| println("Hello World!"); | |
| let n = 5; | |
| println("The square of ${n} is ${square(n)}."); | |
| runProcess() |
This file contains hidden or 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
| slides: | |
| charset: utf-8 | |
| theme: night | |
| highlight_theme: monokai-sublime | |
| separator_vertical: ^\s*----\s*$ | |
| revealjs: | |
| transition: convex | |
| plugins: | |
| - extra_css: | |
| - https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder