Commit f5edc6b0 authored by Ian Lynagh's avatar Ian Lynagh
Browse files

Remove ilxGen; part of trac #2243

parent 911e7de1
.assembly test { }
.assembly extern 'mscorlib' { }
.assembly extern ilx 'std' { }
// ENTRYPOINT
.class MainMain {
.method public static void Main(class [mscorlib]System.String[]) {
.entrypoint
ldstr "LOG: *** loading main value" call void [mscorlib]System.Console::WriteLine(class [mscorlib]System.String)
ldsfld thunk<(func ( /* unit skipped */ ) --> class [std]PrelBase_Z0T)> class Main::'Main_main'
ldstr "LOG: *** evaluating main value"
call void [mscorlib]System.Console::WriteLine(class [mscorlib]System.String)
callfunc () --> (func ( /* unit skipped */ ) --> class [std]PrelBase_Z0T)
ldstr "LOG: *** calling main value"
call void [mscorlib]System.Console::WriteLine(class [mscorlib]System.String)
// ldunit
callfunc ( /* unit skipped */ ) --> class [std]PrelBase_Z0T
pop
// HACK HACK HACK
// Call the "finalizers" for stdin, stdout and stderr, because COM+ doesn't
// guarantee that finalizers will be run. WE DON'T GUARANTEE TO RUN ANY
// OTHER FINALIZERS...
ldstr "LOG: ***calling critical finalizers manually in main()"
call void [mscorlib]System.Console::WriteLine(class [mscorlib]System.String)
ldsfld thunk<(func (thunk<class [std]PrelIOBase_MVar<class [std]PrelIOBase_Handlezuzu>>) --> (func (/* unit skipped */) --> class [std]PrelBase_Z0T))> [std]'PrelHandle'::'PrelHandle_stdHandleFinalizzer'
ldsfld thunk<class [std]PrelIOBase_MVar<class [std]PrelIOBase_Handle__>> [std]'PrelHandle'::'PrelHandle_stdin'
callfunc () (thunk<class [std]PrelIOBase_MVar<class [std]PrelIOBase_Handle__>>) --> (func ( /* unit skipped */ ) --> class [std]PrelBase_Z0T)
callfunc ( /* unit skipped */ ) --> class [std]PrelBase_Z0T
pop
ldsfld thunk<(func (thunk<class [std]PrelIOBase_MVar<class [std]PrelIOBase_Handlezuzu>>) --> (func (/* unit skipped */) --> class [std]PrelBase_Z0T))> [std]'PrelHandle'::'PrelHandle_stdHandleFinalizzer'
ldsfld thunk<class [std]PrelIOBase_MVar<class [std]PrelIOBase_Handle__>> [std]'PrelHandle'::'PrelHandle_stdout'
callfunc () (thunk<class [std]PrelIOBase_MVar<class [std]PrelIOBase_Handle__>>) --> (func ( /* unit skipped */ ) --> class [std]PrelBase_Z0T)
callfunc ( /* unit skipped */ ) --> class [std]PrelBase_Z0T
pop
ldsfld thunk<(func (thunk<class [std]PrelIOBase_MVar<class [std]PrelIOBase_Handlezuzu>>) --> (func (/* unit skipped */) --> class [std]PrelBase_Z0T))> [std]'PrelHandle'::'PrelHandle_stdHandleFinalizzer'
ldsfld thunk<class [std]PrelIOBase_MVar<class [std]PrelIOBase_Handle__>> [std]'PrelHandle'::'PrelHandle_stderr'
callfunc () (thunk<class [std]PrelIOBase_MVar<class [std]PrelIOBase_Handle__>>) --> (func ( /* unit skipped */ ) --> class [std]PrelBase_Z0T)
callfunc ( /* unit skipped */ ) --> class [std]PrelBase_Z0T
pop
ldstr "LOG: exit main()\n"
call void [mscorlib]System.Console::WriteLine(class [mscorlib]System.String)
ret
}
}
This diff is collapsed.
PrelAll_SRC=Array.lhs Maybe.lhs PrelDynamic.lhs PrelIOBase.lhs PrelShow.lhs \
CPUTime.lhs Monad.lhs PrelEnum.lhs PrelList.lhs PrelStable.lhs \
Char.lhs Numeric.lhs PrelErr.lhs PrelTup.lhs \
Complex.lhs PrelAddr.lhs PrelException.lhs PrelMaybe.lhs PrelWeak.lhs \
Directory.lhs PrelArr.lhs PrelFloat.lhs PrelNum.lhs Prelude.lhs \
IO.lhs PrelArrExtra.lhs PrelForeign.lhs PrelPack.lhs Random.lhs \
Ix.lhs PrelBase.lhs PrelHandle.lhs PrelRead.lhs Ratio.lhs \
List.lhs PrelByteArr.lhs PrelHugs.lhs PrelReal.lhs System.lhs \
Locale.lhs PrelConc.lhs PrelIO.lhs PrelST.lhs Time.lhs
PrelAll_ILX=$(patsubst %.lhs,%.ilx,$(PrelAll_SRC))
CLEAN_FILES += $(PrelAll_ILX)
PrelAll_ILX_FWD=$(patsubst %.lhs,%.ilx.fwd.ok,$(PrelAll_SRC))
PrelAll_IL=$(patsubst %.lhs,%.il,$(PrelAll_SRC)) PrelGHC.il
PrelAll_MOD=$(patsubst %.il,%.mod,$(PrelAll_IL))
%.ilx %.ilx.fwd: %.lhs
$(HC_PRE_OPTS)
$(HC) $(HC_OPTS) -Onot -D__ILX__ --ilx $*.lhs -o $*.ilx
$(HC_POST_OPTS)
CORRUN=
LOCALRUN=./
ifeq ($(HOSTNAME),msrc-hilda)
CORRUN=cmd /c "devvs && "
LOCALRUN=.\\
endif
ILXASM=/devel/fcom/src/bin/ilxasmx.exe -l /devel/fcom/src/ilxasm --no-ilasm --box-everything
ILASM=$(CORRUN)ilasm
AL=$(CORRUN)al
%.ilx.fwd.ok: %.ilx.fwd
if diff -q $< $@; then true; else cp $< $@; fi
%.mod : %.il
$(ILASM) /QUIET /DLL /OUT=$@ $<
PrelGHC.il: ../../compiler/ilxGen/PrelGHC.il
cp $< $@
PrelAll.dll : ilxasm-stdlib.mod $(PrelAll_MOD)
$(AL) ilxasm-stdlib.mod $(PrelAll_MOD) -out:$@
%.ilx_with_fwd: %.ilx $(PrelAll_ILX_FWD)
cat $(PrelAll_ILX_FWD) $*.ilx > $@
%.il : %.ilx_with_fwd /devel/fcom/src/bin/ilxasmx.exe
$(ILXASM) --no-stdlib -o $@ $*.ilx_with_fwd
ilxasm-stdlib.il : /devel/fcom/src/bin/ilxasmx.exe /devel/fcom/src/ilxasm/stdlib-func-by-mcalli.ilx
rm -f tmp.ilx
touch tmp.ilx
$(ILXASM) -o $@ tmp.ilx
rm -f tmp.ilx
#--------------------
# For validation only:
PrelAll.il: $(PrelAll_IL) ilxasm-stdlib.il
cat ilxasm-stdlib.il $(PrelAll_IL) > $@
%.mvl: %.il
make -C ../../compiler/ilxGen/tests ilvalidx
ILVALID_HOME=/devel/fcom/src /devel/fcom/src/bin/ilvalidx.exe $*.il
ilxasm:
make -C ../../compiler/ilxGen/tests ilxasmx
ilvalid:
$(MAKE) -C /devel/fcom/src bin/ilvalidx.exe
ghc:
make -C ../../compiler/ilxGen/tests ghc
.PRECIOUS: %.ilx.fwd %.ilx.fwd.ok %.il %.ilx_with_fwd
TOP = ../../..
include $(TOP)/mk/boilerplate.mk
WAYS=$(GhcLibWays)
#-----------------------------------------------------------------------------
# Setting the standard variables
#
HC = $(GHC_INPLACE)
SRC_HC_OPTS+=-cpp -fglasgow-exts
#-----------------------------------------------------------------------------
#
CORENV_DEBUG=
CORENV_RETAIL=
LOCALRUN=./
ifeq ($(HOSTNAME),MSRC-HILDA)
CORENV_DEBUG="call devcorb2gen.bat checked"
CORENV_RETAIL="call devcorb2gen.bat free"
LOCALRUN=.\\
endif
ghc:
$(MAKE) -C ../..
ilx:
$(MAKE) -C $(ILX2IL_HOME) ilxdefault
prel: ilx
$(MAKE) -C ../../../lib/std std.$(ilx_way).dll std.$(ilx_way).vlb
#========================================================================
# 1. From Haskell to ILX and then to IL - see build.mk
#------------------------------------------------------------------------
# 2. From IL to .EXE
%.$(ilx_way).exe : %.$(ilx_way).il ../Entry.$(ilx_way).il
cat $*.$(ilx_way).il ../Entry.$(ilx_way).il > $@.tmp
# echo "call devcorb2gen free" > tmp.bat
echo "ilasm /DEBUG /QUIET /OUT=$@ $@.tmp" >> tmp.bat
cmd /c tmp.bat
../Entry.$(hs2ilx_suffix)_o: ../Entry.ilx
sed -e "s|ilx std|ilx std.$(hs2ilx_suffix)|g" ../Entry.ilx > $@.tmp
mv $@.tmp $@
%.$(ilx_way).mvl: %.$(ilx_way).il
(ILVALID_HOME=c:\\devel\\fcom\\src\\ ILVALID_MSCORLIB=mscorlib.vlb $(ILVALID) c:\\devel\\fcom\\src\\bin\\msilxlib$(ilx2il_suffix).vlb $(TOP)/lib/std/std.$(ilx_way).vlb $<) 2>&1
#------------------------------------------------------------------------
# From .HS to .EXE without using ILX
# Used to run performance comparisons against native code GHC
%.Onot.exe: %.hs
$(GHC_INPLACE) -Onot -o $@ $<
%.O.exe: %.hs
$(GHC_INPLACE) -O -o $@ $<
WIN_TOP_ABS = $(subst /,\,$(FPTOOLS_TOP_ABS))
WIN_ILX2IL_HOME = $(subst /,\,$(ILX2IL_HOME))
app.config:
echo "<configuration>" > $@
echo "<runtime>" >> $@
echo "<assemblyBinding xmlns=\"urn:schemas-microsoft-com:asm.v1\">" >> $@
echo "<probing privatePath=\"$(WIN_TOP_ABS)\\ghc\\lib\\std;$(WIN_ILX2IL_HOME)\\bin\"/>" >> $@
echo "</assemblyBinding>" >> $@
echo "</runtime>" >> $@
echo "</configuration>" >> $@
%.run: %.exe app.config
time -p $<
#------------------------------------------------------------------------
# Running:
HSstd_cbits.dll: $(DLL_PEN)/HSstd_cbits.dll
cp $< $@
%.cordbg.run: HSstd_cbits.dll %.exe
cp app.config $@.config
# echo "call devcorb2gen fastchecked" > $@.bat
echo "$(LOCALRUN)$(subst /,\\,$*).exe 2>&1" >> $@.bat
time -p cmd /c $(subst /,\\,$@).bat
rm $@.bat
%.debug.run: HSstd_cbits.dll %.exe
cp app.config $@.config
# echo "call devcorb2gen fastchecked" > $@.bat
echo "$(LOCALRUN)$(subst /,\\,$*).exe 2>&1" >> $@.bat
time -p cmd /c $(subst /,\\,$@).bat
rm $@.bat
%.retail.run: HSstd_cbits.dll %.exe
cp app.config $@.config
# echo "call devcorb2gen free" > $@.bat
echo "$(LOCALRUN)$(subst /,\\,$*).exe 2>&1" >> $@.bat
time -p cmd /c $(subst /,\\,$@).bat
rm $@.bat
%.run: %.exe
time -p $<
#--------------------
%.mvl: %.nolib.il
ILVALID_HOME=$(ILX2IL_HOME) $(ILVALID) $*.nolib.il
ci:
(cd $(ILX2IL_HOME); $(CVS) ci -m "")
(cd ../..; cvs ci -m "")
(cd ../../../lib/std; $(CVS) ci -m "")
upd:
(cd $(ILX2IL_HOME); $(CVS) up)
(cd ../..; $(CVS) up)
(cd ../../../lib/std; $(CVS) up)
.PHONY: %.run
include $(TOP)/mk/target.mk
{-# OPTIONS -fglasgow-exts -fno-implicit-prelude #-}
module PrelNum where
import {-# SOURCE #-} PrelErr
import PrelBase
import PrelList
import PrelEnum
import PrelShow
infixl 7 *
infixl 6 +, -
default () -- Double isn't available yet,
-- and we shouldn't be using defaults anyway
class (Eq a, Show a) => Num a where
(+), (-), (*) :: a -> a -> a
negate :: a -> a
abs, signum :: a -> a
fromInteger :: Integer -> a
fromInt :: Int -> a -- partain: Glasgow extension
x - y = x + negate y
negate x = 0 - x
fromInt (I# i#) = fromInteger (S# i#)
-- Go via the standard class-op if the
-- non-standard one ain't provided
subtract :: (Num a) => a -> a -> a
{-# INLINE subtract #-}
subtract x y = y - x
ord_0 :: Num a => a
ord_0 = fromInt (ord '0')
instance Num Int where
(+) x y = plusInt x y
(-) x y = minusInt x y
negate x = negateInt x
(*) x y = timesInt x y
abs n = if n `geInt` 0 then n else (negateInt n)
signum n | n `ltInt` 0 = negateInt 1
| n `eqInt` 0 = 0
| otherwise = 1
fromInt n = n
-- These can't go in PrelBase with the defn of Int, because
-- we don't have pairs defined at that time!
quotRemInt :: Int -> Int -> (Int, Int)
a@(I# _) `quotRemInt` b@(I# _) = (a `quotInt` b, a `remInt` b)
-- OK, so I made it a little stricter. Shoot me. (WDP 94/10)
divModInt :: Int -> Int -> (Int, Int)
divModInt x@(I# _) y@(I# _) = (x `divInt` y, x `modInt` y)
-- Stricter. Sorry if you don't like it. (WDP 94/10)
data Integer
= S# Int# -- small integers
| J# Int# ByteArray# -- large integers
zeroInteger :: Integer
zeroInteger = S# 0#
# 1. To make standard library:
#
# e.g. from lib/std directory:
# $(MAKE) way=ilx-Onot-mono std.ilx-Onot.mono.dll std.ilx-Onot.mono.vlb
# $(MAKE) way=ilx-O-mono std.ilx-O.mono.dll std.ilx-O.mono.vlb
# $(MAKE) way=ilx-Onot-generic std.ilx-Onot.generic.dll
#
# 2. To make tests:
#
# e.g. from ilxGen/tests directory:
#
# $ make -n way=ilx-Onot-mono test1.ilx-Onot.mono.retail.run
#
# $ make -n way=ilx-Onot-mono test1-nostdlib.ilx-Onot.mono.retail.run HC_OPTS="-fno-implicit-prelude -fglasgow-exts"
#
# Add all the ILX ways so dependencies get made correctly.
# (n.b. Actually we only need to add "ilx-Onot" and "ilx-O" for the
# GHC --> ILX dependencies, as these are the portions of the ILX
# ways that are relevant in terms of GHC options,
# but we list some of the others anyway. Also note that
# there are no dependencies required for the ILX --> IL or
# IL --> CLR phases as these operate on the "standalone"
# ILX and IL files).
#
#GhcLibWays+= ilx-Onot-mono ilx-Onot ilx-O ilx-O-mono
GhcLibWays+=i
GhcWithIlx=YES
ILXized=YES
GhcHcOpts+=-DILX -DNO_BIG_TUPLES
GhcLibHcOpts+=-optI--mono -optI--add-suffix-to-assembly -optImsilxlib -optI--suffix-to-add -optI.mono
# Each set of args below defines one ILX way.
#ALL_WAYS+=ilx-Onot-generic
#WAY_ilx-Onot-generic_NAME=ILX with Haskell Optimizer Off to run on Generic CLR
#WAY_ilx-Onot-generic_HC_OPTS=-buildtag ilx-Onot $(GHC_ILX_OPTS) -Onot
#WAY_ilx-Onot-generic_ILX2IL_OPTS=--generic
#WAY_ilx-Onot-generic_ILX=YES
#ALL_WAYS+=ilx-Onot-fullgeneric-verifiable
#WAY_ilx-Onot-fullgeneric-verifiable_NAME=ILX with Haskell Optimizer Off to run on Generic CLR
#WAY_ilx-Onot-fullgeneric-verifiable_HC_OPTS=-buildtag ilx-Onot $(GHC_ILX_OPTS) -Onot
#WAY_ilx-Onot-fullgeneric-verifiable_ILX2IL_OPTS=--fullgeneric --verifiable
#WAY_ilx-Onot-fullgeneric-verifiable_ILX=YES
#ALL_WAYS+=ilx-Onot-repgeneric-verifiable
#WAY_ilx-Onot-repgeneric-verifiable_NAME=ILX with Haskell Optimizer Off to run on Generic CLR
#WAY_ilx-Onot-repgeneric-verifiable_HC_OPTS=-buildtag ilx-Onot $(GHC_ILX_OPTS) -Onot
#WAY_ilx-Onot-repgeneric-verifiable_ILX2IL_OPTS=--repgeneric --verifiable
#WAY_ilx-Onot-repgeneric-verifiable_ILX=YES
#ALL_WAYS+=ilx-O-generic
#WAY_ilx-O-generic_NAME=ILX with Haskell Optimizer On to run on Generic CLR
#WAY_ilx-O-generic_HC_OPTS=-buildtag ilx-O $(GHC_ILX_OPTS) -O
#WAY_ilx-O-generic_ILX2IL_OPTS=--generic
#WAY_ilx-O-generic_ILX=YES
#ALL_WAYS+=ilx-Onot-mono
#WAY_ilx-Onot-mono_NAME=ILX with Haskell Optimizer Off to run on V1 CLR
#WAY_ilx-Onot-mono_HC_OPTS=-buildtag ilx-Onot $(GHC_ILX_OPTS) -Onot
#WAY_ilx-Onot-mono_ILX2IL_OPTS=--mono
#WAY_ilx-Onot-mono_ILX=YES
#ALL_WAYS+=ilx-Onot-mono-verifiable
#WAY_ilx-Onot-mono-verifiable_NAME=ILX with Haskell Optimizer Off to run on V1 CLR, verifiable code (CURRENTLY WILL NOT RUN BECAUSE OF LACK OF HIGHER KINDED TYPE PARAMETERS BUT IS USEFUL TO FIND BUGS USING THE VERIFIER)
#WAY_ilx-Onot-mono-verifiable_HC_OPTS=-buildtag ilx-Onot $(GHC_ILX_OPTS) -Onot
#WAY_ilx-Onot-mono-verifiable_ILX2IL_OPTS=--mono --verifiable
#WAY_ilx-Onot-mono-verifiable_ILX=YES
#ALL_WAYS+=ilx-O-mono
#WAY_ilx-O-mono_NAME=ILX with Haskell Optimizer On to run on V1 CLR
#WAY_ilx-O-mono_HC_OPTS=-buildtag ilx-O $(GHC_ILX_OPTS) -O
#WAY_ilx-O-mono_ILX2IL_OPTS=--mono
#WAY_ilx-O-mono_ILX=YES
#ALL_WAYS+=ilx-Onot-generic-traced
#WAY_ilx-Onot-generic-traced_NAME=ILX with Haskell Optimizer Off to run on Generic CLR
#WAY_ilx-Onot-generic-traced_HC_OPTS=-buildtag ilx-Onot $(GHC_ILX_OPTS) -Onot
#WAY_ilx-Onot-generic-traced_ILX2IL_OPTS=--generic --traced
#WAY_ilx-Onot-generic-traced_ILX=YES
#ALL_WAYS+=ilx-O-generic-traced
#WAY_ilx-O-generic-traced_NAME=ILX with Haskell Optimizer On to run on Generic CLR
#WAY_ilx-O-generic-traced_HC_OPTS=-buildtag ilx-O $(GHC_ILX_OPTS) -O
#WAY_ilx-O-generic-traced_ILX2IL_OPTS=--generic --traced
#WAY_ilx-O-generic-traced_ILX=YES
#ALL_WAYS+=ilx-Onot-mono-traced
#WAY_ilx-Onot-mono-traced_NAME=ILX with Haskell Optimizer Off to run on V1 CLR
#WAY_ilx-Onot-mono-traced_HC_OPTS=-buildtag ilx-Onot $(GHC_ILX_OPTS) -Onot
#WAY_ilx-Onot-mono-traced_ILX2IL_OPTS=--mono --traced
#WAY_ilx-Onot-mono-traced_ILX=YES
#ALL_WAYS+=ilx-O-mono-traced
#WAY_ilx-O-mono-traced_NAME=ILX with Haskell Optimizer On to run on V1 CLR
#WAY_ilx-O-mono-traced_HC_OPTS=-buildtag ilx-O $(GHC_ILX_OPTS) -O
#WAY_ilx-O-mono-traced_ILX2IL_OPTS=--mono --traced
#WAY_ilx-O-mono-traced_ILX=YES
# Put a "." after the Haskell portion of the way. Way names can't contain
# dots for some reason elsewhere in the Make system. But we need to be able
# to split out the Haskell portion of the way from the ILX portion (e.g. --generic)
# and the runtime portion (e.g. --retail).
ilx_way=$(subst ilx-Onot-,ilx-Onot.,$(subst ilx-O-,ilx-O.,$(way)))
ilx2il_suffix=$(subst ilx-Onot.,.,$(subst ilx-O.,.,$(ilx_way)))
hs2ilx_suffix=$(subst $(ilx2il_suffix),,$(ilx_way))
HS_ILX=$(subst $(way),$(hs2ilx_suffix),$(HS_OBJS))
#HS_IL=$(subst $(hs2ilx_suffix)_o,$(ilx_way).il,$(HS_ILX))
HS_IL=$(subst .o,.il,$(HS_ILX))
ILVALID=C:/devel/fcom/bin/ilvalid.exe
ILVERIFY=C:/devel/fcom/bin/ilverify.exe
%.$(ilx_way).mvl : %.$(ilx_way).il $(HS_IL)
((ILVALID_HOME=c:\\devel\\fcom\\src\\ ILVALID_MSCORLIB=mscorlib.vlb $(ILVALID) c:\\devel\\fcom\\src\\bin\\msilxlib$(ilx2il_suffix).vlb $(addprefix --other-il-module ,$(filter-out $*.$(ilx_way).il,$(HS_IL))) $<) 2>&1) | tee $@
%.$(ilx_way).mvr : %.$(ilx_way).il $(HS_IL)
((ILVALID_HOME=c:\\devel\\fcom\\src\\ ILVALID_MSCORLIB=mscorlib.vlb $(ILVERIFY) c:\\devel\\fcom\\src\\bin\\msilxlib$(ilx2il_suffix).vlb $(addprefix --other-il-module ,$(filter-out $<,$(HS_IL))) $<) 2>&1) | tee $@
{-# OPTIONS -fglasgow-exts #-}
module Foo where
import PrelGHC
import PrelNum
import PrelBase
integer2Intx :: Integer -> Int
integer2Intx (S# i) = I# i
integer2Intx (J# s d) = case (integer2Int# s d) of { n# -> I# n# }
--------------------------------
-- The Game of Life --
--------------------------------
generations x = 30
data L a = N | C1 a (L a)
data Tuple2 a b = T2 a b
data Tuple3 a b c = T3 a b c
main = putStr (listChar_string
(append1 (C1 '\FF' N)
(life1 (generations ()) (start ()))))
listChar_string :: L Char -> String
listChar_string N = []
listChar_string (C1 x xs) = x : listChar_string xs
start :: a -> L (L Int)
start x = (C1 N
(C1 N
(C1 N
(C1 N
(C1 N
(C1 N
(C1 N
(C1 N
(C1 N
(C1 N
(C1 N
(C1 N
(C1 N
(C1 N
(C1
(C1 0
(C1 0
(C1 0
(C1 1
(C1 1
(C1 1
(C1 1
(C1 1
(C1 0
(C1 1
(C1 1
(C1 1
(C1 1
(C1 1
(C1 0
(C1 1
(C1 1
(C1 1
(C1 1
(C1 1
(C1 0
(C1 1
(C1 1
(C1 1
(C1 1
(C1 1
(C1 0 N))))))))))))))))))))))))))) N)))))))))))))))
-- Calculating the next generation
gen1 :: Int -> L (L Int) -> L (L Int)
gen1 n board = map1 row1 (shift1 (copy1 n 0) board)
row1 :: Tuple3 (L Int) (L Int) (L Int) -> L Int
row1 (T3 last this next)
= zipWith31 elt1 (shift2 0 last)
(shift2 0 this)
(shift2 0 next)
elt1 :: Tuple3 Int Int Int
-> (Tuple3 Int Int Int)
-> (Tuple3 Int Int Int) -> Int
elt1 (T3 a b c) (T3 d e f) (T3 g h i)
= if (not (eq tot 2))
&& (not (eq tot 3))
then 0
else if (eq tot 3) then 1 else e
where tot = a `plus` b `plus` c `plus` d
`plus` f `plus` g `plus` h `plus` i
eq :: Int -> Int -> Bool
eq x y = x == y
plus :: Int -> Int -> Int
plus x y = x + y
shiftr1 :: L Int -> L (L Int) -> L (L Int)
shiftr1 x xs = append2 (C1 x N) (init1 xs)
shiftl1 :: L Int -> L (L Int) -> L (L Int)
shiftl1 x xs = append2 (tail1 xs) (C1 x N)