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 Git = { | |
type commitish = Sha(string); | |
type commit = { | |
title: string, | |
descriptiong: string, | |
author: string, | |
date: Date.t | |
}; |
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
type state = {products: RemoteData.t(array(Product.t), string)}; | |
type action = | |
| FetchProducts | |
| SetProducts(RemoteData.t(array(Product.t), string)); | |
let component = ReasonReact.reducerComponent(__MODULE__); | |
let make = _children => { | |
...component, | |
initialState: () => {products: NotAsked}, |
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
let render = ({ state }) => { | |
let { viewport, page } = state; | |
let { width, height } = viewport; | |
let content = | |
switch (page) { | |
| Overview => <Welcome /> | |
| ShowUsers(users) => <UserTable users /> | |
| NewUser(userForm) => <AddUser user=userForm /> | |
}; |
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
type error('err) = | |
| NetworkError | |
| ExpectedJson | |
| ParseError('err); | |
/** | |
* Map one kind of Belt.Result.Error into another kind of Belt.Result.Error | |
* e.g. (('err => 'otherError), Belt.Result.t('a, 'err)) => Belt.Result.t('a, 'otherError) | |
*/ | |
let mapErr = (fn, r) => switch r { |
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
type state = string; | |
type action = | |
| SetValue(string); | |
let component = ReasonReact.reducerComponent("SearchInput"); | |
let valueFromEvent = (evt) => | |
ReactDOMRe.domElementToObj(ReactEventRe.Form.target(evt))##value; |
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
type t('a) = | |
| NonEmpty('a, list('a)); | |
let singleton = (x: 'a) => NonEmpty(x, []); | |
let fromList = (l: list('a)): option(t('a)) => switch l { | |
| [] => None | |
| [x, ...xs] => Some(NonEmpty(x, xs)) | |
}; | |
let toList = (NonEmpty(x, xs)) => [x, ...xs]; |
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
-- http://www.mrpowell.net/progra/javascript/project4/project4.htm | |
-- A perfect number is a number where the sum of all the divisors is equal to two times the number. For example. | |
-- The divisors of the number 6 are 1, 2 , 3 and 6. 2 times 6 is 12. | |
-- 2 * 6 = 1 + 2 + 3 + 6 | |
-- Write a Java script program which will output the first nine perfect numbers. | |
import Data.Foldable (fold, sum) | |
import Data.List (List(..), (:), range, filter, reverse) | |
import Data.Int (toNumber) |
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 ManaSymbol | |
= Generic | |
| Specific SpecificMana | |
| Split ManaColor ManaColor | |
data SpecificMana = Colorless | Colored ManaColor | |
data ManaColor = W | U | R | B | G | |
newtype Land = Land (List SpecificMana) |
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 BinaryTree where | |
import Prelude | |
import Data.Maybe (Maybe(..)) | |
import Data.Tuple (Tuple(..)) | |
data Tree a | |
= Empty | |
| Node (Tree a) a (Tree a) |