I would like to know if this can be done:
data NumeroConBase = NumeroConBase { num :: Integer, base :: Integer}
(|) :: String -> Int -> NumeroConBase
Basically, I would like to write 344D|5
and work with that...
I'm getting an error on "|"
...
|
is one of the very few symbol sequences which cannot be used as an operator name in Haskell. The full list is:..
,:
,::
,=
,\
,|
,<-
,->
,@
,~
,=>
and the comment delimiters. All of these have special syntactical meaning. In your case, the lone pipe is used in guards anddata
declarations.(Minutiae: the restrictions only apply if the sequences are used on their own; so something like
@@
or-->
works fine. Also, operators starting with:
can only be used as infix constructors indata
declarations.)