跳至內容
野空文庫
使用者工具
登入
網站工具
搜尋
工具
顯示頁面
舊版
反向連結
最近更新
多媒體管理器
網站地圖
登入
>
最近更新
多媒體管理器
網站地圖
您在這裏:
root
»
learn
»
functional-programming
learn:functional-programming
本頁是唯讀的,您可以看到原始碼,但不能更動它。您如果覺得它不應被鎖上,請詢問管理員。
# Functional Programming 筆記 ## Library - [Ramda](https://www.npmjs.com/package/ramda) - [fp-ts](https://www.npmjs.com/package/fp-ts) ## 值 vs Functor ^ f ^ g ^ composition ^ | pure | pure | compose(f, g) | | effects | pure(unary) | f.map(g) | | effects | pure(n-ary) | f1.map(g).ap(f2) | | effects | effects | m.chain(f).chain(g) | ## Functor ^ ADT ^ Effect ^ | Either | 處理錯誤情境 | | Future | #TODO | | Identity | #TODO | | IO | 處理永不失敗的同步計算 | | Maybe | 處理無值情境 | | Reader | #TODO | | Tuple | #TODO | | State | #TODO | ### Either * 處理錯誤情境 * 分成 `Either.Right` 和 `Either.Left` * `Either.Right` 會繼續跑,而 `Either.Left` 則會忽略後續運算,執意將手上的值傳下去 * <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> ## Articles - <https://ithelp.ithome.com.tw/users/20140431/ironman/4122?page=1> - <https://medium.com/hannah-lin/9edc7d705c3f> - <https://medium.com/@mirkomariani/e83e54fcd86b> - <https://medium.com/let-s-learn/5db457997554>
learn/functional-programming.txt
· 上一次變更: 2024/12/22 21:17 由
127.0.0.1
頁面工具
顯示頁面
舊版
反向連結
回到頁頂