fyxov
fyxov

Reputation: 33

How do I define nonfix operators in Haskell?

In SML the "nonfix" operator can be used like:

datatype Proposition = Not_ of Proposition 

nonfix ~:
val ~: = Not_ 

In Haskell it would be like:

data Proposition = Not_ Proposition 

nonfix ~
(~) = Not_ 

But I didn't find an equivalent to "nonfix" in Haskell.

Upvotes: 3

Views: 167

Answers (1)

Daniel Wagner
Daniel Wagner

Reputation: 153222

You didn't find an equivalent because there isn't one. Make a different plan. Options include a non-embedded DSL; quasiquoters; using postfix instead of prefix; using a non-operator name (such as not or (!)); using CPP or another preprocessor.

Upvotes: 2

Related Questions