看板 PLT 關於我們 聯絡資訊
最近看code時, 看到好幾個的地方都出現 free monad: http://www.haskellforall.com/2013/06/ from-zero-to-cooperative-threads-in-33.html Data types `a la carte 最後考慮結合monad也只考慮free monad (因為結構最少?) Extensible Effects推到後來他拿來包 effect 的 monad 型別 data VE r w = Val w | E (Union r (VE r w)) 看起來也有幾分像 free monad (Union是某個由 r indexed 的 coproduct) 而且後來舉的 coroutine 例子 type CoT a m = ContT (Y m a) m data Y m a = Done | Y a (() -> m (Y m a)) 雖然前面 Done 那項不太一樣, 但後面 Y 那裡一樣有遞迴, 也是丟進 m 裡面 我只知道 free monad 是當我們想要給一個 functor F 多加上 monad 的結構時所自然衍生出來的東西, 不過那個結構[aka. data Free f a = Pure a | Impure (f (Free f a))] 到底要怎麼推出來呢...? 這個定出來以後 instance 怎麼寫就比較好猜了..雖然還是很神奇QQ [1]關於free monad http://stackoverflow.com/questions/13352205/ - 另外有人聽過 codensity monad 嗎? 查不太到什麼資料orz... -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.166.53.15
xcycl:那個結構其實可以看 free monoid 的構造 10/30 07:42
xcycl:構造 free monoid 的時候可以用遞歸的方式層層迭代 10/30 07:43
xcycl:每一次加進一層 operation 10/30 07:46