Skip to content

Instantly share code, notes, and snippets.

@sordina
Created April 22, 2015 05:29
Show Gist options
  • Save sordina/a803b5536ab16c678b45 to your computer and use it in GitHub Desktop.
Save sordina/a803b5536ab16c678b45 to your computer and use it in GitHub Desktop.
Evaluate Haskell Expression and allow for module imports.
#!/bin/sh
if [[ ! "$1" ]]
then
echo 'usage: ghcm <expression> <module>*'
exit 1
fi
tmp_mod="/tmp/tmp_mod_$$.hs"
exp="$1"
shift
echo "$@" | xargs -n 1 echo import | sed 's/$/;/' > $tmp_mod
ghc -e "$exp" $tmp_mod
rm $tmp_mod
@sordina
Copy link
Author

sordina commented Apr 22, 2015

Is there a way to do this using ghc -e on its own?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment