Hello everybody,
I’m experimenting with typesafe routing and compiling of this code:
module Routing where
import Type.Proxy (Proxy(Proxy))
import Data.Symbol (class IsSymbol, SProxy(SProxy), reflectSymbol)
import Record (insert, get)
data Param (label :: Symbol) ty = Param
class ParseParam a where
parseParam :: String -> Maybe a
renderParam :: a -> String
class CreatePath xs params where
createPath :: Proxy xs -> Record params -> String
instance paramCreatePath :: ( IsSymbol label, ParseParam ty ) => CreatePath (Param label ty) params where
createPath _ params = renderParam (get (SProxy :: SProxy label) params)
results in this error:
No type class instance was found for
Routing.ParseParam t0
The instance head contains unknown type variables. Consider adding a type annotation.
while applying a function renderParam
of type ParseParam t0 => t0 -> String
to argument (get SProxy) params
while checking that expression renderParam ((get SProxy) params)
has type String
in value declaration paramCreatePath
where t0 is an unknown type
See https://github.com/purescript/documentation/blob/master/errors/NoInstanceFound.md for more information,
or to contribute content related to this error.
I understand error as ty
is of unknown type, but I would like to awoid specify it to by able to work with everithing in typeclass ParseParam
…
Thank you in advance