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
| 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.
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
| (ns arith | |
| (:require | |
| [clojure.spec.alpha :as s])) | |
| ;;; definition of terms | |
| ;;; <term> ::= true | |
| ;;; | false | |
| ;;; | (if <term> <term> <term>) | |
| ;;; | <number> | |
| ;;; | (+ <term>*) |
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
| module Factorial where | |
| factorial :: Integral a => a -> a | |
| factorial 0 = 1 | |
| factorial n = n * factorial (n - 1) | |
| factorialSeq :: Integral a => [a] | |
| factorialSeq = scanl (*) 1 [1..] |
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
| λ> data Box a = Box a deriving (Show, Eq) | |
| type Box :: * -> * | |
| data Box a = ... | |
| -- Functorの実装 | |
| λ> :{ | |
| λ| instance Functor Box where | |
| λ| fmap f (Box x) = Box $ f x | |
| λ| :} | |
| -- Applicativeの実装 | |
| λ> :{ |
NewerOlder