agda / agda2hs

Compiling Agda code to readable Haskell

Home Page:https://agda.github.io/agda2hs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Check that types of non-erased instance arguments are type classes

jespercockx opened this issue · comments

Currently we do not check that the type of an instance argument is actually compiled to a Haskell Constraint, causing agda2hs to generate ill-formed Haskell code. Here's an example:

open import Haskell.Prelude

instance
  favoriteNumber : Int
  favoriteNumber = 42
{-# INLINE favoriteNumber #-}

test : {{Int}}  Int
test {{x}} = x
{-# COMPILE AGDA2HS test #-}

Currently agda2hs happily compiles this to the following nonsense:

test :: Int => Int
test = x

We should either disallow this, or else detect that the type has kind * and compile it to a regular (explicit) argument in Haskell.

Related: #217 and #218