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 std::boxed::Box; | |
use std::rc::Rc; | |
use std::borrow::Borrow; | |
use std::mem; | |
struct BP_Borrow; | |
struct BP_RC; | |
trait BorrowPlus<Borrowed, TRef> : Borrow<Borrowed> |
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 std::boxed::Box; | |
use std::borrow::Borrow; | |
#[derive(Debug)] | |
enum List<T> { | |
Null, | |
Cons(T, Box<List<T>>), | |
} | |
fn map<A, B, F: Fn(&A) -> B, L: Borrow<List<A>>>(f: F, lst: L) -> List<B> { |
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 std::boxed::Box; | |
enum List<T> { | |
Null, | |
Cons(T, Box<List<T>>), | |
} | |
fn map_noref<A, B, F>(f: &F, lst: List<A>) -> List<B> | |
where F: Fn(A) -> B |
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 std::rc::Rc; | |
enum List<T> { | |
Null, | |
Cons(Rc<T>, Rc<List<T>>), | |
} | |
fn map_noref<A, B, F>(f: &F, lst: Rc<List<A>>) -> Rc<List<B>> | |
where F: Fn(Rc<A>) -> Rc<B> |
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 std::rc::Rc; | |
enum List<T> { | |
Null, | |
Cons(Rc<T>, Rc<List<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
-- Given these simplified types: | |
data Model = Model { something :: SomeSubData } | |
data SomeSubData = SomeSubData { moreThing :: Integer } | |
-- And given this value | |
where | |
model = Model (SomeSubData 42) |
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
maxNum : List ( comparable, number ) -> Maybe ( comparable, number ) | |
maxNum tuples = | |
case tuples of | |
x :: xs -> | |
Just | |
(List.foldl | |
(\(( _, count ) as tup) maxSoFar -> | |
if count > (snd maxSoFar) then | |
tup | |
else |
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
import Color exposing (..) | |
import Graphics.Element exposing (show) | |
d x = x | |
f x = x | |
labToColor : { l : Float, a : Float, b : Float } -> Color | |
labToColor { l, a, b } = | |
let |
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
-- interface is a more familiar name for the intention of the construct | |
type alias Append a rest = { rest | append : a -> a -> a} | |
-- implement is a more familiar name | |
stringAppend rest = {rest | append = \x y -> x ++ y} | |
-- this is Monoid | |
type alias AppendWithId a rest = Append a {rest | id : a} | |
-- ^ 1 potential superclass |
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 Dict | |
( Dict | |
, empty, singleton, insert, update | |
, isEmpty, get, remove, member, size | |
, filter | |
, partition | |
, foldl, foldr, map | |
, union, intersect, diff | |
, keys, values | |
, toList, fromList |