-
Notifications
You must be signed in to change notification settings - Fork 597
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Obey horizontal space restrictions in Reason snippets.
- Loading branch information
1 parent
ba86c7b
commit 84cf2cc
Showing
49 changed files
with
123 additions
and
125 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
let safe_head = (fmap([x, ...xs])) == safe_head(f([x, ... xs])) == Some(f(x)); | ||
let safe_head = | ||
(fmap([x, ...xs])) == safe_head(f([x, ... xs])) == Some(f(x)); |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
// ReasonML/OCaml only allows special characters in the infix operator. | ||
// ReasonML only allows special characters in the infix operator. | ||
// So, the above function name cannot be applied as infix. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
module Const_Functor = (T: T) : Functor => { | ||
type t('a) = const(T.t, 'a); | ||
|
||
let fmap = (f, Const(c)) => Const(c); /* or even let fmap = (_ c) => c */ | ||
// or even let fmap = (_, c) => c; | ||
let fmap = (f, Const(c)) => Const(c); | ||
}; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
let bimap: ('a => 'c, 'b => 'd, Bifunctor_Product.t('a, 'b)) => Bifunctor_Product.t('c, 'd) | ||
let bimap: ('a => 'c, 'b => 'd, Bifunctor_Product.t('a, 'b)) => | ||
Bifunctor_Product.t('c, 'd) |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
let bimap: (FU.t(a) => FU.t(a')) => (GU.t(b) => GU.t(b')) => (FU.t(a), GU.t(b)) => (FU.t(a'), GU.t(b')) | ||
let bimap: (FU.t(a) => FU.t(a')) => (GU.t(b) => GU.t(b')) => | ||
(FU.t(a), GU.t(b)) => (FU.t(a'), GU.t(b')) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
/** Deriving a functor in ReasonML/OCaml is not available as a language extension. You could try experimental library like ocsigen to derive functors.*/ | ||
/** Deriving a functor in ReasonML is not available as a | ||
* language extension. You could try experimental library | ||
* like ocsigen to derive functors.*/ | ||
type tree('a) = | ||
| Leaf('a) | ||
| Node(tree('a), tree('a)); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
let contramap: ('c_prime => 'c, 'c => 'limD, 'c_prime) => 'limD = ( | ||
(f, u) => compose(u, f): ('c_prime => 'c, 'c => 'limD, 'c_prime) => 'limD | ||
(f, u) => compose(u, f): | ||
('c_prime => 'c, 'c => 'limD, 'c_prime) => 'limD | ||
); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
/* Pseudo ReasonML/OCaml expressing function equality */ | ||
/* Pseudo ReasonML expressing function equality */ | ||
compose(f, p) == compose(g, p); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
/* Pseudo ReasonML/OCaml expressing function equality */ | ||
/* Pseudo ReasonML expressing function equality */ | ||
compose(f, p') == compose(g, p'); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
/* There is no compose operator in ReasonML */ | ||
|
||
compose(dimap(id, f), alpha) == compose(dimap(f, id), alpha); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
module EndsEqualizer = (P: Profunctor) => { | ||
let lambda: (P.p('a, 'a), 'a => 'b) => P.p('a, 'b) = ( | ||
(paa, f) => P.dimap(id, f, paa): (P.p('a, 'a), 'a => 'b) => P.p('a, 'b) | ||
(paa, f) => P.dimap(id, f, paa) | ||
); | ||
|
||
let rho: (P.p('b, 'b), 'a => 'b) => P.p('a, 'b) = ( | ||
(pbb, f) => P.dimap(f, id, pbb): (P.p('b, 'b), 'a => 'b) => P.p('a, 'b) | ||
(pbb, f) => P.dimap(f, id, pbb) | ||
); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
module EndsWithDiaProd = | ||
( | ||
P: Profunctor, | ||
D: DiaProd with type p('a, 'b) = P.p('a, 'b), | ||
PP: ProdP with type p('a, 'b) = P.p('a, 'b), | ||
) => { | ||
module EndsWithDiaProd = ( | ||
P: Profunctor, | ||
D: DiaProd with type p('a, 'b) = P.p('a, 'b), | ||
PP: ProdP with type p('a, 'b) = P.p('a, 'b), | ||
) => { | ||
module E = EndsEqualizer(P); | ||
|
||
let lambdaP: D.diaprod('a) => PP.prod_p('a, 'b) = ( | ||
(DiaProd(paa)) => E.lambda(paa): D.diaprod('a) => PP.prod_p('a, 'b) | ||
(DiaProd(paa)) => E.lambda(paa) | ||
); | ||
|
||
let rhoP: D.diaprod('b) => PP.prod_p('a, 'b) = ( | ||
(DiaProd(pbb)) => E.rho(pbb): D.diaprod('b) => PP.prod_p('a, 'b) | ||
(DiaProd(pbb)) => E.rho(pbb) | ||
); | ||
}; |
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
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
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
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
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
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
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
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
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
/* Import Str module using this - #require "str" */ | ||
let to_words = s => Writer(Str.split(Str.regexp("\b"), s), "to_words"); | ||
|
||
module Writer_Process = (W: Monad with type m('a) = writer(string, 'a)) => { | ||
module Writer_Process = (W: Monad with type m('a) = | ||
writer(string, 'a)) => { | ||
let process = W.(up_case >=> to_words); | ||
}; |
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
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
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
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
Oops, something went wrong.