This file contains 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 std::convert::From; | |
use std::ops::{Add, Mul}; | |
trait Sumable<T> { | |
fn sum(&self) -> T; | |
} | |
trait Productable<T> { | |
fn product(&self) -> T; | |
} |
This file contains 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
import Html exposing (..) | |
import Html.Attributes exposing (..) | |
import Html.Events exposing (..) | |
import Html.App exposing (..) | |
import Json.Decode exposing (..) | |
import Http | |
import Task | |
type alias Photo = |
This file contains 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
import Html exposing (..) | |
import Html.Attributes exposing (..) | |
import Html.Events exposing (..) | |
import Html.App exposing (..) | |
import Json.Decode exposing (..) | |
import Http | |
import Task | |
type alias Todo = |
This file contains 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
import Html exposing (..) | |
import Html.Attributes exposing (..) | |
import Html.Events exposing (..) | |
import Html.App exposing (..) | |
import Html.Lazy exposing (..) | |
import Json.Decode exposing (..) | |
import Http | |
import Task |
This file contains 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
protocol Zero { | |
static var zero: Self { get } | |
} | |
protocol Sumable { | |
static func +(lhs: Self, rhs: Self) -> Self | |
} | |
extension Int: Sumable {} |
This file contains 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
exports.random = Math.random; |
This file contains 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
type NewType<Name extends string, Type> = Type & { | |
readonly "": Type; | |
}; | |
function to<T extends NewType<string, U>, U = T[""]>(x: U): T { | |
return x as T; | |
} | |
type Size = NewType<"Size", number>; |
This file contains 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
function coroutine<Props>( | |
generator: (props: Props) => IterableIterator<JSX.Element> | |
): React.ComponentType<Props> { | |
return (props: Props) => { | |
const iterator = generator(props); | |
const rec = (Component: JSX.Element, done: boolean): JSX.Element => { | |
if (!done) { | |
const { done, value } = iterator.next(); |
This file contains 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
/// Records | |
// Straigth forward, use this when an object remains in the BuckleScript realm | |
type record = { foo: int }; | |
// Will _not_ compile to a JS object (at least, until some pr like https://github.com/BuckleScript/bucklescript/pull/3741 are merged) | |
let record: record = { foo: 42 }; | |
/// OCaml objects |
This file contains 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
type empty; | |
type nonempty; | |
type t(_, _) = | |
| []: t('a, empty) | |
| ::('a, t('a, _)): t('a, nonempty); | |
let rec fromList: ('a, list('a)) => t('a, nonempty) = | |
x => |
OlderNewer