Last active
          July 20, 2019 05:32 
        
      - 
      
- 
        Save bitwombat/7695bbdc8ef018a0a84aa0debd69664c to your computer and use it in GitHub Desktop. 
    Page475
  
        
  
    
      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
    
  
  
    
  | module Page475 where | |
| -- Ex 5 | |
| either' :: (a -> c) -> (b -> c) -> Either a b -> c | |
| either' f g eab = | |
| case eab of | |
| Left a -> f a | |
| Right b -> g b | |
| -- Ex 6 | |
| rightVal :: Either a b -> b | |
| rightVal (Right x) = x | |
| eitherMaybe'' :: (b -> c) -> Either a b -> Maybe c | |
| eitherMaybe'' f eab = | |
| case eab of | |
| Left _ -> Nothing | |
| _ -> Just (either' (f . g (rightVal eab)) f eab) | |
| where | |
| g :: b -> a -> b | |
| g b a = b | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment