Skip to content

Instantly share code, notes, and snippets.

@BrianHicks
Created July 10, 2019 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BrianHicks/84bb628af49487dba4e8907c7921c0a7 to your computer and use it in GitHub Desktop.
Save BrianHicks/84bb628af49487dba4e8907c7921c0a7 to your computer and use it in GitHub Desktop.
var author$project$Main$main = elm_explorations$benchmark$Benchmark$Runner$program(
A2(
elm_explorations$benchmark$Benchmark$describe,
'unicode segmentation',
_List_fromArray(
[
A5(
elm_explorations$benchmark$Benchmark$compare,
'map2 vs case',
'map2',
function (_n0) {
return A3(
elm$core$Maybe$map2,
F2(
function (a, b) {
return a + b;
}),
elm$core$List$head(
_List_fromArray(
[1])),
elm$core$List$head(
_List_fromArray(
[2])));
},
'case',
function (_n1) {
var _n2 = _Utils_Tuple2(
elm$core$List$head(
_List_fromArray(
[1])),
elm$core$List$head(
_List_fromArray(
[2])));
if ((_n2.a.$ === 'Just') && (_n2.b.$ === 'Just')) {
var a = _n2.a.a;
var b = _n2.b.a;
return elm$core$Maybe$Just(a + b);
} else {
return elm$core$Maybe$Nothing;
}
})
])));
module Main exposing (main)
import Benchmark exposing (..)
import Benchmark.Runner exposing (BenchmarkProgram, program)
main : BenchmarkProgram
main =
program <|
Benchmark.compare "map2 vs case"
"map2"
(\_ ->
Maybe.map2 (\a b -> a + b)
(List.head [ 1 ])
(List.head [ 2 ])
)
"case"
(\_ ->
case ( List.head [ 1 ], List.head [ 2 ] ) of
( Just a, Just b ) ->
Just (a + b)
_ ->
Nothing
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment