compiler bug report

2001-07-31 Thread Hal Daume

Here is a transcript:

enescu:/nfs/isd/hdaume/stat-sum-ulf 54% ghci -package lang
ghci -package lang
   ___ ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |  GHC Interactive, version 5.00.2, For Haskell
98.
/ /_\\/ __  / /___| |  http://www.haskell.org/ghc/
\/\/ /_/\/|_|  Type :? for help.

Loading package std ... linking ... done.
Loading package lang ... linking ... done.
Prelude> :l Util
:l Util
Skipping  Util ( Util.hs, ./Util.o )
Ok, modules loaded: Util.
Util> List.[]
List.[]

Ambiguous type variable(s) `t' in the constraint `PrelShow.Show t'
arising from use of `PrelIO.print' at 
in a `do' expression pattern binding: PrelIO.print it
Util> `eq`
`eq`
:0: parse error on input ``'
Util> 3 `eq` 4
3 `eq` 4

:0: Variable not in scope: `eq'
Util> :l Util
:l Util
unloadObj: can't find `./Util.o' to unload
ghc-5.00.2: panic! (the `impossible' happened, GHC version 5.00.2):
unloadObj: failed

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


Util> 
-

I'm not sure exactly what went wrong, but here's a copy of Util.hs...

-- 
Hal Daume III

 "Computer science is no more about computers| [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

module Util
where

import List
import Maybe
import Char
import IO
import IOExts

infix !=

a != b = not (a == b)

nth [] i = error ("nth out of range: " ++ (show i))
nth (x:_) 1 = x
nth (_:x) (n+1) = nth x n

containsFn f l = isJust (find f l)

contains x = containsFn (==x)

mapPartial :: (a -> Maybe b) -> [a] -> [b]
mapPartial f l = mapPartial' f l []
where mapPartial' _ [] acc = acc
  mapPartial' f (x:xs) acc = mapPartial' f xs (case f x of
   Nothing -> acc
   Just x' -> x':acc)

-- same as otherwise
ow = True

foldMaybe :: (a -> b -> Maybe a) -> a -> [b] -> Maybe a
foldMaybe _ a [] = Just a
foldMaybe f a (b:bs) = case f a b of
 Nothing -> Nothing
 Just a' -> foldMaybe f a' bs

allButLast :: [a] -> [a]
allButLast [] = error "allButLast on []"
allButLast [x] = []
allButLast (x:xs) = x:allButLast xs

putErr s = unsafePerformIO (do hPutStrLn stderr s)

maybeGood Nothing  = Error "maybeGood"
maybeGood (Just a) = Good a

goodMaybe (Error _) = Nothing
goodMaybe (Good a)  = Just a

infixr 9 ===, =~=

good (Good a) = a
good (Error err) = error err

class LCaseEq a where
(===) :: a -> a -> Bool

instance LCaseEq Char where
c1 === c2 = toLower c1 == toLower c2

instance LCaseEq a => LCaseEq [a] where
[] === [] = True
[] === _  = False
_  === [] = False
(c:cs) === (c':cs') = c === c' && cs === cs'

class Approx a where
(=~=) :: a -> a -> Bool

instance Eq a => Approx [a] where
a =~= b = take 50 a == take 50 b

data Errored a = Good a | Error String
 deriving (Eq, Show, Ord, Read)


isNum x = isAlphaNum x && (not (isAlpha x))

--beginsWithBy "abc" "abcd" (==) = True
--beginsWithBy "abc" "ab"   (==) = False
beginWithBy _ [] _ = True
beginWithBy _ _ [] = False
beginWithBy eq (x:xs) (y:ys) | x `eq` y  = beginWithBy xs ys eq
 | otherwise = False

beginWith = beginWithBy (==)



Re: compiler bug report

2001-08-01 Thread Hal Daume

I can't reliably repro the bug, but it happens to me a *lot*.  At least
one every hour or two...not only on that file...I don't think it happens
if I delete all the .o files...not sure though...

 - Hal

Simon Marlow wrote:
> 
> Hi there,
> 
> Thanks for the report.  I can't repro the bug though - after I commented
> out the definition of beginWithBy at the end of Util.hs (it had some
> type errors), and tried the exact same sequence of commands in ghci, it
> happily re-loaded Util.o at the end.
> 
> Is there any more information you can provide that will help us to repro
> it?
> 
> Cheers,
> Simon
> 
> > Here is a transcript:
> > 
> > enescu:/nfs/isd/hdaume/stat-sum-ulf 54% ghci -package lang
> > ghci -package lang
> >___ ___ _
> >   / _ \ /\  /\/ __(_)
> >  / /_\// /_/ / /  | |  GHC Interactive, version 5.00.2,
> > For Haskell
> > 98.
> > / /_\\/ __  / /___| |  http://www.haskell.org/ghc/
> > \/\/ /_/\/|_|  Type :? for help.
> >
> > Loading package std ... linking ... done.
> > Loading package lang ... linking ... done.
> > Prelude> :l Util
> > :l Util
> > Skipping  Util ( Util.hs, ./Util.o )
> > Ok, modules loaded: Util.
> > Util> List.[]
> > List.[]
> >
> > Ambiguous type variable(s) `t' in the constraint `PrelShow.Show t'
> > arising from use of `PrelIO.print' at 
> > in a `do' expression pattern binding: PrelIO.print it
> > Util> `eq`
> > `eq`
> > :0: parse error on input ``'
> > Util> 3 `eq` 4
> > 3 `eq` 4
> >
> > :0: Variable not in scope: `eq'
> > Util> :l Util
> > :l Util
> > unloadObj: can't find `./Util.o' to unload
> > ghc-5.00.2: panic! (the `impossible' happened, GHC version 5.00.2):
> > unloadObj: failed
> >
> > Please report it as a compiler bug to
> > [EMAIL PROTECTED],
> > or http://sourceforge.net/projects/ghc/.
> >
> >
> > Util>
> > -
> >
> > I'm not sure exactly what went wrong, but here's a copy of Util.hs...
> >
> > --
> > Hal Daume III
> >
> >  "Computer science is no more about computers| [EMAIL PROTECTED]
> >   than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume
> >

-- 
Hal Daume III

 "Computer science is no more about computers| [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



small bug with :info and ids beginning with _

2003-06-30 Thread Hal Daume
:info treats _a as an infix operator in ghci.

Prelude> let _a = 'a'
Prelude> :i _a
-- _a is a variable, defined at :1
(_a) :: Char


should have not enclosed _a in parens.

--
 Hal Daume III   | [EMAIL PROTECTED]
 "Arrest this man, he talks in maths."   | www.isi.edu/~hdaume
___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


non-intuitive error message in ghci

2003-08-14 Thread Hal Daume
When we'd try to evaluate a finite map at the prompt, we get an error
about there not being a show instance:

Prelude> :m Data.FiniteMap
Prelude Data.FiniteMap> emptyFM

No instance for (Show (FiniteMap key elt))
arising from use of `print' at 
In a 'do' expression pattern binding: print it


However, if we have Control.Exception in scope, we get a very different
message:

Prelude> :m Prelude Control.Exception Data.FiniteMap
Data.FiniteMap Control.Exception Prelude> emptyFM

No instance for (Monad (FiniteMap key))
  arising from use of `print' at 
In a 'do' expression: print it


Presumably this is because Control.Exception introduces some instance of
Monad which then confuses the environment.  It took me a while to figure
this out and I can imagine that it would be confusing to other people
too.

Is there any (relatively easy) way to get it to report the "real" error
message?

 - Hal

 --
 Hal Daume III   | [EMAIL PROTECTED]
 "Arrest this man, he talks in maths."   | www.isi.edu/~hdaume
___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


RE: very strange behavior (crashes!) with Dynamics

2003-08-14 Thread Hal Daume
This hasn't yet been posted, but I've actually whittled it down quite a
bit.

All we need is to import the Util.DynamicMap and do:

> dm1 = addToDM emptyDM (Range 1 2)
> showDM :: DShow -> DynamicMap -> ShowS
> showDM sd = foldDM (\d b -> case sd d of { Nothing -> b ; Just s -> s
. b }) id

and do the show definition for Coref and then we get:

Compiling ReadCorefData(
c:/home/t-hald/projects/PennUtil/ReadCorefData.hs, interpreted )
Ok, modules loaded: ReadCorefData, PennUtil.Util, Util.DynamicMap,
NLP.PennParser, NLP.FiniteMap, NLP.String, NLP.Util, Common.
*ReadCorefData> showDM corefDShow dm1 ""
Loading package haskell98 ... linking ... done.
""
*ReadCorefData> :!touch ReadCorefData.hs
*ReadCorefData> :r
Compiling ReadCorefData(
c:/home/t-hald/projects/PennUtil/ReadCorefData.hs, interpreted )
Ok, modules loaded: ReadCorefData, PennUtil.Util, Util.DynamicMap,
NLP.PennParser, NLP.FiniteMap, NLP.String, NLP.Util, Common.
*ReadCorefData> showDM corefDShow dm1 ""
"Coref=Coref 1 2 
Process ghci exited abnormally with code 5


interestingly it seems to be trying to read this as the range (since the
two ints are the same as the initial ones)...

 --
 Hal Daume III   | [EMAIL PROTECTED]
 "Arrest this man, he talks in maths."   | www.isi.edu/~hdaume


> -Original Message-
> From: Hal Daume 
> Sent: Thursday, August 14, 2003 12:37 PM
> To: '[EMAIL PROTECTED]'
> Subject: very strange behavior (crashes!) with Dynamics
> 
> 
> First, I apologize for the length of this message.  
> Unfortunately, I cannot whittle this down to a smaller example.
> 
> I'm dealing with parse trees, whose datatype looks like:
> 
> > data AnnTree a
> > = Term{ treeTag :: PackedString, treeText :: 
> PackedString   , treeAnn :: a }
> > | NonTerm { treeTag :: PackedString, treeChildren :: 
> [AnnTree a], treeAnn :: a }
> > deriving (Eq, Ord)
> 
> In particular, I parameterize these over a DynamicMap 
> datatype, which looks like:
> 
> > import Data.Dynamic
> > type DynamicMap = FiniteMap String Dynamic  -- cuz TypeRep 
> \not \in Ord :(
> 
> This supports, for instance:
> 
> > stypeOf x = show (typeOf x)
> > ttypeOf (x :: T a) = stypeOf (undefined :: a)
> > 
> > emptyDM :: DynamicMap
> > emptyDM = emptyFM
> > 
> > addToDM :: Typeable a => DynamicMap -> a -> DynamicMap
> > addToDM dm a = addToFM dm (stypeOf a) (toDyn a)
> > 
> > lookupDM :: Typeable a => DynamicMap -> Maybe a
> > lookupDM dm :: Maybe a =
> > case lookupFM dm (stypeOf (undefined :: a)) of
> >   Nothing -> Nothing
> >   Just x  -> fromDynamic x
> 
> as well as a few other of the standard FM functions that I need.
> 
> I have a type synonym:
> 
> > type DTree = AnnTree DynamicMap
> 
> so that I can add whatever types of annotations I want to the tree.
> 
> I also provide methods of showing the trees with various 
> annotations shown, based on a DShow type:
> 
> > type DShow = Dynamic -> Maybe ShowS
> > dshowLabel :: Typeable a => (a -> ShowS) -> DShow
> > dshowLabel x d = 
> >   case fromDynamic d of
> > Nothing -> Nothing
> > Just v  -> Just (shows (typeOf v) . showChar '=' . x v)
> > 
> > showDTreeWith :: DShow -> DTree -> ShowS
> > showDTreeWith shws t =
> >   showChar '(' . 
> > showString (unpackPS (treeTag t)) .
> > showChar ' ' . showAnn (treeAnn t) .
> > (if isTerm t 
> >then showString (unpackPS (treeText t))
> >else showChildren (treeChildren t)) .
> > showChar ')'
> >   where
> > showChildren []   = showString "<>"
> > showChildren [ch] = showDTreeWith shws ch
> > showChildren (ch:chl) = showDTreeWith shws ch . 
> showChar ' ' . showChildren chl
> > showAnn a = showList (foldDM showAnn' [] a)
> > showAnn' dyn acc = 
> >   case shws dyn of
> > Nothing -> acc
> > Just ss -> showChar '{' . ss . showChar '}' : acc
> > showList [] = id
> > showList [x] = showChar '{' . x . showChar '}' . showChar ' '
> > showList (x:xs) = showChar '{' . x . showList' xs . 
> showChar '}' . showChar ' '
> > showList' [] = id
> > showList' (x:xs) = showChar ';' . x . showList' xs
> 
> Basically, what this does is it is given a DShow (which can 
> be combined, 

RE: very strange behavior (crashes!) with Dynamics

2003-08-14 Thread Hal Daume
Okay, this is the last spam from me.

Here's exactly what you need to do to get the bug.

Create three modules, DynamicMap.hs, Range.hs and Coref.hs, containing
the following:

 DynamicMap.hs 
module DynamicMap
( DynamicMap,
  emptyDM,
  addToDM,
  foldDM
)
where

import Data.FiniteMap
import Data.Dynamic

type DynamicMap = FiniteMap String Dynamic  -- cuz TypeRep \not \in Ord
:(

stypeOf x = show (typeOf x)

emptyDM :: DynamicMap
emptyDM = emptyFM

addToDM :: Typeable a => DynamicMap -> a -> DynamicMap
addToDM dm a = addToFM dm (stypeOf a) (toDyn a)

foldDM :: (Dynamic -> b -> b) -> b -> DynamicMap -> b
foldDM f = foldFM (const f)


-- Range.hs ---
module Range where

import Data.Dynamic

data Range = Single Int
   | Range  Int Int

minRange (Single x) = x
minRange (Range x _) = x

maxRange (Single x) = x
maxRange (Range _ x) = x

instance Show Range where
  showsPrec _ (Single i) = shows i
  showsPrec _ (Range i j) = shows i . showChar '^' . shows j

instance Eq Range where
Single i == Single k = i == k
Single i == Range k l = i == k && k == l
Range i j == Range k l = i == k && j == l
Range i j == Single k = i == k && j == k

instance Read Range where
  readsPrec i s
  | '^' `elem` s = 
  let n1 = takeWhile (/='^') s
  n2 = drop (length n1+1) s
  in  [(Range l h, rest) | (l,[]) <- readsPrec i n1, (h,rest) <-
readsPrec i n2]
  | otherwise = map (\ (a,s) -> (Single a,s)) (readsPrec i s)

instance Ord Range where
r `compare` s = case minRange r `compare` minRange s of
  EQ -> maxRange r `compare` maxRange s
  x  -> x

rangeTypeCon = mkTyCon "Range" ; rangeTypeRep = mkAppTy rangeTypeCon []
instance Typeable Range where typeOf _ = rangeTypeRep
{-# NOINLINE rangeTypeCon #-}
{-# NOINLINE rangeTypeRep #-}

rangeDShow :: DShow
rangeDShow = dshowLabel (shows :: Range -> ShowS)

type DShow = Dynamic -> Maybe ShowS

dshow0 :: DShow
dshow0 = const Nothing

dshowLabel :: Typeable a => (a -> ShowS) -> DShow
dshowLabel x d = 
  case fromDynamic d of
Nothing -> Nothing
Just v  -> Just (shows (typeOf v) . showChar '=' . x v)


-- Coref.hs ---
module Coref where

import DynamicMap
import Data.Dynamic
import Range

data Coref = Coref Int Int Bool (Maybe String) 
 deriving (Eq, Ord, Show)

corefTypeCon = mkTyCon "Coref" ; corefTypeRep = mkAppTy corefTypeCon []
instance Typeable Coref where typeOf _ = corefTypeRep
{-# NOINLINE corefTypeCon #-}
{-# NOINLINE corefTypeRep #-}

corefDShow = dshowLabel (shows :: Coref -> ShowS)


showDM :: DShow -> DynamicMap -> ShowS
showDM sd = foldDM (\d b -> case sd d of { Nothing -> b ; Just s -> s .
b }) id

dm1 = addToDM emptyDM (Range 1 2)
---

Now, load Coref.hs in GHCi:

   ___ ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |  GHC Interactive, version 6.0, for Haskell 98.
/ /_\\/ __  / /___| |  http://www.haskell.org/ghc/
\/\/ /_/\/|_|  Type :? for help.

Loading package base ... linking ... done.
Loading package lang ... linking ... done.
Prelude> :load c:/home/t-hald/projects/Bugs/Coref.hs
Compiling DynamicMap   ( DynamicMap.hs, interpreted )
Compiling Range( Range.hs, interpreted )
Compiling Coref( c:/home/t-hald/projects/Bugs/Coref.hs,
interpreted )
Ok, modules loaded: Coref, Range, DynamicMap.
*Coref> showDM corefDShow dm1 ""
""
*Coref> :!touch Coref.hs
*Coref> :r
Compiling Coref( c:/home/t-hald/projects/Bugs/Coref.hs,
interpreted )
Ok, modules loaded: Coref, Range, DynamicMap.
*Coref> showDM corefDShow dm1 ""
"Coref=Coref 1 2 
Process ghci exited abnormally with code 5


for some reason having the DShow definitions in the same file as Range
is important (I originally tried having the DShow definitions in their
own file, imported by all the others, but that didn't exhibit the bug).


 --
 Hal Daume III           | [EMAIL PROTECTED]
 "Arrest this man, he talks in maths."   | www.isi.edu/~hdaume


> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Hal Daume
> Sent: Thursday, August 14, 2003 3:46 PM
> To: Hal Daume; [EMAIL PROTECTED]
> Subject: RE: very strange behavior (crashes!) with Dynamics
> 
> 
> This hasn't yet been posted, but I've actually whittled it 
> down quite a
> bit.
> 
> All we need is to import the Util.DynamicMap and do:
> 
> > dm1 = addToDM emptyDM (Range 1 2)
> > showDM :: DShow -> DynamicMap -> ShowS
> > showDM sd = foldDM (\d b -> case sd d of { Nothing ->

RE: very strange behavior (crashes!) with Dynamics

2003-08-14 Thread Hal Daume
Okay, I know I promised that was the last one, but you can actually get
it simpler.  Remove all the dynamic map stuff.  Just have two files,
Range.hs and Coref.hs, with:

module Range where

import Data.Dynamic

data Range = Single Int
   | Range  Int Int
   deriving (Eq, Ord, Show)

rangeTypeCon = mkTyCon "Range" ; rangeTypeRep = mkAppTy rangeTypeCon []
instance Typeable Range where typeOf _ = rangeTypeRep
{-# NOINLINE rangeTypeCon #-}
{-# NOINLINE rangeTypeRep #-}

rangeDShow :: DShow
rangeDShow = dshowLabel (shows :: Range -> ShowS)

type DShow = Dynamic -> Maybe ShowS

dshowLabel :: Typeable a => (a -> ShowS) -> DShow
dshowLabel x d = 
  case fromDynamic d of
Nothing -> Nothing
Just v  -> Just (shows (typeOf v) . showChar '=' . x v)



and



module Coref where

import Data.Dynamic
import Range

data Coref = Coref Int Int Bool (Maybe String) 
 deriving (Eq, Ord, Show)

corefTypeCon = mkTyCon "Coref" ; corefTypeRep = mkAppTy corefTypeCon []
instance Typeable Coref where typeOf _ = corefTypeRep
{-# NOINLINE corefTypeCon #-}
{-# NOINLINE corefTypeRep #-}

corefDShow = dshowLabel (shows :: Coref -> ShowS)



now load Coref, do 'Monad.liftM ($"") (corefDShow (toDyn (Range 1 1)))'
which works fine (returns Nothing), then touch it and reload it and do
the same thing and you'll crash.

 --
 Hal Daume III   | [EMAIL PROTECTED]
 "Arrest this man, he talks in maths."   | www.isi.edu/~hdaume


> -----Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Hal Daume
> Sent: Thursday, August 14, 2003 4:06 PM
> To: Hal Daume; [EMAIL PROTECTED]
> Subject: RE: very strange behavior (crashes!) with Dynamics
> 
> 
> Okay, this is the last spam from me.
> 
> Here's exactly what you need to do to get the bug.
> 
> Create three modules, DynamicMap.hs, Range.hs and Coref.hs, containing
> the following:
> 
>  DynamicMap.hs 
> module DynamicMap
> ( DynamicMap,
>   emptyDM,
>   addToDM,
>   foldDM
> )
> where
> 
> import Data.FiniteMap
> import Data.Dynamic
> 
> type DynamicMap = FiniteMap String Dynamic  -- cuz TypeRep 
> \not \in Ord
> :(
> 
> stypeOf x = show (typeOf x)
> 
> emptyDM :: DynamicMap
> emptyDM = emptyFM
> 
> addToDM :: Typeable a => DynamicMap -> a -> DynamicMap
> addToDM dm a = addToFM dm (stypeOf a) (toDyn a)
> 
> foldDM :: (Dynamic -> b -> b) -> b -> DynamicMap -> b
> foldDM f = foldFM (const f)
> 
> 
> -- Range.hs ---
> module Range where
> 
> import Data.Dynamic
> 
> data Range = Single Int
>| Range  Int Int
> 
> minRange (Single x) = x
> minRange (Range x _) = x
> 
> maxRange (Single x) = x
> maxRange (Range _ x) = x
> 
> instance Show Range where
>   showsPrec _ (Single i) = shows i
>   showsPrec _ (Range i j) = shows i . showChar '^' . shows j
> 
> instance Eq Range where
> Single i == Single k = i == k
> Single i == Range k l = i == k && k == l
> Range i j == Range k l = i == k && j == l
> Range i j == Single k = i == k && j == k
> 
> instance Read Range where
>   readsPrec i s
>   | '^' `elem` s = 
>   let n1 = takeWhile (/='^') s
>   n2 = drop (length n1+1) s
>   in  [(Range l h, rest) | (l,[]) <- readsPrec i n1, 
> (h,rest) <-
> readsPrec i n2]
>   | otherwise = map (\ (a,s) -> (Single a,s)) (readsPrec i s)
> 
> instance Ord Range where
> r `compare` s = case minRange r `compare` minRange s of
>   EQ -> maxRange r `compare` maxRange s
>   x  -> x
> 
> rangeTypeCon = mkTyCon "Range" ; rangeTypeRep = mkAppTy 
> rangeTypeCon []
> instance Typeable Range where typeOf _ = rangeTypeRep
> {-# NOINLINE rangeTypeCon #-}
> {-# NOINLINE rangeTypeRep #-}
> 
> rangeDShow :: DShow
> rangeDShow = dshowLabel (shows :: Range -> ShowS)
> 
> type DShow = Dynamic -> Maybe ShowS
> 
> dshow0 :: DShow
> dshow0 = const Nothing
> 
> dshowLabel :: Typeable a => (a -> ShowS) -> DShow
> dshowLabel x d = 
>   case fromDynamic d of
> Nothing -> Nothing
> Just v  -> Just (shows (typeOf v) . showChar '=' . x v)
> 
> 
> -- Coref.hs ---
> module Coref where
> 
> import DynamicMap
> import Data.Dynamic
> import Range
> 
> data Coref = Coref Int Int Bool (Maybe String) 
>  deriving (Eq, Ord, Show)
> 
> corefTypeCon = mkTyCon "Coref" ; corefTypeRe

very strange behavior (crashes!) with Dynamics

2003-08-15 Thread Hal Daume
dCorefData> :r
Compiling ReadCorefData(
c:/home/t-hald/projects/PennUtil/ReadCorefData.hs, interpreted )
Ok, modules loaded: ReadCorefData, PennUtil.Util, Util.DynamicMap,
NLP.PennParser, NLP.FiniteMap, NLP.String, NLP.Util, Common.
*ReadCorefData> showDTreeWith corefDShow pTree ""
"(TOP {{Coref=Coref 1 32 
Process ghci exited abnormally with code 5


I can do this every time :).

I should mention that NLP.FiniteMap was created by stealing the code
from Data.FiniteMap and adding a few functions I felt were missing.

I've attached all the relevant source code.  The
PennUtil/ReadCorefData.hs is the module we're trying to run.  You should
untar it into a new directory if you want to experiment with it.

Any help would really be incredibly appreciated.

Thanks!

 - Hal

--
 Hal Daume III   | [EMAIL PROTECTED]
 "Arrest this man, he talks in maths."   | www.isi.edu/~hdaume


PennError.tar.gz
Description: PennError.tar.gz


RE: very strange behavior (crashes!) with Dynamics

2003-08-15 Thread Hal Daume
When deriving Typeable instead of writing the instances myself, this bug
doesn't pop up.  This puts it on a back burner for me, but it's still
something that should probably get fixed :).

 --
 Hal Daume III   | [EMAIL PROTECTED]
 "Arrest this man, he talks in maths."   | www.isi.edu/~hdaume


> -Original Message-
> From: [EMAIL PROTECTED] 
> [mailto:[EMAIL PROTECTED] On Behalf Of Hal Daume
> Sent: Thursday, August 14, 2003 4:47 PM
> To: Hal Daume; [EMAIL PROTECTED]
> Subject: RE: very strange behavior (crashes!) with Dynamics
> 
> 
> Okay, I know I promised that was the last one, but you can 
> actually get
> it simpler.  Remove all the dynamic map stuff.  Just have two files,
> Range.hs and Coref.hs, with:
> 
> module Range where
> 
> import Data.Dynamic
> 
> data Range = Single Int
>| Range  Int Int
>deriving (Eq, Ord, Show)
> 
> rangeTypeCon = mkTyCon "Range" ; rangeTypeRep = mkAppTy 
> rangeTypeCon []
> instance Typeable Range where typeOf _ = rangeTypeRep
> {-# NOINLINE rangeTypeCon #-}
> {-# NOINLINE rangeTypeRep #-}
> 
> rangeDShow :: DShow
> rangeDShow = dshowLabel (shows :: Range -> ShowS)
> 
> type DShow = Dynamic -> Maybe ShowS
> 
> dshowLabel :: Typeable a => (a -> ShowS) -> DShow
> dshowLabel x d = 
>   case fromDynamic d of
> Nothing -> Nothing
> Just v  -> Just (shows (typeOf v) . showChar '=' . x v)
> 
> 
> 
> and
> 
> 
> 
> module Coref where
> 
> import Data.Dynamic
> import Range
> 
> data Coref = Coref Int Int Bool (Maybe String) 
>  deriving (Eq, Ord, Show)
> 
> corefTypeCon = mkTyCon "Coref" ; corefTypeRep = mkAppTy 
> corefTypeCon []
> instance Typeable Coref where typeOf _ = corefTypeRep
> {-# NOINLINE corefTypeCon #-}
> {-# NOINLINE corefTypeRep #-}
> 
> corefDShow = dshowLabel (shows :: Coref -> ShowS)
> 
> 
> 
> now load Coref, do 'Monad.liftM ($"") (corefDShow (toDyn 
> (Range 1 1)))'
> which works fine (returns Nothing), then touch it and reload it and do
> the same thing and you'll crash.
> 
>  --
>  Hal Daume III   | [EMAIL PROTECTED]
>  "Arrest this man, he talks in maths."   | www.isi.edu/~hdaume
___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


GHC bug

2001-11-30 Thread Hal Daume III

Prelude> :reload 
Compiling XBar ( /nfs/isd/hdaume/projects/XBar/XBar.hs,
interpreted )
ghc-5.02.1: panic! (the `impossible' happened, GHC version 5.02.1):
TcGenDeriv:mk_FunMonoBind

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

This happened immediately after I change line 35 in the attached program
from:

  data DummyHead

to

  data DummyHead deriving (Show, Eq)

I wasn't sure whether it would allow me to derive instances on a datatype
with no constructors...I know this was recently added and I guess all the
bugs haven't been worked out.  I'm using the solaris build of ghc.

--
Hal Daume III

 "Computer science is no more about computers| [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume


module XBar
where


data IsHead x => XP x = forall y . IsHead y => XP (Maybe (XP y)) (X' x)
data IsHead x => X' x = forall y . IsHead y => X' (X x) (Maybe (XP y))
  | forall y . IsHead y => X'L (XP y) (X' x)
  | forall y . IsHead y => X'R (X' x) (XP y)
data IsHead x => X  x = X x

data Tree = Branch String [Tree]
  | Leaf String

class HasHead t h where
getHead :: t -> h

instance HasHead (XP x) (X' x) where
getHead (XP _ head) = head

instance HasHead (X' x) (X x) where
getHead (X' head _) = head
getHead (X'L _ x) = getHead x
getHead (X'R x _) = getHead x

class (Show x, Eq x) => IsHead x where
headType :: x -> String  -- should ignore it's argument
headString :: x -> String
headString = headType

data N = N String deriving (Show, Eq)
data V = V String deriving (Show, Eq)
data D = D String deriving (Show, Eq)
data I = I String deriving (Show, Eq)

data DummyHead deriving (Show, Eq)

instance IsHead N where { headString _ = "N" }
instance IsHead V where { headString _ = "V" }
instance IsHead D where { headString _ = "D" }
instance IsHead I where { headString _ = "I" }

instance IsHead x => Show (XP x) where
show _ = (headString (undefined :: x)) ++ "P"

instance IsHead x => Show (X' x) where
show _ = (headString (undefined :: x)) ++ "'"

instance IsHead x => Show (X x) where
show _ = (headString (undefined :: x)) ++ "0"

class ShowTree a where
showTree :: a -> Tree

instance IsHead x => ShowTree (XP x) where
showTree x@(XP (Just spec) proj) = Branch (show x) [showTree spec, showTree proj]
showTree x@(XP  Nothingproj) = Branch (show x) [showTree proj]

instance IsHead x => ShowTree (X' x) where
showTree x@(X'  head (Just arg)) = Branch (show x) [showTree head, showTree arg]
showTree x@(X'  head  Nothing  ) = Branch (show x) [showTree head]
showTree x@(X'L adj proj) = Branch (show x) [showTree adj, showTree proj]
showTree x@(X'R proj adj) = Branch (show x) [showTree proj, showTree adj]

instance IsHead x => ShowTree (X  x) where
showTree x@(X head) = Branch (show x) [Leaf (show head)]

instance Show Tree where
show (Branch name clist) = "[." ++ name ++ " " ++ unwords (map show clist) ++ " ]"
show (Leaf   head) = head

-- now the code to build trees
mergeArgument :: (IsHead x, IsHead y) => X x -> XP y -> X' x
mergeArgument head arg = X' head (Just arg)

--projectHead :: (IsHead x, IsHead y) => X x -> X' x
projectHead head = X' head (Nothing)

mergeAdjunctR :: (IsHead x, IsHead y) => X' x -> XP y -> X' x
mergeAdjunctR proj adj = X'R proj adj

mergeAdjunctL :: (IsHead x, IsHead y) => XP y -> X' x -> X' x
mergeAdjunctL adj proj = X'L adj proj

mergeSpec :: (IsHead x, IsHead y) => XP y -> X' x -> XP x
mergeSpec spec proj = XP (Just spec) proj

projectFull :: IsHead x => X' x -> XP x
projectFull proj = XP Nothing proj



fix: small error in ghc/driver/ghc-usage.txt

2002-02-15 Thread Hal Daume III

used to read "-H14m ... (might make the faster, especially on large...)"
fixed to "-H14m ... (might make the compilation faster, especially...)"

--
Hal Daume III

 "Computer science is no more about computers| [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume


Usage:

$$ [command-line-options-and-input-files]

To compile and link a complete Haskell program, run the compiler like
so:

$$ --make Main

where the module Main is in a file named Main.hs (or Main.lhs) in the
current directory.  The other modules in the program will be located
and compiled automatically, and the linked program will be placed in
the file `a.out' (or `Main.exe' on Windows).

Alternatively, $$ can be used to compile files individually.  Each
input file is guided through (some of the) possible phases of a
compilation:

- unlit:extract code from a "literate program"
- hscpp:run code through the C pre-processor (if -cpp flag given)
- hsc:  run the Haskell compiler proper
- gcc:  run the C compiler (if compiling via C)
- as:   run the assembler
- ld:   run the linker

For each input file, the phase to START with is determined by the
file's suffix:

- .lhs  literate Haskell unlit
- .hs   plain Haskellghc
- .hc   C from the Haskell compiler  gcc
- .cC not from the Haskell compiler  gcc
- .sassembly languageas
- other passed directly to the linkerld

The phase at which to STOP processing is determined by a command-line
option:

-E  stop after generating preprocessed, de-litted Haskell
 (used in conjunction with -cpp)
-C  stop after generating C (.hc output)
-S  stop after generating assembler (.s output)
-c  stop after generating object files (.o output)

Other commonly-used options are:

-v[n]   Control verbosity (n is 0--5, normal verbosity level is 1,
  -v alone is equivalent to -v3)

-fglasgow-exts  Allow Glasgow extensions (unboxed types, etc.)

-O  An `optimising' package of compiler flags, for faster code

-prof   Compile for cost-centre profiling
 (add -auto-all for automagic cost-centres on all
  top-level functions)

-H14m   Increase compiler's heap size (might make the compilation
faster, especially on large source files).

-M  Output Makefile rules recording the
dependencies of a list of Haskell files.

The User's Guide has more information about GHC's *many* options.

Given the above, here are some TYPICAL invocations of $$:

# compile a Haskell module to a .o file, optimising:
% $$ -c -O Foo.hs
# link three .o files into an executable called "test":
% $$ -o test Foo.o Bar.o Baz.o
# compile a Haskell module to C (a .hc file), using a bigger heap:
% $$ -C -H16m Foo.hs
# compile Haskell-produced C (.hc) to assembly language:
% $$ -S Foo.hc




weird ghci thing (exception in rdrNameModule)

2002-07-24 Thread Hal Daume III

I have no idea what I did to cause this, but ghci just crapped out on me
:)


*ExtractConcepts> mapM putStrLn (lines it)

:1:
Couldn't match `Char' against `[Char]'
Expected type: String
Inferred type: [[Char]]
In the first argument of `lines', namely `it'
In the second argument of `mapM', namely `(lines it)'
*ExtractConcepts> mapM putStrLn it
*** Exception: basicTypes/RdrName.lhs:83: Non-exhaustive patterns in
function rdrNameModule

--
Hal Daume III

 "Computer science is no more about computers| [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



the impossible happened with _casm_

2002-07-25 Thread Hal Daume III

11:17am moussor:src/ ghco -iHBlas:HLAPack HLAPack/TestDGEEV.hs
ghc-5.04: chasing modules from: HLAPack/TestDGEEV.hs
Skipping  StdDIS   (
/nfs/isd/hdaume/projects/green-card/StdDIS.hs,
/nfs/isd/hdaume/projects/green-card/StdDIS.sun4.o )
Compiling DIS  ( HBlas/DIS.hs, HBlas/DIS.sun4.o )
Skipping  HBlas.PrivateTypes ( HBlas/PrivateTypes.hs,
HBlas/PrivateTypes.sun4.o )
Compiling HLAPack.HLAPackGC ( HLAPack/HLAPackGC.hs,
HLAPack/HLAPackGC.sun4.o )
ghc-5.04: panic! (the `impossible' happened, GHC version 5.04):
process_casm: non-void result not assigned while processing _casm_
"do {int jobvl; int jobvr; int ua; int ma; int na; double * a; int
vnwr; double * wr; int vnwi; double * wi; int uvl; int mvl; int
nvl; double * vl; int uvr; int mvr; int nvr; double * vr;
   jobvl = (int)%0; jobvr = (int)%1; ua = (int)%2; ma =
(int)%3; na = (int)%4; a = (double *)%5; vnwr = (int)%6; wr = (double
*)%7; vnwi = (int)%8; wi = (double *)%9; uvl = (int)%10; mvl =
(int)%11; nvl = (int)%12; vl = (double *)%13; uvr = (int)%14; mvr =
(int)%15; nvr = (int)%16; vr = (double *)%17;
   do { double* work = malloc(4 * ma * sizeOf(double));   //
todo: fix this
 int info;
 int result_variable;
 char jobvlc = jobvl ? 'V' : 'N';
 char jobvrc = jobvr ? 'V' : 'N';
 result_variable = dgeev_(&jobvlc, &jobvrc, &na, a, &ma, wr, wi, vl,
&mvl, vr, &mvr, work, &lwork, &info);
 result_variable = info;
 free(work);
   } while(0);} while(0);"
(Try changing result type to IO ()


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



--
Hal Daume III

 "Computer science is no more about computers| [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



orphan modules

2002-08-01 Thread Hal Daume III

in the ghc docs, section 4.9.8, it says

You can identify an orphan module by looking in its interface file,
M.hi. If there is a ``!'' on the first line, GHC
considers it an orphan module. 

which i don't think is true anymore since .hi files are binary now...

--
Hal Daume III

 "Computer science is no more about computers| [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



weird :t uncurry flip

2002-08-09 Thread Hal Daume III

not sure what's going on here...

3:34pm moussor:libraries/ ghci
   ___ ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |  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.
Loading package lang ... linking ... done.
Prelude> :t uncurry flip
forall a c b. (a -> b -> c, b) -> a -> c


--
Hal Daume III

 "Computer science is no more about computers| [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



Re: weird :t uncurry flip

2002-08-09 Thread Hal Daume III

> On 2002-08-09T15:52:04-0700, Hal Daume III wrote:
> > Prelude> :t uncurry flip
> > forall a c b. (a -> b -> c, b) -> a -> c
> 
> Um, what is weird about this type?

Shouldn't it be

  (a -> b -> (c,b)) -> a -> c

?

like

Prelude> :t (\f -> fst . f)
forall a b a1. (a1 -> (a, b)) -> a1 -> a


___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



Re: weird :t uncurry flip

2002-08-09 Thread Hal Daume III

Nevermind, I'm dumb :)

--
Hal Daume III

 "Computer science is no more about computers| [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

On Fri, 9 Aug 2002, Hal Daume III wrote:

> > On 2002-08-09T15:52:04-0700, Hal Daume III wrote:
> > > Prelude> :t uncurry flip
> > > forall a c b. (a -> b -> c, b) -> a -> c
> > 
> > Um, what is weird about this type?
> 
> Shouldn't it be
> 
>   (a -> b -> (c,b)) -> a -> c
> 
> ?
> 
> like
> 
> Prelude> :t (\f -> fst . f)
> forall a b a1. (a1 -> (a, b)) -> a1 -> a
> 
> 
> 

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



RE: bug with rank n polymorphism in classes

2002-09-01 Thread Hal Daume III

5.04 for solaris (but it doesn't seem to work in the linux version,
either).

--
Hal Daume III

 "Computer science is no more about computers| [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

On Wed, 28 Aug 2002, Simon Peyton-Jones wrote:

> Please say which version of GHC you are using.
> 
> This program works fine with GHC 5.02.2
> 
> Simon
> 
> | -----Original Message-
> | From: Hal Daume III [mailto:[EMAIL PROTECTED]] 
> | Sent: 22 August 2002 20:47
> | To: [EMAIL PROTECTED]
> | Subject: bug with rank n polymorphism in classes
> | 
> | 
> | consider:
> | 
> | module Foo where
> | 
> | class Foo p where
> | foo :: p -> (forall q . Foo q => q -> a) -> a
> | 
> | instance Foo Int where
> | 
> | 
> | if you load this in to ghci, it complains:
> | 
> | /home/hdaume/projects/NLP/Foo.hs:6:
> | Ambiguous type variable(s) `q' in the constraint `Foo q'
> | arising from a function with an overloaded argument type 
> | at /home/hdaume/projects/NLP/Foo.hs:6
> | Expected type: Int -> (forall q1. (Foo q1) => q1 -> a) -> a
> | Inferred type: Int -> (q -> a) -> a
> | In the application `GHC.Err.noMethodBindingError 
> | "/home/hdaume/projects/NLP/Foo.hs:6|Foo.foo"#'
> | 
> | which is a reasonable complaint, but is emiited in a rather 
> | bizzare way.
> | 
> | --
> | Hal Daume III
> | 
> |  "Computer science is no more about computers| [EMAIL PROTECTED]
> |   than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume
> | 
> | ___
> | Glasgow-haskell-bugs mailing list 
> | [EMAIL PROTECTED] 
> | http://www.haskell.org/mailman/listinfo/glasgow-| haskell-bugs
> | 
> 

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



bug with rank-n polymorphism on datatypes

2002-09-03 Thread Hal Daume III

Hi again, I've got another bug (and I'm sure this time -- ghc tells me
so).  Of course, this is with 5.04 (on linux, this time):

module Foralls
where

data Foo a b = Foo { foo :: a -> b }

bar1 :: String -> (forall a . Foo a) -> IO ()
bar1 s _ = putStrLn s

{- bug:
*Foralls> :t bar

Couldn't match `* -> *' against `?'
When matching types `Foo a' and `t'
Expected type: String -> t -> t1
Inferred type: String -> (forall a1. Foo a1) -> IO ()

probably shouldn't be accepted at all
-}

bar2 :: String -> (forall a b . Foo a) -> IO ()
bar2 s (Foo { foo = foo }) = putStrLn s

{- bug:
Compiling Foralls  ( /home/hdaume/projects/Bugs/Foralls.hs, interpreted )
ghc-5.04: panic! (the `impossible' happened, GHC version 5.04):
tcSplitTyConApp
forall a{-r1ll-} :: *. Foralls.Foo{-r1kQ-} a{-r1ll-} b{-a1oY-}

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

this even happens in the case when bar2 is given the type:

bar2 :: String -> (forall a b . Foo a b) -> IO ()
-}

--
Hal Daume III

 "Computer science is no more about computers| [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume


___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



uh oh, another bug report :) (it and big computations)

2002-09-25 Thread Hal Daume III

Me again :)

Here's the offending code:

> module Foo where
> foo :: Int -> [((Int,Int), Int)]
> foo width = [((i,j),if i==j then 0 else 1) | i <- [1..50], j <-
>  [1..width]]

largely arbitrary, the point is to make something that takes a while to
compute.

now, using ghci (5.04.1, sparc solaris, from binaries), we load Foo.  now,
if we execute "foo 5" and then when it's done, type "it", it correctly
reproduces what it had.  however, if we do something which will take a
while (say "foo 100") and then pound control-c to get it to be
"Interrupted!", then type "it", we get:

...43,4),1),((43,5),1),((43,6),1),((43,7),1),((43,8),1),((43,9),1),((43,10),Interrupted.
*Foo> it
ghc-5.04.1: panic! (the `impossible' happened, GHC version 5.04.1):
rdrNameModule it

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


Should be pretty easy to reproduce.  Happens on things other than lists,
too (for example, arrays -- which is where i noticed it).


--
Hal Daume III

 "Computer science is no more about computers| [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



empty field label constructor infelicity

2002-09-25 Thread Hal Daume III

Hi again,

The report says "The expression F {}, where F is a data constructor, is
legal whether or not F was declared with record syntax, provided F has no
strict fields: it denotes F _|_1 ... _|_n where n is the arity of F."

It unclear to me why there needs to be this provision for records with
strict fields -- just let them be undefined -- but that notwithstanding,
GHC seems to do the wrong thing:

> module Foo where
> data F = F !Int deriving (Show, Eq)
> data G = G  Int deriving (Show, Eq)

If we then load it up in ghci, both "F {}" and "G {}" ellicit the same
error: "Missing field in record construction".

If we do:

Foo> case (F {}) of { F x -> "1" }

we get the exeption.  If we use G instead of F, we correctly get "1".

Hugs seems to obey the report.  For "F {}" it
give: "INTERNAL_ERROR: depConFlds" which is different from "G {}" which
yields "G" followed by "Program error: {undefined}".

For the case expressions, Hugs generates "INTERNAL ERROR: depConFlds" for
F and "1" for G.

Arguably, this is weirdness in the report, but I think it's clear that GHC
isn't doing the right thing (where right thing is defined to be what the
report says).

 - Hal

--
Hal Daume III

 "Computer science is no more about computers| [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



RE: Haskell 98

2002-09-25 Thread Hal Daume III

> Blargh. Excellent point.  I had totally forgotten that.  I withdraw all
> suggested changes except a cross-ref to the section you mention.  Sigh.
> My brain is getting soft.

Actually the rules referenced appear immediately above, so no reference is
necessary.

My original message was not suggesting a change to the report (though I
don't know that I agree with it -- i can see arguments in each
direction): I was primarily pointing out an infelicity in GHCs
implementation...

Out of curiousity, it's a bit strange that

 > data D = D !Int
 > myD = D {}

in invalid, but

 > newtype N = N !Int
 > myN = N {}

is not.

Not that I'm proposing a change...I just think it's od..

 - Hal

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



typo in unboxed types section + feature request

2002-09-26 Thread Hal Daume III

First off, in section 7.2.7 "Primitive-Double and Float
operations" there's a typo.  It says "minux" instead of "minux" on the
line reading: "{plus,minux,times,divide}Float# :: ...".

For the feature request, could we get the rest of the trig functions,
namely:

  asinhFloat#, acoshFloat#, atanhFloat# and the Double# versions

as well as the corresponding function to the

  isInfinite :: (RealFloat a) => a -> Bool

function on Float# and Double#?  I suggest the following names:

  isInfiniteFloat#, isInfiniteDouble#

:)

and possibly

  piFloat# and piDouble#

to round things out?

Thanks!

 - Hal, who just moved his library from 'newtype Log = Log Float' to
   'data Log = Log Float#' and got his programs to run much faster

--
Hal Daume III

 "Computer science is no more about computers| [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



RE: typo in unboxed types section + feature request

2002-09-27 Thread Hal Daume III

Hi,

> > First off, in section 7.2.7 "Primitive-Double and Float
> > operations" there's a typo.  It says "minux" instead of "minux" on the
> > line reading: "{plus,minux,times,divide}Float# :: ...".

Oops, I just realised I made the same typo here :).

> You can use the FFI for all these operations, just import the C
> versions.  You can even use unboxed types if you really want (mostly it
> shouldn't be necessary, though).

Ah, yes, that works too :).  I only suggested it because all the other
Float# functions seem to be exactly what is found in the RealFloat class
and these were "missing"...foreign works too, though.

Out of curiousity, why would I get better performance when using:

  data Log = Log Float#

instead of

  newtype Log = Log Float

?  GHC should be removing the newtype constructor anyway, so I don't
understand the difference.

(FOr some about what I'm doing, I multiply probabilities like 10^-8
together a lot and we always get underflow, even on Doubles.  THe solution
is to represent x by log x, thus 10^-8 is represented as
-8.  Multiplication of logs is trivial (addition) and there are some
tricks to do addition and subtraction without expanding out the log.  I
basically define the Log type above as instances of Num, FLoating, etc. so
I can conveniently use it.)

 - Hal

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



RE: typo in unboxed types section + feature request

2002-09-27 Thread Hal Daume III

Hi,

> There shouldn't be any difference, as far as I can tell.  The two types
> have the same representation.  But strange things do happen.  If you
> have an example where it makes a difference, we can take a look.

If I can manage to get a small example, I'll let you know (adds this to
his list of things to get small examples of).

Also, I'm curious about something.  You obviously can't do:

  5.0# < 6.0#

because they aren't instances of Ord (they can't be, as the have the wrong
kind).  Yet somehow:

  data Log = Log Float# deriving (Eq, Ord)

works fine.  Is this the compiler just being a little goosey about these
things (note that I'm not complaining -- not having to write Eq and Ord
instances is wonderful)?  And do I need to worry that maybe they're not
being derived correctly?

 - Hal


___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



mod 0 results in core dump

2002-10-23 Thread Hal Daume III
Prelude> 4 `mod` 0
Floating exception (core dumped)

'nuf said.  ghc 5.04.1, solaris.

--
Hal Daume III

 "Computer science is no more about computers| [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



new -fext-core bug (X = zdwX)

2002-11-22 Thread Hal Daume III
Me again...

given test.hs:

> 10:27am moussor:Prelude/ cat test.hs
> module Prelude where
> 
> data Ordering = LT | GT | EQ

we compile:

> 10:29am moussor:Prelude/ ~/mou/ghc-cvs/ghc/compiler/ghc-inplace 
>-fno-implicit-prelude -fext-core -fno-code test.hs
> 10:29am moussor:Prelude/ ~/mou/ghc-cvs/ghc/compiler/ghc-inplace --version
> The Glorious Glasgow Haskell Compilation System, version 5.05

(This is a cvs head from a few weeks ago)

then the beginning of the generated core is:

> 10:29am moussor:Prelude/ head test.hcr
> %module Prelude
>   %data Prelude.Ordering =
> {Prelude.LT;
>  Prelude.GT;
>  Prelude.EQ};
>   Prelude.LT :: Prelude.Ordering = Prelude.zdwLT;
>   Prelude.GT :: Prelude.Ordering = Prelude.zdwGT;
>   Prelude.EQ :: Prelude.Ordering = Prelude.zdwEQ;

Except these last three lines are backwards.  They should read:

>   Prelude.zdwLT :: Prelude.Ordering = Prelude.LT;

and so on.

 - Hal

--
Hal Daume III

 "Computer science is no more about computers| [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



RE: new -fext-core bug (X = zdwX)

2002-11-28 Thread Hal Daume III
Okay, my bad.  Then there's a bug in the core parser, since it doesn't
accept these.  The toplevel 'vdef' non-terminal expects first a qname,
which is "name" or "mname '.' name".  However, according to the lexer,
name must begin with a lower-case character...should this be changed so
that 'vdef' becomes "name" or "mname.name" or "cname" or "mname.cname"?

 - Hal

--
Hal Daume III

 "Computer science is no more about computers| [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

On Thu, 28 Nov 2002, Simon Peyton-Jones wrote:

> 
> | >   Prelude.LT :: Prelude.Ordering = Prelude.zdwLT;
> | >   Prelude.GT :: Prelude.Ordering = Prelude.zdwGT;
> | >   Prelude.EQ :: Prelude.Ordering = Prelude.zdwEQ;
> | 
> | Except these last three lines are backwards.  They should read:
> | 
> | >   Prelude.zdwLT :: Prelude.Ordering = Prelude.LT;
> 
> Not so, in fact.   Check out the commentary:
> 
> http://www.cse.unsw.edu.au/~chak/haskell/ghc/comm/the-beast/data-types.h
> tml
> 

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



RULES/SPECIALIZE not parsing:

2002-12-03 Thread Hal Daume III
Rules.hs:

module Rules where

my_id :: a -> a
my_id a = a

my_int_id :: Int -> Int
my_int_id a = a

{-# RULES my_id = my_int_id #-}
{-# SPECIALIZE my_id :: Int -> Int = my_int_id #-}


Neither of the pragmas are accepted.  The first elicits a parse error on
my_id, the second elicits a parse error on '='.

GHC 5.04.1 Solaris.

 - Hal

--
Hal Daume III

 "Computer science is no more about computers| [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



bug with -O -ffi and multiple module

2003-01-28 Thread Hal Daume III
Okay, here's a weird one.  There's something wrong with the ffi when using
-O and the foreign imports are from another module.  For example, our
foreign module, foo.c contains functions:

   void* openFile(char*fn);
   void closeFile(void*f);
   float readFloat(void*f);

which are interfaced from foo.h.  We have a FooIntr.hs interface file,
which looks like:

   foreign import ccall "foo.h openFile"  c__openFile  :: Ptr CChar -> IO
   (Ptr ())
   foreign import ccall "foo.h closeFile" c__closeFile :: Ptr () -> IO ()
   foreign import ccall "foo.h readFloat" c__readFloat :: Ptr () -> IO
   CFloat

openFile fn = cstring fn >>= c__openFile
closeFile = c__closeFile
readFloat h = do CFloat f <- c__readFloat h; return f

(plus helper definition of cstring)

Now, in our Foo.hs main file, we have:

  main = do
 [fn] <- getArgs
 h <- openFile fn
 f1 <- readFloat h
 f2 <- readFloat h
 closeFile h
 print (f1,f2)

In a file "bar", we have "1.234 5.678".

We compile foo.c via 'gcc -c foo.c' which works fine, then compile Foo.hs
using 

  ghc --make -ffi Foo.hs foo.o -o foo

we then run

  ./foo bar

and everything works fine.  We erase the intermediate files and recompile
with:

  ghc --make -ffi Foo.hs foo.o -o foo -O

and then run

  ./foo bar

and the results are random (seemingly) numbers.

Interestingly, if we include FooIntr into Foo and don't have Foo import it
anymore, everything works fine with -O on.

I've attached the actual files in a tar so someone can take a look.

 - Hal

--
Hal Daume III

 "Computer science is no more about computers| [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume




bug.tar.gz
Description: Binary data


badness with -fmax-simplifier-iterations

2003-02-04 Thread Hal Daume III
A few things.  First of all, if you're stupid and say:

  ghc ... -fmax-simplifier-iterations=5

then ghc crashes with:

ghc-5.05: panic! (the `impossible' happened, GHC version 5.05):
Prelude.read: no parse

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

(same thing happens in 5.04.2)

I think in DriverFlags.hs, the command for max-simpl... should be changed
from:

  Prefix (writeIORef v_MaxSimplifierIterations . read)

to

  PrefixPred (all isDigit) (writeIORef v_MaxSimplifierIterations . read)

Now, more importantly, it seems to obey this command unless you give it,
for instance, 0 as an argument:

  ghc ... -v5 -fmax-simplifier-iterations0 | grep 'Simplifier'


yields:

 Simplifier phase 0, iteration 1 out of 0

 Simplifier phase 0, iteration 1 out of 0

 Simplifier phase 0, iteration 2 out of 0

 Simplifier phase 0, iteration 2 out of 0



which seems pretty bad to me :)

 - Hal


--
Hal Daume III

 "Computer science is no more about computers| [EMAIL PROTECTED]
  than astronomy is about telescopes." -Dijkstra | www.isi.edu/~hdaume

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs



"unknown architecture" bug

2003-02-28 Thread Hal Daume III
Any idea what would cause this:

ch --make Train.hs -fglasgow-exts -osuf sun4.o -hisuf sun4.hi
ghc-5.04.2: chasing modules from: Train.hs
Compiling NLP.PTBDefs2 ( /nfs/isd/hdaume/projects/NLP/PTBDefs2.lhs,
/nfs/isd/hdaume/projects/NLP/PTBDefs2.sun4.o )

/nfs/isd/hdaume/projects/NLP/PTBDefs2.lhs:221: Warning: Pattern
match(es) are overlapped
In the definition of `fixLex': fixLex (TDash : (TRP : xs)) = ...
Compiling NLP.PTBParser2   ( /nfs/isd/hdaume/projects/NLP/PTBParser2.hs,
/nfs/isd/hdaume/projects/NLP/PTBParser2.sun4.o )
Compiling Train( Train.hs, ./Train.sun4.o )
8:55am moussor:Paraphrases/ touch Train.hs
DING! moussor:Paraphrases/ ghci Train.hs
   ___ ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |  GHC Interactive, version 5.04.2, for Haskell
98.
/ /_\\/ __  / /___| |  http://www.haskell.org/ghc/
\/\/ /_/\/|_|  Type :? for help.

Loading package base ... linking ... done.
Loading package haskell98 ... linking ... done.
Loading package lang ... linking ... done.
Skipping  NLP.PTBDefs2 ( /nfs/isd/hdaume/projects/NLP/PTBDefs2.lhs,
/nfs/isd/hdaume/projects/NLP/PTBDefs2.sun4.o )
Skipping  NLP.PTBParser2   ( /nfs/isd/hdaume/projects/NLP/PTBParser2.hs,
/nfs/isd/hdaume/projects/NLP/PTBParser2.sun4.o )
Compiling Train( Train.hs, interpreted )
/nfs/isd/hdaume/projects/NLP/PTBDefs2.sun4.o: unknown architecture
ghc-5.04.2: panic! (the `impossible' happened, GHC version 5.04.2):
loadObj: failed

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



This has happened to me a few times and by removing the offending .o file
and rebuilding, everything works (sometimes).

--
 Hal Daume III   | [EMAIL PROTECTED]
 "Arrest this man, he talks in maths."   | www.isi.edu/~hdaume

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


bug with splitPS in Data.PackedString

2003-03-07 Thread Hal Daume III
there's a bug in Data.PackedString that doesn't exist in PackedString:

Prelude> :m PackedString
Prelude PackedString> splitPS ('\t') (packString "Foo\tBar")
["Foo","Bar"]
Prelude PackedString> :m Data.PackedString
Prelude Data.PackedString> splitPS ('\t') (packString "Foo\tBar")
["Foo"*** Exception: Ix{Int}.index: Index (7) out of range ((0,6))

--
 Hal Daume III   | [EMAIL PROTECTED]
 "Arrest this man, he talks in maths."   | www.isi.edu/~hdaume

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


bug with definition at top-level:

2003-06-11 Thread Hal Daume III
3:54pm moussor:handalign/ ghci
   ___ ___ _
  / _ \ /\  /\/ __(_)
 / /_\// /_/ / /  | |  GHC Interactive, version 6.0, for Haskell 98.
/ /_\\/ __  / /___| |  http://www.haskell.org/ghc/
\/\/ /_/\/|_|  Type :? for help.

Loading package base ... linking ... done.
Loading package lang ... linking ... done.
Prelude> let f s = let (p1:_:p2:_:r1:_:f2:_) = map read (words s) in show
((2*p1*r1)/(p1+r1)) ++ " & " ++ show ((2*p2*f2)/(p2+f2))
ghc-6.0: panic! (the `impossible' happened, GHC version 6.0):
getLinkDeps No iface for []GHCziErr

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



--
 Hal Daume III   | [EMAIL PROTECTED]
 "Arrest this man, he talks in maths."   | www.isi.edu/~hdaume

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


internal error: evacuate: strange closure type 33544

2003-12-05 Thread Hal Daume III
Hi guys,

I have no idea what this is:

8:45am dixiechicks:DUC04/ ../SVMseq/SVMseqLearn -m 1800 --string-maxn=3 -h 
0 data.dis.svm data.dis.model-linear
Reading training examples.13612 examples read (highest 
feature=13)
Initializing...SVMseqLearn: internal error: evacuate: strange closure type 
33544
Please report this as a bug to [EMAIL PROTECTED],
or http://www.sourceforge.net/projects/ghc/
695.190u 4.160s 11:39.41 99.9%  0+0k 0+0io 250pf+0w
8:56am dixiechicks:DUC04/ 


unfortunately, this is the first time i've seen this error and, as you can 
see, the program was running for a *long* time before it cropped up.  if 
you want, i can send you the source/data files it was running on, but i 
don't know that you'd be able to glean much information from that...

 - hal

-- 
 Hal Daume III   | [EMAIL PROTECTED]
 "Arrest this man, he talks in maths."   | www.isi.edu/~hdaume

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: internal error: evacuate: strange closure type 33544

2003-12-05 Thread Hal Daume III
I recompiled after a minor change (which is in code that hasn't been 
reached at the point this error occurs) and am now getting:

9:39am dixiechicks:DUC04/ ../SVMseq/SVMseqLearn -m 1800 --string-maxn=3 -h 
0 data.dis.svm data.dis.model-linear
Reading training examples.Segmentation fault (core dumped)

9:40am dixiechicks:DUC04/ ../SVMseq/SVMseqLearn -m 1800 --string-maxn=3 -h 
0 data.dis.svm data.dis.model-linear
Reading training examples...SVMseqLearn: internal error: scavenge: 
unimplemented/strange closure type 23675 @ 0x406960b0
Please report this as a bug to [EMAIL PROTECTED],
or http://www.sourceforge.net/projects/ghc/

9:40am dixiechicks:DUC04/ ../SVMseq/SVMseqLearn -m 1800 --string-maxn=3 -h 
0 data.dis.svm data.dis.model-linear
Reading training examples...Segmentation fault (core dumped)

9:40am dixiechicks:DUC04/ ../SVMseq/SVMseqLearn -m 1800 --string-maxn=3 -h 
0 data.dis.svm data.dis.model-linear
Reading training examples...Segmentation fault (core dumped)

9:40am dixiechicks:DUC04/ ../SVMseq/SVMseqLearn -m 1800 --string-maxn=3 -h 
0 data.dis.svm data.dis.model-linear
Reading training examples...SVMseqLearn: internal error: scavenge: 
unimplemented/strange closure type 1001 @ 0x406640d0
Please report this as a bug to [EMAIL PROTECTED],
or http://www.sourceforge.net/projects/ghc/


On Fri, 5 Dec 2003, Hal Daume III wrote:

> Hi guys,
> 
> I have no idea what this is:
> 
> 8:45am dixiechicks:DUC04/ ../SVMseq/SVMseqLearn -m 1800 --string-maxn=3 -h 
> 0 data.dis.svm data.dis.model-linear
> Reading training examples.13612 examples read (highest 
> feature=13)
> Initializing...SVMseqLearn: internal error: evacuate: strange closure type 
> 33544
> Please report this as a bug to [EMAIL PROTECTED],
> or http://www.sourceforge.net/projects/ghc/
> 695.190u 4.160s 11:39.41 99.9%  0+0k 0+0io 250pf+0w
> 8:56am dixiechicks:DUC04/ 
> 
> 
> unfortunately, this is the first time i've seen this error and, as you can 
> see, the program was running for a *long* time before it cropped up.  if 
> you want, i can send you the source/data files it was running on, but i 
> don't know that you'd be able to glean much information from that...
> 
>  - hal
> 
> 

-- 
 Hal Daume III   | [EMAIL PROTECTED]
 "Arrest this man, he talks in maths."   | www.isi.edu/~hdaume

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


RE: internal error: evacuate: strange closure type 33544

2003-12-08 Thread Hal Daume III
I believe it was a --make after modifications (but not to the 'Main' 
module).  Probably related to the earlier bug then -- a recompile from 
scratch seems to have fixed it.

On Mon, 8 Dec 2003, Simon Marlow wrote:

> Did you do a complete recompile from scratch, or is this the result of
> ghc --make after modifications?  (there's a known bug in --make which
> can cause this).
> 
> Are you using any custom GC options (eg. in the GHCRTS env. variable)?
> 
> If it's a recompile from scratch, can you package it up so we can
> investigate?
> 
> Cheers,
>   Simon
> 
> > -Original Message-
> > From: [EMAIL PROTECTED] 
> > [mailto:[EMAIL PROTECTED] On Behalf 
> > Of Hal Daume III
> > Sent: 05 December 2003 17:40
> > To: [EMAIL PROTECTED]
> > Subject: Re: internal error: evacuate: strange closure type 33544
> > 
> > I recompiled after a minor change (which is in code that hasn't been 
> > reached at the point this error occurs) and am now getting:
> > 
> > 9:39am dixiechicks:DUC04/ ../SVMseq/SVMseqLearn -m 1800 
> > --string-maxn=3 -h 
> > 0 data.dis.svm data.dis.model-linear
> > Reading training examples.Segmentation fault (core dumped)
> > 
> > 9:40am dixiechicks:DUC04/ ../SVMseq/SVMseqLearn -m 1800 
> > --string-maxn=3 -h 
> > 0 data.dis.svm data.dis.model-linear
> > Reading training examples...SVMseqLearn: internal error: scavenge: 
> > unimplemented/strange closure type 23675 @ 0x406960b0
> > Please report this as a bug to [EMAIL PROTECTED],
> > or http://www.sourceforge.net/projects/ghc/
> > 
> > 9:40am dixiechicks:DUC04/ ../SVMseq/SVMseqLearn -m 1800 
> > --string-maxn=3 -h 
> > 0 data.dis.svm data.dis.model-linear
> > Reading training examples...Segmentation fault (core dumped)
> > 
> > 9:40am dixiechicks:DUC04/ ../SVMseq/SVMseqLearn -m 1800 
> > --string-maxn=3 -h 
> > 0 data.dis.svm data.dis.model-linear
> > Reading training examples...Segmentation fault (core dumped)
> > 
> > 9:40am dixiechicks:DUC04/ ../SVMseq/SVMseqLearn -m 1800 
> > --string-maxn=3 -h 
> > 0 data.dis.svm data.dis.model-linear
> > Reading training examples...SVMseqLearn: internal error: scavenge: 
> > unimplemented/strange closure type 1001 @ 0x406640d0
> > Please report this as a bug to [EMAIL PROTECTED],
> > or http://www.sourceforge.net/projects/ghc/
> > 
> > 
> > On Fri, 5 Dec 2003, Hal Daume III wrote:
> > 
> > > Hi guys,
> > > 
> > > I have no idea what this is:
> > > 
> > > 8:45am dixiechicks:DUC04/ ../SVMseq/SVMseqLearn -m 1800 
> > --string-maxn=3 -h 
> > > 0 data.dis.svm data.dis.model-linear
> > > Reading training examples.13612 examples 
> > read (highest 
> > > feature=13)
> > > Initializing...SVMseqLearn: internal error: evacuate: 
> > strange closure type 
> > > 33544
> > > Please report this as a bug to [EMAIL PROTECTED],
> > > or http://www.sourceforge.net/projects/ghc/
> > > 695.190u 4.160s 11:39.41 99.9%  0+0k 0+0io 250pf+0w
> > > 8:56am dixiechicks:DUC04/ 
> > > 
> > > 
> > > unfortunately, this is the first time i've seen this error 
> > and, as you can 
> > > see, the program was running for a *long* time before it 
> > cropped up.  if 
> > > you want, i can send you the source/data files it was 
> > running on, but i 
> > > don't know that you'd be able to glean much information from that...
> > > 
> > >  - hal
> > > 
> > > 
> > 
> > -- 
> >  Hal Daume III   | [EMAIL PROTECTED]
> >  "Arrest this man, he talks in maths."   | www.isi.edu/~hdaume
> > 
> > ___
> > Glasgow-haskell-bugs mailing list
> > [EMAIL PROTECTED]
> > http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs
> > 
> > 
> 

-- 
 Hal Daume III   | [EMAIL PROTECTED]
 "Arrest this man, he talks in maths."   | www.isi.edu/~hdaume

___
Glasgow-haskell-bugs mailing list
[EMAIL PROTECTED]
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs