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
(ns typed-play.core | |
(:require-macros [cljs.core.typed :as t]) | |
(:require [cljs.core.typed :as t])) | |
(t/ann my-identity (All [x] (Fn [x -> x]))) | |
(defn my-identity [x] | |
(if (number? x) | |
(inc x) | |
x)) |
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
/** | |
* Examples of writing mixed unit/property-based (ScalaCheck) tests. | |
* | |
* Includes tables and generators as well as 'traditional' tests. | |
* | |
* @see http://www.scalatest.org/user_guide/selecting_a_style | |
* @see http://www.scalatest.org/user_guide/property_based_testing | |
*/ | |
import org.scalatest._ |
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
-- | check for parens in a string, exiting early if the left paren count is -1. Fully point-free and | |
-- arrow-fied | |
-- It works as follows: | |
-- 1. use a monadic fold (foldM) with the Either monad to exit early | |
-- 2. take a list of methods that test if the count is -1, or the paren is '(', or the paren is ')' | |
-- 3. zip the list with another list that looks at the booleans and decides what functions they should | |
-- result in. if there are no parens, the functions just add 0 to the count | |
-- 4. sequence the monad actions (this will exit early if there is a Left present) | |
-- 5. fold over the functions in the Right branch with function composition | |
-- 6. at this piont we just want to apply the the resulting function in the Right branch to the current |