Re: panic

2005-12-16 Thread Frederik Eaton
By the way, the variable "b" which "b{tv a1hL}" seems to be referring
to is on the last line of vecQ. Help is much appreciated!

Thanks,

Frederik

On Fri, Dec 16, 2005 at 09:54:28PM +, Frederik Eaton wrote:
> $ ghc --make Vector.hs -fth
> Chasing modules from: Vector.hs
> [1 of 2] Skipping  Fu.Prepose   ( Fu/Prepose.hs, Fu/Prepose.o )
> [2 of 2] Compiling Fu.Vector( Vector.hs, Vector.o )
> ghc-6.5.20051208: panic! (the `impossible' happened, GHC version 
> 6.5.20051208):
> Failed binder lookup: b{tv a1hL}
> 
> Please report it as a compiler bug to glasgow-haskell-bugs@haskell.org,
> or http://sourceforge.net/projects/ghc/.

> {-# OPTIONS -fglasgow-exts -fallow-undecidable-instances #-}
> module Fu.Vector where
> 
> import System.IO.Unsafe
> import Control.Exception
> import Data.Ix
> import Data.Array.IO
> import qualified Data.Array as Array
> import Data.Array hiding ((!))
> import Fu.Prepose hiding (__)
> import Prelude hiding (sum)
> import Language.Haskell.TH
> import Language.Haskell.TH.Syntax
> import qualified Data.List
> 
> __ = __
> 
> data L n = L Int deriving (Show, Eq, Ord)
> unL l@(L x) = check l x
> 
> checkBounds :: ReflectNum n => L n -> a -> a
> checkBounds (l::L n) y =
> if l < (L 0) || l > maxBound then
> error ("Value "++show l++" out of bounds for L "++(show $ (maxBound 
> :: L n)))
> else y
> 
> -- need Ord too?
> class (Bounded a, Ix a, Eq a, Show a) => IxB a
> 
> instance (Bounded a, Ix a, Eq a, Show a) => IxB a
> 
> --instance (IxB a, IxB b) => IxB (a,b)
> 
> --instance IxB ()
> 
> instance (Bounded a, Bounded b) => Bounded (Either a b) where
> minBound = Left minBound
> maxBound = Right maxBound
> 
> instance (IxB a, IxB b) => Ix (Either a b) where
> range (Left x, Left y) = map Left $ range (x,y)
> range (Right x, Right y) = map Right $ range (x,y)
> range (Left x, Right y) =
> (map Left $ range (x,maxBound))++
> (map Right $ range (minBound,y))
> range (Right _, Left _) = error "range endpoints out of order"
> index (Left x, Left y) (Left z) = index (x,y) z
> index (Left x, Left y) (Right z) = error "out of bounds"
> index (Right x, Right y) (Right z) = index (x,y) z
> index (Right x, Right y) (Left z) = error "out of bounds"
> index (Left x, Right y) (Left z) = index (x,maxBound) z
> index (Left x, Right y) (Right z) =
> rangeSize (x,maxBound) + index (minBound,y) z
> index (Right _, Left _) _ = error "range endpoints out of order"
> inRange (x,y) z = (x<=z) && (z<=y)
> 
> --instance (IxB a, IxB b) => IxB (Either a b)
> 
> domain :: IxB a => [a]
> domain = range (minBound, maxBound)
> 
> instance ReflectNum n => Bounded (L n) where
> minBound = L 0
> maxBound = L $ reflectNum (__ :: n) - 1
> 
> instance ReflectNum n => Check (L n) where
> check l = checkBounds l
> 
> class Check a where
> check :: a -> (b -> b)
> 
> instance ReflectNum n => Ix (L n) where
> index (a, b) (c) = index (unL a, unL b) (unL c)
> range (a, b) = map L $ range (unL a, unL b)
> inRange (a, b) c = inRange (unL a, unL b) (unL c)
> rangeSize (a, b) = rangeSize (unL a, unL b)
> 
> -- needed?
> type One = Succ Zero
> 
> -- needed?
> -- singleton domain
> type S = L One
> 
> -- needed?
> -- empty domain
> type Z = L Zero
> 
> -- like Array but uses IxB instead of Ix
> newtype Vector k i = Vector (Array.Array i k) deriving (Eq, Show)
> 
> type Matrix k a b = Vector k (a,b)
> 
> boundaries :: Bounded a => (a,a)
> boundaries = (minBound, maxBound)
> 
> vector :: IxB a => (a -> k) -> Vector k a
> vector f = Vector
> (array boundaries (map (\i -> (i, f i)) domain))
> 
> (!) :: IxB a => Vector k a -> a -> k
> (!) (Vector ax) i = (Array.!) ax i
> 
> slice :: (IxB a, IxB b) => Vector k a -> (b -> a) -> Vector k b
> slice v f = vector ((v!) . f)
> 
> updateArray ax i f = do
> e <- readArray ax i
> writeArray ax i (f e)
> 
> margin :: (IxB a, IxB b, Num k) => Vector k a -> (a -> b) -> Vector k b
> margin (Vector v) f = unsafePerformIO $ (do
> (ax::IOArray a k) <- newArray (minBound, maxBound) 0
> mapM_ (\ (i,x) -> updateArray ax (f i) (+x)) (assocs v)
> ac <- getAssocs ax
> return $ Vector $ array boundaries ac
>   )
> 
> -- terminal map
> terminal :: a -> ()
> terminal x = ()
> 
> 
> sum :: (IxB a, Num k) => Vector k a -> k
> sum v = margin v (const ()) ! ()
> 
> diag :: a -> (a,a)
> diag x = (x,x)
> 
> trace m = sum $ slice m diag
> 
> -- initial map
> initial :: Z -> a
> initial _ = undefined
> 
> (*>) :: (Num k, IxB a, IxB b, IxB c) => Matrix k a b -> Matrix k b c -> 
> Matrix k a c
> (*>) m n =
> vector (\ (i,k) -> Data.List.sum $ map (\j -> m ! (i,j) + n ! (j,k)) 
> domain)
> 
> mapv :: (IxB a) => (k -> l) -> Vector k a -> Vector l a
> mapv f v = vector (\i -> f (v!i))
> 
> mapv2 :: (IxB a) => (k -> l -> m) -> Vector k a -> Vector l a -> Vector m a
> mapv2 f u v = vector (\i -> f (u!i) (v!i))
> 
> -- element-wise operations
> insta

panic

2005-12-16 Thread Frederik Eaton
$ ghc --make Vector.hs -fth
Chasing modules from: Vector.hs
[1 of 2] Skipping  Fu.Prepose   ( Fu/Prepose.hs, Fu/Prepose.o )
[2 of 2] Compiling Fu.Vector( Vector.hs, Vector.o )
ghc-6.5.20051208: panic! (the `impossible' happened, GHC version 6.5.20051208):
Failed binder lookup: b{tv a1hL}

Please report it as a compiler bug to glasgow-haskell-bugs@haskell.org,
or http://sourceforge.net/projects/ghc/.
{-# OPTIONS -fglasgow-exts -fallow-undecidable-instances #-}
module Fu.Vector where

import System.IO.Unsafe
import Control.Exception
import Data.Ix
import Data.Array.IO
import qualified Data.Array as Array
import Data.Array hiding ((!))
import Fu.Prepose hiding (__)
import Prelude hiding (sum)
import Language.Haskell.TH
import Language.Haskell.TH.Syntax
import qualified Data.List

__ = __

data L n = L Int deriving (Show, Eq, Ord)
unL l@(L x) = check l x

checkBounds :: ReflectNum n => L n -> a -> a
checkBounds (l::L n) y =
if l < (L 0) || l > maxBound then
error ("Value "++show l++" out of bounds for L "++(show $ (maxBound :: 
L n)))
else y

-- need Ord too?
class (Bounded a, Ix a, Eq a, Show a) => IxB a

instance (Bounded a, Ix a, Eq a, Show a) => IxB a

--instance (IxB a, IxB b) => IxB (a,b)

--instance IxB ()

instance (Bounded a, Bounded b) => Bounded (Either a b) where
minBound = Left minBound
maxBound = Right maxBound

instance (IxB a, IxB b) => Ix (Either a b) where
range (Left x, Left y) = map Left $ range (x,y)
range (Right x, Right y) = map Right $ range (x,y)
range (Left x, Right y) =
(map Left $ range (x,maxBound))++
(map Right $ range (minBound,y))
range (Right _, Left _) = error "range endpoints out of order"
index (Left x, Left y) (Left z) = index (x,y) z
index (Left x, Left y) (Right z) = error "out of bounds"
index (Right x, Right y) (Right z) = index (x,y) z
index (Right x, Right y) (Left z) = error "out of bounds"
index (Left x, Right y) (Left z) = index (x,maxBound) z
index (Left x, Right y) (Right z) =
rangeSize (x,maxBound) + index (minBound,y) z
index (Right _, Left _) _ = error "range endpoints out of order"
inRange (x,y) z = (x<=z) && (z<=y)

--instance (IxB a, IxB b) => IxB (Either a b)

domain :: IxB a => [a]
domain = range (minBound, maxBound)

instance ReflectNum n => Bounded (L n) where
minBound = L 0
maxBound = L $ reflectNum (__ :: n) - 1

instance ReflectNum n => Check (L n) where
check l = checkBounds l

class Check a where
check :: a -> (b -> b)

instance ReflectNum n => Ix (L n) where
index (a, b) (c) = index (unL a, unL b) (unL c)
range (a, b) = map L $ range (unL a, unL b)
inRange (a, b) c = inRange (unL a, unL b) (unL c)
rangeSize (a, b) = rangeSize (unL a, unL b)

-- needed?
type One = Succ Zero

-- needed?
-- singleton domain
type S = L One

-- needed?
-- empty domain
type Z = L Zero

-- like Array but uses IxB instead of Ix
newtype Vector k i = Vector (Array.Array i k) deriving (Eq, Show)

type Matrix k a b = Vector k (a,b)

boundaries :: Bounded a => (a,a)
boundaries = (minBound, maxBound)

vector :: IxB a => (a -> k) -> Vector k a
vector f = Vector
(array boundaries (map (\i -> (i, f i)) domain))

(!) :: IxB a => Vector k a -> a -> k
(!) (Vector ax) i = (Array.!) ax i

slice :: (IxB a, IxB b) => Vector k a -> (b -> a) -> Vector k b
slice v f = vector ((v!) . f)

updateArray ax i f = do
e <- readArray ax i
writeArray ax i (f e)

margin :: (IxB a, IxB b, Num k) => Vector k a -> (a -> b) -> Vector k b
margin (Vector v) f = unsafePerformIO $ (do
(ax::IOArray a k) <- newArray (minBound, maxBound) 0
mapM_ (\ (i,x) -> updateArray ax (f i) (+x)) (assocs v)
ac <- getAssocs ax
return $ Vector $ array boundaries ac
  )

-- terminal map
terminal :: a -> ()
terminal x = ()


sum :: (IxB a, Num k) => Vector k a -> k
sum v = margin v (const ()) ! ()

diag :: a -> (a,a)
diag x = (x,x)

trace m = sum $ slice m diag

-- initial map
initial :: Z -> a
initial _ = undefined

(*>) :: (Num k, IxB a, IxB b, IxB c) => Matrix k a b -> Matrix k b c -> Matrix 
k a c
(*>) m n =
vector (\ (i,k) -> Data.List.sum $ map (\j -> m ! (i,j) + n ! (j,k)) domain)

mapv :: (IxB a) => (k -> l) -> Vector k a -> Vector l a
mapv f v = vector (\i -> f (v!i))

mapv2 :: (IxB a) => (k -> l -> m) -> Vector k a -> Vector l a -> Vector m a
mapv2 f u v = vector (\i -> f (u!i) (v!i))

-- element-wise operations
instance (Num k, IxB a) => Num (Vector k a) where
(+) = mapv2 (+)
(-) = mapv2 (-)
(*) = mapv2 (*)
negate = mapv negate
signum = mapv signum
abs = mapv abs
fromInteger n = (fromInteger n) .* ones

-- should probably be able to do this in constant time
vec :: (Num k, IxB a, IxB b) => Matrix k a b -> Matrix k (a,b) S
vec m = slice m (\ ((i,j),_) -> (i,j))

-- better name?
inv :: (RealFrac k, IxB a) => Matrix k a a -> Matrix k a a
inv = undefined

-- need least squares operator: />?

det :: (Num k, IxB a) => Ma

Re: Bug in cvs head ghci

2005-12-16 Thread Sigbjorn Finne

Yep, reproducible with last night's HEAD build on mingw
(but not STABLE.)

--sigbjorn

- Original Message - 
From: "Simon Peyton-Jones" <[EMAIL PROTECTED]>

To: "wld" <[EMAIL PROTECTED]>; 
Sent: Friday, December 16, 2005 08:13
Subject: RE: Bug in cvs head ghci



Strange.  This does not happen for me on Linux or Windows (GHc 6.4.1).
Has anyone else seen it?

Simon

| -Original Message-
| From: [EMAIL PROTECTED]
[mailto:glasgow-haskell-bugs-
| [EMAIL PROTECTED] On Behalf Of wld
| Sent: 08 December 2005 13:25
| To: glasgow-haskell-bugs@haskell.org
| Subject: Bug in cvs head ghci
| 
| HI,
| 
| Typing

|Prelude> :b GHC.Base
| 
| I get

| [snip]
|   data Addr#
|   data Array# a
|   data Bool = False | True
|   data ByteArray#
|   data Char#
|   data Char = C# Char#
|   data Double#
|   data Float#*** Exception: No match in record selector
TyCon.tyConTyVars
|   Prelude>
| 
| ghc built on Linux with

| - ghc 6.4.1
| - gcc 4.0.2
| 
| --

| V.Rudenko
___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs

___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


RE: Bug in cvs head ghci

2005-12-16 Thread Simon Peyton-Jones
Strange.  This does not happen for me on Linux or Windows (GHc 6.4.1).
Has anyone else seen it?

Simon

| -Original Message-
| From: [EMAIL PROTECTED]
[mailto:glasgow-haskell-bugs-
| [EMAIL PROTECTED] On Behalf Of wld
| Sent: 08 December 2005 13:25
| To: glasgow-haskell-bugs@haskell.org
| Subject: Bug in cvs head ghci
| 
| HI,
| 
| Typing
|Prelude> :b GHC.Base
| 
| I get
| [snip]
|   data Addr#
|   data Array# a
|   data Bool = False | True
|   data ByteArray#
|   data Char#
|   data Char = C# Char#
|   data Double#
|   data Float#*** Exception: No match in record selector
TyCon.tyConTyVars
|   Prelude>
| 
| ghc built on Linux with
| - ghc 6.4.1
| - gcc 4.0.2
| 
| --
| V.Rudenko
___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #636: deriving Show for infix constructors forgets backquotes

2005-12-16 Thread GHC
#636: deriving Show for infix constructors forgets backquotes
--+-
  Reporter:  [EMAIL PROTECTED]  |  Owner: 
  Type:  bug  | Status:  closed 
  Priority:  normal   |  Milestone: 
 Component:  Compiler |Version:  6.4.1  
  Severity:  normal   | Resolution:  fixed  
  Keywords:   | Os:  Unknown
Difficulty:  Unknown  |   Architecture:  Unknown
--+-
Changes (by anonymous):

  * resolution:  => fixed
  * status:  new => closed

Comment:

 I've just fixed this in the HEAD.  Test is drvrun018.

 The fix should appear in 6.4.2

 Simon

-- 
Ticket URL: 
GHC 
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #637: Ctrl-Break handler doesn't work in forked threads in "-threaded" RTS

2005-12-16 Thread GHC
#637: Ctrl-Break handler doesn't work in forked threads in "-threaded" RTS
--+-
Reporter:  [EMAIL PROTECTED]  |Owner: 
Type:  bug|   Status:  new
Priority:  normal |Milestone: 
   Component:  Compiler   |  Version:  6.4.1  
Severity:  normal | Keywords: 
  Os:  Unknown|   Difficulty:  Unknown
Architecture:  Unknown|  
--+-
The following program demonstrates bug in 6.4.1 (6.4.0 was ok).
 if you compile it with "-threaded", run and press Ctrl-Break, you will
 see message "main.EXE: : hGetLine: end of file" and program
 blocks (because forked thread is dead). the problem is that installed
 ctrl-break handler don't called in forked threads

 if you compile program without "-threaded" or with 6.4.0, it works as
 expected - pressing Ctrl-Break runs my handler so you will see
 "^Break! main.EXE: thread killed" message



 import Control.Concurrent
 import Control.Exception
 import GHC.ConsoleHandler

 handleCtrlBreak action = do
   myThread <- myThreadId
   let onBreak event = do
 putStrLn " ^Break!"
 killThread myThread
   bracket (installHandler$ Catch onBreak) (installHandler) $  \oldHandler
 -> do
 action

 main =  do
   handleCtrlBreak $ do
 x <- newEmptyMVar
 forkIO$ do a <- getLine
print a
putMVar x ()
return ()
 takeMVar x
 return ()

-- 
Ticket URL: 
GHC 
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #636: deriving Show for infix constructors forgets backquotes

2005-12-16 Thread GHC
#636: deriving Show for infix constructors forgets backquotes
--+-
  Reporter:  [EMAIL PROTECTED]  |  Owner: 
  Type:  bug  | Status:  new
  Priority:  normal   |  Milestone: 
 Component:  Compiler |Version:  6.4.1  
  Severity:  normal   | Resolution: 
  Keywords:   | Os:  Unknown
Difficulty:  Unknown  |   Architecture:  Unknown
--+-
Old description:

> When compiling and running the following module:
>
> >>>
> module Main where
>
> data Foo = Int `Bar` Int
>  deriving ( Show )
>
> main = print (3 `Bar` 4)
> <<<
>
> The expected output is:
>
> 3 `Bar` 4
>
> Or even just;
>
> Bar 3 4
>
> Instead, I get:
>
> 3 Bar 4

New description:

 When compiling and running the following module:

 {{{
 module Main where

 data Foo = Int `Bar` Int
  deriving ( Show )

 main = print (3 `Bar` 4)
 }}}

 The expected output is:

 {{{
 3 `Bar` 4
 }}}

 Or even just;

 {{{
 Bar 3 4
 }}}

 Instead, I get:

 {{{
 3 Bar 4
 }}}

Comment (by simonmar):

 formatting

-- 
Ticket URL: 
GHC 
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #636: deriving Show for infix constructors forgets backquotes

2005-12-16 Thread GHC
#636: deriving Show for infix constructors forgets backquotes
--+-
  Reporter:  [EMAIL PROTECTED]  |  Owner: 
  Type:  bug  | Status:  new
  Priority:  normal   |  Milestone: 
 Component:  Compiler |Version:  6.4.1  
  Severity:  normal   | Resolution: 
  Keywords:   | Os:  Unknown
Difficulty:  Unknown  |   Architecture:  Unknown
--+-
Comment (by anonymous):

 It seems that this Wiki also removes backquotes!

 The expected output is:

 3 <>Bar<> 4

 What I get is:

 3 Bar 4

-- 
Ticket URL: 
GHC 
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #636: deriving Show for infix constructors forgets backquotes

2005-12-16 Thread GHC
#636: deriving Show for infix constructors forgets backquotes
+---
Reporter:  [EMAIL PROTECTED]  |Owner: 
Type:  bug  |   Status:  new
Priority:  normal   |Milestone: 
   Component:  Compiler |  Version:  6.4.1  
Severity:  normal   | Keywords: 
  Os:  Unknown  |   Difficulty:  Unknown
Architecture:  Unknown  |  
+---
When compiling and running the following module:

 >>>
 module Main where

 data Foo = Int `Bar` Int
  deriving ( Show )

 main = print (3 `Bar` 4)
 <<<

 The expected output is:

 3 `Bar` 4

 Or even just;

 Bar 3 4

 Instead, I get:

 3 Bar 4

-- 
Ticket URL: 
GHC 
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #635: Replace use of select() in the I/O manager with epoll/kqueue/etc.

2005-12-16 Thread GHC
#635: Replace use of select() in the I/O manager with epoll/kqueue/etc.
---+
Reporter:  simonmar|Owner:
Type:  task|   Status:  new   
Priority:  normal  |Milestone:
   Component:  libraries/base  |  Version:  6.4.1 
Severity:  normal  | Keywords:
  Os:  Unknown |   Difficulty:  Difficult (1 week)
Architecture:  Unknown |  
---+
Subject says it all.  We've known about this problem for ever, but haven't
 got around to doing anything about it.

 Here is a library that provides a unified API over the various event APIs:
 [http://monkey.org/~provos/libevent/].

 See also [http://www.kegel.com/c10k.html].

 1 week is an estimate for doing it properly on all relevant platforms, by
 someone who is familiar with the APIs and code.

-- 
Ticket URL: 
GHC 
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs