使用者工具

網站工具


learn:functional-programming

差異處

這裏顯示兩個版本的差異處。

連向這個比對檢視

兩邊的前次修訂版前次修改
下次修改
前次修改
learn:functional-programming [2022/06/21 06:02] – [Library] admin_wi1d5kylearn:functional-programming [2022/06/21 08:47] (目前版本) admin_wi1d5ky
行 3: 行 3:
  
 - [Ramda](https://www.npmjs.com/package/ramda) - [Ramda](https://www.npmjs.com/package/ramda)
-- [Ramda Fantasy](https://www.npmjs.com/package/ramda-fantasy)+- [fp-ts](https://www.npmjs.com/package/fp-ts)
  
  
行 17: 行 17:
 ## Functor ## Functor
  
-  * Either + 
-    * 處理錯誤情境 +^ ADT ^ Effect ^ 
-    * 分成 `Either.Right` 和 `Either.Left` +| Either | 處理錯誤情境 | 
-    * `Either.Right` 會繼續跑,而 `Either.Left` 則會忽略後續運算,執意將手上的值傳下去 +| Future | #TODO | 
-    * <https://ithelp.ithome.com.tw/articles/10279389> +| Identity | #TODO | 
-  Future +| IO | 處理永不失敗的同步計算 | 
-  Identity +| Maybe | 處理無值情境 | 
-  IO +| Reader | #TODO | 
-    * 處理永不失敗的同步計算 +| Tuple | #TODO | 
-    * <https://ithelp.ithome.com.tw/articles/10278925> +| State | #TODO | 
-  Maybe + 
-    * 處理無值情境 ( null || undefined ) + 
-    * <https://ithelp.ithome.com.tw/articles/10277399> +### Either 
-  Reader + 
-    * 用來避免中間傳送無用的 `dep` +  * 處理錯誤情境 
-    * <https://ithelp.ithome.com.tw/articles/10280177> +  * 分成 `Either.Right` 和 `Either.Left` 
-  Tuple +  * `Either.Right` 會繼續跑,而 `Either.Left` 則會忽略後續運算,執意將手上的值傳下去 
-  State+  * <https://ithelp.ithome.com.tw/articles/10279389> 
 + 
 +```javascript 
 +const addOne = num => Right(R.add(1)); 
 +const error = () => Left(new Error('error')) 
 + 
 +Right(10) 
 +    .chain(addOne) 
 +    .map(R.add(2)) 
 +    .inspect() // Right(13) 
 +     
 +Right(10) 
 +    .chain(error) 
 +    .map(R.add(2)) 
 +    .inspect() // Left(Error: error) 
 + 
 +``` 
 + 
 +### Future 
 + 
 +> TODO 
 + 
 + 
 +### Identity 
 + 
 +> TODO 
 + 
 + 
 +### IO 
 + 
 +  * 處理永不失敗的同步計算 
 +  * <https://ithelp.ithome.com.tw/articles/10278925> 
 + 
 +### Maybe 
 + 
 +  * 處理無值情境 ( null || undefined ) 
 +  * <https://ithelp.ithome.com.tw/articles/10277399> 
 + 
 +### Reader 
 +  * 用來避免中間傳送無用的 `dep` 
 +  * <https://ithelp.ithome.com.tw/articles/10280177> 
 + 
 +### Tuple 
 + 
 +> TODO 
 + 
 + 
 +### State 
     * <https://ithelp.ithome.com.tw/articles/10280554>     * <https://ithelp.ithome.com.tw/articles/10280554>
  
learn/functional-programming.1655791334.txt.gz · 上一次變更: 2022/06/21 06:02 由 admin_wi1d5ky

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki