Dear bug hunters,

ghci is unhappy with the attached module (stripped down version).

---

ralf/tmp> ghci -fglasgow-exts Arr.lhs
   ___         ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |      GHC Interactive, version 5.04, for Haskell 98.
/ /_\\/ __  / /___| |      http://www.haskell.org/ghc/
\____/\/ /_/\____/|_|      Type :? for help.

Loading package base ... linking ... done.
Loading package haskell98 ... linking ... done.
Compiling Arr              ( Arr.lhs, interpreted )
ghc-5.04: panic! (the `impossible' happened, GHC version 5.04):
        ByteCodeGen.schemeE P_

Please report it as a compiler bug to [EMAIL PROTECTED],
or http://sourceforge.net/projects/ghc/.


> Leaving GHCi.
ralf/tmp> ghc -O2 -c -Wall -fglasgow-exts Arr.lhs

Arr.lhs:22:
    Warning: This binding for `s1#' shadows an existing binding

Arr.lhs:24:
    Warning: This binding for `s2#' shadows an existing binding

Arr.lhs:27:
    Warning: This binding for `s2#' shadows an existing binding
ralf/tmp> ghci -fglasgow-exts Arr.lhs
   ___         ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |      GHC Interactive, version 5.04, for Haskell 98.
/ /_\\/ __  / /___| |      http://www.haskell.org/ghc/
\____/\/ /_/\____/|_|      Type :? for help.

Loading package base ... linking ... done.
Loading package haskell98 ... linking ... done.
Skipping  Arr              ( Arr.lhs, ./Arr.o )
Ok, modules loaded: Arr.
Prelude Arr>

---

However, ghci loads precompiled code so it's not a show stopper.

Cheers, Ralf
% ghci -fglasgow-exts Arr.lhs
% ghc -O2 -c -Wall -fglasgow-exts Arr.lhs

Standard Int-indexed arrays.

> module Arr
> where
> import GHC.Exts
> import GHC.Base
> import GHC.ST

> data Arr x			=  Arr Int# (Array# x)

> update			:: (x -> x) -> Int -> Arr x -> Arr x
> update f (I# i#) (Arr n# arr#)
>   | 0# <=# i# && i# <# n#	=  runST (ST (upd f i# n# arr#))
>   | otherwise			=  error "out of range"

> upd				:: (x -> x) -> Int# -> Int# -> Array# x -> STRep s (Arr x)
> upd f i# n# arr# s1#		=  case newArray# n# undefined s1# of { (# s2#, marr# #) ->
>                                  let fill j# s1#
>                                        | j# >=# 0# =	case indexArray# arr# j# of { (# x #) ->
>					                case writeArray# marr# j# x s1# of { s2# ->
>							fill (j# -# 1#) s2# }}
>					 | otherwise =  case indexArray# arr# i# of { (# x #) ->
>					                case writeArray# marr# i# (f x) s1# of { s2# ->
>							case unsafeFreezeArray# marr# s2# of { (# s3#, arr2# #) ->
>                                                       (# s3#, Arr n# arr2# #) }}} in
>			           fill (n# -# 1#) s2# }

Reply via email to