Haskell Playground is live at play.haskell.org

Dear haskellers,
it is with great pleasure that the Haskell.org Committee is announcing the availability of the Haskell Playground at https://play.haskell.org!

The playground is a work of love by @tomsmeding, now with support from Haskell.org. He deserves all your encouragement!


Now, to the details:

Exposed Packages

Click here to see the list of exposed packages
  • aeson,
  • array,
  • assoc,
  • async,
  • attoparsec,
  • base,
  • base16,
  • base64,
  • bifunctors,
  • binary,
  • bytestring,
  • Cabal,
  • comonad,
  • containers,
  • contravariant,
  • deepseq,
  • directory,
  • distributive,
  • dlist,
  • effectful,
  • effectful-core,
  • exceptions,
  • filepath,
  • generically,
  • ghc-boot,
  • ghc-boot-th,
  • ghc-heap,
  • ghci,
  • ghc-prim,
  • hashable,
  • haskeline,
  • hpc,
  • indexed-traversable,
  • integer-gmp,
  • integer-logarithms,
  • libiserv,
  • monad-control,
  • mtl,
  • parsec,
  • pretty,
  • primitive,
  • process,
  • QuickCheck,
  • random,
  • safe-exceptions,
  • scientific,
  • semialign,
  • semigroupoids,
  • stm,
  • strict,
  • template-haskell,
  • terminfo,
  • text,
  • text-short,
  • th-abstraction,
  • these,
  • time,
  • transformers,
  • transformers-base,
  • unix,
  • unliftio,
  • unliftio-core,
  • unordered-containers,
  • uuid-types,
  • vector,
  • vector-stream,
  • witherable,
  • xhtml

GHC Versions supported

  • 8.6.5
  • 8.8.4
  • 8.10.7
  • 9.0.2
  • 9.2.5
  • 9.4.4

Aaaaand in bonus, thanks to @hasufell’s pre-release channel for ghcup, the two latest alpha releases of GHC 9.6 are available. Especially interesting if you want to compare Core or ASM outputs across compiler versions, test the new TypeData extension. You can even try out the Delimited Continuations.

Sandboxing

The playground uses Bubblewrap for sanboxing.

API

You can perform an API request to the playground like this:

{
  "code": "main :: IO ()\nmain = print 42",
  "version": "9.2.4",  // or "8.10.7", or "9.6.0.20230210", etc.
  "opt": "O1",  // "O0", "O1" or "O2"
  "output": "run"  // "run", "core" or "asm"
}

Playground Initialisation

If you wish to provide a link that open a new playground with custom code, you can provide the code url-encoded as the code query parameter, like this:

https://play.haskell.org/?code=main%20%3A%3A%20IO%20() main%20%3D%20putStrLn%20"Hello%20Discourse!"

Happy hacking!

56 Likes

Is the set of available packages final? For little experiments (kinda what tools like this one are well suited) I like to use extra.

Also, vector usually makes more sense if vector-algorithms is available.

1 Like

The set of available packages is not final at all! I’m not comfortable yet with including all of Stackage, not least because of the disk space and build time requirements. So at least for now, sensible requests like yours are welcome.

In fact if you look again, you’ll see that your suggested packages are now available on all provided GHC versions. :slight_smile:

The full list of available packages is here, which is of course not very convenient to read/find. Making this nicely available in the interface (and fixing synchronisation of package versions across multiple worker machines) is a TODO item.

13 Likes

This is fantastic! Great job, and a great addition to the ecosystem!

Just one suggestion: Maybe it’s possible to start with a simpler example? For Haskell newcomers who have just been patted on the back by a seasoned Haskeller with the words “No worries, you don’t need to understand category theory for this” it’s maybe a bit intimidating to start with import Data.Bifunctor. One could rewrite the example by expanding the first and second functions, or defining toright and toleft with an accumulator argument, …

4 Likes

For other readers: this has been addressed in the course of fixing #23 :slight_smile:

5 Likes

Playground is fantastic!
It’s fun to use.

I have made this in the playground today, surprisingly quickly almost from scratch.
Here is a new better version of it.

3 Likes

Would it be possible to somehow integrate the playground with HLS?

1 Like

In what way do you imagine that?

1 Like

Dearest thanks to @tomsmeding for this gem! I successfully used it to demo some combinatorics in a school environment, where no-setup coding solutions like this are particularly helpful.
The greatest feature for getting the teachers to use Haskell is the “save and share” button. What I could not determine from the source code (and what is probably local to the server instance): Is there a limit for how long saved source code is stored? Will a link to play.haskell.org/saved/ expire some day or continue to function until the database is full, like the source code suggests?

6 Likes

Thanks for the feedback! This is really heartwarming

Thanks, happy to hear that it’s useful! Yes, there is currently no expiration on the saved snippets. In theory, this doesn’t scale at all; in practice, the database growth rate is, as yet, slow enough. We’ll have to see if usage remains relatively quiet in the future. :slight_smile:

1 Like