4

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?

Shersh
  • 9,019
  • 3
  • 33
  • 61
vrom911
  • 694
  • 1
  • 5
  • 16
  • Is giving `Uid a` a concrete type, i.e. `mkSumType (Proxy :: (Uid ())` possible/helpful? – trevor cook Aug 07 '17 at 18:07
  • 1
    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 Aug 07 '17 at 18:29
  • `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 Aug 07 '17 at 18:34

1 Answers1

4

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.

vrom911
  • 694
  • 1
  • 5
  • 16