Skip to content

Instantly share code, notes, and snippets.

@bgamari
Last active June 5, 2019 18:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bgamari/4e80c34e6a9aca77c4112d34a7c10bb7 to your computer and use it in GitHub Desktop.
Save bgamari/4e80c34e6a9aca77c4112d34a7c10bb7 to your computer and use it in GitHub Desktop.
#!/usr/bin/bash
set -e
rm -f *.hi *.o
args="-O -package-env -"
#args="$args -ddump-hi-diffs -ddump-hi"
cat >Z.hs <<EOF
module Z where
class Hello a where
hello :: a -> String
instance Hello () where
hello _ = "hello"
EOF
cat >Y.hs <<EOF
module Y(Hello(..)) where
import Z
EOF
cat >X.hs <<EOF
module X(x) where
import Y
x = print (hello ())
EOF
compile() {
echo "===================== $1 ==============================="
ghc -c $args $1.hs
echo >> $log
echo "===================== $1 ===============================" >> $log
ghc --show-iface $1.hi >> $log
}
echo
echo
echo "###############################################"
echo " before "
echo "###############################################"
log=before
rm -f $log
compile Z
compile Y
compile X
ls --time-style=full-iso -lh *.hi
sleep 2
cat >Z.hs <<EOF
module Z where
class Hello a where
hello :: a -> String
instance Hello () where
hello _ = "hi"
EOF
echo
echo
echo "###############################################"
echo " after "
echo "###############################################"
log=after
rm -f $log
compile Z
compile Y
compile X
ls --time-style=full-iso -lh *.hi
echo
echo
echo "###############################################"
echo " diff "
echo "###############################################"
meld before after
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment