Type class members have not been implemented

Hi there,
I am very new to purescript and haskel as well, so currently i am working on a project to migrate purescript module from pulp to spago. Earlier with pulp there was no issue but while migrating i am facing this issue. Can someone help me on this. Thanks in advance.

 The following type class members have not been implemented:
  identity :: forall t. Price t t

in type class instance

  Control.Category.Category Price

this is the issue, need some context on this issue.

1 Like

Hi and welcome!
I’ll take a guess here, and we can see if it helps with diagnosing the issue.

A little background first. Here’s the docs for Category. A Category is just a thing for which there is an identity function defined. There’s one thing for which this definition already exists, which is Function. So identity :: forall t. a t t when we specialize a = Function would be simplified to
forall t. Function t t or
forall t. (->) t t or
forall t. t -> t. And the implementation for that is

instance Category (->) where
  identity x = x

In other words, identity (for Function) is just a function that returns exactly what it’s given as input.

Now, your error message there is saying that it expected to find that Price was a Category, and that didn’t work because there is no identity definition for Price. Now it could be that somebody was actually trying to make Price into a Category, but the more likely scenario in my opinion is that somebody used identity where originally a function of Price _ -> Price _ was expected, and now instead of a function being expected, it’s just expecting a single Price _ value. This maybe is from a package having a breaking update in a later version or something. So when you try to pass identity in now that it’s expecting a single Price _ value, the compiler thinks you’re trying to say that Price is a Category and gives you that error.

Any chance you can check around where the error is popping up to see if you are using identity somewhere that’s not expecting a function (but maybe was expecting a function in an earlier version)?

1 Like

@ntwilson Thanks for answering my question. I will start diagnosing the issue today…