Applicative functors other than monads and ZipList?

前端 未结 7 820
小鲜肉
小鲜肉 2020-12-31 07:36

Two well-known examples of applicatives are monads and ziplists. Are there any other examples?

7条回答
  •  独厮守ぢ
    2020-12-31 08:21

    Conal Elliott writes about signal processors and how they're applicatives. Those are similar to ZipList in nature, where each respective pair of items in the two "containers" gets combined.

    I've been using this concept a lot in an unfinished yet cute game I made (cabal install DefendTheKing to check it out).

    Code snippet/example of Applicative-style usage:

    draw font
    <$> lstP gABoard
    <*> lstP gASelection
    <*> mouseMotion
    <*> lstP gASide
    <*> lstP gAGameIteration
    

提交回复
热议问题