Skip to content

Instantly share code, notes, and snippets.

@phrz
Last active January 16, 2018 12:42
Show Gist options
  • Select an option

  • Save phrz/2944d7307d20ba5cc61b63bbdfbff075 to your computer and use it in GitHub Desktop.

Select an option

Save phrz/2944d7307d20ba5cc61b63bbdfbff075 to your computer and use it in GitHub Desktop.
A CodeRunner 2 for Mac compile script to enable execution of Haskell.
#!/bin/bash
# This is a CodeRunner compile script. Compile scripts are used to compile
# code before being run using the run command specified in CodeRunner
# preferences. This script is invoked with the following properties:
#
# Current directory: The directory of the source file being run
#
# Arguments $1-$n: User-defined compile flags
#
# Environment: $CR_FILENAME Filename of the source file being run
# $CR_ENCODING Encoding code of the source file
# $CR_TMPDIR Path of CodeRunner's temporary directory
#
# This script should have the following return values:
#
# Exit status: 0 on success (CodeRunner will continue and execute run command)
#
# Output (stdout): On success, one line of text which can be accessed
# using the $compiler variable in the run command
#
# Output (stderr): Anything outputted here will be displayed in
# the CodeRunner console
BASE_FILENAME=$(basename "$CR_FILENAME")
BASE_FILENAME="${BASE_FILENAME%.*}"
EXECUTABLE=$CR_TMPDIR/$BASE_FILENAME
ghc "${@:1}" --make -outputdir $CR_TMPDIR -o $EXECUTABLE $CR_FILENAME >/dev/null
STATUS=$?
if [ $STATUS == 0 ]
then
echo $EXECUTABLE
fi
exit $STATUS
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment