What are practical uses of applicative style?

后端 未结 11 692
误落风尘
误落风尘 2021-01-30 01:32

I am a Scala programmer, learning Haskell now. It\'s easy to find practical use cases and real world examples for OO concepts, such as decorators, strategy pattern etc. Books an

11条回答
  •  日久生厌
    2021-01-30 02:13

    Here is an example taken from the aeson package:

    data Coord = Coord { x :: Double, y :: Double }
    
    instance FromJSON Coord where
       parseJSON (Object v) = 
          Coord <$>
            v .: "x" <*>
            v .: "y"
    

提交回复
热议问题