Last active
June 26, 2017 07:23
-
-
Save abiodun0/ecb0c20f14e04359f4f704cd319a55ae to your computer and use it in GitHub Desktop.
fp-ts-io_fantasy
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 { IO } from 'fp-ts/lib/IO' | |
| import * as io from 'fp-ts/lib/IO' | |
| import * as array from 'fp-ts/lib/Array' | |
| import { sequence } from 'fp-ts/lib/Traversable' | |
| const add = (classes: string) => (sel: HTMLElement): IO<HTMLElement> => { | |
| return new IO(() => { | |
| sel.classList.add(classes) | |
| return sel | |
| }) | |
| } | |
| const addClass = (classes: string) => (selectors: Array<HTMLElement>): IO<Array<HTMLElement>> => { | |
| // ios :: Array<IO<HTMLElement>> | |
| const ios = selectors.map(add(classes)) | |
| // ret :: IO<Array<HTMLElement>> | |
| const ret = sequence(io, array)(ios) | |
| return ret | |
| } | |
| export default addClass |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment