agda2hs icon indicating copy to clipboard operation
agda2hs copied to clipboard

Unary operators

Open bwbush opened this issue 9 months ago • 2 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."

bwbush avatar May 08 '24 17:05 bwbush

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.)

jespercockx avatar May 09 '24 14:05 jespercockx

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

UlfNorell avatar May 10 '24 14:05 UlfNorell

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

jmchapman avatar May 24 '24 12:05 jmchapman