ghc-reskin is a tool based on ghc-exactprint which allows quick
experimentation with the Haskell language syntax. It provides a single
executable, ghc-reskin, which accepts the following arguments:
<source file>: The name of the source file it is processing.<input file>: Where to read the source file from.<output file>: Where to write its output to.- Extensions: After the first three positional arguments,
ghc-reskinaccepts extension flags which change the syntax of the source language.
ghc-reskin is meant to be used as a preprocessor with GHC via the -F -pgmF flags. To do, provide arguments to GHC, as in the following example:
$ ghc Test.hs -F -pgmF ghc-reskin -optF -XArgumentBlock
This can also be used in a pragma, as in the examples below.
To install ghc-reskin, clone the repository:
git clone https://github.com/gibiansky/ghc-reskin.gitEnter the repository directory and run stack install:
cd ghc-reskin
stack installIf you encounter issues with the parser being generated (or get errors about
Parser.hs not being found), run stack clean and then cabal configure.
Currently supported extensions include:
-XArgumentBlock: This extension allows lambdas,case, anddoarguments to functions to be provided without a$. For example, the following function is valid:
{-# OPTIONS_GHC -F -pgmF ghc-reskin -optF -XArgumentBlock #-}
module Main where
import System.Environment (getArgs)
import Control.Monad
main :: IO ()
main = do
args <- getArgs
-- No $ before the lambda
forM_ args \arg ->
putStrLn arg
putStrLn case args of
[] -> "Empty argument list..."
xs -> "Num arguments: " ++ show (length xs)
-- No $ before do
when (null args) do
putStrLn "No arguments"
putStrLn "Why didn't you argue?"