Interactive diagrams pastebin


The site you are looking at is very similar to other web pasting services like or Gist. However this service is made specifically for Haskell and will compile and run the code you paste for you. Your code will be checked and any errors during the compilation or runtime will be displayed. The service will try to render the value you provide under the name ‘example’.

module Test where
example :: Int
example = 4 + 4

paste link


The pastesite is able to render a bunch of types, including the Diagram datatype.

For example:

module DiaTest where

import Diagrams.Backend.SVG
import Diagrams.Prelude

example :: Diagram SVG R2
example = circle 1

paste link

Values of the following types can be rendered on the server: Char, String, Text, number types, Bool, Ordering, Maybe, Either, [a], tuples, Diagram (via SVG), Markup.

Standard imports

If you tick the “Import standard modules” checkbox (checked by default), the service will automatically bring a number of “default” modules into the scope so you can avoid writing boilerplate header code. Modules that are imported are:


Interactive widgets

Of course, users should not be limited to rendering values that can be computed on the server. If the services determines that the example you are trying to paste is a function, it will try to compile the code to JavaScript for you and return a nice widget you can run.

Check out this example:

module Main where

main = return ()
example :: Int -> Bool -> String
example i = concat . replicate i . show

paste link

Note: if you are trying to paste code that requires interaction, make sure to put it into the Main module

Using your own datatype in interactive widgets

You can try using your own datatypes in the functions you want to compile to JavaScript. You’ll need to derive some instances first though.

{-# LANGUAGE DeriveGeneric #-}
module Main where
import GHC.Generics
import Diagrams.Interactive
data Foo = Bar String | Baz Int Int
           deriving (Show, Generic)

instance Input Foo
instance Output Foo
instance Display Foo

example :: Foo -> Int
example (Bar s)   = length s
example (Baz i j) = i + j

main = return ()

paste link

Reporting bugs and suggestions

I would be happy to hear out your suggestions and bug reports. Feel free to use the issue tracker and don’t hesitate to contact me.