Re: thread blocked indefinitely in an MVar operation in unsafePerformIO

2012-07-31 Thread Marco Túlio Gontijo e Silva
Hi Simon. On Mon, Jul 30, 2012 at 12:00 PM, Simon Marlow marlo...@gmail.com wrote: (...) Is it possible that the String you are passing to uLog contains unevaluated calls to uLog itself, which would thereby create a deadlock as uLog tries to take the MVar that is already being held by the same

thread blocked indefinitely in an MVar operation in unsafePerformIO

2012-07-30 Thread Marco Túlio Gontijo e Silva
Hi. I'm having a problem calling logM from hsLogger inside unsafePerformIO. I have described the problem in Haskell-cafe, so I'll avoid repeating it here: http://www.haskell.org/pipermail/haskell-cafe/2012-July/102545.html I've had this problem both with GHC 7.4.1 and 7.4.2. Do you have any

Re: thread blocked indefinitely in an MVar operation in unsafePerformIO

2012-07-30 Thread Simon Marlow
On 30/07/2012 15:30, Marco Túlio Gontijo e Silva wrote: Hi. I'm having a problem calling logM from hsLogger inside unsafePerformIO. I have described the problem in Haskell-cafe, so I'll avoid repeating it here: http://www.haskell.org/pipermail/haskell-cafe/2012-July/102545.html I've had

Re: Strange performance effects with unsafePerformIO

2011-04-08 Thread Simon Marlow
On 07/04/2011 13:51, Björn Peemöller wrote: Simon Marlow schrieb: Incidentally this will be faster with GHC 7.2, because we implemented chunked stacks, so unsafePerformIO never has to traverse more than 32k of stack (you can tweak the chunk size with an RTS option). This is still quite a lot

Re: Strange performance effects with unsafePerformIO

2011-04-07 Thread Björn Peemöller
Simon Marlow schrieb: Incidentally this will be faster with GHC 7.2, because we implemented chunked stacks, so unsafePerformIO never has to traverse more than 32k of stack (you can tweak the chunk size with an RTS option). This is still quite a lot of overhead, but at least it is bounded

Re: Strange performance effects with unsafePerformIO

2011-03-25 Thread Sebastian Fischer
2011/3/25 Thomas Schilling nomin...@googlemail.com: unsafePerformIO traverses the stack to perform blackholing.  It could be that your code uses a deep stack and unsafePerformIO is repeatedly traversing it.  Just a guess, though. Sounds reasonable. Here is a variant of the program without

Re: Strange performance effects with unsafePerformIO

2011-03-25 Thread Simon Marlow
On 25/03/2011 08:56, Sebastian Fischer wrote: 2011/3/25 Thomas Schillingnomin...@googlemail.com: unsafePerformIO traverses the stack to perform blackholing. It could be that your code uses a deep stack and unsafePerformIO is repeatedly traversing it. Just a guess, though. Sounds reasonable

Strange performance effects with unsafePerformIO

2011-03-24 Thread Björn Peemöller
Hello, we have a strange performance behaviour when we use unsafePerformIO, at least with GHC 6.12.3 and 7.0.1. Please consider the example program following at the end of this post. Running the original code the execution time is about 26 seconds, while uncommenting one (or both

Re: Strange performance effects with unsafePerformIO

2011-03-24 Thread Thomas Schilling
unsafePerformIO traverses the stack to perform blackholing. It could be that your code uses a deep stack and unsafePerformIO is repeatedly traversing it. Just a guess, though. 2011/3/24 Björn Peemöller b...@informatik.uni-kiel.de: Hello, we have a strange performance behaviour when we use

Re: [Haskell-cafe] Space leak with unsafePerformIO

2010-07-01 Thread Simon Marlow
On 30/06/2010 18:13, Yitzchak Gale wrote: Henning Thielemann wrote on Haskell Cafe: Attached is a program with a space leak... I have coded a simple 'map' function, once using unsafePerformIO and once without. UnsafePerformIO has a space leak in some circumstances. In the main program I

Re: [Haskell-cafe] Space leak with unsafePerformIO

2010-06-30 Thread Yitzchak Gale
Henning Thielemann wrote on Haskell Cafe: Attached is a program with a space leak... I have coded a simple 'map' function, once using unsafePerformIO and once without. UnsafePerformIO has a space leak in some circumstances. In the main program I demonstrate cases with and without space leak

Re: What does unsafePerformIO do to the stack

2008-02-08 Thread Bernd Brassel
Simon Marlow wrote: Perhaps there are some trivial examples of unshared thunks that we could spot, though. The sharing analysis in the interpreter is also very simple and inexpensive. But the gain is frequent. Maybe giving it a try would be worthwhile. Thanks again for all your answers! Bernd

Re: What does unsafePerformIO do to the stack

2008-02-08 Thread Simon Marlow
removes them leaving you with O(1) stack again. The problem with unsafePerformIO was that the duplication-protection was interfering with stack squeezing. Regarding sharing analysis, we did used to have an update analyser in GHC, but it was expensive to run and rarely gave worthwhile benefits, so

Re: What does unsafePerformIO do to the stack

2008-02-07 Thread Bernd Brassel
I have got around the problem by defining my unsafe actions by the foreign function interface. But I still think there is a bug concerning stack use in unsafePerformIO in ghc. And I also think that this bug potentially concerns every use of unsafe. Or did I just not get the point of your argument

Re: What does unsafePerformIO do to the stack

2008-02-07 Thread Simon Marlow
x) --no stack overflow badStack x = unsafePerformIO (return x) --stack overflow fromJust (Just x) = x goodStack == id, and GHC even with no optimisation will transform it into id, and inline it into sim. So with goodStack, sim ends up being tail-recursive. With badStack, sim

Re: What does unsafePerformIO do to the stack

2008-02-07 Thread Bernd Brassel
Simon Marlow wrote: So the upshot is: you can use unsafeDupablePerformIO right now, or you can wait until I've tested and committed this patch to get tail-recursion with unsafePerformIO. Wow, thank you for the detailed answer! That was really interesting. I've no idea how it works in Hugs

Re: What does unsafePerformIO do to the stack

2008-02-07 Thread Bernd Brassel
There is another point that makes me wonder now. If the update frame for the recursive call is the problem then my solution with foreign C functions would produce a bad stack also. But this is not the case. The code looks now like this: sim [] = True sim (_:xs) = yags (sim xs) ref =

Re: What does unsafePerformIO do to the stack

2008-02-01 Thread Simon Marlow
Bernd Brassel wrote: Consider the following program: module Stack where import System.IO.Unsafe main = print (sim (replicate 1299959 ())) sim [] = True sim (_:xs) = goodStack (sim xs) goodStack x = fromJust (Just x) --no stack overflow badStack x = unsafePerformIO (return x

Re: What does unsafePerformIO do to the stack

2008-02-01 Thread Bernd Brassel
) --no stack overflow badStack x = unsafePerformIO (return x) --stack overflow fromJust (Just x) = x goodStack == id, and GHC even with no optimisation will transform it into id, and inline it into sim. So with goodStack, sim ends up being tail-recursive. With badStack, sim is no longer tail

What does unsafePerformIO do to the stack

2008-01-31 Thread Bernd Brassel
Consider the following program: module Stack where import System.IO.Unsafe main = print (sim (replicate 1299959 ())) sim [] = True sim (_:xs) = goodStack (sim xs) goodStack x = fromJust (Just x) --no stack overflow badStack x = unsafePerformIO (return x) --stack overflow

Prevent optimization from tempering with unsafePerformIO

2007-10-18 Thread Bernd Brassel
Hello to all who have given me hints an suggestions about this topic whether directly by mail or over the mailing list. I do now have a much more concrete idea of how to optimize my programs. Thanks for your time! Bernd ___ Glasgow-haskell-users mailing

Re: Prevent optimization from tempering with unsafePerformIO

2007-10-17 Thread Bernd Brassel
Hi Stefan! Thanks for your answer. Stefan O'Rear wrote: Might I suggest, that the problem is your use of unsafePerformIO? Yes you might. And you are surely right. But not using it in this way is not an alternative. why do you want to do this unsafely, instead of just using 'length

Prevent optimization from tempering with unsafePerformIO

2007-10-17 Thread Bernd Brassel
Hi David, thank you! This is really useful information! I think it's the let floating (out) together with common subexpression elimination: ghc --make -O2 -no-recomp -fno-cse -o curry-no-cse curry.hs [1 of 1] Compiling Main ( curry.hs, curry.o ) Linking curry-no-cse ...

Re: Prevent optimization from tempering with unsafePerformIO

2007-10-17 Thread Josef Svenningsson
On 10/17/07, Bernd Brassel [EMAIL PROTECTED] wrote: why do you want to do this unsafely, instead of just using 'length'? unsafePerformIO is a very slow function, remember) The big picture is that we generate programs like this example in order to compile the functional logic language

Re: Prevent optimization from tempering with unsafePerformIO

2007-10-17 Thread David Sabel
Hi Bernd, Bernd Brassel wrote: Hi David, thank you! This is really useful information! I think it's the let floating (out) together with common subexpression elimination: ghc --make -O2 -no-recomp -fno-cse -o curry-no-cse curry.hs [1 of 1] Compiling Main ( curry.hs,

RE: Prevent optimization from tempering with unsafePerformIO

2007-10-17 Thread Simon Peyton-Jones
I think you'll find it useful to be explicit about what you are relying on. For example I think that if your program contains two calls unsafePerformIO e1 unsafePerformIO e2 then * You don't care about the *order* in which these are performed * You do care that they are both

Prevent optimization from tempering with unsafePerformIO

2007-10-17 Thread Bernd Brassel
of the programs can run in a monad. This approach should be more robust than relying on unsafePerformIO. It is also very much in the spirit of your slogan. Thank you for the suggestion. We were thinking along the lines of identifying the purely functional parts and compile them directly to pure

Prevent optimization from tempering with unsafePerformIO

2007-10-17 Thread Bernd Brassel
I think you'll find it useful to be explicit about what you are relying on. Yes, good point. For example I think that if your program contains two calls unsafePerformIO e1 unsafePerformIO e2 then * You don't care about the *order* in which these are performed Right

Re: Prevent optimization from tempering with unsafePerformIO

2007-10-17 Thread Isaac Dupree
Bernd Brassel wrote: * I'm not sure if you care whether they are performed once or many times. E.g. f = \x. x + unsafePerformIO (h z) If the (h z) doesn't mention 'x', GHC will transform this to v = unsafePerformIO (h z) f = \x. x+v So now

Re: Prevent optimization from tempering with unsafePerformIO

2007-10-16 Thread Bernd Brassel
part --- (?) :: Bool' - Bool' - Bool' x ? y = Or (unsafeNextOrRef ()) [x,y] globalCounter :: IORef Int globalCounter = unsafePerformIO (newIORef 0) unsafeNextOrRef :: () - Int unsafeNextOrRef _ = unsafePerformIO $ do r - readIORef globalCounter writeIORef globalCounter (r+1

Re: Prevent optimization from tempering with unsafePerformIO

2007-10-16 Thread Bernd Brassel
Neil Mitchell schrieb: It varies by each piece of code, can you post a code fragment that gets optimised in the wrong way? Sorry for posting this twice! I have added the code to the other thread. Thanks! Bernd ___ Glasgow-haskell-users mailing list

Re: Prevent optimization from tempering with unsafePerformIO

2007-10-16 Thread David Sabel
Hi, I think it's the let floating (out) together with common subexpression elimination: ghc --make -O2 -no-recomp -fno-cse -o curry-no-cse curry.hs [1 of 1] Compiling Main ( curry.hs, curry.o ) Linking curry-no-cse ... ghc --make -O2 -no-recomp -fno-full-laziness -o

Re: Prevent optimization from tempering with unsafePerformIO

2007-10-16 Thread Stefan O'Rear
of unsafePerformIO? If you use unsafePerformIO in accordance with the rules listed in the specification (which happens to be the FFI addendum), -O options will have no effect. (Not that what you are trying to do is achievable with correct use of unsafePerformIO; why do you want to do this unsafely

Prevent optimization from tempering with unsafePerformIO

2007-10-15 Thread Bernd Brassel
Hello, I am writing a compiler from the functional logic language Curry to Haskell. As the result is a real extension of Haskell, there has to be SOME side effect involved. Unfortunately, this seems to prevent me from using any of ghc's optimizations on the resulting code. I have tried for some

Re: GHC -O2 and unsafePerformIO

2007-05-03 Thread Simon Marlow
Neil Mitchell wrote: Hi Thanks to dcoutts, I have now come up with an answer. I don't understand why it works now, but not before. I do remember than browsing either Core or STG is not a fun thing to do... p_System_IO_hGetChar h = trace i am here $ unsafePerformIO $ getCharIO h

Re: GHC -O2 and unsafePerformIO

2007-05-03 Thread Neil Mitchell
Hi Simon, This is clearly a misuse of unsafePerformIO (as I'm sure you're aware). Just out of interest - what's the context? I am writing an optimiser for Yhc, doing whole-program optimisation, with the intention of keeping it fast and high performance. Since writing out Yhc bytecode would

GHC -O2 and unsafePerformIO

2007-05-02 Thread Neil Mitchell
Data.Word import Debug.Trace main = p_System_IO_hGetChar 1 `seq` p_System_IO_hGetChar 2 `seq` putStrLn done {-# NOINLINE wrapIO #-} wrapIO x = unsafePerformIO (x = return) foreign import ccall stdio.h getchar getchar :: IO Word8 {-# NOINLINE p_System_IO_hGetChar #-} p_System_IO_hGetChar h = trace

Re: GHC -O2 and unsafePerformIO

2007-05-02 Thread Bulat Ziganshin
Hello Neil, Wednesday, May 2, 2007, 7:00:05 PM, you wrote: {-# NOINLINE wrapIO #-} wrapIO x = unsafePerformIO (x = return) -fno-cse ? it's usual company for unsafePerformIO+NOINLINE :) -- Best regards, Bulatmailto:[EMAIL PROTECTED

Re: GHC -O2 and unsafePerformIO

2007-05-02 Thread Neil Mitchell
Hi Bulat, Wednesday, May 2, 2007, 7:00:05 PM, you wrote: {-# NOINLINE wrapIO #-} wrapIO x = unsafePerformIO (x = return) -fno-cse ? it's usual company for unsafePerformIO+NOINLINE :) No luck, alas. A slightly tweaked version, which is slightly simpler and still gives the same behaviour

Re: GHC -O2 and unsafePerformIO

2007-05-02 Thread Neil Mitchell
Hi Thanks to dcoutts, I have now come up with an answer. I don't understand why it works now, but not before. I do remember than browsing either Core or STG is not a fun thing to do... p_System_IO_hGetChar h = trace i am here $ unsafePerformIO $ getCharIO h {-# NOINLINE getCharIO

Re: GHC -O2 and unsafePerformIO

2007-05-02 Thread Duncan Coutts
that p_System_IO_hGetChar 1 is a constant) the real problem is here: {-# NOINLINE p_System_IO_hGetChar #-} p_System_IO_hGetChar h = trace i am here $ unsafePerformIO $ getchar = \c - print c return (if c == (-1) then 0 else chr_ c) You've tried to trick ghc into always calling

Re: unsafePerformIO safety.

2007-03-07 Thread Lennart Augustsson
I wouldn't like if unsafePerformIO could never be inlined, sometimes you want it inlined for performance. And not all uses are hacky, it's just that when I use it, then burden is on me to convince myself that it is safe. On Mar 6, 2007, at 23:56 , Neil Mitchell wrote: Hi On 3/6/07

Re: unsafePerformIO safety.

2007-03-07 Thread Simon Marlow
Lennart Augustsson wrote: I wouldn't like if unsafePerformIO could never be inlined, sometimes you want it inlined for performance. And not all uses are hacky, it's just that when I use it, then burden is on me to convince myself that it is safe. unsafePerformIO is currently not inlined

Re: unsafePerformIO safety.

2007-03-07 Thread Isaac Dupree
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Simon Marlow wrote: You're right that sometimes you really want it to be inlined - this is why there's a function called inlinePerformIO in Data.ByteString.Base, for example. You'd better really know what you're doing before using that one,

unsafePerformIO safety.

2007-03-06 Thread David Brown
I've noticed quite a few pages referencing constructs such as: var :: MVar ([Foo]) var = unsafePerformIO (newMVar ([])) and the likes. Is there a danger of different uses of 'var' getting new MVars instead of all sharing one. Having a reliable way to create a piece of global state would

Re: unsafePerformIO safety.

2007-03-06 Thread Seth Kurtzberg
On Tue, 06 Mar 2007 12:03:05 -0800 David Brown [EMAIL PROTECTED] wrote: I've noticed quite a few pages referencing constructs such as: var :: MVar ([Foo]) var = unsafePerformIO (newMVar ([])) and the likes. Is there a danger of different uses of 'var' getting new MVars instead

Re: unsafePerformIO safety.

2007-03-06 Thread David Brown
Seth Kurtzberg wrote: On Tue, 06 Mar 2007 12:03:05 -0800 David Brown [EMAIL PROTECTED] wrote: I've noticed quite a few pages referencing constructs such as: var :: MVar ([Foo]) var = unsafePerformIO (newMVar ([])) and the likes. Is there a danger of different uses of 'var' getting

Re: unsafePerformIO safety.

2007-03-06 Thread Isaac Dupree
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 David Brown wrote: I've noticed quite a few pages referencing constructs such as: var :: MVar ([Foo]) var = unsafePerformIO (newMVar ([])) and the likes. Is there a danger of different uses of 'var' getting new MVars instead of all

Re: unsafePerformIO safety.

2007-03-06 Thread Lennart Augustsson
([Foo]) var = unsafePerformIO (newMVar ([])) and the likes. Is there a danger of different uses of 'var' getting new MVars instead of all sharing one. Having a reliable way to create a piece of global state would be very convenient. This operation is unsafe by definition. I use

Re: unsafePerformIO safety.

2007-03-06 Thread Neil Mitchell
Hi On 3/6/07, Lennart Augustsson [EMAIL PROTECTED] wrote: Yeah, you really need {-# NOINLINE var #-} to make it reasonable safe. Couldn't GHC bake in knowledge about unsafePerformIO, and never inline it? It is a slightly hacky solution, but since unsafePerformIO is pretty much only used

Re: unsafePerformIO safety.

2007-03-06 Thread David Brown
Neil Mitchell wrote: On 3/6/07, Lennart Augustsson [EMAIL PROTECTED] wrote: Yeah, you really need {-# NOINLINE var #-} to make it reasonable safe. Couldn't GHC bake in knowledge about unsafePerformIO, and never inline it? It is a slightly hacky solution, but since unsafePerformIO is pretty

RE: [Haskell] crash unsafeperformio stm

2006-07-14 Thread Simon Peyton-Jones
[Redirecting to GHC users] A crash is bad, and the HEAD reports an error in a civilised way. It is indeed illegal to use atomically inside an unsafePerformIO. I've also committed a fix to the documentation of atomically to mention this point. In general, the documentation of STM is very thin

Re: unsafePerformIO and NOINLINE Pragma

2005-09-14 Thread Jan Christiansen
Am Dienstag, 13. September 2005 16:13 schrieb David Sabel: Hi, Hi! I want to analyse the laziness of a data structure. To check how many nodes are constructed I use a global counter. counter :: IORef Int counter = unsafePerformIO (newIORef 0) This counter is increased every

unsafePerformIO and optimizations

2005-08-06 Thread Wolfgang Jeltsch
Hello, http://haskell.org/ghc/docs/latest/html/libraries/base/ System.IO.Unsafe.html#v%3AunsafePerformIO talks about what optimizations you should disable if you apply unsafePerformIO to an action which contains side effects. These are: * inlining of functions which call

STM and unsafePerformIO

2005-08-03 Thread Robert van Herk
Hello All, I think I've read somewhere that STM doesn't like unsafePerformIO. However, I would like to use a global STM variable. Something like this: *module* Main *where* import GHC.Conc import System.IO.Unsafe tSid = unsafePerformIO (atomically (newTVar 0)) tickSessionID :: STM Int

Re: STM and unsafePerformIO

2005-08-03 Thread Robert van Herk
Never mind, I can probably use an MVar to work around this... Robert Robert van Herk wrote: Hello All, I think I've read somewhere that STM doesn't like unsafePerformIO. However, I would like to use a global STM variable. Something like this: module Main where import GHC.Conc import

Re: STM and unsafePerformIO

2005-08-03 Thread Remi Turk
On Wed, Aug 03, 2005 at 12:50:54PM +0200, Robert van Herk wrote: Hello All, I think I've read somewhere that STM doesn't like unsafePerformIO. However, I would like to use a global STM variable. Something like this: module Main where import GHC.Conc import System.IO.Unsafe tSid

RE: STM and unsafePerformIO

2005-08-03 Thread Simon Marlow
On 03 August 2005 11:51, Robert van Herk wrote: I think I've read somewhere that STM doesn't like unsafePerformIO. However, I would like to use a global STM variable. Something like this: *module* Main *where* import GHC.Conc import System.IO.Unsafe tSid = unsafePerformIO (atomically

Re: STM and unsafePerformIO

2005-08-03 Thread Robert van Herk
Oh I see! Your sollutions are indeed a lot better than implementating all my code using MVars :-). Thanks, Robert Remi Turk wrote: On Wed, Aug 03, 2005 at 12:50:54PM +0200, Robert van Herk wrote: Hello All, I think I've read somewhere that STM doesn't like unsafePerformIO. However, I

Re: unsafePerformIO

2004-04-08 Thread George Russell
Sven Panne wrote: Huh? I'm not sure what you mean exactly, but with the help of unsafePerformIO and a pragma for clever compilers you can simulate something like a global variable in Haskell. Here an excerpt from the GLUT menu handling module: {-# NOINLINE theMenuTable #-} theMenuTable

RE: unsafePerformIO and IORefs

2002-11-19 Thread Simon Marlow
Hal Daume III wrote: You can't. [...] Well, you can, but only for CAFs. This idiom/hack is used quite happily throughout GHC, HOpenGL, H/Direct, ... I think quite happily is a bit strong ;-) We'd much rather have a safe way to do what is really quite a reasonable thing. Cheers,

unsafePerformIO and IORefs

2002-11-18 Thread Nicolas Oury
I want to write something like type State a = IORef a newState :: a - State a newState v = unsafePerformIO (newIORef v) But I don't want the compileer to inline this nor to inline any application of this. {#NOINLINE newState#} But how can I stop this function to be inlined when applied

Re: unsafePerformIO and IORefs

2002-11-18 Thread Sven Panne
:-) global :: a - IORef a global a = unsafePerformIO (newIORef a) #define GLOBAL_VAR(name,value,ty) \ name :: IORef (ty) ; \ name = global (value) ; \ {-# NOINLINE name #-} -- examples

Re: unsafePerformIO and IORefs

2002-11-18 Thread Michael Weber
]% grep global ghc/compiler/utils/Util.lhs , global global :: a - IORef a global a = unsafePerformIO (newIORef a) [233]% ghc/compiler/HsVersions.h: [...] #ifdef __GLASGOW_HASKELL__ #define GLOBAL_VAR(name,value,ty) \ name = Util.global (value) :: IORef (ty); \ {-# NOINLINE name #-} #endif

Re: Optimisation and unsafePerformIO

2002-10-30 Thread David Sabel
- Original Message - From: Albert Lai [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, October 30, 2002 7:35 AM Subject: Re: Optimisation and unsafePerformIO David Sabel [EMAIL PROTECTED] writes: {-# NOINLINE b #-} b x = if even x then unsafePerformIO getChar else

Re: Optimisation and unsafePerformIO

2002-10-29 Thread Albert Lai
David Sabel [EMAIL PROTECTED] writes: {-# NOINLINE b #-} b x = if even x then unsafePerformIO getChar else bot bot = bot main = do putChar (b 4) putChar (b 6) I am not a compiler implementer (or lawyer, for that matter :) But I propose this guess. First, both even

RE: Optimisation and unsafePerformIO

2002-10-28 Thread Simon Marlow
Consider the following program: - {-# NOINLINE b #-} b x = if even x then unsafePerformIO getChar else bot bot = bot main = do putChar (b 4) putChar (b 6) - when you compile the programm

Re: Optimisation and unsafePerformIO

2002-10-28 Thread David Sabel
Of course, I used unsafePerformIO in an unsafe way! I'm thinking about a way to make unsafePerformIO safe. Therefore the compiler can't do any transformation the ghc does and I want to locate these transformations. - Original Message - From: Simon Marlow [EMAIL PROTECTED] To: David Sabel

Optimisation and unsafePerformIO

2002-10-27 Thread David Sabel
Consider the following program: - {-# NOINLINE b #-} b x = if even x then unsafePerformIO getChar else bot bot = bot main = do putChar (b 4) putChar (b 6) - when you compile the programm with the options: -O0

Re: unsafePerformIO

2002-10-09 Thread David Sabel
- Original Message - From: Simon Marlow [EMAIL PROTECTED] Sent: Tuesday, September 24, 2002 2:58 PM Subject: RE: unsafePerformIO [...] As for sharing, we currently don't provide any guarnatees, although we should. It is currently the case that if you write a = unsafePerformIO

RE: unsafePerformIO

2002-09-24 Thread Simon Peyton-Jones
The actions performed by unsafePerformIO are simply done at some entirely unpredictable time, perhaps interleaved with actions on the main execution path. The formal semantics in the notes doesn't have a good way to express that because the purely-functional part is given a denotational

RE: unsafePerformIO

2002-09-24 Thread Koen Claessen
Simon Peyton-Jones wrote: | The actions performed by unsafePerformIO are simply | done at some entirely unpredictable time, perhaps | interleaved with actions on the main execution path. But it is a fact that many of us have at least some idea of what happens under the hood when we use

RE: unsafePerformIO

2002-09-24 Thread Simon Marlow
But it is a fact that many of us have at least some idea of what happens under the hood when we use unsafePerformIO. This is also described in your paper Stretching the storage manager: weak pointers and stable names in Haskell. However, I for example have no idea what happens when

RE: unsafePerformIO

2002-09-24 Thread Simon Peyton-Jones
Koen Based on this info, how would you like to write the notes you would like to see on unsafePerformIO? The starting point is at http://haskell.cs.yale.edu/ghc/docs/latest/html/base/GHC.IOBase.html#uns afePerformIO If you write the notes, we'll check their veracity and add them. We'll do

Re: unsafePerformIO

2002-09-24 Thread Alastair Reid
different behaviour between Hugs and GHC when using unsafePerformIO with threads and exceptions. The Hugs version of unsafePerformIO isn't intended to receive as much abuse as the GHC version whereas the GHC version has been (ab)used by large numbers of people. -- Alastair

unsafePerformIO

2002-09-20 Thread David Sabel
In read your paper Tackling the Awkward Squad: monadic input / output, concurrency, exceptions, and foreign-language calls in Haskell, and have a question about unsafePerformIO. In your operational semantic of the IO-Monad you tell nothing about, how 'unsafe' IO actions are performed

Re: unsafePerformIO

2002-09-20 Thread Hal Daume III
I'm not sure of a reference, the basic idea is this: IO a is represented by the pair (RealWorld, a) (unboxed, really but whatever) When an IO action is run (via main), a RealWorld state is provided by the compiler and passes it around. When you do unsafePerformIO, the compiler

RE: unsafePerformIO around FFI calls

2002-07-09 Thread Simon Marlow
Hal Daume [EMAIL PROTECTED] writes: I'm curious exactly what is safe and what is unsafe to wrap unsafePerformIO around when it comes to FFI calls. Here's a simple test: Could you imagine an alternative implementation of the same API in pure Haskell? (Don't consider efficiency

Re: unsafePerformIO around FFI calls

2002-07-09 Thread Alastair Reid
That's a nice succinct way to describe it. Another way, which boils down to the same thing but which is a little more concrete, is to ask: - Does the function's result depend only on the values of its arguments? I have two problems with this alternative test: 1) It is sometimes

RE: unsafePerformIO around FFI calls

2002-07-09 Thread Simon Marlow
a function which uses some temporary allocation on the C heap as safe to use from unsafePerformIO. But its side effect is visible from the IO monad by inspecting the C heap pointer. Cheers, Simon ___ Glasgow-haskell-users mailing list [EMAIL

unsafePerformIO around FFI calls

2002-07-08 Thread Hal Daume III
I'm curious exactly what is safe and what is unsafe to wrap unsafePerformIO around when it comes to FFI calls. If there's a general discussion of this somewhere and someone could send me a pointer that would be another acceptable solution. I googled for unsafePerformIO FFI but nothing relevant

Re: unsafePerformIO around FFI calls

2002-07-08 Thread Alastair Reid
Hal Daume [EMAIL PROTECTED] writes: I'm curious exactly what is safe and what is unsafe to wrap unsafePerformIO around when it comes to FFI calls. Here's a simple test: Could you imagine an alternative implementation of the same API in pure Haskell? (Don't consider efficiency or effort

RE: unIO vs. unsafePerformIO

2002-02-01 Thread Simon Marlow
What's the difference between unIO and unsafePerformIO? And why is the former safe? (I would like to apply the same questions to unsafeIOToST and ioToST) unIO is an internal function used in GHC's libraries, it is not for external consumption. GHC represents the IO type using newtype

unIO vs. unsafePerformIO

2002-01-31 Thread Andre W B Furtado
What's the difference between unIO and unsafePerformIO? And why is the former safe? (I would like to apply the same questions to unsafeIOToST and ioToST) Thanks, -- Andre ___ Glasgow-haskell-users mailing list [EMAIL PROTECTED] http://www.haskell.org