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

Unary operators

bwbush opened this issue · comments

Running agda2hs on code like

+++_ : Nat  Nat
+++_ x = 2 * x
{-# COMPILE AGDA2HS +++_ #-}

usage : Nat
usage = +++ 5

reports an error

Invalid name for Haskell function:  +++_

Is there a way to define unary operators in agda2hs?

Note that according to the Haskell Wiki, "Unary operators may also be defined and used by the programmer with similar rules to infix operators."

Currently this is not supported by agda2hs, though a PR adding support for it would be welcome. (I personally didn't even know that Haskell had unary operators.)

What does the Haskell code look like for the unary operator (I also was not aware of user-defined unary operators in Haskell)?

Hi @bwbush , what is the expected code this should compile to?