Re: Does newByteArray clear?

2020-08-26 Thread Bertram Felgenhauer via Glasgow-haskell-users
David Feuer wrote: > I'm looking to play around with an array-based structure with > sub-linear worst-case bounds. Array is pretty awkward in that context > because creating a new one takes O(n) time to initialize it. Is that > all true of newByteArray, or can I get one with arbitrary garbage in

Re: What does freezing an array really do?

2020-08-20 Thread Bertram Felgenhauer via Glasgow-haskell-users
David Feuer wrote: > I know that a frozen array doesn't have to be searched for elements in > a younger generation, but how does it differ from an unfrozen array > that hasn't been mutated since the last collection? Frozen arrays are not put on the mutable list once they're clean (meaning they

Re: TDNR without new operators or syntax changes

2016-05-21 Thread Bertram Felgenhauer
AntC wrote: > > > > With syntaxless TDNR enabled, the last line could be: > > > > f b c = do { reset b; reset c } > > > > Heck, I didn't think you meant something that radical. > So bare name in a function application context is to need disambiguating. > > I think you'll find rather a lot

Re: What happened to -optdep option?

2016-05-05 Thread Bertram Felgenhauer
Volker Wysk wrote: > Hello! > > I'm using GHC 7.10.3 after an upgrade. I have the following in my Makefile: > > depend_mod :: lib/abh > ghc -M $(CFLAGS_GHC_0) -dep-makefile -optdepbuild/depend.tmp > -dep-suffix "p_" You should drop the -optdep here > \ > $(foreach m,

Re: Increased memory usage with GHC 7.10.1

2015-04-03 Thread Bertram Felgenhauer
George Colpitts wrote: I'm curious why the amount of RAM is relevant as all of our OS have virtual memory so it is only the size of the heap and the amount of swap that should be relevant for an Out Of Memory error, right? The computer may not be your own. VPSs are essentially priced based on

Re: Document for review: evaluation order and state tokens

2014-08-25 Thread Bertram Felgenhauer
Dear Michael, Michael Snoyman wrote: As part of trac ticket 9390[1], Simon PJ recommended that we try to get a document written that clarifies some of the issues regarding evaluation order, and get it included in the GHC wiki. After a few iterations with review from Simon, I've got a first

Re: Overlapping and incoherent instances

2014-08-07 Thread Bertram Felgenhauer
Simon Peyton Jones wrote: | On a largely unrelated note, here's another thing I don't | understand: when is OVERLAPPABLE at one instance declaration | preferable to using only OVERLAPPING at the instance declarations | that overlap it? It's a user decision. GHC allows - OVERLAPPABLE at

Re: how to compile non-dynamic ghc-7.8.2 ?

2014-04-25 Thread Bertram Felgenhauer
John Lato wrote: I'd like to compile ghc-7.8.2 with DynamicGhcPrograms disabled (on 64-bit linux). I downloaded the source tarball, added DYNAMIC_GHC_PROGRAMS = NO I've had success with setting both DYNAMIC_BY_DEFAULT = NO DYNAMIC_GHC_PROGRAMS = NO and removing the 'dyn' way altogether

Re: throwTo semantics

2013-07-28 Thread Bertram Felgenhauer
Roman Cheplyaka wrote: The documentation for throwTo says: throwTo does not return until the exception has been raised in the target thread. The calling thread can thus be certain that the target thread has received the exception. This is a useful property to know when dealing with

Re: mask, catch, myThreadId, throwTo

2013-04-15 Thread Bertram Felgenhauer
Felipe Almeida Lessa wrote: I have some code that is not behaving the way I thought it should. The gist of it is sleeper = mask_ $ forkIOWithUnmask $ \restore - forever $ restore sleep `catch` throwBack throwBack (Ping tid) = myThreadId = throwTo tid . Pong

Re: Problems installing 7.6.2 on MACOS

2013-04-07 Thread Bertram Felgenhauer
Dear Dominic, Dominic Steinitz wrote: bash-3.2$ ./configure --prefix=/Library/Haskell ... bash-3.2$ which ghc-pkg /Library/Haskell/lib/ghc-7.6.2/ghc-pkg bash-3.2$ which ghc /Library/Haskell/lib/ghc-7.6.2/ghc These are the wrong executables; the right ones would be in

Re: Race-condition in alternative 'System.Timeout.timeout' implementation

2013-02-27 Thread Bertram Felgenhauer
Akio Takano wrote: Thank you for the explanation. My previous attempt obviously suffers from the race condition you mention. However it still seems to be possible to implement a compromise, using both the IO manager and a new thread, i.e. forking only when the computation is being timed

Re: Race-condition in alternative 'System.Timeout.timeout' implementation

2013-02-25 Thread Bertram Felgenhauer
Dear Herbert, I've been experimenting with an alternative implementation of 'System.Timeout.timeout'[1] which avoids the overhead of spawning a new thread for each invocation. Be warned that timeouts are very intricate. We had a lengthy discussion on the topic 2 years ago, starting at

Re: GADTs in the wild

2012-08-18 Thread Bertram Felgenhauer
Christopher Done wrote: The context === In a fat-client web app (like GMail) you have the need to send requests back to the server to notify the server or get information back, this is normally transported in JSON format. For a Haskell setup, it would be: JavaScript (Client)

Re: GADTs in the wild

2012-08-18 Thread Bertram Felgenhauer
Christopher Done wrote: On 18 August 2012 20:57, Bertram Felgenhauer bertram.felgenha...@googlemail.com wrote: The natural encoding as a GADT would be as follows: data Command result where GetFoo :: Double - Command Foo PutFoo :: String - Command Double Right

Re: build failures when hiding non-visible imports

2012-08-18 Thread Bertram Felgenhauer
Simon Peyton-Jones wrote: | Would it be reasonable to change ghc's behavior to treat this | (ie an 'import' statement that hides something that isn't exported) as a | warning instead of an error? Yes, that would be easy if it's what everyone wants. Any other opinions? +1 for a warning from

Re: [GHC Users] Dictionary sharing

2012-07-02 Thread Bertram Felgenhauer
Jonas Almström Duregård wrote: Thank you for your response Edward, You write that it is usually only evaluated once, do you know the circumstances under which it is evaluated more than once? I have some examples of this but they are all very large. Only the dictionaries for type class

Re: read-Int implementation

2012-02-13 Thread Bertram Felgenhauer
Serge D. Mechveliani wrote: Who can tell, please, how read string :: Integer is implemented in ghc-7.4.1 ? Is it linked from the GMP (Gnu Multi-Precision) library? I believe your numbers simply were not large enough. I changed strs n to be strs n = if n == 0 then []

Re: Is this a concurrency bug in base?

2011-10-14 Thread Bertram Felgenhauer
Simon Marlow wrote: import Control.Concurrent import Control.Exception import Control.Monad import System.IO.Unsafe main :: IO () main = do -- evaluate lock -- adding this line fixes the problem fin1- newEmptyMVar fin2- newEmptyMVar forkIO $ ping= putMVar fin1

Re: Is this a concurrency bug in base?

2011-10-12 Thread Bertram Felgenhauer
Jean-Marie Gaillourdet wrote: This is my previous program with your workaround, it is also attached as TypeRepEqLock.hs [snip] Compile and execute: $ ghc-7.0.3 -threaded -rtsopts TypeRepEqLock.hs snip $ while true ; do ./TypeRepEqLock +RTS -N ; done Ok Ok Ok Ok Ok Ok Ok Ok Ok

Re: Bug in GC's ordering of ForeignPtr finalization?

2011-08-29 Thread Bertram Felgenhauer
Dear Ben, Ben Gamari wrote: After looking into this issue in a bit more depth, I'm even more confused. In fact, I would not be surprised if I have stumbled into a bug in the GC. [...] MessagesMessage | | msmpp \/ QueryMessages

Re: Space leak question

2011-07-28 Thread Bertram Felgenhauer
Hi Will, Will Ness wrote: Will Ness will_n48 at yahoo.com writes: CORRECTION: just with gaps (but not the other ones), changing the g function from composed pieces into a normal code, it did it! (probably some ghc version-specific stuff at play): g xs = 3 : gaps 5 (

Re: Space leak question

2011-07-26 Thread Bertram Felgenhauer
Hi Will, in reformulation of a code with no space leak, the leak reappeares. It takes near constant space to get at the n-th elt in the produced list here (http://ideone.com/fiifl): {-# OPTIONS_GHC -O2 -fno-cse #-} primes = 2 : ([3,5..] `minus` foldi (\(x:xs) - (x:) .

Re: Local evidence and type class instances

2010-11-02 Thread Bertram Felgenhauer
Hello, Now that the Glorious New type checker can handle local evidence seamlessly, is it a big implementation burden to extend it to deal with local *type class instances* in addition to local *equality constraints*? For example, you could write this: f :: Bool f = id id where

Re: Wadler space leak

2010-10-28 Thread Bertram Felgenhauer
Hi, let (first,rest) = break (const False) input in print (length (first ++ rest)) When I compile this program using -O2 and use a large text file as input the code runs in constant space. If I understand correctly, the program runs in constant space because ghc uses an optimization

Re: ld memory usage

2010-04-17 Thread Bertram Felgenhauer
Roman Beslik wrote: This is not strictly a GHC question. I observed that ld when linking GHC-compiled programs eats 0.5 GB of resident memory. ~3 times more than GHC or Haddock. Oh I remember investigating this problem 2 years ago. Looking back it seems I never made my observations public.

Annotations and Template Haskell

2010-03-08 Thread Bertram Felgenhauer
Hello, I'm wondering whether annotations [1] could be made available to Template Haskell users as a ghc specific extension. Would that be feasible? Would it be useful? An example use would be annotating a type with a representation of a default value that could be used in generating instances

Re: Working with GHC HEAD

2009-08-02 Thread Bertram Felgenhauer
Antoine Latter wrote: I was trying to see what GHC head was like, but I've run into a few snags compiling packages. There's a discrepancy between ghc and ghc-pkg that causes this. See http://hackage.haskell.org/trac/ghc/ticket/3410 My existing binary for cabal-install can install quite a few

Re: bug: unstable myThreadId in GHC 6.6.1

2009-04-11 Thread Bertram Felgenhauer
Bulat Ziganshin wrote: Hello glasgow-haskell-users, i've looked for this bug in Trac but don't found anything. so: startGUI action = runInBoundThread $ do unsafeInitGUIForThreadedRTS myThreadId = writeIORef guiThread action = widgetShowAll mainGUI guiThread =

Re: Re[2]: Compiler optimizations questions for ghc 6.10...

2009-02-21 Thread Bertram Felgenhauer
Krasimir Angelov wrote: Well I actually did, almost. I added this function: quotX :: Int - Int - Int a `quotX` b | b == 0 = error divZeroError | b == (-1) a == minBound = error overflowError | otherwise = a `quotInt` b It does the right

Re: [reactive] Re: black hole detection and concurrency

2009-01-03 Thread Bertram Felgenhauer
Conal Elliott wrote: Thanks very much for these ideas. Peter Verswyvelen suggested running the example repeatedly to see if it always runs correctly. He found, and I verified, that the example runs fine with Bertram's last version of unamb below, *unless* it's compiled with -threaded and run

Re: black hole detection and concurrency

2008-12-29 Thread Bertram Felgenhauer
Simon Peyton-Jones wrote: | I have a good theory on the latter symptom (the thread killed | message). Sticking in some traces, as in my appended code, helped me | to see what's going on. It seems to be exactly what you describe -- | the variable v is permanently bound to the exception it

Re: [reactive] Re: black hole detection and concurrency

2008-12-28 Thread Bertram Felgenhauer
Peter Verswyvelen wrote: I fail to understand this part of the code: case fromException e of Just ThreadKilled - do myThreadId = killThread unblock (race a b) So the current thread gets killed synchronously, then then the race

Re: black hole detection and concurrency

2008-12-27 Thread Bertram Felgenhauer
Sterling Clover wrote: I have a good theory on the latter symptom (the thread killed message). Sticking in some traces, as in my appended code, helped me to see what's going on. It seems to be exactly what you describe -- the variable v is permanently bound to the exception it evaluates to.

Re: black hole detection and concurrency

2008-12-27 Thread Bertram Felgenhauer
Hi, Bertram Felgenhauer wrote: [snip] race :: IO a - IO a - IO a Two quick notes on that function: race a b = block $ do v - newEmptyMVar let t x = x = putMVar v Should be let t x = unblock (x = putMVar v) Otherwise the computation 'x' not be interruptible unless

Re: black hole detection and concurrency

2008-12-27 Thread Bertram Felgenhauer
Sterling Clover wrote: On Dec 27, 2008, at 9:02 AM, Bertram Felgenhauer wrote: In the above code, there is a small window between catching the ThreadKilled exception and throwing it again though, where other exceptions may creep in. The only way I see of fixing that is to use 'block

Building ghc-6.10 with ghc-6.6.1

2008-10-20 Thread Bertram Felgenhauer
Hi, I've successfully built ghc-6.10 with ghc-6.6.1; there was one minor problem: Building extensible-exceptions-0.1.0.0... Control/Exception/Extensible.hs:2:13: cannot parse LANGUAGE pragma ghc 6.6.1 does not know about DeriveDataTypeable - I just removed that line. Software used:

Re: invoking a Haskell script without a .hs extension

2008-08-18 Thread Bertram Felgenhauer
Paul Jarc wrote: I have a Haskell script called notify, without a .hs extension, which causes some problems. (I'm using ghc 6.8.3.) First attempt: runhaskell notify Without the .hs extension, ghc doesn't know it's a Haskell script, and so I get Could not find module `notify'. Maybe

Re: Assembly decoding help?

2008-03-04 Thread Bertram Felgenhauer
Justin Bailey wrote: I'm trying to get a feel for the assembly output by GHC on my platform. Below is a module containing one function and the associated assembly. I've put in comments what I think is going on, but I'd appreciate it if anyone could give me some pointers. I'd really like to

Re: returning to instance overlap

2008-01-19 Thread Bertram Felgenhauer
Serge D. Mechveliani wrote: Dear GHC developers, I'm not one of them, but maybe I can help anyway. can you exaplain, please, how to use overlapping instances? For example, the following program uses overlapping instances for DShow [a] and DShow String, but ghc-6.8.2 reports an error:

Re: GHC Data.List.sort performance question

2008-01-15 Thread Bertram Felgenhauer
Marcus D. Gabriel wrote: By a rather indirect route, I discovered that I obtain an almost factor of two improvement in performance in Data.List.sort if I make one small change in the implementation of the function merge which supports mergesort and hence sortBy and sort. Admittedly, the

Re: GHC Data.List.sort performance question

2008-01-15 Thread Bertram Felgenhauer
Judah Jacobson wrote: This means that the library version produces a stack overflow on lists generated in an iterate like fashion (say, take 100 [0..]). The modified version produces a stack overflow on the reverse of that list, but I believe such lists are much rarer in practice.

Re: Need help understanding the Coverage Condition

2007-07-04 Thread Bertram Felgenhauer
Philip K.F. H??lzenspies wrote: [snip] {- begin -} {-# OPTIONS -fglasgow-exts #-} data Z-- Zero data S x -- Successor of x class Add a b c | a b - c instance Add Z q q instance Add p q r = (S p) q (S r) {- end -} [snip] The coverage condition. For each functional dependency,

Re: Error compiling GHC/Num.lhs

2007-05-02 Thread Bertram Felgenhauer
[Note: Sorry if this is a duplicate. I originally sent the patches inline in the mail, but the resulting mail grew rather big and is awaiting moderators approval now. (moderators: no need to approve it)] Bas van Dijk wrote: On 5/2/07, Simon Marlow [EMAIL PROTECTED] wrote: I believe this one is

Re: hrm...

2007-01-28 Thread Bertram Felgenhauer
Donald Bruce Stewart wrote: john: so I have this simple bit of code, which should be fast but seems to be being compiled to something very slow. import Data.Word import Data.Bits fhb :: Word - Word fhb w = b1 .|. b2 where b2 = if 0x .. w /= 0 then 0x2 else 0

Curious behaviour of irrefutable pattern.

2006-12-20 Thread Bertram Felgenhauer
Hi, consider this program: module Main (f, main) where f ~(a:as) = 1 + f as main = print $ f (error Foobar!) Obviously, the program should result in an error - the irrefutable pattern of f always succeeds, so f calls itself recursively ad infinitum and the result is Loop or

Re: Curious behaviour of irrefutable pattern.

2006-12-20 Thread Bertram Felgenhauer
Simon Peyton-Jones wrote: In general, GHC (like every other compiler that does strictness analysis) feels free to change non-termination into a call to 'error' and vice versa. One could change that, but a lot of programs would become less efficient as a result. Just to clarify, I'm happy

Re: Common subexpression elemination (CSE)

2006-11-28 Thread Bertram Felgenhauer
Dinko Tenev wrote: On 11/27/06, Lennart Augustsson [EMAIL PROTECTED] wrote: GHC doesn't normally do CSE. CSE can cause space leaks, so you can't do it willy-nilly. I'm sure there are some strict contexts where it could be done safely, but I don't think ghc uses that information (yet).