evancz/Elm — pull request #484 by JoeyEremondi (2014-02-01 06:35:46+00:00)
Title: Add Pretty instance to SourceSyntax.Module

Doesn't change any previous code, just adds a Pretty instance declaration for SourceSyntax.Module.
This is a low priority change, but it's not a big change and it would be helpful to have it.

There's not much testing infrastructure, but I've tried the following (pretty basic example):

module Main where
import Y
getType = \(Object d) -> case Dict.lookup "__type" d of
Just (Json.String t) -> t
getCtor = \(Object d) -> case Dict.lookup "__ctor" d of
Just (Json.String c) -> c
varNamed = \(Object d) n -> case Dict.lookup (show n) d of
Just val -> val
mapJson = \f (Array l) -> map f l
makeList = \(Array l) -> l
error = \s -> case True of False -> s

It can be parsed, pretty printed, then re-parsed and re-pretty printed (i.e. the output of the pretty printer successfully parses).