sanctuary-js / sanctuary

:see_no_evil: Refuge from unsafe JavaScript
https://sanctuary.js.org
MIT License
3.04k stars 94 forks source link

Function Signature formatting makes it more difficult to search for Haskell or PureScript equivalents #647

Closed kurtmilam closed 5 years ago

kurtmilam commented 5 years ago

It would be nice to be able to copy a function signature from SanctuaryJS docs and paste it into Hoogle or Pursuit to find equivalent or similar functions in Haskell or PureScript.

Unfortunately, the use of WORD JOINER / U+2060 in -> and friends in SanctuaryJS function signatures makes it harder to do this.

Searching for the Haskell and PureScript equivalent of Sanctuary's chain function (fn sig copied directly from the SanctuaryJS docs):

Haskell: image

PureScript: image

Ramda uses the character, which works in Pursuit, but not in Hoogle: image

CrossEye commented 5 years ago

Yes, I want to fix this in Ramda too; it's just never made it to the top of the list. What I really want to do is to use Fira Code, a font with programmers' ligatures, which I first noticed on Tom Harding's site (for example, on his Setoid overview.)

This would allow users to cut and paste -> but still have it appear as a readable arrow.

I think this would improve things quite a bit.

kurtmilam commented 5 years ago

@CrossEye That sounds like a good solution!

I use Fira in VSCode, where I mostly write PureScript (still learning), but I also take advantage of the fact that PureScript allows unicode characters like , , and :)

Examples: image

image

davidchambers commented 5 years ago

@kurtmilam, might it be possible to write a few lines of JavaScript to intercept the copy event?

@CrossEye, if you have Fira Code installed you should see it in use on the Sanctuary website.

CrossEye commented 5 years ago

@davidchambers: Interesting. When I tried copying the chain signature to Hoogle earlier in the day, I got the same result that Kurt described. Now it works fine. Did this change recently, or could it be a difference between Windows and Ubuntu?

davidchambers commented 5 years ago

@CrossEye, were you copying from the website or from the readme? The script that generates the website removes WORD JOINER characters.

kurtmilam commented 5 years ago

@davidchambers That sounds like an interesting solution. I'll do some research as soon as I get a chance.

I'm on a Mac and copied the sigs from the readme, btw.

davidchambers commented 5 years ago

That sounds like an interesting solution. I'll do some research as soon as I get a chance.

My suggestion was misleading. I mistakenly assumed the problem applies to the website, but after investigating I convinced myself that it only applies to the readme.

I'm ready to revert plaid/transcribe#14, as it introduced more problems than it solved (in addition to the copy and paste problem, Safari incorrectly renders WORD JOINER characters as spaces).

@kurtmilam, if you have a chance please open an issue and include a link to this one. I think further discussion should take place in Transcribe's issue tracker.

kurtmilam commented 5 years ago

Ah, OK. I had just worked out a solution to remove the WORD JOIN character on the copy event and was going to see how / whether it was possible to run javascript on a GitHub md page 😄

CrossEye commented 5 years ago

@davidchambers: Perhaps I switched from one to the other when I switched from work (Windows) to home (Mac). I didn't check.

kurtmilam commented 5 years ago

Also, for posterity, the screenshots I shared above, which I thought were showing Fira Code, were actually showing Hasklig, which also supports ligatures.

I had specified Fira Code as the primary font in my editor, but I'd somehow managed to bungle font's installation.

I've rectified that now 😄

Bradcomp commented 5 years ago

@kurtmilam OT, but I prefer Hasklig to Fira anyway because Fira is too skinny for me anyway. :wink:

I was using a fork of Hasklig called Blackfont for a while that had better support for JS ligatures, but still looks the same.

Now I am using the ligature variant of Fantasque Sans which is more pleasing to my eyes but has less ligatures.