Skip to content

agda2hs cannot compile Traversable instances defined with traverse=_ #457

Description

@ggrandi

I was trying to use mapM from agda2hs and when I compiled it I am getting the output:

agda2hs failed:
<...>: error: [CustomBackendError]
agda2hs:
  illegal instance:  Haskell.Prim.Traversable.traverse=
                     Haskell.Prim.Traversable.traverseList

The code I got it to fail on was as follows:

usingMapM : Maybe (List Nat)
usingMapM = mapM pure []

{-# COMPILE AGDA2HS usingMapM #-}

The other thing that confused me is that when I inlined the definition of traverse=_ into iTraversableList in lib/base/Haskell/Prim/Traversable.agda to

   iTraversableList : Traversable List
-  iTraversableList = traverse= traverseList
+  iTraversableList = record {DefaultTraversable (record {traverse = traverseList})}

without making any other changes it seemed to work.

I am not quite sure what is going on so I wanted to make an issue since I think this might happen again in other places where there is a record created from a default record with a helper (I don't think there are any other instances of it within base).

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglibraryFor issues in and enhancements to the agda2hs libraries (currently prelude and containers)

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions