how to implement the differential operation with Haskell?