Created
March 25, 2014 19:53
-
-
Save mausch/9769943 to your computer and use it in GitHub Desktop.
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
// broken fmap for option | |
let fmap f = | |
function | |
| None -> None | |
| Some a -> | |
let b = f a | |
if box b = null then None else Some b | |
// second functor law, see http://www.haskell.org/haskellwiki/Functor | |
let fmapL p q = fmap (p << q) | |
let fmapR p q = fmap p << fmap q | |
let test (p: string -> string) (q: string -> string) (x: string option) = fmapL p q x = fmapR p q x | |
test (fun _ -> "") (fun _ -> null) (Some "") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment