尤川豪   ·  2年前
445 貼文  ·  275 留言

functional programming learning notes

0. write some 'Elm' for front-end applications to gain some feelings

  • guess I will only want to use them for 金流系統、訂票系統、醫療系統. I only consider using them in extremely sensitive systems that cannot allow runtime errors.

1. learn some basics - https://adit.io/posts/2013-04-17-functors,_applicatives,_and_monads_in_pictures.html

  • Maybe, Lists, Functions => they are all Functors.
  • A Functor is any data type that defines how fmap applies to it. Here's how fmap works:
fmap :: (a -> b) -> f a -> f b
  • 注意 f a 是 functor a 的縮寫然後 f b 是 functor b 的縮寫,只是兩個代稱,不是執行 function 的意思喔。
  • conclusion 1:
    • A functor is a data type that implements the Functor typeclass.
    • An applicative is a data type that implements the Applicative typeclass.
    • A monad is a data type that implements the Monad typeclass.
    • A Maybe implements all three, so it is a functor, an applicative, and a monad.
  • conclusion 2:
    • functors: you apply a function to a wrapped value using fmap or <$>
    • applicatives: you apply a wrapped function to a wrapped value using <*> or liftA
    • monads: you apply a function that returns a wrapped value, to a wrapped value using >>= or liftM

2. recognize the terminology precisely - https://jrsinclair.com/articles/2019/what-i-wish-someone-had-explained-about-functional-programming/

x. more description - https://haskellcamargo.gitbooks.io/pragmatic-functional-javascript/content/

  • When the first physical computers appeared and programming languages started to be designed and implemented, there were mainly 2 mindsets:
    • Start from the Von Neumann architecture and add abstraction;
    • Start from mathematics and remove abstraction.
  分享   共 843 次點閱
按了喜歡:
共有 2 則留言
尤川豪   ·  2年前
445 貼文  ·  275 留言
 
尤川豪   ·  2年前
445 貼文  ·  275 留言
 
您的留言
尤川豪
445 貼文  ·  275 留言

Devs.tw 是讓工程師寫筆記、網誌的平台。隨手紀錄、寫作,方便日後搜尋!

歡迎您一起加入寫作與分享的行列!

查看所有文章