Last active
          June 21, 2017 09:42 
        
      - 
      
- 
        Save chenglou/54cf2f6e50d45da9905b78d676697c75 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
    
  
  
    
  | // Generated by BUCKLESCRIPT VERSION 1.7.5, PLEASE EDIT WITH CARE | |
| 'use strict'; | |
| function counter(state, action) { | |
| var match = action.type; | |
| switch (match) { | |
| case 0 : | |
| return state + 1 | 0; | |
| case 1 : | |
| return state - 1 | 0; | |
| case 2 : | |
| return state + 2 | 0; | |
| } | |
| } | |
| function bump_counter() { | |
| return { | |
| type: /* Increment */0 | |
| }; | |
| } | |
| var increment = /* Increment */0; | |
| var decrement = /* Decrement */1; | |
| var somethingElse = /* SomethingElse */2; | |
| exports.increment = increment; | |
| exports.decrement = decrement; | |
| exports.somethingElse = somethingElse; | |
| exports.counter = counter; | |
| exports.bump_counter = bump_counter; | |
| /* No side effect */ | 
  
    
      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 actions = | |
| | Increment | |
| | Decrement | |
| | SomethingElse | |
| [@@bs.deriving {accessors: accessors}]; | |
| let counter ::state ::action => | |
| switch action##_type { | |
| | Increment => state + 1 | |
| | Decrement => state - 1 | |
| | SomethingElse => state + 2 | |
| }; | |
| let bump_counter () => {"_type": Increment}; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment