Re: [Haskell-cafe] Code generation and optimisation for compiling Haskell
On 1/12/12 8:50 PM, Jason Dagit wrote: On Tue, Jan 10, 2012 at 9:25 AM, Steve Horne wrote: Also, what papers should I read? Am I on the right lines with the ones I've mentioned above? Thomas Schilling gave you a good response with papers so I will give you a different perspective on where to look. Most of the Haskell implementations were written by academics studying languages and compilers. This is good but it also implies that the implementors are likely to share biases and assumptions. I know of one Haskell compiler in particular that was written by someone who did not know Haskell when starting the project. The compiler was developed to be different than GHC. That person was John Meacham. He created JHC, a work in progress, so you might want to study his compiler and implementation notes as they should provide a different perspective on how to tackle Haskell implementation and optimization. http://repetae.net/computer/jhc/ JHC is also notable as a point of contrast because GHC strives to have a uniform representation in order to simplify adding high-level optimizations, whereas JHC is especially focused on the low-level optimizations obtainable by using non-uniform representations. More and more of these representational issues have been creeping into GHC over the years, so you should definitely take a look at JHC to get a different perspective on the space of possibilities than just those illuminated by the trajectory of GHC. On the other end of things, if your heart lies in the compiler itself rather than the generated code per se, you should definitely take a look at UHC. We often talk about "Haskell" as if it were a language, when in fact it is a family of related languages with subtly different features and properties. One of the principal goals of EHC/UHC is to design a compiler as a series of small passes in order to better disentangle the issues surrounding trying to compile an entire family of languages. They also have some novel code for dealing with the parsing end of the compiler, which is worth exploring separately from the overall design. -- Live well, ~wren ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] LDAP hackage problem.
Hi, I have a Windows AD server. And ldapsearch tool works to get someone's information. But when I turned it into Haskell code. It does not work as expected. Here is the ldapsearch and result. You can see that sn/givenName have values that are encoded utf-8. Next to it is the code I am using. Running this code returns the similar thing. The problem is that only sn/givenName/displayName are empty. I have tried a few diag ways trying to find out why. No luck. $ ldapsearch -h vancloa.cn -D CN=wangshida.admin,OU=admin_accounts,DC=vancloa,DC=cn -w -b "DC=vancloa,DC=cn" -x '(&(sAMAccountName=chengtao)(&(objectClass=user)(!(ou=Recycle_Bin' # extended LDIF # # LDAPv3 # base with scope subtree # filter: (&(sAMAccountName=chengtao)(&(objectClass=user)(!(ou=Recycle_Bin # requesting: ALL # # 000634, Employees_Accounts, vancloa.cn dn: CN=000634,OU=Employees_Accounts,DC=vancloa,DC=cn objectClass: top objectClass: person objectClass: organizationalPerson objectClass: user cn: 000634 sn:: 56iL c: CN title:: 5oqA5pyv5pSv5oyB5bel56iL5biI description: 000634 physicalDeliveryOfficeName:: 5oiQ6YO95LuT5YKo givenName:: 5rab distinguishedName: CN=000634,OU=Employees_Accounts,DC=vancloa,DC=cn instanceType: 4 whenCreated: 20101231073752.0Z whenChanged: 20120106005157.0Z displayName:: 56iL5rab # search reference ref: ldap://ForestDnsZones.vancloa.cn/DC=ForestDnsZones,DC=vancloa,DC=cn # search reference ref: ldap://DomainDnsZones.vancloa.cn/DC=DomainDnsZones,DC=vancloa,DC=cn # search reference ref: ldap://vancloa.cn/CN=Configuration,DC=vancloa,DC=cn # search result search: 2 result: 0 Success # numResponses: 5 # numEntries: 1 # numReferences: 3 6|main :: IO () 7|main = do 8| args <- getArgs 9| let alias = head args 10| putStrLn alias 11| entries <- failLDAP $ do 12|ldap <- ldapOpen "vancloa.cn" 389 13|ldapSimpleBind ldap "CN=wangshida.admin,OU=admin_accounts,DC=vancloa,DC=cn" "" 14|ldapSearch ldap (Just "DC=vancloa,DC=cn") LdapScopeSubtree (Just ("(&(sAMAccountName=" ++ alias ++ ")(&(objectClass=user)(!(ou=Recycle_Bin"\ )) LDAPAllUserAttrs False --(LDAPAttrList ["sn", "givenname"]) False 15| let LDAPEntry _ attrs = head entries 16| sn = head $ snd $ head $ filter (\(a, _) -> a == "sn") attrs 17| givenName = head $ snd $ head $ filter (\(a, _) -> a == "givenName") attrs 18| print entries -- 竹密岂妨流水过 山高哪阻野云飞 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Code generation and optimisation for compiling Haskell
On Tue, Jan 10, 2012 at 9:25 AM, Steve Horne wrote: > Also, what papers should I read? Am I on the right lines with the ones I've > mentioned above? Thomas Schilling gave you a good response with papers so I will give you a different perspective on where to look. Most of the Haskell implementations were written by academics studying languages and compilers. This is good but it also implies that the implementors are likely to share biases and assumptions. I know of one Haskell compiler in particular that was written by someone who did not know Haskell when starting the project. The compiler was developed to be different than GHC. That person was John Meacham. He created JHC, a work in progress, so you might want to study his compiler and implementation notes as they should provide a different perspective on how to tackle Haskell implementation and optimization. http://repetae.net/computer/jhc/ I hope that helps, Jason ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] STM: "nested atomically" error
On Thu, Jan 12, 2012 at 22:56, Brandon Allbery wrote: > On Thu, Jan 12, 2012 at 16:50, Andrew Coppin > wrote: >> >> My guess is that your "debug printing" is causing something to be >> evaluated when it otherwise wouldn't be, causing a transaction to begin >> within a transaction. > > > My guess is something is being lazily evaluated as usual, but if that is > forced within a transaction, well, last I checked the GHC I/O system used > STM internally so unsafePerformIO debug prints could well cause nested > transactions. > This could be it. If I'm computing a value atomically and then using this value in another transaction, I may nest transactions if the value isn't forced? x <- atomically $ foo let x' = someOp x atomically $ bar x' Is it necessary to use seq here, or is it merely the debug printing that's getting in the way? Also, if the GHC IO system is using STM internally, what would be the correct way to say write a file? (where the IO action can be retried safely but have to run at least once, idempotent?). Please don't say "don't" :-) -- Johan Brinch ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Code generation and optimisation for compiling Haskell
On 11/01/2012 15:20, Thomas Schilling wrote: Based on your stated background, the best start would be the (longer) paper on the Spineless Tagless G-machine [1]. Thanks for the tips. I haven't read much yet, but considering [1], I guess I shouldn't have dismissed SPJs early 90's stuff so quickly. Should be interesting. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] STM: "nested atomically" error
On Thu, Jan 12, 2012 at 7:48 AM, Johan Brinch wrote: > Hi all, > > I'm seeing the "Control.Concurrent.STM.atomically was nested" error, > but I just can't figure out what's happening. I'm not using any unsafe > IO (only for debug printing), and the test program is only running one > thread. Where is a transaction being nested? > > What are the scenarios where this error is reported? I might as well state the obvious. The type system prevents this from happening under normal circumstances. However, it is possible to circumvent the type system using, for example, unsafePerformIO or unsafeInterleaveIO: nest1 :: IO () nest1 = let x = unsafePerformIO $ atomically $ return () in atomically (x `seq` return ()) nest2 :: IO () nest2 = do x <- unsafeInterleaveIO $ atomically $ return () atomically (x `seq` return ()) In both nest1 and nest2, x is a thunk whose evaluation performs an STM transaction. In both cases, this produces an "atomically was nested" error. On GHC, the Debug.Trace functions internally call a C function called debugBelch (defined in RtsMessages.c). These don't appear to use 'atomically' at all. Thus, I doubt using trace will produce an "atomically was nested" error. - Joey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Unboxed Rationals?
On 12/01/2012, at 21:01, Artyom Kazak wrote: > Yves Parès писал(а) в своём письме Thu, 12 Jan 2012 > 13:14:16 +0200: > >> uvector is deprecated, its functionnalities has been ported into vector. > > Yes, but a Ratio a instance hasn't been ported. FWIW, vector isn't a port of uvector in any sense, shape or form. Rather, uvector was a fork of a very old version of an internal DPH package, whereas vector is a from-scratch implementation of arrays based on the experience gained while working on DPH. Vector is an open-source project and has a trac. If you need something, open a ticket or better yet, send me patches! Emails sometimes work, too :-) Roman ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] STM: "nested atomically" error
On Thu, Jan 12, 2012 at 16:50, Andrew Coppin wrote: > My guess is that your "debug printing" is causing something to be > evaluated when it otherwise wouldn't be, causing a transaction to begin > within a transaction. > My guess is something is being lazily evaluated as usual, but if that is forced within a transaction, well, last I checked the GHC I/O system used STM internally so unsafePerformIO debug prints could well cause nested transactions. -- brandon s allbery allber...@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] STM: "nested atomically" error
On 12/01/2012 12:48 PM, Johan Brinch wrote: I'm not using any unsafe IO OK, good... (only for debug printing) ...ah. It seems we have reached a contradiction. Where is a transaction being nested? My guess is that your "debug printing" is causing something to be evaluated when it otherwise wouldn't be, causing a transaction to begin within a transaction. I could, however, be horribly wrong about that... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Spurious pattern match warnings with GADTs
Type classes are open, so nothing prevents someone from adding an instance 'C0 T1' and calling 't' with constructor 'B', causing a crash due to the missing pattern. Erik On Thu, Jan 12, 2012 at 21:40, Tom Hawkins wrote: > Let's say I have: > > data T0 > data T1 > > data T a where > A :: T T0 > B :: T T1 > > Then I can write the following without getting any non-exhaustive > pattern match warnings: > > t :: T T0 -> String > t a = case a of > A -> "A" > > However, if I use type classes to constrain the constructors, instead > of using the phantom types directly: > > class C0 a > instance C0 T0 > > class C1 a > instance C1 T1 > > data T a where > A :: C0 a => T a > B :: C1 a => T a > > Then I get a non-exhaustive pattern match warning on 't'. How come? > (I'm using GHC 7.0.4) > > It appears that the intelligent pattern analysis of the first example > is a relatively recent addition [1]. > > -Tom > > [1] http://hackage.haskell.org/trac/ghc/ticket/3476 > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Spurious pattern match warnings with GADTs
Type classes are inherently open. The compiler uses only the facts that there ARE some instances of the classes it needs, but it doesn't attempt to use information that some types AREN'T instances of certain classes. So, it can't use information that T0 isn't an instance of C1. And that's right thing to do — it could happen that there is "instance C1 T0" in another module, which imports this one. On 13 Jan 2012, at 00:40, Tom Hawkins wrote: > Let's say I have: > > data T0 > data T1 > > data T a where > A :: T T0 > B :: T T1 > > Then I can write the following without getting any non-exhaustive > pattern match warnings: > > t :: T T0 -> String > t a = case a of > A -> "A" > > However, if I use type classes to constrain the constructors, instead > of using the phantom types directly: > > class C0 a > instance C0 T0 > > class C1 a > instance C1 T1 > > data T a where > A :: C0 a => T a > B :: C1 a => T a > > Then I get a non-exhaustive pattern match warning on 't'. How come? > (I'm using GHC 7.0.4) > > It appears that the intelligent pattern analysis of the first example > is a relatively recent addition [1]. > > -Tom > > [1] http://hackage.haskell.org/trac/ghc/ticket/3476 > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Spurious pattern match warnings with GADTs
Let's say I have: data T0 data T1 data T a where A :: T T0 B :: T T1 Then I can write the following without getting any non-exhaustive pattern match warnings: t :: T T0 -> String t a = case a of A -> "A" However, if I use type classes to constrain the constructors, instead of using the phantom types directly: class C0 a instance C0 T0 class C1 a instance C1 T1 data T a where A :: C0 a => T a B :: C1 a => T a Then I get a non-exhaustive pattern match warning on 't'. How come? (I'm using GHC 7.0.4) It appears that the intelligent pattern analysis of the first example is a relatively recent addition [1]. -Tom [1] http://hackage.haskell.org/trac/ghc/ticket/3476 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] named pipe interface
Quoth "Serge D. Mechveliani" , > (I wonder: is this for beginn...@haskell.org ?) No, not really! As already mentioned, the use of UnsafePerformIO goes a little beyond what I think is its intended purpose, and I think you might have better luck here with a test program that illustrates the problem and doesn't depend on that. But while you're looking into that ... you might be interested to know that there's a problem with named pipes in GHC (beyond the problems that afflict anyone who tries to work with named pipes.) GHC I/O routinely sets file descriptors to non-blocking, unlike the IO libraries for C and other languages, and this could add to your troubles with named pipes. You can read up on that and possibly find clues to the present problem. Donn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Unboxed Rationals?
Yves Parès писал(а) в своём письме Thu, 12 Jan 2012 13:14:16 +0200: uvector is deprecated, its functionnalities has been ported into vector. Yes, but a Ratio a instance hasn't been ported. I admit that I have overlooked the “deprecated” warning, and agree that it is better to write an instance by yourself than use a deprecated package. Dead things should stay dead. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] named pipe interface
On 01/12/2012 07:53 PM, Serge D. Mechveliani wrote: [...] > For the "to-A" part writen in C (instead of Haskell), this interface loop works all right. With Haskell, I manage to process only a single string in the loop, and then it ends with an error. Main.hs is given below. I never dealt with such an IO in Haskell. Can you, please, fix the code or give comments? Please, copy the response to mech...@botik.ru (I am not in the list). [...] --- import System.IO (IOMode(..), IO(..), Handle, openFile, hPutStr, hGetLine, hFlush) import System.IO.Unsafe (unsafePerformIO) dir = showString "/home/mechvel/ghc/axiomInterface/byLowerLevel/" toA_IO = openFile (dir "toA") WriteMode:: IO Handle fromA_IO = openFile (dir "fromA") ReadMode -- used as global values toA = unsafePerformIO toA_IO -- fromA = unsafePerformIO fromA_IO -- axiomIO :: String -> IO String axiomIO str = do hPutStr toA str hFlush toA hGetLine fromA axiom :: String -> String -> String axiom str = showString (unsafePerformIO $ axiomIO str) -- Examples of usage tl;dr, but did you try to write your program without using unsafePerformIO? It's "considered harmful" for a reason. Cheers, Steffen ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] named pipe interface
People, (I wonder: is this for beginn...@haskell.org ?) I need to organize a string interface for a Haskell function Main.axiom and a C program fifoFromA.c via a pair of named pipes (in Linux, UNIX). The pipes are created before running, by the commands > mkfifo toA > mkfifo fromA Main.axiom outputs a string to toA and inputs the respond string from fromA as the result. fifoFromA inputs a string from toA, converts it to the string resStr, outputs resStr to fromA. Main.axiom must be able to be applied in a loop, and there must be avoided repeated opening of a file/channel in a loop. As an example, the string conversion in fifoFromA.c is put the conversion of each character to the lower case: -- fifoFromA.c -- #include #include #include #define BOUND 64 int main() { int toA, fromA, i, numread; char buf[BOUND]; toA = open("toA", O_RDONLY); fromA = open("fromA", O_WRONLY); for (;;) { numread = read(toA, buf, BOUND); buf[numread] = '\0'; // printf("A: Read from toA: %s\n", buf); i = 0; // convert the string to the lower case while (i < numread) {buf[i] = tolower(buf[i]); i++;} write(fromA, buf, strlen(buf)); } } --- For the "to-A" part writen in C (instead of Haskell), this interface loop works all right. With Haskell, I manage to process only a single string in the loop, and then it ends with an error. Main.hs is given below. I never dealt with such an IO in Haskell. Can you, please, fix the code or give comments? Please, copy the response to mech...@botik.ru (I am not in the list). Thank you in advance for your notes, -- Sergei mech...@botik.ru --- import System.IO (IOMode(..), IO(..), Handle, openFile, hPutStr, hGetLine, hFlush) import System.IO.Unsafe (unsafePerformIO) dir = showString "/home/mechvel/ghc/axiomInterface/byLowerLevel/" toA_IO = openFile (dir "toA") WriteMode:: IO Handle fromA_IO = openFile (dir "fromA") ReadMode -- used as global values toA = unsafePerformIO toA_IO -- fromA = unsafePerformIO fromA_IO -- axiomIO :: String -> IO String axiomIO str = do hPutStr toA str hFlush toA hGetLine fromA axiom :: String -> String -> String axiom str = showString (unsafePerformIO $ axiomIO str) -- Examples of usage -- main = putStr (axiom "ABC1" "\n")-- I -- putStr (axiom "ABC1" $ showChar '\n' $ axiom "ABC2" "\n") -- II {- III: putStr (shows resPairs "\n") where n= 9000 str0 = "ABC" strings = [str0 ++ (show i) | i <- [1 .. n]] resPairs = [(str, axiom str "") | str <- strings] -} - I use Glasgow Haskell ghc-7.01. Build:> gcc -o fifoFromA fifoFromA.c > ghc --make Main Running: first, command > ./fifoFromA on terminal-2, then command > ./Main on terminal-1. Now, the example (I) works -- in the sense that terminal-1 shows the result "abc1" after the program on terminal-2 is interrupted. II and III do not work. And the aim is the examples like III. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to terminate the process group of a process created with createProcess?
Hello, On 12.01.2012 at 17:00 Brandon Allbery wrote: > > I need to go look at the implementation of System.Process, though; the > documentation strongly implies that (a) it already creates a process group, System.Process-1.1.0.0 introduces the new field "create_group :: Bool" in the datatype CreateProcess, which ensures that the process (and its children) is spawned in an new process group. > but the documentation for interruptProcessGroupOf is correct. Maybe that > function will work for you? This function is also in System.Process-1.1.0.0 and does indeed, what i want to do! > In any case, I would not mix System.Process and System.Posix.Process. I'd > probably use the latter, but that's because it's closer to what I'm used to > as a Unix/SVID/POSIX programmer. I thought so, but the means justified the ends (for me , in this case). But now i don't need System.Posix.Process at all, since all i need is provided by the new System.Process-1.1.0.0. Thank you for pointing out the function "interruptProcessGroupOf" which lead me to this new version of System.Process. Kind regards, André ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to terminate the process group of aprocesscreated with createProcess?
Quoth Brandon Allbery , > On Thu, Jan 12, 2012 at 06:56, André Scholz > wrote: > >>gid <- createProcessGroup pid >> >> but i get the error message: >> "createProcessGroup: permission denied" > the documentation for terminateProcess is incorrect and should not > mention process groups Right - and terminateProcess should _not_ be fixed to work like the documentation says! I think it's just a point of confusion over how the shell works - in fact, process groups are normally created by the shell, but only when it's serving as the top level interactive shell. > In any case, I would not mix System.Process and System.Posix.Process. I'd > probably use the latter, but that's because it's closer to what I'm used to > as a Unix/SVID/POSIX programmer. Same here, and in any case I don't expect there's any way to do this with System.Process, i.e., portably on non-UNIX platforms. In the System.Posix.Process variant, you get to use "fork" directly: spawn :: String -> [String] -> IO ProcessID spawn exe cmd = forkProcess $ executeFile exe False cmd Nothing To set the process group, spawnpg exe cmd = forkProcess $ do getProcessID >>= joinProcessGroup -- equivalent to setpgrp() executeFile exe False cmd Nothing ... to terminate the process group, signalProcessGroup sigTERM pid ... and wait for the spawned process getProcessStatus True False pid When you're running Haskell in the child fork like this, you could run afoul of runtime thread support, and depending on your situation it might make sense to move the fork/setpgrp/exec out into a C function to avoid that. Donn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to terminate the process group of a processcreated with createProcess?
On Thu, Jan 12, 2012 at 06:56, André Scholz wrote: >gid <- createProcessGroup pid > > but i get the error message: > "createProcessGroup: permission denied" > It's only going to work on BSDish systems; on systems using the SVID/POSIX model, only the current process can be converted into a process group leader, and only if it isn't already one. I need to go look at the implementation of System.Process, though; the documentation strongly implies that (a) it already creates a process group, at least on UNIX (there's an additional step needed to do so on Windows?) and (b) terminateProcess is claimed to signal the process group, as is interruptProcessGroupOf (the documentation is clearer here). [[Having looked: the documentation for terminateProcess is incorrect and should not mention process groups, but the documentation for interruptProcessGroupOf is correct. Maybe that function will work for you?]] In any case, I would not mix System.Process and System.Posix.Process. I'd probably use the latter, but that's because it's closer to what I'm used to as a Unix/SVID/POSIX programmer. -- brandon s allbery allber...@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANNOUNCE: quickcheck-instances
Hello! I'd like to announce the first release of the quickcheck-instances package, which aims to consolidate commonly needed class instances for use with QuickCheck. These instances are appropriate when your tests don't have strong requirements on the nature of the input data - for example, if you are testing a network-protocol parser, the ByteString instance provided in this package might not be what you want to use. Other limitations: * I do not have full coverage of the Haskell Platform - I have been adding instances as I need them. Patches are warmly welcomed, however. * I only have instances of the 'Arbitrary' class, however I would be happy to accept patches for instances of CoArbitrary and other classes that would be useful in quickcheck-based testing. On Hackage: http://hackage.haskell.org/package/quickcheck-instances Ordinarily I frown on orphaned instances in library packages, but the fact that quickcheck properties should never appear in a library Cabal package, most of the downsides of orphans are mitigated. Thanks, Antoine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] STM: "nested atomically" error
On Thu, Jan 12, 2012 at 14:56, Antoine Latter wrote: > Where is 'evalCacheSTM' defined? Here you go: https://gist.github.com/8dbff672a14533c70aa2 -- Johan Brinch ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] STM: "nested atomically" error
On Thu, Jan 12, 2012 at 6:48 AM, Johan Brinch wrote: > Hi all, > > I'm seeing the "Control.Concurrent.STM.atomically was nested" error, > but I just can't figure out what's happening. I'm not using any unsafe > IO (only for debug printing), and the test program is only running one > thread. Where is a transaction being nested? > > What are the scenarios where this error is reported? > Where is 'evalCacheSTM' defined? > The behaviour is consistent on GHC 7.4.0 RC and GHC 7.2.2 (stable). > > That function that's being run can be found here: > https://gist.github.com/30b94760abc27b05ec7c > > And here is the last output from the runtime system: > https://gist.github.com/4356ae541895becb4169 > > > Any ideas to track this down will be greatly appreciated! > > -- > Johan Brinch, > Dept. of Computer Science, > University of Copenhagen > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Well-Typed are hiring: Haskell consultant
In order to keep up with customer demand, we are looking to hire a Haskell expert to work with us at Well-Typed (http://www.well-typed.com/) as a Haskell consultant. This is an exciting opportunity for someone who is passionate about Haskell and who is keen to improve and promote Haskell in a professional context. The role is quite general and could cover any of the projects and activities that we are involved in as a company. The tasks may involve: * working on the Haskell compilers, libraries and tools; * Haskell application development; * working directly with clients to solve their problems. Well-Typed has a variety of clients. For some we do proprietary Haskell development and consulting. For others, much of the work involves open-source development and cooperating with the rest of the Haskell community: the commercial, open-source and academic users. At the moment, we are running the Parallel GHC Project (http://www.haskell.org/haskellwiki/Parallel_GHC_Project/). It is likely that initial tasks will have some connection with parallel and/or concurrent programming in Haskell. We are also doing quite a bit of GHC maintenance, and some knowledge or interest in compiler internals, operating systems, the foreign language interface, and/or deployment issues would be welcome. Our ideal candidate has excellent knowledge of Haskell, whether from industry, academia, or personal interest. Familiarity with other languages, low-level programming, and good software engineering practices are also useful. Good organisation and ablity to manage your own time, and reliably meet deadlines, is important. You are likely to have a batchelor's degree or higher in computer science or a related field, although this isn't a requirement. Experience of consulting, or running a business, is also a bonus. The position is initially as a contractor for one year with a salary of 150 GBP per day. We offer flexible hours and work from home. Living in England is not required. In the longer term there is the opportunity to become a member of the partnership with a full stake in the business: being involved in business decisions, and fully sharing the risks and rewards. If you are interested, please apply via i...@well-typed.com. Tell us why you are interested and why you would be a good fit for the job, and attach your CV. Please also indicate when you might be able to start. We are more than happy to answer informal enquiries. Contact Duncan Coutts, Ian Lynagh or Andres Löh (http://www.well-typed.com/who_we_are/) for further information, either by email or IRC. The deadline for applications is Friday 27th January 2012. == About Well-Typed Well-Typed LLP is a Haskell services company, providing consultancy services, writing bespoke applications, and offering commercial training in Haskell and related topics. -- Andres Löh, Haskell Consultant Well-Typed LLP, http://www.well-typed.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] STM: "nested atomically" error
Hi all, I'm seeing the "Control.Concurrent.STM.atomically was nested" error, but I just can't figure out what's happening. I'm not using any unsafe IO (only for debug printing), and the test program is only running one thread. Where is a transaction being nested? What are the scenarios where this error is reported? The behaviour is consistent on GHC 7.4.0 RC and GHC 7.2.2 (stable). That function that's being run can be found here: https://gist.github.com/30b94760abc27b05ec7c And here is the last output from the runtime system: https://gist.github.com/4356ae541895becb4169 Any ideas to track this down will be greatly appreciated! -- Johan Brinch, Dept. of Computer Science, University of Copenhagen ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to terminate the process group of a processcreated with createProcess?
On 11.01.2012 at 23:08 Donn Cave wrote: > Quoth Brandon Allbery , > ... > > > terminateProcess passes on the semantics of kill(2); on SVID-compliant > > (and I think POSIX.1-compliant) systems, the negative of the process > > group leader's process ID is used to signal the process group. Note > > that you may need to arrange for your initial child process to invoke > > setpgrp() to insure that the parent program is not part of the process > > group. > > ... and that stuff can be found in System.Posix.Process. Support for > POSIX killpg can be found in System.Posix.Signals, by the way in case > you think that would make your intention more transparent. I tried: import System.Posix.Process import System.Posix.Signals import System.Process import System.Process.Internals terminateProcessGroup :: ProcessHandle -> IO () terminateProcessGroup ph = do let (ProcessHandle pmvar) = ph ph_ <- readMVar pmvar case ph_ of OpenHandle pid -> do -- pid is a POSIX pid gid <- createProcessGroup pid signalProcessGroup 15 pid otherwise -> error "Somethings wrong." but i get the error message: "createProcessGroup: permission denied" Is there a way around this permission problem? Kind regards, André ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to terminate the process group of a process created with createProcess?
> From: Brandon Allbery > > On Wed, Jan 11, 2012 at 16:26, Andr? Scholz wrote: > >> (on unix) creating a process A which spawns itself a subprocess B and >> terminating process A before it finishes leaves process B as a process on >> its >> own. This is because "terminateProcess" sends the sigterm signal to the >> process only and not to its process group. >> > > terminateProcess passes on the semantics of kill(2); on SVID-compliant (and > I think POSIX.1-compliant) systems, the negative of the process group > leader's process ID is used to signal the process group. Note that you may > need to arrange for your initial child process to invoke setpgrp() to > insure that the parent program is not part of the process group. System.Process.terminateProcess takes a ProcessHandle as input, which is an opaque type which essentially can only be created via System.Process.createProcess or similar; it's not possible to pass arbitrary pid's to it. However, on Posix systems it is currently possible (ghc-7.2.1) to import System.Process.Internals, which would allow you to either create a new ProcessHandle from an arbitrary pid or retrieve the pid from a ProcessHandle. My answer on SO now shows how to do so. Of course this approach won't be portable, and it may change depending on your compiler version. (link to SO: http://stackoverflow.com/questions/8820903/haskell-how-to-timeout-a-function-that-runs-an-external-command/ ) John L. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Unboxed Rationals?
uvector is deprecated, its functionnalities has been ported into vector. 2012/1/11 Artyom Kazak > Also, uvector already supports unboxed Ratios: > http://hackage.haskell.org/package/uvector > > In fact, I am surprised that Data.Vector doesn't have a Ratio > instance, but has a Complex instance. Any ideas, why? > > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHCi with wxhaskell-dev
Hi, On 10.01.2012, at 19:05, Dave Tapley wrote: > I'm working on a dev branch of wxHaskell [1] and one of the new > features is that you can use wxHaskell in GHCi (again), but I seem to > have broken something in the process: > Firstly: wxHaskell works in GHCi insomuch as: > You can load the hello world sample [2] in GHCi, do "> main", see the > window spawn, close it and be returned to the GHCi prompt. > > What I'm interested in is the case where you call wxHaskell's start > function [3] from GHCi. > The result is becoming stuck with no way back to the GHCi prompt > without resorting to sending kill signals. > > I made a screen cast to illustrate my findings [4]: > 1. Once you've done "> start $ return ()" you can press ^C all you > want, there's no way back to the GHCi prompt. > 2. If you send three (less has no effect) kills to the GHCi process it > will exit, but it will exit GHCi as well (instead of putting you back > at the GHCi prompt). > 3. If you do "> start $ return ()" but *do not* try and ^C, you can > send a single kill to GHCi and be returned to the GHCi prompt. > > My questions: > 1. Why doesn't GHCi respond to the ^C? > 2a. Why does entering ^C from within GHCi then prevent you from > getting back to the GHCi prompt? > 2b. Why doesn't any other input (i.e. entering anything but ^C) cause > this behaviour? > 3. If you have sent ^C from GHCi, why do you then have to kill three > times to get out of GHCi? > > Feel free to pull the repo [1] and try it out, you'll need the latest > dev release of wxWidgets [5] installed. > I didn't try to reproduce your problem, but are you aware of the -fno-ghci-sandbox flag? E.g. it helps with GLUT based programs on OS X. Cheers, Jean ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] decoupling type classes
Yin, 2012/1/12 Yin Wang : > I have an idea about type classes that I have been experimenting. It > appears to be a generalization to Haskell’s type classes and seems to > be doable. It seems to related the three ideas: type classes, implicit > parameters, and (typed) dynamic scoping. But I don't know whether it > is good or not. I hope to get some opinions before going further. I find your ideas interesting. You may be interested in a related design which I recently implemented for Agda [2], and an ICFP 2011 paper that presents it [1]. Also, you don't seem to have thought about the question of parametric instances: do you allow them or not, if you do, what computational power do they get etc.? > I have an experimental system which “decouples” the dictionary. > Instead of passing on a dictionary, it passes individual “implicit > parameters" around. Those implicit parameters are type inferenced and > they can contain type parameters just as methods in a type class. > Similarly, they are resolved by their types in the call site's scope. I'm surprised that you propose passing all "type class" methods separately. It seems to me that for many type classes, you want to impose a certain correspondence between the types of the different methods in a type class (for example, for the Monad class, you would expect return to be of type (a -> m a) if (>>=) is of type (m a -> (a -> m b) -> m b)). I would expect that inferencing these releations in each function that uses either of the methods will lead to overly general inferenced types and the need for more guidance to the type inferencer? By separating the methods, you would also lose the laws that associate methods in a type class, right? An alternative to what you suggest, is the approach I recommend for using instance arguments: wrapping all the methods in a standard data type (i.e. define the dictionary explicitly), and pass this around as an implicit argument. > The convenience of this approach compared to Haskell’s type classes is > that we no longer require a user of a type class to define ALL the > methods in a type class. For example, a user could just define a > method + without defining other methods in the Num class: -, *, … He > can use the method + independently. For example, if + is defined on > the String type to be concatenation, we can use + in another function: > > weirdConcat x y = x + y + y > > This has a utility, because the methods in the Num class don’t “make > sense” for Strings except +, but the current type class design > requires us to define them. Note here that weirdConcat will not have > the type (Num a) => a -> a -> a, since we no longer have the Num > class, it is decoupled into separate methods. For this example, one might also argue that the problem is in fact that the Num type class is too narrow, and + should instead be defined in a parent type class (Monoid comes to mind) together with 0 (which also makes sense for strings, by the way)? > There is another benefit of this decoupling: it can subsume the > functionality of MPTC. Because the methods are no longer grouped, > there is no “common” type parameter to the methods. Thus we can easily > have more than one parameter in the individual methods and > conveniently use them as MPTC methods. Could you explain this a bit further? > Here g is explicitly declared as “overloaded”, although my > experimental system doesn’t need this. Any undefined variable inside > function body automatically becomes overloaded. This may cause > unintended overloading and it catches bugs late. That’s why we need > the “overload” declarations. I would definitely argue against treating undefined variables as overloaded automatically. It seems this will lead to strange errors if you write typo's for example. > But the automatic overloading of the undefined may be useful in > certain situations. For example, if we are going to use Haskell as a > shell language. Every “command” must be evaluated when we type them. > If we have mutually recursive definitions, the shell will report > “undefined variables” either way we order the functions. The automatic > overloading may solve this problem. The undefined variables will > temporarily exist as automatic overloaded functions. Once we actually > define a function with the same name AND satisfies the type > constraints, they become implicit parameters to the function we > defined before. If we call a function whose implicit parameters are > not associated, the shell reports error very similar to Haskell’s > “type a is not of class Num …” The design you suggest seems to differ from Haskell's current treatment, where functions can refer to other functions defined further in the file, but still have them resolved statically? > RELATIONSHIP TO DYNAMIC SCOPING > > It seems to be helpful to think of the “method calls” as referencing > dynamically scoped variables. They are dispatched depending on the > bindings we have in the call site's scope (and not the