#!/bin/sh
# This package _manually_ sets options for the containers
# repo used. We could extract the options from cabal file
# of from setup-config created by cabal configure.
set -e
FLAGS=-O2
if grep -q '0\.3\.0\.0' $1/containers.cabal
then
FLAGS="$FLAGS -cpp -XMagicHash"
else
FLAGS="$FLAGS -fregs-graph"
fi
for c in Map Set IntMap IntSet
do
cat "$1/Data/$c.hs" | sed '
1i\
{-# OPTIONS_GHC '"$FLAGS"' #-}
s/Data\.IntMap/Container.IntMap/
s/Data\.IntSet/Container.IntSet/
s/Data\.Map/Container.Map/
s/Data\.Set/Container.Set/
' >../src/Container/$c.hs
done