Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for associated type families #288

Open
jespercockx opened this issue Feb 23, 2024 · 1 comment
Open

Add support for associated type families #288

jespercockx opened this issue Feb 23, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@jespercockx
Copy link
Member

It would be useful and relatively easy to add support for associated types to type classes. Here's an example:

open import Haskell.Prelude

record Collection (c : Set) : Set₁ where
    field
        Elem : Set
        empty : c
        insert : Elem  c  c
        member : Elem  c  Bool
        toList : c  List Elem
open Collection {{...}} public

{-# COMPILE AGDA2HS Collection class #-}

instance
  iCollectionList : {{Eq a}}  Collection (List a)
  iCollectionList {a} = record
    { Elem   = a
    ; empty  = []
    ; insert = _∷_
    ; member = elem
    ; toList = id
    }

{-# COMPILE AGDA2HS iCollectionList #-}

Currently this produces a panic in agda2hs:

Panic: Pattern match failure in 'do' block at
src/Agda2Hs/Compile/Term.hs:147:7-26
@jespercockx jespercockx added the enhancement New feature or request label Feb 23, 2024
@UlfNorell
Copy link
Member

To think about: how to support the case when Elem is an associated data type?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants