tweag / ormolu

A formatter for Haskell source code
https://ormolu-live.tweag.io
Other
956 stars 83 forks source link

Add WASM-based Ormolu Live #964

Closed amesgen closed 1 year ago

amesgen commented 1 year ago

New Ormolu Live based on the upcoming GHC WASM backend.

Closes #951

Test deployment at https://ormolu-live-testbed.netlify.app/

Diff is severly inflated by lockfile changes.

amesgen commented 1 year ago

@asarkar As you have been giving feedback on the old Ormolu Live version, I would be interested in your thoughts, in particular if you think that the new version resolves #951.

https://ormolu-live-testbed.netlify.app/

asarkar commented 1 year ago

@amesgen Thanks for doing this, I’ll take a look later. One unrelated comment, can you display a verbiage on the page about the storage/usage of code that is being formatted? In other words, if you’re not saving any of the code or phoning home or using any part of it to train the tool, can you call it out, so that people formatting sensitive code know what to expect.

amesgen commented 1 year ago

One unrelated comment, can you display a verbiage on the page about the storage/usage of code that is being formatted? In other words, if you’re not saving any of the code or phoning home or using any part of it to train the tool, can you call it out, so that people formatting sensitive code know what to expect.

Good point, I could imagine that it might even be illegal under the GDPR to send the data without explicit consent. I added this line:

Note that this website is entirely client-side; in particular, your input is never sent to a remote server.

asarkar commented 1 year ago

I've had a chance to look at the new page, and here are my findings:

  1. The copy button on the right is gone, which, IMO, is a no-go.
  2. It's not clear which of the two panes is for the user. A note like "paste or type here" that disappears as soon as something is pasted or typed would make for a better user experience. For reference, see https://codebeautify.org/jsonvalidator and https://text-compare.com/.
  3. IMO, "See the GitHub repository" button is redundant because you're already linking to a commit in the GitHub repo.
  4. The disclaimer "this website is entirely client-side" is better suited as a footnote.
  5. Can you show the GHC version, perhaps as a second footnote?
  6. In addition to the rows, it'll be helpful to show the column at which the cursor is at. Here's why:

Input abc <- xs results in:

<input>:1:5-6
  The GHC parser (in Haddock mode) failed:
  parse error on input `<-'

Now, while the last line does say what the problem is, this is an exception rather than the rule as Haskell is notorious for hard-to-understand compiler errors. Column 5 happens to be the beginning of <-.

amesgen commented 1 year ago

I've had a chance to look at the new page, and here are my findings:

Thanks, I just updated the site based on your findings with only slight deviations (ghc-lib-parser version is next to the commit link, and I left off point 3 for now, as I find it somewhat neat to be able to directly jump to the README).

asarkar commented 1 year ago

LGTM :thumbsup:

asarkar commented 1 year ago

it'll be helpful to show the column

Just want to say that this was a great idea. I pasted the following code at https://ormolu-live.tweag.io/:

module Chapter03.Lib () where

class Monad m where
return :: a -> m a
(>>=) :: m a -> (a -> m b) -> m b

then_ :: Maybe a -> (a -> Maybe b) -> Maybe b

instance Monad Maybe where
  return = Just
  (>>=) = then_

-- Exercise3.1. Write the implementation of ap.
ap :: Monad m => m (b -> c) -> m b -> m c
ap f x = f >>= $ \f' -> x >>= $ \x' -> f' x'

and it failed with:

The GHC parser failed:

<input>:15:16

parse error on input `$'

However, column numbers aren't shown in the input, so, it's not immediately apparent which of the two $ is the problem. Thanks for implementing my suggestions.

github-actions[bot] commented 1 year ago

🚀 Deployed on https://d824bc9817c754a07674411ef7dd72cc511613ad--ormolu-live.netlify.app