Constraint missing on type parameter
deriving instance Eq A
data Maybe' a = Nothing' | Just' a
deriving (Generic, Eq)
myTypes :: [SumType 'Haskell]
myTypes =
[ let p = (Proxy :: Proxy (Maybe' A)) in equal p (mkSumType p)
]
run :: IO ()
run = writePSTypes "/home/flip111/types" (buildBridge defaultBridge) myTypes
The generated purescript code looks like this
data Maybe' a =
Nothing'
| Just' a
derive instance eqMaybe' :: Eq (Maybe' a)
But instead the instance should be like this
derive instance eqMaybe' :: Eq a => Eq (Maybe' a)
@flip111 , here is a similar issue that appears in https://github.com/eskimor/purescript-bridge/pull/77
Given this
import Data.Either (Either)
import Data.Generic.Rep (class Generic)
import Data.Maybe (Maybe(..))
import Data.Newtype (class Newtype)
data Bar a b m c
= Bar1 (Maybe a)
| Bar2 (Either a b)
| Bar3 a
| Bar4 { myMonadicResult :: m b }
should purescript-bridge generate this?
derive instance (Generic a ra, Generic b rb, Generic (m b) rmb) => Generic (Bar a b m c) _
or this?
derive instance Generic (Bar a b m c) _
Thanks
I think we will need some means of telling the code generator what is correct. There are cases where you want the constraint on the type parameters, sometimes you don't. Depends very much on the type class at hand and the type.
@peterbecich i'm not sure. Could you pass flag -ddump-deriv to GHC and paste the haskell code for the Generic implementation?