Re: Names for pretty-printing combinators

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: Names for pretty-printing combinators

Ivan Lazar Miljenovic
(Changing the subject as it's going off-topic from the original email :p)

On 25 May 2011 22:45, Simon Meier <[hidden email]> wrote:
> 2011/5/25 Ivan Lazar Miljenovic <[hidden email]>:
>>
>> Also, by clashes with Applicative, are you referring to empty and <$>
>> ?  I'm not sure if a better name than "empty" can be found; as for
>> <$>, maybe using pretty's notation of $$ and $+$ rather than <$> and
>> <$$> ?
>
> What about 'emptyDoc'?

It's a bit more of a mouthful, and getting a bit close to Hungarian
Notation, isn't it? :p  Also, empty is already used a fair amount in
other libraries as it stands (admittedly, most of those are in modules
that are typically imported qualified...).

> Moreover, if you are changing the names of
> combinators, then moving them away from Applicative and Arrow would be
> a good idea; i.e., don't use <+>, as it already used by ArrowPlus.

*sigh* We really need to get a list of used operators somewhere so
that libraries can stake a claim :p

> Moreover, if you can make a Monoid instance such that `mappend` equals
> <>, you would also make the library compatible to a future
> introduction of (<>) = mappend.

I was thinking about that actually...

--
Ivan Lazar Miljenovic
[hidden email]
IvanMiljenovic.wordpress.com

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Names for pretty-printing combinators

Stephen Tetley-2
Hi Ivan

empty is fine as is, obviously with a Monoid instance as well, people
can choose to use mempty which removes potential name clashes.

I was thinking of (<$>) and (<+>), though I was forgetting that (<+>)
is actually ArrowPlus.

If you are mostly gifting angles as notation to Applicative, maybe a
pretty print library can live with fewer infix ops? Though you could
still define fixities for the binary cases:

infixr 6 `sep1`

Or maybe steal the notation form Vector-Space (^+^) as cases where you
would want both imported at the same time may be uncommon.

Although "trivial" proposals often get rejected for changes to Base, I
suspect a proposal for (<>) as a synonym for `mappend` might have
legs, it would certainly have a lot of support...

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Names for pretty-printing combinators

Casey McCann
One drastic approach I've used in personal libraries--operator-heavy EDSLs specifically--is to define everything first with alphanumeric names, then put operators in their own modules. In some cases I'd have three such modules: One providing a minimal set of operators that don't clash with anything significant, one providing a larger set of operators that clash with one or more common modules (often deliberately, e.g. duplicating Arrow combinators for some type with similar semantics but no valid Arrow instance), and one providing a bunch of gratuitous Unicode operators that look pretty in my code editor but I don't know how to type in GHCi.

I'm not sure if I've seen that approach anywhere else, however, so it might not be something most people would care for.

- C.


On Wed, May 25, 2011 at 10:45 AM, Stephen Tetley <[hidden email]> wrote:
Hi Ivan

empty is fine as is, obviously with a Monoid instance as well, people
can choose to use mempty which removes potential name clashes.

I was thinking of (<$>) and (<+>), though I was forgetting that (<+>)
is actually ArrowPlus.

If you are mostly gifting angles as notation to Applicative, maybe a
pretty print library can live with fewer infix ops? Though you could
still define fixities for the binary cases:

infixr 6 `sep1`

Or maybe steal the notation form Vector-Space (^+^) as cases where you
would want both imported at the same time may be uncommon.

Although "trivial" proposals often get rejected for changes to Base, I
suspect a proposal for (<>) as a synonym for `mappend` might have
legs, it would certainly have a lot of support...

_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Names for pretty-printing combinators

Henning Thielemann-4
Casey McCann schrieb:

> One drastic approach I've used in personal libraries--operator-heavy
> EDSLs specifically--is to define everything first with alphanumeric
> names, then put operators in their own modules. In some cases I'd have
> three such modules: One providing a minimal set of operators that don't
> clash with anything significant, one providing a larger set of operators
> that clash with one or more common modules (often deliberately, e.g.
> duplicating Arrow combinators for some type with similar semantics but
> no valid Arrow instance), and one providing a bunch of gratuitous
> Unicode operators that look pretty in my code editor but I don't know
> how to type in GHCi.

I use explicit imports in order to avoid infix operator clashes.


_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe