- 
      
- 
        Save aaronlifton3/6d7e759372941ed3c48e to your computer and use it in GitHub Desktop. 
  
    
      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
    
  
  
    
  | type 'a monoid = {zero : 'a; plus : 'a -> 'a -> 'a} | |
| let sum (m : 'a monoid) (l : 'a list) : 'a = List.fold_left m.plus m.zero l | |
| let string_summer = sum {zero = ""; plus = (^)} | |
| let int_summer = sum {zero = 0; plus = (+)} | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment