Flow cookbook (gradual typechecker for js)
sitr.us1 pointsby happy4crazy0 comments
(++) <$> myStrings <*> yourStrings
you're saying: yeah yeah, I know my string hasn't made up its mind yet, and neither has your string, but just concatenate them. So you concatenate all the pairwise possibilities. The monad stuff says you can do control flow: (yeah yeah), but if my string is this long, and your string is a palindrome... replicate <$> promisedInt <*> promisedChar
to promise some repetitive String. (And presumably promisedInt and promisedChar will resolve themselves in parallel!) The monad stuff: if this promised Int ends up being prime, then... replicate <$> intParser <*> charParser
makes a parser that tries to parse an Int, and then a Char, and then gives you a repetitive String. Monad stuff: if I parse a prime number, then... (++) <$> almostAString <*> almostAnotherString,
I'm making a new function of type Float -> String that feeds a Float (the same Float) to both subcomputations and then concatenates their results. Monad stuff: if this almost-Int ends up being prime...