Created
January 17, 2022 15:02
-
-
Save namenu/568e0e3ec55867396b544378f84dcc63 to your computer and use it in GitHub Desktop.
Resx proposal
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
module Array = { | |
let map = (xs: array<'a>, f: 'a => React.element): React.element => { | |
Belt.Array.map(xs, f)->React.array | |
} | |
let mapWithIndex = (xs: array<'a>, f: (int, 'a) => React.element): React.element => { | |
Belt.Array.mapWithIndex(xs, f)->React.array | |
} | |
} | |
module Option = { | |
let get = (x: option<React.element>): React.element => { | |
Belt.Option.getWithDefault(x, React.null) | |
} | |
let map = (x: option<'a>, f: 'a => React.element): React.element => { | |
Belt.Option.mapWithDefault(x, React.null, f) | |
} | |
let flatMap = (x: option<'a>, f: 'a => option<React.element>): React.element => { | |
Belt.Option.flatMap(x, f)->Belt.Option.getWithDefault(React.null) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment