
Say you write data Callback = Error ... | ... because one of the kinds of callbacks you need to model is an error callback. Then, later, you write data Error = ... to model some error that can happen. They're both good names, but there's a conflict. So I started thinking I should prefix my constructor names like data Callback = CallbackError ... | ... It will work, but it's not the nicest looking. I discovered I can write data Callback = Callback'Error ... | ... Where can I find the syntax reference to see what's allowed? Will people kill me if I start doing this? I could import qualified, but in my case, there would be too many modules. Thanks for any advice.

I found syntax reference here.
http://www.haskell.org/onlinereport/syntax-iso.html
consym->(: {symbol | :})<reservedop>
symbol->ascSymbol | uniSymbol
Say you write data Callback = Error ... | ... because one of the kinds of callbacks you need to model is an error callback.
Then, later, you write data Error = ... to model some error that can happen.
They're both good names, but there's a conflict. So I started thinking I should prefix my constructor names like data Callback = CallbackError ... | ... It will work, but it's not the nicest looking.
I discovered I can write data Callback = Callback'Error ... | ... Where can I find the syntax reference to see what's allowed? Will people kill me if I start doing this?
I could import qualified, but in my case, there would be too many modules.
Thanks for any advice.
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org javascript:; http://www.haskell.org/mailman/listinfo/haskell-cafe

On Sat, Jun 22, 2013 at 04:26:14AM -0500, Brian Lewis wrote:
Say you write data Callback = Error ... | ... [...]
Then, later, you write data Error = ... [...]
They're both good names, but there's a conflict.
What do you mean by a conflict? That's fine as far as the compiler is concerned because constructors live in a different namespace from types. If you meant it will be too confusing for the programmer that's fair enough. Tom

On Sat, Jun 22, 2013 at 12:15:07PM +0100, Tom Ellis wrote:
On Sat, Jun 22, 2013 at 04:26:14AM -0500, Brian Lewis wrote:
Say you write data Callback = Error ... | ... [...]
Then, later, you write data Error = ... [...]
They're both good names, but there's a conflict.
What do you mean by a conflict? That's fine as far as the compiler is concerned because constructors live in a different namespace from types.
I think he meant something like: data Callback = Error Error | Success data Error = Error String ...in which case there is a clash for the identifier "Error" at the value level.
participants (4)
-
Brian Lewis
-
Suzuki Tomohiro
-
Tobias Dammers
-
Tom Ellis