Polymorphic types with a bridge

I have a type in Haskell

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

Using the purescript-bridgelibrary mkSumTypefunction, I cannot make from it SumType. Now i have

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

and he 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 this?

+4
source share
1 answer

The TypeParameters module can be used for this purpose. Just adding

import Language.PureScript.Bridge.TypeParameters (A)

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

will do its job.

+4
source

Source: https://habr.com/ru/post/1683185/


All Articles