lhs2tex icon indicating copy to clipboard operation
lhs2tex copied to clipboard

Can something be done with <$> (infix fmap from Control.Applicative)? Because it looks awful.

Open kindaro opened this issue 7 years ago • 7 comments

This must be an insignificant rant, but can something be done to improve this typesetting?

swaygrab_1509108057-cut

It's way spread out and not nicely vertically aligned: the $ character is way too high up relative to the angle brackets and the rest of the line.

Since <$> made it to Prelude, it sees more use as a nicer replacement for infix `fmap`, so there must be quite a bunch of code around that would benefit from a better out-of-the-box typesetting.

Even just setting <$> in monospace font with some spacing from the surrounding code will make it look better (as you can see throughout this very message). To my knowledge, there's no nice and commonly accepted Unicode codepoint for this operator, but, for example, here on github someone made a set of ligatures that features a nice <$> glyph.

P.S. This typesetting is observed in both poly and math styles.

kindaro avatar Oct 27 '17 12:10 kindaro

You can just define a formatting directive and map it to anything you like.

kosmikus avatar Oct 27 '17 13:10 kosmikus

I agree. It does not look very good. In my opinion, the issues are both height and separation.

For a paper we wrote together, @turion created this rule:

https://github.com/ivanperez-keera/lhs2tex-haskell-operators/blob/master/document.lhs#L16

It looks like this:

untitled

I've created that repo to start collecting these formatting rules. We can keep it simple, just putting them in a versioned file that everyone can download regularly and import for all their projects.

ivanperez-keera avatar Mar 18 '18 06:03 ivanperez-keera

I use this: $$foo\mathbin{\langle$\rangle} a \mathbin{\langle*\rangle} b$$

%format <$> = "\mathbin{\langle\$\rangle}"
%format <*> = "\mathbin{\langle*\rangle}"

plredmond avatar May 26 '23 06:05 plredmond

https://github.com/ivanperez-keera/lhs2tex-haskell-operators/blob/master/document.lhs#L16

@ivanperez-keera do you know where this repository is now?

turion avatar May 26 '23 08:05 turion

I removed the repository because I wasn't using it anymore and didn't know that anybody was. I did not keep a copy, apparently.

I have a copy of our paper and the rule you created was:

%format <$> = "\inanglebrackets{\raisebox{0.1pt}{\scalebox{.8}{\$}}}"

where

\newcommand{\inanglebrackets}[1]{\mathbin{<\hspace{-1.6pt}\mathclap{#1}\hspace{-1.6pt}>}}

Does that help?

ivanperez-keera avatar May 28 '23 15:05 ivanperez-keera

I did not keep a copy, apparently.

Oh no :(

Does that help?

Yes, that's helpful, thanks! I don't know whether there is interest collecting these formatting rules again and maybe adding them to lhs2tex (optionally)?

turion avatar May 30 '23 09:05 turion

I'll leave that to you. For the most part, I stopped using lhs2TeX. When using extensions and such it always required too much tweaking and I had to modify my haskell to make it work, which defused the whole purpose :(

ivanperez-keera avatar May 30 '23 19:05 ivanperez-keera