antalsz / hs-to-coq

Convert Haskell source code to Coq source code
https://hs-to-coq.readthedocs.io
MIT License
279 stars 27 forks source link

Translating Definitions of Applicative and Functor instances based on Control.Monad #96

Open lastland opened 6 years ago

lastland commented 6 years ago

The following way of declaring a monad instance is quite common in Haskell:

instance Monad Hp where
  return = returnHp
  m >>= f = bindHp m f

instance Applicative Hp where
  pure = return
  (<*>) = ap

instance Functor Hp where
  fmap = liftM

However, it cannot be translated to Coq directly using hs-to-coq. Reordering would not help, either, because of the entangled dependency.

nomeata commented 6 years ago

I don't think an automatic solution will happen any time soon. You can redefine (rename? rewrite?) Applicative_Hp__ap to Monad_Hp__return, that should work.