Last active
February 4, 2016 14:32
-
-
Save hodzanassredin/d230313d762d508caee1 to your computer and use it in GitHub Desktop.
reader option functor
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
let howIsMyName t f = f >> Option.map t | |
//mapReaderT :: (m a -> n b) -> ReaderT r m a -> ReaderT r n b | |
type Reader<'environment,'a> = 'environment -> 'a | |
//func application | |
let run environment (action : Reader<_,_>) = action environment | |
//functor | |
let map f (action : Reader<_,_>) : Reader<_,_> = action >> f | |
type OptionReader<'environment,'a> = Reader<'environment,'a option> | |
//('a -> 'b) -> ('environment -> 'a option) ('environment -> 'b option) | |
let mapOptionReader f (action : OptionReader<_,_>) : OptionReader<_,_> = action >> Option.map f | |
let composeFmaps = (>>) | |
//('a -> 'b) -> ('environment -> 'a option) ('environment -> 'b option) | |
let mapOptionReaderC f = composeFmaps Option.map map f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment