4
votes

I have type in Haskell

newtype Uid a = Uid {uidToText :: Text}
  deriving (Eq, Ord, Show, Data, Typeable, Generic)

Using purescript-bridge library mkSumType function I can't make SumType of it. Now I have

clientTypes :: [SumType  'Haskell]
clientTypes =
  [ ...
  , mkSumType (Proxy :: Proxy (Uid a))
  ]
main :: IO ()
main = writePSTypes path (buildBridge bridge) clientTypes

and it says

• No instance for (Data.Typeable.Internal.Typeable a0)
    arising from a use of ‘mkSumType’
• In the expression: mkSumType (Proxy :: Proxy (Uid a))

How can I fix it?

1
Is giving Uid a a concrete type, i.e. mkSumType (Proxy :: (Uid ()) possible/helpful? - trevor cook
It's hard to say how it should be fixed because it's unclear what you're trying to accomplish. Polymorphic types do not have Typeable instances, and the SumType datatype does not support polytypes (so you cannot even bypass the Typeable requirement of mkSumType). - user2407038
Proxy itself is a polykinded type, so you can do Proxy Uid instead of Proxy (Uid a). However, functions cannot be polykinded, which means that the mkSumType function is "frozen" to accept only Proxy * a and cannot accept Proxy (* -> *) a. - Fyodor Soikin

1 Answers

4
votes

TypeParameters module can be used for this purpose. Simply adding

import Language.PureScript.Bridge.TypeParameters (A)

clientTypes :: [SumType  'Haskell]
clientTypes =
  [ ...
  , mkSumType (Proxy :: Proxy (Uid A))
  ]

will make the job done.