krisajenkins / elm-export

Create Elm types and JSON decoders from Haskell source.
Eclipse Public License 1.0
116 stars 47 forks source link

Make int32 sortable #60

Closed ap-nri closed 10 months ago

ap-nri commented 10 months ago

When, in the monorepo, I try

newtype TopicId = TopicId Data.Int.Int32
  deriving
    ( Eq,
      Ord,
      Show,
      Generic,
      PGColumn "integer",
      PGParameter "integer",
      ToJSONKey,
      FromJSONKey,
      ElmType,
      HasElmSorter
    )

I get

Haskell               | src/Data/Topic/Id.hs:25:7-18: error:
Haskell               |     • No instance for (HasElmSorter Data.Int.Int32)
Haskell               |         arising from the 'deriving' clause of a data type declaration
Haskell               |       Possible fix:
Haskell               |         use a standalone 'deriving instance' declaration,
Haskell               |           so you can specify the instance context yourself
Haskell               |     • When deriving the instance for (HasElmSorter TopicId)

so I figure I can solve this right in my code with

instance HasElmSorter Data.Int.Int32 where
  elmSorter _ = Elm.Increasing

but then my problem is

Haskell               | src/Data/Topic/Id.hs:29:17-30: error:
Haskell               |     Not in scope: data constructor ‘Elm.Increasing’
Haskell               |     Module ‘Elm’ does not export ‘Increasing’.
Haskell               |    |
Haskell               | 29 |   elmSorter _ = Elm.Increasing

so that's why I'm adding the sorter here. I do not know how to use my local copy of this repo with my monorepo and test this.

ap-nri commented 10 months ago

wrong remote! Sorry!!