Re: [Haskell-cafe] Opinion about JHC
On Tue, Nov 10, 2009 at 07:41:54PM -0800, Philippos Apolinarius wrote: I discovered a Haskell compiler that generates very small and fast code. In fact, it beats Clean. It has the following properties: Excellent. that was my goal ;) 1 --- One can cross-compile programs easily. For instance, here is how I generated code for Windows: jhc --cross -mwin32 genetic.hs -o genetic Yup. This was a major goal. compiling for iPhones and embedded arches is just as easy assuming you have a gcc toolchain set up. (at least with the hacked iPhone SDK.. I have never tried it with the official one) 2 -- It seems to be quite complete. 3 -- However, it often compiles a file, but the program fails to run. I have the following questions about it: 1 -- How active is the team who is writing the JHC compiler? Hi, I am the main contributor, but others are welcome and several have made signifigant contributions. Development tends to be spurty. A lot of work will get done in a short amount of time, this generally corresponds to when an external contributor gets involved and the back and forth helps stimulate patches on my part to complement theirs. Although I have not been able to devote a lot of my time to jhc in the past, hopefully this will change in the not to distant future and I will be able to work on it full time. 2 -- Is it complete Haskell? The author claims that it is; it compiled all programs that I wrote, but that does not mean much, because my programs are quite simple. It does Haskell 98 and several extensions, which is pretty much what GHC does. However, it does not implement the same set of extensions as GHC so this causes issues as a lot of people use GHC extensions extensively. I plan on supporting all of Haskell' of course, and the popular GHC extensions to help compatibility. Not all are implemented. 3 -- Why the Haskell community almost never talks about JHC? Part of it is that I am not very good at advocacy. I don't always post announcements on the main haskell lists figuring the interested parties are on the jhc list already. I do try to make jhc good, fast, and usable, I always hoped someone better at advocacy than me would join the project :) In truth, I think the spurty nature of development also affects this, the list will be quite for a long time with a flurry of development lasting a few weeks occasionally inspiring some discussion in the other groups. In any case, I am glad you liked what you found! please join the mailing list for jhc if you are interested in its development or using it. John -- John Meacham - ⑆repetae.net⑆john⑈ - http://notanumber.net/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Problems with Language.Haskell.Interpreter and errors
I still have problems and your code won't typecheck on my machine printing the following error: Test.hs:9:34: No instance for (Control.Monad.CatchIO.MonadCatchIO (InterpreterT IO)) arising from a use of `catch' at Test.hs:9:34-53 Possible fix: add an instance declaration for (Control.Monad.CatchIO.MonadCatchIO (InterpreterT IO)) In the first argument of `runInterpreter', namely `(code `catch` handler)' In the second argument of `(=)', namely `(runInterpreter (code `catch` handler))' In the expression: print = (runInterpreter (code `catch` handler)) I assume we are using different versions of some packages. Could you please send me the output of your 'ghc-pkg list'. Thanks, Martin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Working with multiple projects
Tony Morris wrote: I have two projects that I intend to put on hackage soon. One depends on the other. I have cabaled both. I am wondering how others work with this kind of set up where changes are made to both libraries as they work. You just update and re-upload the packages as necessary. It really helps here if you follow the versioning guidelines: http://www.haskell.org/haskellwiki/Package_versioning_policy HTH, Martijn. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] caba install with external gcc toolchain not the ghc-bundled one
Hello friends, I have a question regarding one thing I can't get my head around: First my problem is, that wanted to install 'bindings-common' here on my Windows machine. Usually that is no problem with the help of the glorious cabal. Now, 'bindings-common' needs a higher version of gcc than the one bundled with ghc-6.10.4 to build as the developer told me, so I install the gcc version 4.4.0 by mingw and try to give the needed options to 'cabal install bindings-common...' - '--with-gcc=... --with-ld=...' etc. - At the same time I log everything cabal is putting to the outside world when doing the tasks for building the 'binding-commons': For this sake I use the '--build-log=...' option of 'cabal install' and at the same time pipe what gets shown on the terminal with 'tee' as well as verbosity level 3 for 'cabal install'. So far nothing new... But the package isn't built, so I wonder what the transcript is saying and have a look at the two generated log files, stating that the one generated by 'tee' tells me another linker (the one coming with the ghc-6.10.4 bundle) than I thought to have specified is actually used. An excerpt from the tee built log file: *** Linker: E:\programme\ghc\ghc-6.10.4\gcc -BE:\programme\ghc\ghc-6.10.4\gcc-lib/ ... Configured with: ../gcc-3.4.5-20060117-3/configure --with-gcc ... Thread model: win32 gcc version 3.4.5 (mingw-vista special r3) (Sorry if I'm mis-interpreting something here) While the log file resulting from the '--build-log' cabal install option has nothing suspicious in it telling me to (plan to?) use exactly what I specified by options. A little excerpt from that log file: (e:\\programme\\ghc\\ghc-6.10.4\\bin\\hsc2hs.exe,[--cc=e:/programme/ghc/mingw-gcc4/bin/gcc.exe,--ld=e:/programme/ghc/mingw-gcc4/bin/gcc.exe,--cflag=-Be:/programme/ghc/mingw-gcc4/lib/,--cflag=-Ie:/programme/ghc/mingw4-gcc/include,--cflag=-Le:/programme/ghc/mingw-gcc4/lib,--lflag=-Be:/programme/ghc/mingw-gcc4/lib/,--lflag=-Ie:/programme/ghc/mingw4-gcc/include,--lflag=-Le:/programme/ghc/mingw-gcc4/lib,--cflag=-D__GLASGOW_HASKELL__=610,--cflag=-Isrc,--cflag=-Ie:/programme/ghc/mingw-gcc4/include,--cflag=-D_ISOC99_SOURCE,--lflag=-Le:/programme/ghc/mingw-gcc4/lib,--cflag=-Ie:\\programme\\ghc\\ghc-6.10.4\\base-4.1.0.0\\include,--cflag=-Ie:\\programme\\ghc\\ghc-6.10.4/include,--lflag=-Le:\\programme\\ghc\\ghc-6.10.4\\base-3.0.3.1,--lflag=-Le:\\programme\\ghc\\ghc-6.10.4\\syb-0.1.0.1,--lflag=-Le:\\programme\\ghc\\ghc-6.10.4\\base-4.1.0.0,--lflag=-lwsock32,--lflag=-luser32,--lflag=-lshell32,--lflag=-Le:\\programme\\ghc\\ghc-6.10.4\\integer-0 .1.0.1,--lflag=-Le:\\programme\\ghc\\ghc-6.10.4\\ghc-prim-0.1.0.0,--lflag=-Le:\\programme\\ghc\\ghc-6.10.4,--lflag=-Le:\\programme\\ghc\\ghc-6.10.4/gcc-lib,--lflag=-lm,--lflag=-lffi,--lflag=-lgmp,--lflag=-lwsock32,-o,H:\\.homedir\\hugsdata\\build\\Bindings\\C\\Ctype.hs,src\\Bindings\\C\\Ctype.hsc]) ... Using ld given by user at: e:/programme/ghc/mingw-gcc4/bin/ld.exe So now my question is: Can anybody give me a good hint or tell me how I would, aside from using hard links or other file system related tasks, specify the external compiler, linker or gcc-toolchain to be used by 'cabal install' (or in consequence by 'ghc')? Cheers and thanks for your Daniel searching for ghc in path. found ghc at e:\programme\ghc\ghc-6.10.4\bin\ghc.exe (e:\\programme\\ghc\\ghc-6.10.4\\bin\\ghc.exe,[--numeric-version]) e:\programme\ghc\ghc-6.10.4\bin\ghc.exe is version 6.10.4 looking for package tool: ghc-pkg near compiler in e:\programme\ghc\ghc-6.10.4\bin found package tool in e:\programme\ghc\ghc-6.10.4\bin\ghc-pkg.exe (e:\\programme\\ghc\\ghc-6.10.4\\bin\\ghc-pkg.exe,[--version]) e:\programme\ghc\ghc-6.10.4\bin\ghc-pkg.exe is version 6.10.4 (e:\\programme\\ghc\\ghc-6.10.4\\bin\\ghc.exe,[--supported-languages]) Reading installed packages... (e:\\programme\\ghc\\ghc-6.10.4\\bin\\ghc-pkg.exe,[dump,--global]) (e:\\programme\\ghc\\ghc-6.10.4\\bin\\ghc-pkg.exe,[dump,--package-conf=h:\\.homedir\\ghc\\i386-mingw32-6.10.4\\package.conf]) Reading available packages... Resolving dependencies... selecting bindings-common-1.3.3 (hackage) and discarding bindings-common-0.1, 0.1.1, 0.1.2, 0.1.3, 0.1.4, 0.2, 0.2.1, 0.2.2, 0.2.3, 0.2.4, 0.2.5, 0.2.6, 1.0, 1.1, 1.2, 1.3, 1.3.1 and 1.3.2 selecting base-3.0.3.1 (installed) and 4.1.0.0 (installed) and discarding syb-0.1.0.0 and 0.1.0.1 selecting ghc-prim-0.1.0.0 (installed) selecting integer-0.1.0.1 (installed) selecting rts-1.0 (installed) selecting syb-0.1.0.1 (installed) In order, the following would be installed: bindings-common-1.3.3 (new package) bindings-common-1.3.3 has already been downloaded. Extracting C:\Dokumente und Einstellungen\Zyx\Anwendungsdaten\cabal\packages\hackage.haskell.org\bindings-common\1.3.3\bindings-common-1.3.3.tar.gz to c:\DOKUME~1\Zyx\LOKALE~1\Temp\bindings-common-1.3.31176... Using external setup method with build-type Simple Creating h:\.homedir\hugsdata\setup (and its parents) Using Cabal
Re: [Haskell-cafe] Working with multiple projects
I don't want to have to upload every time I make a minor change as I am working. Surely there is an easier way. Martijn van Steenbergen wrote: Tony Morris wrote: I have two projects that I intend to put on hackage soon. One depends on the other. I have cabaled both. I am wondering how others work with this kind of set up where changes are made to both libraries as they work. You just update and re-upload the packages as necessary. It really helps here if you follow the versioning guidelines: http://www.haskell.org/haskellwiki/Package_versioning_policy HTH, Martijn. -- Tony Morris http://tmorris.net/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Working with multiple projects
To install a package from local sources, just run 'cabal install' in the directory with the package's .cabal file. Tony Morris wrote: I don't want to have to upload every time I make a minor change as I am working. Surely there is an easier way. Martijn van Steenbergen wrote: Tony Morris wrote: I have two projects that I intend to put on hackage soon. One depends on the other. I have cabaled both. I am wondering how others work with this kind of set up where changes are made to both libraries as they work. You just update and re-upload the packages as necessary. It really helps here if you follow the versioning guidelines: http://www.haskell.org/haskellwiki/Package_versioning_policy HTH, Martijn. === Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html === ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Working with multiple projects
On Wed, Nov 11, 2009 at 10:26:32AM -, Sittampalam, Ganesh wrote: To install a package from local sources, just run 'cabal install' in the directory with the package's .cabal file. You can even have some kind of script like cd lib1 cabal install || exit 1 cd ../lib2 cabal install || exit 2 -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] unboxed arrays restricted to simple types (Int, Float, ..)
Hi, I tried to use unboxed arrays for generating an antialiased texture. To make it easier to understand, here is the stripped down code that produces an error: import Control.Monad.ST import Data.Array.ST import Data.Array.Unboxed import Data.Word type BitMask = UArray Int Word16 -- for determining the grey value of a pixel type Pixels = (Int, Int, T) data T = N | B BitMask -- this does not work -- type T = Int -- this works if int the next line N is replaced by ..lets say 0 f = newArray (0,10) N :: (ST s (STUArray s Int T)) http://hackage.haskell.org/packages/archive/array/0.2.0.0/doc/html/Data-Array-MArray.html#t%3AMArray shows that mutable/unboxed arrays only allow simple types: i.e. MArray (STUArray s) Int32 (ST s) Isn't this ugly? Imagine this would be the case in C: struct stupidArrayElement{ int a; int b; // not allowed! } stupidArrayElement s[10]; Wouldn't it be nice to have something like: MArray (STUArray s) e (ST s) with e being a non-recursive data type (like data T = N | B Bitmask). My understanding of Haskell isn't deep enough to know if I have overlooked something or if the problem is solvable without a language extension. With a language extension I guess that it is not hard to find out if an abstract data type is non-recursive. Then this type should be serializable automatically. What do you think? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] unboxed arrays restricted to simple types (Int, Float, ..)
On Wed, Nov 11, 2009 at 12:58 PM, Tillmann Vogt tillmann.v...@rwth-aachen.de wrote: Hi, I tried to use unboxed arrays for generating an antialiased texture. To make it easier to understand, here is the stripped down code that produces an error: *snip* What do you think? It is generally acknowledged that the array types bundled with GHC have serious shortcomings, such as for example the one you just pointed out. There is not, however, a consensus on how to change them. To solve your particular problem, I would suggest looking up the storablevector package on Hackage, which I know can handle arbitrary unboxed elements. That said, I'm sure someone will be along shortly to give you the full story. :-) -- Svein Ove Aas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] unboxed arrays restricted to simple types (Int, Float, ..)
On Wed, Nov 11, 2009 at 5:28 PM, Tillmann Vogt tillmann.v...@rwth-aachen.de wrote: Hi, I tried to use unboxed arrays for generating an antialiased texture. To make it easier to understand, here is the stripped down code that produces an error: import Control.Monad.ST import Data.Array.ST import Data.Array.Unboxed import Data.Word type BitMask = UArray Int Word16 -- for determining the grey value of a pixel type Pixels = (Int, Int, T) data T = N | B BitMask -- this does not work -- type T = Int -- this works if int the next line N is replaced by ..lets say 0 f = newArray (0,10) N :: (ST s (STUArray s Int T)) http://hackage.haskell.org/packages/archive/array/0.2.0.0/doc/html/Data-Array-MArray.html#t%3AMArray shows that mutable/unboxed arrays only allow simple types: i.e. MArray (STUArray s) Int32 (ST s) Isn't this ugly? Imagine this would be the case in C: struct stupidArrayElement{ int a; int b; // not allowed! } stupidArrayElement s[10]; Wouldn't it be nice to have something like: MArray (STUArray s) e (ST s) with e being a non-recursive data type (like data T = N | B Bitmask). My understanding of Haskell isn't deep enough to know if I have overlooked something or if the problem is solvable without a language extension. With a language extension I guess that it is not hard to find out if an abstract data type is non-recursive. Then this type should be serializable automatically. What do you think? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe Actually, there's a cool package called storable record. Could it be of some use to you? (Perhaps you *might* be able to use it if the BitMasks are of uniform length). Am not 100% sure though. Isn't this ugly? I am not sure if it is really *ugly*...and if am allowed to nit-pick, the analogy with C is not appropriate either. Arrays are just different. (At least thats how I console myself, when am looking for a high performance strict array). Also, on an approximately related issue, I was suggested to look into data parallel arrays. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Problem with JHC
Hi, John. I am trying JHC in a small embedded system (Medical instruments). The software is written in Clean, and I am translating to Haskell. You may want to take a look at my page: http://www.discenda.org/med/ I am writing because I found something in JHC that smells like a bug. The program compiles without a single complaint both in GHC and JHC, but the resulting binary file does not work in JHC. I wrote a simplified example so you can spot the problem easily. The original program is used to design and simplify digital circuits for sensors (capnograms, electrocardiograms, electroencephalograms, electromyograms, and temperature). It seems that JHC is not able to deal with the trees representing the circuits. Here is a very small program. All it does is to read a tree and show it: {- file: tree.hs -} {- compile: jhc tree.hs -dc -o jtree } import System (getArgs) import System.IO import IO data Op = AND | OR | NOT deriving (Show, Read) data Tree= L Int | T Op [Tree] deriving (Show, Read) main= do putStrLn Give me a tree: s - getLine let xx= read s putStrLn (show (xx::Tree)) Here is what happens when I try to run it: phi...@desktop:~/jhctut$ ./jtree Give me a tree: T AND (L 1, L 2) jtree_code.c:2670: case fell off Aborted It seems that the problem is in the Read class, since it works if I use the Show class only: import System (getArgs) import System.IO import IO data Op = AND | OR | NOT deriving (Show, Read) data Tree= L Int | T Op [Tree] deriving (Show, Read) main= do putStrLn Give me a tree: s - getLine let xx= T AND [L 1, L 2] putStrLn (show (xx::Tree)) I hope you can fix it. --- On Wed, 11/11/09, John Meacham j...@repetae.net wrote: From: John Meacham j...@repetae.net Subject: Re: [Haskell-cafe] Opinion about JHC To: haskell-cafe@haskell.org Received: Wednesday, November 11, 2009, 1:37 AM On Tue, Nov 10, 2009 at 07:41:54PM -0800, Philippos Apolinarius wrote: I discovered a Haskell compiler that generates very small and fast code. In fact, it beats Clean. It has the following properties: Excellent. that was my goal ;) 1 --- One can cross-compile programs easily. For instance, here is how I generated code for Windows: jhc --cross -mwin32 genetic.hs -o genetic Yup. This was a major goal. compiling for iPhones and embedded arches is just as easy assuming you have a gcc toolchain set up. (at least with the hacked iPhone SDK.. I have never tried it with the official one) 2 -- It seems to be quite complete. 3 -- However, it often compiles a file, but the program fails to run. I have the following questions about it: 1 -- How active is the team who is writing the JHC compiler? Hi, I am the main contributor, but others are welcome and several have made signifigant contributions. Development tends to be spurty. A lot of work will get done in a short amount of time, this generally corresponds to when an external contributor gets involved and the back and forth helps stimulate patches on my part to complement theirs. Although I have not been able to devote a lot of my time to jhc in the past, hopefully this will change in the not to distant future and I will be able to work on it full time. 2 -- Is it complete Haskell? The author claims that it is; it compiled all programs that I wrote, but that does not mean much, because my programs are quite simple. It does Haskell 98 and several extensions, which is pretty much what GHC does. However, it does not implement the same set of extensions as GHC so this causes issues as a lot of people use GHC extensions extensively. I plan on supporting all of Haskell' of course, and the popular GHC extensions to help compatibility. Not all are implemented. 3 -- Why the Haskell community almost never talks about JHC? Part of it is that I am not very good at advocacy. I don't always post announcements on the main haskell lists figuring the interested parties are on the jhc list already. I do try to make jhc good, fast, and usable, I always hoped someone better at advocacy than me would join the project :) In truth, I think the spurty nature of development also affects this, the list will be quite for a long time with a flurry of development lasting a few weeks occasionally inspiring some discussion in the other groups. In any case, I am glad you liked what you found! please join the mailing list for jhc if you are interested in its development or using it. John -- John Meacham - ⑆repetae.net⑆john⑈ - http://notanumber.net/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe __ Looking for the perfect gift? Give the gift of Flickr! http://www.flickr.com/gift/___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org
Re: [Haskell-cafe] unboxed arrays restricted to simple types (Int, Float, ..)
You might also look at how Data Parallel Haskell implements its arrays. IIRC, it implements an array of n-field records as n arrays. You can easily do that with typeclasses and type families. 2009/11/11 Tillmann Vogt tillmann.v...@rwth-aachen.de: Hi, I tried to use unboxed arrays for generating an antialiased texture. To make it easier to understand, here is the stripped down code that produces an error: import Control.Monad.ST import Data.Array.ST import Data.Array.Unboxed import Data.Word type BitMask = UArray Int Word16 -- for determining the grey value of a pixel type Pixels = (Int, Int, T) data T = N | B BitMask -- this does not work -- type T = Int -- this works if int the next line N is replaced by ..lets say 0 f = newArray (0,10) N :: (ST s (STUArray s Int T)) http://hackage.haskell.org/packages/archive/array/0.2.0.0/doc/html/Data-Array-MArray.html#t%3AMArray shows that mutable/unboxed arrays only allow simple types: i.e. MArray (STUArray s) Int32 (ST s) Isn't this ugly? Imagine this would be the case in C: struct stupidArrayElement{ int a; int b; // not allowed! } stupidArrayElement s[10]; Wouldn't it be nice to have something like: MArray (STUArray s) e (ST s) with e being a non-recursive data type (like data T = N | B Bitmask). My understanding of Haskell isn't deep enough to know if I have overlooked something or if the problem is solvable without a language extension. With a language extension I guess that it is not hard to find out if an abstract data type is non-recursive. Then this type should be serializable automatically. What do you think? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Eugene Kirpichov Web IR developer, market.yandex.ru ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] unboxed arrays restricted to simple types (Int, Float, ..)
There's a couple of things going on here: -If you use storablevector and storable-tuple, or uvector, you can store tuples of things. So your stupidArrayElement could be mimicked by (Int, Int). -But what you want to do is store a variable-sized data type. How would you do that in C? If you can spare another bit of memory, it might be better to define type T = (Bool, Bitmask) and use storablevector. Or maybe you want a sparse array of Bitmasks? -Yes it is a shame that Haskell does not have good support for unbounded polymorphic arrays. What if I want an array of functions? Here's a little trick that can make it a bit easier to store any data type in an unboxed array. I don't know, for instance, of any other way to define unrestricted functor/applicative for unboxed arrays. This trick should work with any other array library. {-# LANGUAGE GADTs#-} module FArray where import Data.StorableVector import Foreign.Storable import Control.Applicative data EqOrF a b where Eq :: EqOrF a a F :: (a-b) - EqOrF a b data FArray a where FArray :: Storable a = Vector a - EqOrF a b - FArray b ConstArr :: a - FArray a instance Functor FArray where fmap f (ConstArr x) = ConstArr $ f x fmap f (FArray sv Eq) = FArray sv $ F f fmap f (FArray sv (F g)) = FArray sv $ F $ f . g instance Applicative FArray where pure x = ConstArr x (ConstArr f) * farr = fmap f farr -- other cases left as an exercise. Which is to say, my bladder is bursting and I also need lunch. arrayOfInts = FArray (pack [1..10]) Eq arrayOfAdders = (+) `fmap` arrayOfInts Tom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Problems with Language.Haskell.Interpreter and errors
On Nov 11, 2009, at 5:39 AM, Martin Hofmann wrote: I still have problems and your code won't typecheck on my machine printing the following error: [...] I assume we are using different versions of some packages. Could you please send me the output of your 'ghc-pkg list'. Thanks, Martin Sure. Global: Cabal-1.6.0.3, GLUT-2.1.1.2, HTTP-4000.0.6, HUnit-1.2.0.3, OpenGL-2.2.1.1, QuickCheck-1.2.0.0, array-0.2.0.0, base-3.0.3.1, base-4.1.0.0, bytestring-0.9.1.4, cgi-3001.1.7.1, containers-0.2.0.1, directory-1.0.0.3, (dph-base-0.3), (dph-par-0.3), (dph-prim-interface-0.3), (dph-prim-par-0.3), (dph-prim-seq-0.3), (dph-seq-0.3), editline-0.2.1.0, extensible-exceptions-0.1.1.0, fgl-5.4.2.2, filepath-1.1.0.2, (ghc-6.10.4), ghc-prim-0.1.0.0, haddock-2.4.2, haskell-src-1.0.1.3, haskell98-1.0.1.0, hpc-0.5.0.3, html-1.0.1.2, integer-0.1.0.1, mtl-1.1.0.2, network-2.2.1.2, network-2.2.1.4, old-locale-1.0.0.1, old-time-1.0.0.2, packedstring-0.1.0.1, parallel-1.1.0.1, parsec-2.1.0.1, pretty-1.0.1.0, process-1.0.1.1, random-1.0.0.1, regex-base-0.72.0.2, regex-compat-0.71.0.1, regex-posix-0.72.0.3, rts-1.0, stm-2.1.1.2, syb-0.1.0.1, template-haskell-2.3.0.1, time-1.1.2.4, time-1.1.4, unix-2.3.2.0, xhtml-3000.2.0.1, zlib-0.5.0.0 User: MonadCatchIO-mtl-0.2.0.0, ghc-mtl-1.0.1.0, ghc-paths-0.1.0.5, hint-0.3.2.0, utf8-string-0.3.5. Hope that helps Daniel ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Problem with JHC
On Wed, Nov 11, 2009 at 04:32:05AM -0800, Philippos Apolinarius wrote: data Op = AND | OR | NOT deriving (Show, Read) data Tree= L Int | T Op [Tree] deriving (Show, Read) Hmm, you see, phi...@desktop:~/jhctut$ ./jtree Give me a tree: T AND (L 1, L 2) jtree_code.c:2670: case fell off Aborted you declared 'T Op [Tree]' so you should give 'T AND [L 1, L 2]' as the tree, right? -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Help Haskell driving Medical Instruments
On Tue, Nov 10, 2009 at 5:04 AM, Philippos Apolinarius phi50...@yahoo.ca wrote: foreign import ccall rs232.h opencport opencport :: CInt - IO () foreign import ccall rs232.h closecport closecport :: CInt - CInt [...] Originally, I had the following line (that did not work properly): foreign import ccall rs232.h closecport closecport :: IO () I don't know why the latter line didn't work properly, but I'm pretty sure it's closer to the right answer than the former. If you don't have an IO type for your function, then Haskell is allowed to assume it is pure (has no side effects) and can then call it only when the result is needed, or multiple times if it likes, without affecting the meaning of the program. For a function that closes a handle this is clearly not the case. So I'm pretty sure your type signature needs to be in IO if you want to guarantee it is called at the right time; it might be worth elaborating on how the IO () version did not work, and how you used it. The way you are using it now would appear to work most of the time because the print statement will force the result to be evaluated, forcing the function to be called - but having a handle closed based on when an apparently irrelevant print statement runs or doesn't is obviously not ideal. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] (state) monad and CPS
Excerpts from jean-christophe mincke's message of Tue Nov 10 21:18:34 +0100 2009: Hello, Hello, I would like to get some advice about state monad (or any other monad I guess) and CPS. Here is to remarks somewhat off topic: [...] walk Empty acc k = k acc walk (Leaf _) acc k = k (acc+1) walk (Node (l, _, r)) acc k = let k1 acc = walk r acc k in walk l (acc+1) k1 Remember that by default laziness and accumulators does not fits well together. Here you are probably building a chain of thunks. Making acc a strict argument (using !acc) or using 'seq' (acc `seq` ...) will cure this. [...] do acc - get put (acc+1) ... Since this pattern occurs often 'modify' is a combination of get and put: do modify (+1) ... About your CPS question, you should have a look at the 'transformers' package, in particular the Control.Monad.Trans.Cont [1] module. [1]: http://hackage.haskell.org/packages/archive/transformers/0.1.4.0/doc/html/Control-Monad-Trans-Cont.html Best regards, -- Nicolas Pouillard http://nicolaspouillard.fr ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Static Linking Problem
On Tue, Nov 10, 2009 at 4:29 PM, Ketil Malde ke...@malde.org wrote: MightyByte mightyb...@gmail.com writes: After a bit of googling, I came to the conclusion that I needed to compile it with ghc --make -static -optl-static Foo.hs. Using only -static or -optl-static by themselves did not generate a statically linked binary. But when I compile with both those parameters I get a bunch of linker errors: [..] (.text+0x59c): undefined reference to `pthread_mutex_lock' For some reason, GHC doesn't link with the pthreads library, so you need to compile (link) with two options: -opt-static -optl-pthread Excellent, that appears to have solved my problem. It still gives me the warning: (.text+0x3068): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking But glibc is pretty standard, so I don't think this will be a problem for me. Thanks for the help. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Problems with Language.Haskell.Interpreter and errors
Thanks, using MonadCatchIO-mtl-0.2.0.0 and hint-0.3.2.0 did it. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: ANN: haskell-mode 2.6
Svein Ove Aas svein@aas.no writes: Haskell-mode 2.6 has been released. The first hit for haskell-mode is http://www.haskell.org/haskell-mode/ This still points to Stefan's home page as the place to find it, which then points to http://projects.haskell.org/haskellmode-emacs/ , which is the right place. I don't know who has the right permissions, but can someone update http://www.haskell.org/haskell-mode/ to point to the right place? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] looking for a good algorithm
Hong Yang schrieb: The question is more about algorithm than Haskell. But I am going to code in Haskell which I am still learning. Suppose I have a large table, with hundreds of columns and thousands of rows. But not every cell has a value (of String, or Int, or Double type). I want to shuffle the rows to maximize the number of columns whose first 100 rows have at least one number, given a list of preferred column names since there is no guarantee that every number column will have at least one number in its first 100 rows after shuffling. Can someone provide a good algorithm for this problem? (I do not have any background in algorithms.) You can assume I already know which columns are of Int or Double type. I would say it depends on the distribution of values in the table. If there are rows with a lot of values and rows with few values, then I would first sort the rows after the number of cells with values. If you look at all the columns and the number of values for each row is unique then it would be perfectly solved. With a list of preferred columns and also a uniform distribution the problem might be hard (NP-complete?), but these hard problems can often be approximated, i.e with simulated annealing, which in short is switching two rows repeatedly as long as the result improves. This is not a homework. Thanks, Hong ___ 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] Long running Haskell program
As some of you may know, I've been writing commercial Haskell code for a little bit here (about a year and a half) and I've just recently had to write some code that was going to run have to run for a really long time before being restarted, possibly months or years if all other parts of the system cooperate as it's part of a server infrastructure management system. I recently ran into some serious space leak difficulties that would ultimately cause this program to crash some time after startup (my simulator is also written in Haskell, and runs a LOT faster than the real application ever could, this has enabled me to fast forward a bit the data growth issues and crash in minutes instead of days!) Anyway, rather than try to paste it all here with images and such I thought I'd stick it up on my blog so others could maybe benefit from the anecdote. It's difficult to disclose enough useful information as it is commercial code not under an open source license, but there's neat diagrams and stuff there so hopefully the colors are at least amusing :-) http://leimy9.blogspot.com/2009/11/long-running-haskell-applications.html Dave ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Working with multiple projects
On Wednesday 11 November 2009 08:23:53 am Tony Morris wrote: I have two projects that I intend to put on hackage soon. One depends on the other. I have cabaled both. I am wondering how others work with this kind of set up where changes are made to both libraries as they work. What i did in situations like this, is the following: If B depends on A: 1. Uninstall A (for not mistakenly link to an old version.) 2. Add the source directories of a local copy of A to the src-dirs in the cabal file of B. 3. remove the dependency of A in the cabal file of B. I know, that this is not very elegant, though. You end up changing your cabal file very often :( If you could tell cabal, which cabal file to use, the situation would be a little better, i think. Sönke ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Static Linking Problem
On Wed, Nov 11, 2009 at 3:22 PM, MightyByte mightyb...@gmail.com wrote: (.text+0x3068): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking But glibc is pretty standard, so I don't think this will be a problem for me. Thanks for the help. You may have unexpected results. That warning occurs because some of glibc (namely, the getaddrinfo bit) is dynamically linked regardless of what you want; this is apparently to make NSS work, or something along those lines. However, if you then link the rest of glibc statically, you get dependencies between your program and the installed glibc, for internal, unstable APIs. (!) This is generally a Big No. Doing this means your program definitely won't be compatible with older versions of glibc, but it probably wouldn't be either way. However, in this case it also won't be compatible with *newer* versions of glibc. My recommendation would be to take glibc off the list of statically linked libraries. -- Svein Ove Aas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Problem with JHC
you declared 'T Op [Tree]' so you should give 'T AND [L 1, L 2]' as the tree, right? Hi, Felipe. You are right. This means that I gave the correct input to the program. As you can see, I typed 'T AND [L 1, L 2]'. Therefore, JHC was expected to parse and print it. However, it failed to parse it. The program works perfectly well in GHC. Here is the GHC output: phi...@desktop:~/jhctut$ ghc tree.hs --make [1 of 1] Compiling Main ( tree.hs, tree.o ) Linking tree ... phi...@desktop:~/jhctut$ ./tree Give me a tree: T AND [L 1, L 2] T AND [L 1,L 2] --- On Wed, 11/11/09, Felipe Lessa felipe.le...@gmail.com wrote: From: Felipe Lessa felipe.le...@gmail.com Subject: Re: [Haskell-cafe] Problem with JHC To: haskell-cafe@haskell.org Received: Wednesday, November 11, 2009, 6:23 AM On Wed, Nov 11, 2009 at 04:32:05AM -0800, Philippos Apolinarius wrote: data Op = AND | OR | NOT deriving (Show, Read) data Tree= L Int | T Op [Tree] deriving (Show, Read) Hmm, you see, phi...@desktop:~/jhctut$ ./jtree Give me a tree: T AND (L 1, L 2) jtree_code.c:2670: case fell off Aborted you declared 'T Op [Tree]' so you should give 'T AND [L 1, L 2]' as the tree, right? -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe __ Make your browsing faster, safer, and easier with the new Internet Explorer® 8. Optimized for Yahoo! Get it Now for Free! at http://downloads.yahoo.com/ca/internetexplorer/___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Problem with JHC
According to the paste you gave for the JHC test run: Here is what happens when I try to run it: phi...@desktop:~/jhctut$ ./jtree Give me a tree: T AND (L 1, L 2) jtree_code.c:2670: case fell off Aborted You gave it parens not square brackets. -Ross On Nov 11, 2009, at 11:45 AM, Philippos Apolinarius wrote: you declared 'T Op [Tree]' so you should give 'T AND [L 1, L 2]' as the tree, right? Hi, Felipe. You are right. This means that I gave the correct input to the program. As you can see, I typed 'T AND [L 1, L 2]'. Therefore, JHC was expected to parse and print it. However, it failed to parse it. The program works perfectly well in GHC. Here is the GHC output: phi...@desktop:~/jhctut$ ghc tree.hs --make [1 of 1] Compiling Main ( tree.hs, tree.o ) Linking tree ... phi...@desktop:~/jhctut$ ./tree Give me a tree: T AND [L 1, L 2] T AND [L 1,L 2] --- On Wed, 11/11/09, Felipe Lessa felipe.le...@gmail.com wrote: From: Felipe Lessa felipe.le...@gmail.com Subject: Re: [Haskell-cafe] Problem with JHC To: haskell-cafe@haskell.org Received: Wednesday, November 11, 2009, 6:23 AM On Wed, Nov 11, 2009 at 04:32:05AM -0800, Philippos Apolinarius wrote: data Op = AND | OR | NOT deriving (Show, Read) data Tree= L Int | T Op [Tree] deriving (Show, Read) Hmm, you see, phi...@desktop:~/jhctut$ ./jtree Give me a tree: T AND (L 1, L 2) jtree_code.c:2670: case fell off Aborted you declared 'T Op [Tree]' so you should give 'T AND [L 1, L 2]' as the tree, right? -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe Get the name you've always wanted ! @ymail.com or @rocketmail.com.___ 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] Re: looking for a good algorithm
Hong Yang hyang...@gmail.com wrote in article f31db34d090452x7786572ay4482dffc4824a...@mail.gmail.com in gmane.comp.lang.haskell.cafe: I want to shuffle the rows to maximize the number of columns whose first 100 rows have at least one number Sounds like the maximum coverage problem, which is said to be NP-hard. [citation needed] http://en.wikipedia.org/wiki/Maximum_coverage_problem -- Edit this signature at http://www.digitas.harvard.edu/cgi-bin/ken/sig The answer to the ultimate question of life the universe and everything = 42 but usually it's not. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Long running Haskell program
David Leimbach leim...@gmail.com writes: As some of you may know, I've been writing commercial Haskell code for a little bit here (about a year and a half) and I've just recently had to write some code that was going to run have to run for a really long time before being restarted, possibly months or years if all other parts of the system cooperate as it's part of a server infrastructure management system. I recently ran into some serious space leak difficulties that would ultimately cause this program to crash some time after startup (my simulator is also written in Haskell, and runs a LOT faster than the real application ever could, this has enabled me to fast forward a bit the data growth issues and crash in minutes instead of days!) Anyway, rather than try to paste it all here with images and such I thought I'd stick it up on my blog so others could maybe benefit from the anecdote. It's difficult to disclose enough useful information as it is commercial code not under an open source license, but there's neat diagrams and stuff there so hopefully the colors are at least amusing :-) http://leimy9.blogspot.com/2009/11/long-running-haskell-applications.html Can you copy you blog at here? http://leimy9.blogspot.com/2009/11/long-running-haskell-applications.html is filter by GFW (http://en.wikipedia.org/wiki/Golden_Shield_Project) i can't see it. About crash free program, you can consider multi-process design, keep Simple and Stable core running in RootProcess, and Core module won't crash, and make unstable module running in ChildProcess, if you occur some un-catch exception from ChildProcess, just reboot those sub-module. I'm research some Haskell/Gtk+ program, sometimes un-catch exception is unavoidable, multi-process is good chose to avoid some exception crash all program. Cheers, -- Andy ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Long running Haskell program
On Wed, Nov 11, 2009 at 7:43 AM, David Leimbach leim...@gmail.com wrote: I recently ran into some serious space leak difficulties that would ultimately cause this program to crash some time after startup (my simulator is also written in Haskell, and runs a LOT faster than the real application ever could, this has enabled me to fast forward a bit the data growth issues and crash in minutes instead of days!) It sounds to me like you were storing a Map in a StateT. Since the usual State and StateT monads don't force the evaluation of their payload, I'm not terribly surprised that such a leak should arise. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Medical Instruments - Jason
Hi, Jason. Thank you for your explanations. They were very useful. In the light of what you said, I modified the programs as shown below (commented lines failed to work). Forcing the C function to return a number, wrapping the returned number in IO, and printing the number, I succeeded in bringing falures down to 1 case in 20 trials (average). By the way, I talked to doctors who work with capnograms, and they said that all Windows or Linux machines have problems in closing communication ports. However, it seems that capnographs are not turned off very often. I mean, when the doctor move the capnograph from one patient to another, s/he turns off the instrument. Therefore, this behavior does not create problems. However, what bothers me is that Clean always succeds in closeing the port. {-# LANGUAGE ForeignFunctionInterface #-} {- file: SER/IAL.hs -} module SER.IAL where import Control.Monad import Foreign import Foreign.C.Types import Foreign.C foreign import ccall rs232.h opencport opencport :: CInt - IO () -- foreign import ccall rs232.h closecport closecport :: CInt - CInt -- foreign import stdcall unsafe rs232.h closecport closecport :: IO () -- foreign import ccall unsafe rs232.h closecport c_closecport :: CInt foreign import ccall unsafe rs232.h closecport c_closecport :: CInt - CInt closecport :: Int - IO Int closecport n= return (fromIntegral (c_closecport (fromIntegral n))) foreign import ccall rs232.h rdrs232 c_sendmsg :: CInt - CString - CString sendMessage :: Int - String - IO String sendMessage n msg = withCString msg $ \str - peekCString (c_sendmsg (fromIntegral n) str) {- file: sensors.hs -} import Gui.Binding import Gui.Types import Gui.Constants import SER.IAL import Control.Monad import Data.Char main = do rv - j_start frame - j_frame Sensors avg - j_button frame Sampling j_setpos avg 20 150 j_setsize avg 90 30 rb - j_button frame Read j_setpos rb 125 150 j_setsize rb 90 30 tb - j_button frame Acquisition j_setpos tb 230 150 j_setsize tb 90 30 fld - j_textfield frame 40 j_setpos fld 20 100 menubar - j_menubar frame file - j_menu menubar File quitMI - j_menuitem file Quit j_show frame opencport(3) waitForFrameAction frame fld rb tb avg quitMI r - closecport 5 putStrLn (show r) return j_quit waitForFrameAction frame f rb tb avg q = do obj - j_nextaction again - if obj == event q then return False else if obj == event rb then (do msg - sendMessage 1 r putStrLn msg return True) else if obj == event tb then (do tx - sendMessage 1 t let tp= filter ( ' ') tx j_settext f tp return True) else if obj == event avg then (do ok - sendMessage 1 m val - j_gettext f 300 ns - sendMessage 2 val putStrLn ((filter ( ' ') ok) ++ ns) return True) else (do tx - sendMessage 1 t let tp= filter ( ' ') tx rx - sendMessage 1 x let rd= filter ( ' ') rx let x = hex2dec rd let tt= (fromIntegral x)*209.1/1023.0 - 67.23 j_settext f ((show tt)++ == ++tp) return True) if not again then return True else waitForFrameAction frame f rb tb avg q hex2dec :: String - Int hex2dec h= sum (zipWith (*) (map (16^) [3,2,1,0]) [digitToInt c | c - h]) convert d r s0= (fromIntegral (hex2dec d))*r/1024.0- s0 {- 1a43 67.23; 082b - 209.1 -} // file: serial.c #include serial.h #include string.h #include stdio.h /* Possible baudrates on a normal pc: 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200 */ #define BAUD baud=9600 data=8 parity=N stop=1 HANDLE Cport; char comports[16][10]={.\\COM1, .\\COM2, .\\COM3, .\\COM4, .\\COM5, .\\COM6, .\\COM7, .\\COM8, .\\COM9, .\\COM10, .\\COM11, .\\COM12, .\\COM13, .\\COM14, .\\COM15, .\\COM16}; int OpenComport(int comport_number) { if(comport_number15) { printf(illegal comport number\n); return(1); } Cport = CreateFileA(comports[comport_number], GENERIC_READ|GENERIC_WRITE, 0, /* no share */ NULL, /* no security */ OPEN_EXISTING, 0, /* no threads */ NULL); /* no templates */
Re: [Haskell-cafe] Long running Haskell program
Is there a state monad that is strict on the state but lazy on the computation? Of course, strictness in the state will force a portion of the computation to be run, but there may be significant portions of it which are not run. Would there be a way to write a state monad such that it is entirely lazy, but then to wrap either the computation or the state in an 'eager' strategy datatype which takes care of this in a more flexible manner? Thanks, Matthew 2009/11/11 Bryan O'Sullivan b...@serpentine.com On Wed, Nov 11, 2009 at 7:43 AM, David Leimbach leim...@gmail.com wrote: I recently ran into some serious space leak difficulties that would ultimately cause this program to crash some time after startup (my simulator is also written in Haskell, and runs a LOT faster than the real application ever could, this has enabled me to fast forward a bit the data growth issues and crash in minutes instead of days!) It sounds to me like you were storing a Map in a StateT. Since the usual State and StateT monads don't force the evaluation of their payload, I'm not terribly surprised that such a leak should arise. ___ 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] Problem with JHC
FWIW, I just compiled JHC 0.7.2 with ghc 6.12 , doing a couple of corrections to make it compile, which I don't think they are related to this *bug*. Testing the given code, it aborts for every inputs I give it L 1, T AND [L 1,L 2] included. I couldn't make it compile using function reads instead. paolino 2009/11/11 Ross Mellgren rmm-hask...@z.odi.ac According to the paste you gave for the JHC test run: Here is what happens when I try to run it: phi...@desktop:~/jhctut$ ./jtree Give me a tree: T AND (L 1, L 2) jtree_code.c:2670: case fell off Aborted You gave it parens not square brackets. -Ross On Nov 11, 2009, at 11:45 AM, Philippos Apolinarius wrote: you declared 'T Op [Tree]' so you should give 'T AND [L 1, L 2]' as the tree, right? Hi, Felipe. You are right. This means that I gave the correct input to the program. As you can see, I typed 'T AND [L 1, L 2]'. Therefore, JHC was expected to parse and print it. However, it failed to parse it. The program works perfectly well in GHC. Here is the GHC output: phi...@desktop:~/jhctut$ ghc tree.hs --make [1 of 1] Compiling Main ( tree.hs, tree.o ) Linking tree ... phi...@desktop:~/jhctut$ ./tree Give me a tree: T AND [L 1, L 2] T AND [L 1,L 2] --- On *Wed, 11/11/09, Felipe Lessa felipe.le...@gmail.com* wrote: From: Felipe Lessa felipe.le...@gmail.com Subject: Re: [Haskell-cafe] Problem with JHC To: haskell-cafe@haskell.org Received: Wednesday, November 11, 2009, 6:23 AM On Wed, Nov 11, 2009 at 04:32:05AM -0800, Philippos Apolinarius wrote: data Op = AND | OR | NOT deriving (Show, Read) data Tree= L Int | T Op [Tree] deriving (Show, Read) Hmm, you see, phi...@desktop:~/jhctut$ ./jtree Give me a tree: T AND (L 1, L 2) jtree_code.c:2670: case fell off Aborted you declared 'T Op [Tree]' so you should give 'T AND [L 1, L 2]' as the tree, right? -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Get the name you've always wanted http://ca.promos.yahoo.com/jacko/! *@ ymail.com *or *...@rocketmail.com* .___ 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 mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Long running Haskell program
On Wed, Nov 11, 2009 at 1:09 PM, Matthew Pocock matthew.poc...@ncl.ac.uk wrote: Is there a state monad that is strict on the state but lazy on the computation? Of course, strictness in the state will force a portion of the computation to be run, but there may be significant portions of it which are not run. Would there be a way to write a state monad such that it is entirely lazy, but then to wrap either the computation or the state in an 'eager' strategy datatype which takes care of this in a more flexible manner? I think replacing put s with put $! s should guarantee that the state is evaluated. If you're using get and put in many place in the code, you could try something along these lines: newtype SStateT s m a = S { unS :: StateT s m a } deriving (Monad, etc.) instance (Monad m) = MonadState s (SStateT s m) where get = S get put s = S (put $! s) -- Dave Menendez d...@zednenem.com http://www.eyrie.org/~zednenem/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Long running Haskell program
Hello leimy, the only simple solution I have found to avoid a leaking state of a server is doing a periodical rnf of it, this implying the NFData constraint on its datatype. The reader should leak only if you nest forever the local function. paolino 2009/11/11 David Leimbach leim...@gmail.com As some of you may know, I've been writing commercial Haskell code for a little bit here (about a year and a half) and I've just recently had to write some code that was going to run have to run for a really long time before being restarted, possibly months or years if all other parts of the system cooperate as it's part of a server infrastructure management system. I recently ran into some serious space leak difficulties that would ultimately cause this program to crash some time after startup (my simulator is also written in Haskell, and runs a LOT faster than the real application ever could, this has enabled me to fast forward a bit the data growth issues and crash in minutes instead of days!) Anyway, rather than try to paste it all here with images and such I thought I'd stick it up on my blog so others could maybe benefit from the anecdote. It's difficult to disclose enough useful information as it is commercial code not under an open source license, but there's neat diagrams and stuff there so hopefully the colors are at least amusing :-) http://leimy9.blogspot.com/2009/11/long-running-haskell-applications.html Dave ___ 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] Opinion about JHC
John, Do you use jhc when you develop jhc? I.e., does it compile itself. For me, this is the litmus test of when a compiler has become usable. I mean, if even the developers of a compiler don't use it themselves, why should anyone else? :) -- Lennart On Wed, Nov 11, 2009 at 3:37 AM, John Meacham j...@repetae.net wrote: On Tue, Nov 10, 2009 at 07:41:54PM -0800, Philippos Apolinarius wrote: I discovered a Haskell compiler that generates very small and fast code. In fact, it beats Clean. It has the following properties: Excellent. that was my goal ;) 1 --- One can cross-compile programs easily. For instance, here is how I generated code for Windows: jhc --cross -mwin32 genetic.hs -o genetic Yup. This was a major goal. compiling for iPhones and embedded arches is just as easy assuming you have a gcc toolchain set up. (at least with the hacked iPhone SDK.. I have never tried it with the official one) 2 -- It seems to be quite complete. 3 -- However, it often compiles a file, but the program fails to run. I have the following questions about it: 1 -- How active is the team who is writing the JHC compiler? Hi, I am the main contributor, but others are welcome and several have made signifigant contributions. Development tends to be spurty. A lot of work will get done in a short amount of time, this generally corresponds to when an external contributor gets involved and the back and forth helps stimulate patches on my part to complement theirs. Although I have not been able to devote a lot of my time to jhc in the past, hopefully this will change in the not to distant future and I will be able to work on it full time. 2 -- Is it complete Haskell? The author claims that it is; it compiled all programs that I wrote, but that does not mean much, because my programs are quite simple. It does Haskell 98 and several extensions, which is pretty much what GHC does. However, it does not implement the same set of extensions as GHC so this causes issues as a lot of people use GHC extensions extensively. I plan on supporting all of Haskell' of course, and the popular GHC extensions to help compatibility. Not all are implemented. 3 -- Why the Haskell community almost never talks about JHC? Part of it is that I am not very good at advocacy. I don't always post announcements on the main haskell lists figuring the interested parties are on the jhc list already. I do try to make jhc good, fast, and usable, I always hoped someone better at advocacy than me would join the project :) In truth, I think the spurty nature of development also affects this, the list will be quite for a long time with a flurry of development lasting a few weeks occasionally inspiring some discussion in the other groups. In any case, I am glad you liked what you found! please join the mailing list for jhc if you are interested in its development or using it. John -- John Meacham - ⑆repetae.net⑆john⑈ - http://notanumber.net/ ___ 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] Opinion about JHC
Quoth Lennart Augustsson lenn...@augustsson.net, Do you use jhc when you develop jhc? I.e., does it compile itself. For me, this is the litmus test of when a compiler has become usable. I mean, if even the developers of a compiler don't use it themselves, why should anyone else? :) Though that's exactly backwards for minority platforms, where the compilers that compile themselves tend to be no use whatever. Donn Cave, d...@avvanta.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Long running Haskell program
On Wed, Nov 11, 2009 at 8:20 AM, Andy Stewart lazycat.mana...@gmail.comwrote: David Leimbach leim...@gmail.com writes: As some of you may know, I've been writing commercial Haskell code for a little bit here (about a year and a half) and I've just recently had to write some code that was going to run have to run for a really long time before being restarted, possibly months or years if all other parts of the system cooperate as it's part of a server infrastructure management system. I recently ran into some serious space leak difficulties that would ultimately cause this program to crash some time after startup (my simulator is also written in Haskell, and runs a LOT faster than the real application ever could, this has enabled me to fast forward a bit the data growth issues and crash in minutes instead of days!) Anyway, rather than try to paste it all here with images and such I thought I'd stick it up on my blog so others could maybe benefit from the anecdote. It's difficult to disclose enough useful information as it is commercial code not under an open source license, but there's neat diagrams and stuff there so hopefully the colors are at least amusing :-) http://leimy9.blogspot.com/2009/11/long-running-haskell-applications.html Can you copy you blog at here? http://leimy9.blogspot.com/2009/11/long-running-haskell-applications.html is filter by GFW (http://en.wikipedia.org/wiki/Golden_Shield_Project) i can't see it. About crash free program, you can consider multi-process design, keep Simple and Stable core running in RootProcess, and Core module won't crash, and make unstable module running in ChildProcess, if you occur some un-catch exception from ChildProcess, just reboot those sub-module. Believe it or not, this is a stack of Erlang - Haskell - C. It works via pipes and is a concurrent system of management. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Long running Haskell program
On Wed, Nov 11, 2009 at 9:51 AM, Bryan O'Sullivan b...@serpentine.comwrote: On Wed, Nov 11, 2009 at 7:43 AM, David Leimbach leim...@gmail.com wrote: I recently ran into some serious space leak difficulties that would ultimately cause this program to crash some time after startup (my simulator is also written in Haskell, and runs a LOT faster than the real application ever could, this has enabled me to fast forward a bit the data growth issues and crash in minutes instead of days!) It sounds to me like you were storing a Map in a StateT. Since the usual State and StateT monads don't force the evaluation of their payload, I'm not terribly surprised that such a leak should arise. That's exactly what was happening. The system was being far too lazy (by choices I made but didn't fully understand). By pulling the Map out of the state, and pushing it back into the state, as the definition of my looping, things got a lot better. I didn't see another *easy* way to force the state to be evaluated, except by doing IO on intermediate values. seq will only evaluate strictly if it's just underneath something else that's already been evaluated :-). The runtime doesn't look for seqs to force evaluation on. I figured I was better off just creating a dependency in the evaluation, near the outermost portion of the program (the loop) that would cause a strict evaluation, and so far I was right :-) Program behaves very well now, and responds much better too. Dave ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Long running Haskell program
On Wed, Nov 11, 2009 at 10:29 AM, David Menendez d...@zednenem.com wrote: On Wed, Nov 11, 2009 at 1:09 PM, Matthew Pocock matthew.poc...@ncl.ac.uk wrote: Is there a state monad that is strict on the state but lazy on the computation? Of course, strictness in the state will force a portion of the computation to be run, but there may be significant portions of it which are not run. Would there be a way to write a state monad such that it is entirely lazy, but then to wrap either the computation or the state in an 'eager' strategy datatype which takes care of this in a more flexible manner? I think replacing put s with put $! s should guarantee that the state is evaluated. If you're using get and put in many place in the code, you could try something along these lines: newtype SStateT s m a = S { unS :: StateT s m a } deriving (Monad, etc.) instance (Monad m) = MonadState s (SStateT s m) where get = S get put s = S (put $! s) That's interesting, and once I have time to come back to this part of the project (I was behind schedule at this point!) I'll try something like that. -- Dave Menendez d...@zednenem.com http://www.eyrie.org/~zednenem/ ___ 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] Long running Haskell program
leimy2k: I figured I was better off just creating a dependency in the evaluation, near the outermost portion of the program (the loop) that would cause a strict evaluation, and so far I was right :-) Program behaves very well now, and responds much better too. Do you know if Control.Monad.State.Strict is enough to get the behaviour you need? -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Medical Instruments - Jason
On Wed, Nov 11, 2009 at 6:00 PM, Philippos Apolinarius phi50...@yahoo.ca wrote: closecport :: Int - IO Int closecport n= return (fromIntegral (c_closecport (fromIntegral n))) The return here doesn't do what you think it does - semantically, the value of c_closecport is still considered pure and assumed to be referentially transparent, so multiple calls to closecport are allowed to share the value returned, or delay the call until the value is unwrapped, call it multiple times for each use of the value, or anything else. You need to use IO *directly* in the foreign import declaration so that the compiler knows that the function calls can't be shared or inlined or generally messed about with: the IO tells it that order of execution with respect to your other IO actions is important. This one looks the most right: foreign import stdcall unsafe rs232.h closecport closecport :: IO () so I think you need to look closer about why it wasn't working for you, and where or how you were using it. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hoogle is great but ...
Following up on this rather old thread, if you want to see a module which has lots of input/output example pairs, and properties, in the documentation then look at filepath (hoogle for takeExtension as an example). These properties are also automatically transformed in to test cases, so filepath has good documentation and good test coverage all in one, plus the documentation is actually checked for correctness. I think more libraries should do this - so I challenge someone to write the definitive tests and assertions in code package for Haskell. And it's nice to hear that Hoogle is great :-) Thanks, Neil 2009/10/25 zaxis z_a...@163.com: http://www.haskell.org/hoogle/ is VERY great for haskeller. However, i feel hoogle should be improved by providing more examples as : isInfixOf :: Eq a = [a] - [a] - Bool The isInfixOf function takes two lists and returns True iff the first list is contained, wholly and intact, anywhere within the second. Example: isInfixOf Haskell I really like Haskell. - True isInfixOf Ial I really like Haskell. - False The Example code will be helpful for programmer to understand its definition. Sincerely! -- View this message in context: http://www.nabble.com/Hoogle-is-great-but-...-tp26046410p26046410.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ 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] Opinion about JHC
If by minority platform you mean platforms that are resource starved, like some embedded systems, then I would have to agree. -- Lennart On Wed, Nov 11, 2009 at 2:12 PM, Donn Cave d...@avvanta.com wrote: Quoth Lennart Augustsson lenn...@augustsson.net, Do you use jhc when you develop jhc? I.e., does it compile itself. For me, this is the litmus test of when a compiler has become usable. I mean, if even the developers of a compiler don't use it themselves, why should anyone else? :) Though that's exactly backwards for minority platforms, where the compilers that compile themselves tend to be no use whatever. Donn Cave, d...@avvanta.com ___ 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] Long running Haskell program
On Wed, Nov 11, 2009 at 11:19 AM, Don Stewart d...@galois.com wrote: leimy2k: I figured I was better off just creating a dependency in the evaluation, near the outermost portion of the program (the loop) that would cause a strict evaluation, and so far I was right :-) Program behaves very well now, and responds much better too. Do you know if Control.Monad.State.Strict is enough to get the behaviour you need? I'll give that a go. Most of my trouble figuring out the space leak has been around identifying what was really responsible for the problem. The functions that were listed as eating the space in -hc runs were not ultimately the ones causing the lack of strictness, in that they would have had to have been evaluated at a higher layer in a non-lazy way. So my take away from all of this is, when you have a space leak in haskell, start from the outer most evaluations inward, not the other way around!!! I think that would have saved me a ton of time. Dave -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Opinion about JHC
Quoth Lennart Augustsson lenn...@augustsson.net, If by minority platform you mean platforms that are resource starved, like some embedded systems, then I would have to agree. Like anything but the platform the compiler developer(s) use. If you used a platform like that, you would certainly have to agree. If you were a compiler developer for a language that supports like-platform porting the way GHC does, after trying to keep that working while developing the language I suspect you might also be tempted to agree. Donn Cave, d...@avvanta.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Least common supertype?
Is there a name for the following concept? Can you point me to any references on it? Suppose I have the following two functions ... swap1 :: (Int, Char) - (Char, Int) swap2 :: (Char, Int) - (Int, Char) ... and, for some reason, I think I can unify these into a single function. I think, hmm, given that the structure is that same, let's do a first pass: swap? :: (a, b) - (c, d) But then I go back to the input types to confirm that this will work, and, alas, it will not, because there are similarities that I missed. This is way too general. I need to ensure that what's an Int stays an Int and likewise for Char. swap! :: (a, b) - (b, a) And now I have found a type that is more general than swap1 and swap2 and yet not so general that the shared constraints are left out. This seems somewhat analogous to the least common multiple. Another example is the following: showFloat :: Float - String showBool :: Bool - String We could say the more general type is ... show? :: a - String ... but then we lose the implied constraint that we must know something about 'a' to produce a string. So, we add back such some such constraint: show! :: (Show a) = a - String Of course, with all of this, it may not be clear what to do about the definitions of the functions, but I'm curious if there's a name for the concept from a type perspective. Thanks, Sean ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Least common supertype?
Is the name of the concept Most general unifier (MGU) ? (See: Hindley-Milner type inference) 2009/11/11 Sean Leather leat...@cs.uu.nl: Is there a name for the following concept? Can you point me to any references on it? Suppose I have the following two functions ... swap1 :: (Int, Char) - (Char, Int) swap2 :: (Char, Int) - (Int, Char) ... and, for some reason, I think I can unify these into a single function. I think, hmm, given that the structure is that same, let's do a first pass: swap? :: (a, b) - (c, d) But then I go back to the input types to confirm that this will work, and, alas, it will not, because there are similarities that I missed. This is way too general. I need to ensure that what's an Int stays an Int and likewise for Char. swap! :: (a, b) - (b, a) And now I have found a type that is more general than swap1 and swap2 and yet not so general that the shared constraints are left out. This seems somewhat analogous to the least common multiple. Another example is the following: showFloat :: Float - String showBool :: Bool - String We could say the more general type is ... show? :: a - String ... but then we lose the implied constraint that we must know something about 'a' to produce a string. So, we add back such some such constraint: show! :: (Show a) = a - String Of course, with all of this, it may not be clear what to do about the definitions of the functions, but I'm curious if there's a name for the concept from a type perspective. Thanks, Sean ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Eugene Kirpichov Web IR developer, market.yandex.ru ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Least common supertype?
Least Common Generalization. Cheers, Thu 2009/11/11 Eugene Kirpichov ekirpic...@gmail.com: Is the name of the concept Most general unifier (MGU) ? (See: Hindley-Milner type inference) 2009/11/11 Sean Leather leat...@cs.uu.nl: Is there a name for the following concept? Can you point me to any references on it? Suppose I have the following two functions ... swap1 :: (Int, Char) - (Char, Int) swap2 :: (Char, Int) - (Int, Char) ... and, for some reason, I think I can unify these into a single function. I think, hmm, given that the structure is that same, let's do a first pass: swap? :: (a, b) - (c, d) But then I go back to the input types to confirm that this will work, and, alas, it will not, because there are similarities that I missed. This is way too general. I need to ensure that what's an Int stays an Int and likewise for Char. swap! :: (a, b) - (b, a) And now I have found a type that is more general than swap1 and swap2 and yet not so general that the shared constraints are left out. This seems somewhat analogous to the least common multiple. Another example is the following: showFloat :: Float - String showBool :: Bool - String We could say the more general type is ... show? :: a - String ... but then we lose the implied constraint that we must know something about 'a' to produce a string. So, we add back such some such constraint: show! :: (Show a) = a - String Of course, with all of this, it may not be clear what to do about the definitions of the functions, but I'm curious if there's a name for the concept from a type perspective. Thanks, Sean ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Eugene Kirpichov Web IR developer, market.yandex.ru ___ 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] Re: Long running Haskell program
I used to be a victim of GFW, so I can feel your pain. You may try to subscribe to http://leimy9.blogspot.com/feeds/posts/default in your Google Reader. In case that fails too, I've pasted the blog post below, with no images: I've been using Haskell in a serious way for about 2 years. Been using it in a professional sense about 1.5 years now in that, yes, I am one of the lucky ones that gets to use Haskell at work. The ride has been pretty smooth most of the time, as I've found that the type system especially helps me to rule out certain classes of bugs, easily test rather large chunks of programs as they're pure. The interpreter allows experimentation and iteration of ideas that can then be composed into the final compiled programs. All of this gives me a good deal of confidence that the code I'm writing is correct to some degree up front, something I've come to expect from functional programming languages over the years and greatly appreciate. However I've felt compelled to comment that things aren't always so smooth either. I spent the better part of a weekend and a Monday tracking down a space leak in a program that just was not allowed to leak space. I have a stack of a ReaderT StateT IO that I use to communicate with a device through a passthrough program that speaks CAN to a device for the purposes of creating a serial console connection where there is only a CAN bus. The Haskell program is responsible for the management of the data found at the other end o the serial connection and supports operations to the device through the serial channel via a simple text protocol while forever polling data on the serial endpoint. What I had done was the equivalent of pollerLoop :: Poller () pollerLoop = forever pollOnce Where Poller is my monad stack. pollOnce is defined as, pollOnce :: Poller () pollOnce = do checkCommandChannel -- see if there's a pending command to run executePoll Yes, this application is multi-threaded. I have a logger thread, a thread watching standard input of the program for queries and issuing commands to the endpoint. I have a thread per Poller, and the ability to poll devices simultaneously. The poller includes an implementation of my little expect syntax which was based on a naive implementation of hGetChar and checking for a desired result or timing out eventually. The really data inefficient version is a real screamer, beating the heck out of my Parsec or even ReadP version, but because of the way I wrote it, with a lot of reversing and prefix checking and substring slicing into temporary areas, it's not useful for large input blocks over a long time frame. Still it's so fast that it's appropriate for certain sections of code. I measured and verified this via space profiling to see the real runtime heap utilization (nice feature btw, I'd be dead without it right now I think). So what's the problem you're probably thinking? Well it turns out that since part of my state in StateT is a Data.Map, and that all my polling and parsing of expect-passing blocks caused updates to a Map, coupled with the language's default laziness caused a bit of a bomb of PAP (Partial APplications of functions). I had an ill-timed, project wise, discovery of a space leak. I tried sprinkling $! and seq all over the place, rewriting big chunks of code that used Text.Regex.Posix, to use Parsec and only got incremental improvements. The growth problem still existed, and would eventually exhaust memory. This was a real problem as this was an application that was not supposed to stop when the other conditions of the management system were ok. It could run for months or even years! I went through a whirlwind of emotions, and considered that perhaps I should be working a different job. Perhaps I could be a lion tamer? It turned out what I thought was a lion was really an anteater though... but that's literally a different story. It turns out that by looping not inside the monad, but over the execStateT/runReaderT expression I could pull all the state out, and then re-inject it into another execStateT/runReaderT each poll, which forced the strictness I needed on all state data, made the system respond faster, and best of all, not crash Diagrams below: This first one is the before picture. It shows the data growth by cost center in my code. As you can see things are getting worse almost linearly as I poll. This picture illustrates the result of pulling the state out of the Monad, and re-injecting it, forcing it to be evaluated. As you can see, I've got much more manageable memory utilization. This final one shows the new algorithm running with 2 threads, one spawned a few seconds into the run. You can see the initial burst of the fast but inefficient expect algorithm, followed by a much more regular memory utilization pattern. I'd like to thank all the folks on #haskell on FreeNode who gave me suggestions and hints to my vague problems regarding data growth and
Re: [Haskell-cafe] Least common supertype?
For some reference, I found some definition for the lcg function in papers from [1]. In fact, I began to implement the type inference algorithm of System CT (the version of 1999, it has been revised since) and I have an implementation of lcg in that setting. I plan to upload the code to github; I can do it earlier than expected if you're interested. [1] http://homepages.dcc.ufmg.br/~camarao/ Cheers, Thu 2009/11/11 minh thu not...@gmail.com: Least Common Generalization. Cheers, Thu 2009/11/11 Eugene Kirpichov ekirpic...@gmail.com: Is the name of the concept Most general unifier (MGU) ? (See: Hindley-Milner type inference) 2009/11/11 Sean Leather leat...@cs.uu.nl: Is there a name for the following concept? Can you point me to any references on it? Suppose I have the following two functions ... swap1 :: (Int, Char) - (Char, Int) swap2 :: (Char, Int) - (Int, Char) ... and, for some reason, I think I can unify these into a single function. I think, hmm, given that the structure is that same, let's do a first pass: swap? :: (a, b) - (c, d) But then I go back to the input types to confirm that this will work, and, alas, it will not, because there are similarities that I missed. This is way too general. I need to ensure that what's an Int stays an Int and likewise for Char. swap! :: (a, b) - (b, a) And now I have found a type that is more general than swap1 and swap2 and yet not so general that the shared constraints are left out. This seems somewhat analogous to the least common multiple. Another example is the following: showFloat :: Float - String showBool :: Bool - String We could say the more general type is ... show? :: a - String ... but then we lose the implied constraint that we must know something about 'a' to produce a string. So, we add back such some such constraint: show! :: (Show a) = a - String Of course, with all of this, it may not be clear what to do about the definitions of the functions, but I'm curious if there's a name for the concept from a type perspective. Thanks, Sean ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Eugene Kirpichov Web IR developer, market.yandex.ru ___ 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] Least common supertype?
Excerpts from Sean Leather's message of Wed Nov 11 21:24:43 +0100 2009: Is there a name for the following concept? Can you point me to any references on it? Suppose I have the following two functions ... swap1 :: (Int, Char) - (Char, Int) swap2 :: (Char, Int) - (Int, Char) ... and, for some reason, I think I can unify these into a single function. I think, hmm, given that the structure is that same, let's do a first pass: swap? :: (a, b) - (c, d) But then I go back to the input types to confirm that this will work, and, alas, it will not, because there are similarities that I missed. This is way too general. I need to ensure that what's an Int stays an Int and likewise for Char. swap! :: (a, b) - (b, a) In the literature this is also called anti-unification (anti-unifier). These techniques had been used for formalising some overloading systems. -- Nicolas Pouillard http://nicolaspouillard.fr ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Sometimes pinned memory?
Hey everyone! Do you have any suggestions for how I might allocate an aligned block of memory that I can pin while making foreign calls, but leave unpinned the rest of the time to potentially improve allocation and garbage collector performance? Or is this even a good idea? Thanks, Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Sometimes pinned memory?
gcross: Hey everyone! Do you have any suggestions for how I might allocate an aligned block of memory that I can pin while making foreign calls, but leave unpinned the rest of the time to potentially improve allocation and garbage collector performance? Or is this even a good idea? There's no pinned/unpinned memory. You have to pick one. * Use a ForeignPtr to allocate pinned memory (mallocForeignPtr) if you want it mostly poinned. Otherwise, you'll need to copy from unpinned to pinned. -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Problem with JHC
Hi, Ross. Ops, the paste is wrong, but the bug is real. I mean, if I try to run the program with the right input, the program aborts in the same place, with the same error message: phi...@desktop:~/jhctut$ ./jtestarbo Give me a tree: T AND [L 1, L 2] jtestarbo_code.c:2670: case fell off Abortado In fact, it aborts in the same place for any input. This fact may help to discover where the trouble is: phi...@desktop:~/jhctut$ ./jtestarbo Give me a tree: fdsfkldkl jtestarbo_code.c:2670: case fell off Abortado --- On Wed, 11/11/09, Ross Mellgren rmm-hask...@z.odi.ac wrote: From: Ross Mellgren rmm-hask...@z.odi.ac Subject: Re: [Haskell-cafe] Problem with JHC To: Philippos Apolinarius phi50...@yahoo.ca Cc: Felipe Lessa felipe.le...@gmail.com, haskell-cafe@haskell.org Received: Wednesday, November 11, 2009, 9:52 AM According to the paste you gave for the JHC test run: Here is what happens when I try to run it: phi...@desktop:~/jhctut$ ./jtree Give me a tree: T AND (L 1, L 2) jtree_code.c:2670: case fell off Aborted You gave it parens not square brackets. -Ross On Nov 11, 2009, at 11:45 AM, Philippos Apolinarius wrote: you declared 'T Op [Tree]' so you should give 'T AND [L 1, L 2]' as the tree, right? Hi, Felipe. You are right. This means that I gave the correct input to the program. As you can see, I typed 'T AND [L 1, L 2]'. Therefore, JHC was expected to parse and print it. However, it failed to parse it. The program works perfectly well in GHC. Here is the GHC output: phi...@desktop:~/jhctut$ ghc tree.hs --make [1 of 1] Compiling Main ( tree.hs, tree.o ) Linking tree ... phi...@desktop:~/jhctut$ ./tree Give me a tree: T AND [L 1, L 2] T AND [L 1,L 2] --- On Wed, 11/11/09, Felipe Lessa felipe.le...@gmail.com wrote: From: Felipe Lessa felipe.le...@gmail.com Subject: Re: [Haskell-cafe] Problem with JHC To: haskell-cafe@haskell.org Received: Wednesday, November 11, 2009, 6:23 AM On Wed, Nov 11, 2009 at 04:32:05AM -0800, Philippos Apolinarius wrote: data Op = AND | OR | NOT deriving (Show, Read) data Tree= L Int | T Op [Tree] deriving (Show, Read) Hmm, you see, phi...@desktop:~/jhctut$ ./jtree Give me a tree: T AND (L 1, L 2) jtree_code.c:2670: case fell off Aborted you declared 'T Op [Tree]' so you should give 'T AND [L 1, L 2]' as the tree, right? -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe Get the name you've always wanted ! @ymail.com or @rocketmail.com.___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe __ Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now http://ca.toolbar.yahoo.com.___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Sometimes pinned memory?
Hello Gregory, Thursday, November 12, 2009, 12:14:56 AM, you wrote: Hey everyone! Do you have any suggestions for how I might allocate an aligned block of memory that I can pin while making foreign calls, but leave unpinned the rest of the time to potentially improve allocation and garbage collector performance? Or is this even a good idea? if your call FFI function marked as unsafe, you may expect that memory block wouldn't moved across call. it's better to ask ghc gurus about details. just an example where memcpy used across non-pinned arrays: freezeSTUArray :: Ix i = STUArray s i e - ST s (UArray i e) freezeSTUArray (STUArray l u n marr#) = ST $ \s1# - case sizeofMutableByteArray# marr# of { n# - case newByteArray# n# s1# of { (# s2#, marr'# #) - case memcpy_freeze marr'# marr# (fromIntegral (I# n#)) of { IO m - case unsafeCoerce# m s2#of { (# s3#, _ #) - case unsafeFreezeByteArray# marr'# s3# of { (# s4#, arr# #) - (# s4#, UArray l u n arr# #) } foreign import ccall unsafe memcpy memcpy_freeze :: MutableByteArray# s - MutableByteArray# s - CSize - IO (Ptr a) -- Best regards, Bulatmailto:bulat.zigans...@gmail.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Sometimes pinned memory?
Thanks, Don. What made me think that this might be possible was the existence of Foreign.StablePtr, since that seems to take a Haskell expression and pin it down. Could this mechanism be harness to pin down arrays, or am I misunderstanding how it works? (Is StablePtr really just making a copy of the expression behind the scenes?) My motivation for this is that I will be sweeping back and forth along a data structure that is chain of memory blocks (essentially a pointed list), with ~ 10 to 1000 beads. At any given time I am only working with and updating one bead on the chain, so I am wondering if trying to use unpinned memory for the beads not in use would help by speeding up allocations and allowing the g.c. to rearrange their layout in memory. Each bead has a few memory chunks ranging from ~ 100 bytes to possibly up to tens of kilobytes, depending on a scaling parameter on my algorithm. Any thoughts? Cheers, Greg On Nov 11, 2009, at 1:18 PM, Don Stewart wrote: gcross: Hey everyone! Do you have any suggestions for how I might allocate an aligned block of memory that I can pin while making foreign calls, but leave unpinned the rest of the time to potentially improve allocation and garbage collector performance? Or is this even a good idea? There's no pinned/unpinned memory. You have to pick one. * Use a ForeignPtr to allocate pinned memory (mallocForeignPtr) if you want it mostly poinned. Otherwise, you'll need to copy from unpinned to pinned. -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Sometimes pinned memory?
gcross: Thanks, Don. What made me think that this might be possible was the existence of Foreign.StablePtr, since that seems to take a Haskell expression and pin it down. Could this mechanism be harness to pin down arrays, or am I misunderstanding how it works? (Is StablePtr really just making a copy of the expression behind the scenes?) That doesn't make the memory actually stable, it just keeps a dynamic association between a stable pointer and the actual memory address, so you can look up where a block of memory has moved to, keying only with a pointer-sized value. My motivation for this is that I will be sweeping back and forth along a data structure that is chain of memory blocks (essentially a pointed list), with ~ 10 to 1000 beads. At any given time I am only working with and updating one bead on the chain, so I am wondering if trying to use unpinned memory for the beads not in use would help by speeding up allocations and allowing the g.c. to rearrange their layout in memory. Each bead has a few memory chunks ranging from ~ 100 bytes to possibly up to tens of kilobytes, depending on a scaling parameter on my algorithm. If there are many small chunks, unpinned memory is better. Might be ok to copy into pinned memory for the foreign call. -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Opinion about JHC
Hi, John. I am sending you this second email because the first one has a worng paste. However, if I use the right input, I gent the same error. In fact, it gives exactly the same error for any input, right or wrong. {- file: tree.hs -} {- compile: jhc tree.hs -dc -o jtree } import System (getArgs) import System.IO import IO data Op = AND | OR | NOT deriving (Show, Read) data Tree= L Int | T Op [Tree] deriving (Show, Read) main= do putStrLn Give me a tree: s - getLine let xx= read s putStrLn (show (xx::Tree)) Here is what happens when I try to run it: phi...@desktop:~/jhctut$ ./jtree Give me a tree: T AND [L 1, L 2] jtree_code.c:2670: case fell off Aborted It gives the same error for any input: phi...@desktop:~/jhctut$ ./jtestarbo Give me a tree: fdsfkldkl jtestarbo_code.c:2670: case fell off Abortado It seems that the problem is in the Read class, since it works if I use the Show class only: import System (getArgs) import System.IO import IO data Op = AND | OR | NOT deriving (Show, Read) data Tree= L Int | T Op [Tree] deriving (Show, Read) main= do putStrLn Give me a tree: s - getLine let xx= T AND [L 1, L 2] putStrLn (show (xx::Tree)) I hope you can fix it. --- On Wed, 11/11/09, John Meacham j...@repetae.net wrote: From: John Meacham j...@repetae.net Subject: Re: [Haskell-cafe] Opinion about JHC To: haskell-cafe@haskell.org Received: Wednesday, November 11, 2009, 1:37 AM On Tue, Nov 10, 2009 at 07:41:54PM -0800, Philippos Apolinarius wrote: I discovered a Haskell compiler that generates very small and fast code. In fact, it beats Clean. It has the following properties: Excellent. that was my goal ;) 1 --- One can cross-compile programs easily. For instance, here is how I generated code for Windows: jhc --cross -mwin32 genetic.hs -o genetic Yup. This was a major goal. compiling for iPhones and embedded arches is just as easy assuming you have a gcc toolchain set up. (at least with the hacked iPhone SDK.. I have never tried it with the official one) 2 -- It seems to be quite complete. 3 -- However, it often compiles a file, but the program fails to run. I have the following questions about it: 1 -- How active is the team who is writing the JHC compiler? Hi, I am the main contributor, but others are welcome and several have made signifigant contributions. Development tends to be spurty. A lot of work will get done in a short amount of time, this generally corresponds to when an external contributor gets involved and the back and forth helps stimulate patches on my part to complement theirs. Although I have not been able to devote a lot of my time to jhc in the past, hopefully this will change in the not to distant future and I will be able to work on it full time. 2 -- Is it complete Haskell? The author claims that it is; it compiled all programs that I wrote, but that does not mean much, because my programs are quite simple. It does Haskell 98 and several extensions, which is pretty much what GHC does. However, it does not implement the same set of extensions as GHC so this causes issues as a lot of people use GHC extensions extensively. I plan on supporting all of Haskell' of course, and the popular GHC extensions to help compatibility. Not all are implemented. 3 -- Why the Haskell community almost never talks about JHC? Part of it is that I am not very good at advocacy. I don't always post announcements on the main haskell lists figuring the interested parties are on the jhc list already. I do try to make jhc good, fast, and usable, I always hoped someone better at advocacy than me would join the project :) In truth, I think the spurty nature of development also affects this, the list will be quite for a long time with a flurry of development lasting a few weeks occasionally inspiring some discussion in the other groups. In any case, I am glad you liked what you found! please join the mailing list for jhc if you are interested in its development or using it. John -- John Meacham - ⑆repetae.net⑆john⑈ - http://notanumber.net/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe __ Ask a question on any topic and get answers from real people. Go to Yahoo! Answers and share what you know at http://ca.answers.yahoo.com___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: What's the deal with Clean?
Stephen Tetley schrieb: Why speak nonsense when you can test it? // module nonsense import StdEnv nonsense = map ((^) 2) Start = nonsense [1,2,3] // Running gives: [2,4,8] I think they wanted square numbers, not powers of two. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] a problem defining a monad instance
On Fri, 6 Nov 2009, Petr Pudlak wrote: Hi all, (This is a literate Haskell post.) I've encountered a small problem when trying to define a specialized monad instance. Maybe someone will able to help me or to tell me that it's impossible :-). To elaborate: I wanted to define a data type which is a little bit similar to the [] monad. Instead of just having a list of possible outcomes of a computation, I wanted to have a probability associated with each possible outcome. http://hackage.haskell.org/package/probability A natural way to define such a structure is to use a map from possible values to numbers, let's say Floats: module Distribution where import qualified Data.Map as M newtype Distrib a = Distrib { undistrib :: M.Map a Float } Defining functions to get a monad instance is not difficult. return is just a singleton: dreturn :: a - Distrib a dreturn k = Distrib (M.singleton k 1) Composition is a little bit more difficult, but the functionality is quite natural. (I welcome suggestions how to make the code nicer / more readable.) However, the exact definition is not so important. dcompose :: (Ord b) = Distrib a - (a - Distrib b) - Distrib b dcompose (Distrib m) f = Distrib $ M.foldWithKey foldFn M.empty m where foldFn a prob umap = M.unionWith (\psum p - psum + prob * p) umap (undistrib $ f a) The problem is the (Ord b) condition, which is required for the Map functions. When I try to define the monad instance as This won't work and is the common problem of a Monad instance for Data.Set. http://www.randomhacks.net/articles/2007/03/15/data-set-monad-haskell-macros There is however an idea of how to solve this using existential quantification and type families: http://code.haskell.org/~thielema/category-constrained/src/Control/Constrained/Monad.hs ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: What's the deal with Clean?
Hi Henning I spotted that (and also that Clean doesn't have sections) after my blood pressure returned to normal. Best wishes Stephen [2,4,8] I think they wanted square numbers, not powers of two. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] looking for a good algorithm
Thanks. I actually prototyped in Perl the SA method intuitively (though I do not know its name). But it is way slow. So I want to improve the speed by means of both algorithm and language. Hong On Wed, Nov 11, 2009 at 9:36 AM, Tillmann Vogt tillmann.v...@rwth-aachen.de wrote: Hong Yang schrieb: The question is more about algorithm than Haskell. But I am going to code in Haskell which I am still learning. Suppose I have a large table, with hundreds of columns and thousands of rows. But not every cell has a value (of String, or Int, or Double type). I want to shuffle the rows to maximize the number of columns whose first 100 rows have at least one number, given a list of preferred column names since there is no guarantee that every number column will have at least one number in its first 100 rows after shuffling. Can someone provide a good algorithm for this problem? (I do not have any background in algorithms.) You can assume I already know which columns are of Int or Double type. I would say it depends on the distribution of values in the table. If there are rows with a lot of values and rows with few values, then I would first sort the rows after the number of cells with values. If you look at all the columns and the number of values for each row is unique then it would be perfectly solved. With a list of preferred columns and also a uniform distribution the problem might be hard (NP-complete?), but these hard problems can often be approximated, i.e with simulated annealing, which in short is switching two rows repeatedly as long as the result improves. This is not a homework. Thanks, Hong ___ 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] Problem with JHC
Like paolino, I did a couple tests and found: data TreeX = Leaf Int | NotLeaf Int deriving (Show, Read) [to...@mavlo Test]$ ./jtree Give me a tree: Leaf 5 jtree_code.c:2572: case fell off Aborted [to...@mavlo Test]$ ./jtree Give me a tree: NotLeaf jtree_code.c:2572: case fell off Aborted So the read for that does not work... but surprisingly... data TreeX = Leaf Int | NotLeaf deriving (Show, Read) Dropping the Int from the second constructor works (ignore the constructor names, they are just place-holders). [to...@mavlo Test]$ ./jtree Give me a tree: Leaf 43 Leaf 43 [to...@mavlo Test]$ ./jtree Give me a tree: NotLeaf NotLeaf --- OTHER TESTS --- 1) data TreeX = Leaf | NotLeaf 5 deriving (Show, Read) Another unfortunate bug is that reversing the constructors (having Leaf as a nullary constructor and NotLeaf taking an Int) causes compilation to fail (using jhc-0.7.2-0). 2) data TreeX = Leaf Int | NotLeaf Int | OoopsLeaf deriving (Show, Read) Works fine - notice it ends with a nullary constructor... Hypothesis 1: All working Read derivations have data declarations with a nullary constructor at the end. 3) data TreeX = Leaf Int | NotLeaf | OoopsLeaf Int deriving (Show, Read) Fails in with 'case fell off', so H1 seems good 4) data TreeX = Leaf Int | NotLeaf | OoopsLeaf deriving (Show, Read) Works. 5) data TreeX = Leaf | NotLeaf | OoopsLeaf Int deriving (Show, Read) Fails to compile. Hypothesis 2: All working Read derivations that don't cause compile issues have data declarations with non-nullary first constructors. Cheers, Thomas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Least common supertype?
On Nov 12, 2009, at 9:24 AM, Sean Leather wrote: Is there a name for the following concept? [Generalising from (Int, Char) - (Char, Int) (Char, Int) - (Int, Char) to (x,y ) - (y, x )] It's the least specific generalisation, also known as anti- unification. (Because unification finds the most general specialisation.) As far as I know, it originated in this paper: Gordon D. Plotkin. A Note on Inductive Generalization. In B. Meltzer and D. Michie, editors, Machine Intelligence, volume 5, pages 153-163. Elsevier North-Holland, New York, 1970. More precisely, with the type constraints, it's sorted anti-unification. http://www.dfki.uni-kl.de/dfkidok/publications/TM/94/04/abstract.html might be worth a look. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] looking for a good algorithm
So, as I understand it, you have a very large sparse table, thousands of rows and hundreds of columns, of which each cell within a column of type String, Int, or Double can contain one of those types or nothing. Then you to want to shuffle the rows to maximize the number of columns whose first 100 rows have at least one number (Int or Double), given a list of preferred column names since there is no guarantee that every number column will have at least one number in its first 100 rows after shuffling. I'm wondering about hashing on the rows and hashing on the columns, then the column hash has the number of Int's or Double's (don't need the String's) in that column and the rows they are in. The row hash would have the number of Int's and Double's in that row and what column's they are in. Then; Then scan the row hash and sort into descending order, and by tagging those rows, not by actually moving them. Then I think your ready for simmulated annealing. -- Regards, Casey ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] What does the `forall` mean ?
import Text.ParserCombinators.Parsec data PermParser tok st a = Perm (Maybe a) [Branch tok st a] data Branch tok st a = forall b. Branch (PermParser tok st (b - a)) (GenParser tok st b) I have hoogled the `forall` but i cannot find any appropriate answer! thanks! - fac n = foldr (*) 1 [1..n] -- View this message in context: http://old.nabble.com/What-does-the-%60forall%60-mean---tp26311291p26311291.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What does the `forall` mean ?
Forall means the same thing as it means in math, it means for any type -- call it `b` -- then the type of the following it `Branch (PermParser tok st (b - a)` `tok`, `st` and `a` are all given by the declaration of the datatype itself. Hope that makes sense, /Joe On Nov 11, 2009, at 7:24 PM, zaxis wrote: import Text.ParserCombinators.Parsec data PermParser tok st a = Perm (Maybe a) [Branch tok st a] data Branch tok st a = forall b. Branch (PermParser tok st (b - a)) (GenParser tok st b) I have hoogled the `forall` but i cannot find any appropriate answer! thanks! - fac n = foldr (*) 1 [1..n] -- View this message in context: http://old.nabble.com/What-does-the-%60forall%60-mean---tp26311291p26311291.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ 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] ANNOUNCE: simple-observer-0.0.1, a simple implementation of the observer design pattern
Hi all, Further to earlier discussion on this topic, I've just released a first version of this package to hackage: http://hackage.haskell.org/package/simple-observer It is a fairly simple implementation of subject/observer which I've recently used to good effect in an GUI written using wxHaskell. Here's a blog post discussing it further and giving a simple example of use: http://gimbo.org.uk/blog/2009/11/12/simple-observers-in-haskell/ Many thanks for the earlier comments, even if they haven't resulted in any changes (yet?). Best regards, -Andy ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Medical Instruments - Jason
First of all, I find it striking that you are using the declaration: foreign import ccall unsafe rs232.h closecport c_closecport :: CInt - CInt and that it actually works. I would think the only workable declaration would be: foreign import stdcall unsafe rs232.h closecport closecport :: IO () You've tried the signature with `stdcall` and `IO ()` and it doesn't work at all? Likewise, your signature for `c_sendmsg` strikes me as perilous. It should result in a value in `IO`. However, let's ignore all that for now. I wonder, does the Haskell always call `closecport`? Maybe you could put in a print statement in the C to find out? -- Jason Dusek ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What does the `forall` mean ?
On Wed, Nov 11, 2009 at 4:24 PM, zaxis z_a...@163.com wrote: data Branch tok st a = forall b. Branch (PermParser tok st (b - a)) (GenParser tok st b) I have hoogled the `forall` but i cannot find any appropriate answer! That's an example of an existential type. What that line is saying is that for any type b (ie. for all b) that you could pick, the constructor called 'Branch' can take something of type 'PermParser tok st (b - a)' and something of type 'GenParser tok st b' and make something of type 'Branch tok st a' out of it. The reason it's called an existential type is something like this: once you've constructed your thing of type 'Branch tok st a' you've lost the information about what the type b was. So all you know is that inside your thing is a pair of objects of type 'PermParser tok st (b - a)' and 'GenParser tok st b' but you don't know what b is. All you know is that there exists some type 'b' that it was made of. To use these types with ghc you need to use the compilation flag -XExistentialQuantification. There's more to be found here: http://www.haskell.org/haskellwiki/Existential_type -- Dan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Least common supertype?
Richard O'Keefe wrote: On Nov 12, 2009, at 9:24 AM, Sean Leather wrote: Is there a name for the following concept? [Generalising from (Int, Char) - (Char, Int) (Char, Int) - (Int, Char) to(x,y ) - (y, x )] It's the least specific generalisation, also known as anti-unification. (Because unification finds the most general specialisation.) As far as I know, it originated in this paper: Gordon D. Plotkin. A Note on Inductive Generalization. In B. Meltzer and D. Michie, editors, Machine Intelligence, volume 5, pages 153-163. Elsevier North-Holland, New York, 1970. IANTT (I am not a type theorist) but... If you're talking about supertypes and subtypes, then I think this can be classified as a least upper bound. I.e. if there is a function that is used in both the first and second context provided, then one can infer that its constraints must satisfy both signatures. To then unify the signatures, construct a supertype which by definition both must satisfy. Eventually (when you know the constraints are fully saturated), you can then unify the supertype constraints by taking the least upper bound -- which, by contravariance, is the greatest lower bound of the input and the least upper bound of the output. The greatest lower bound of the inputs will enforce parametricity because the only common subtype of Int and Char is bottom. The least upper bound of the output is then trivial. --S ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Problem with JHC
Am Mittwoch 11 November 2009 23:50:21 schrieb Thomas DuBuisson: Like paolino, I did a couple tests and found: So the read for that does not work... but surprisingly... data TreeX = Leaf Int | NotLeaf deriving (Show, Read) Dropping the Int from the second constructor works (ignore the constructor names, they are just place-holders). --- OTHER TESTS --- 1) data TreeX = Leaf | NotLeaf 5 deriving (Show, Read) Another unfortunate bug is that reversing the constructors (having Leaf as a nullary constructor and NotLeaf taking an Int) causes compilation to fail (using jhc-0.7.2-0). 2) data TreeX = Leaf Int | NotLeaf Int | OoopsLeaf deriving (Show, Read) Works fine - notice it ends with a nullary constructor... Hypothesis 1: All working Read derivations have data declarations with a nullary constructor at the end. Must be something like that, it also dies badly reading Either (but reading integers works): module Main where a, n :: Either Int Char a = Right 'a' n = Left 4 sa = Right 'a' sn = Left 4 main :: IO () main = do putStrLn Showing: print (sa == show a) print (sn == show n) putStrLn Reading: print (read 123 :: Integer) print (a == read sa) print (n == read sn) results in $ ./veither Showing: True True Reading: 123 veither_code.c:3642: case fell off $ jhc --version jhc 0.7.2 (0.7.2-0) compiled by ghc-6.10 on a i386 running linux Cheers, Thomas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Package Woes
Sorry, slightly off-topic. I wanted to install LHC to compare that to GHC and JHC, but alas: da...@linux-mkk1:~/Haskell/LHC/lhc-0.8 cabal install -fwith-libs -flhc-regress Resolving dependencies... Configuring libffi-0.1... cabal: The pkg-config package libffi is required but it could not be found. cabal: Error: some packages failed to install: lhc-0.8 depends on libffi-0.1 which failed to install. libffi-0.1 failed during the configure step. The exception was: exit: ExitFailure 1 Okay, so I installed libffi, but to no avail, still can't find libffi. The problem is apparently that libffi doesn't come with a .pc file, so pkg-config doesn't know about it. Does anybody know how to fix that? (openSuse 11.1, if that matters) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANNOUNCE: dbus-core 0.6 and dbus-client 0.2
This is the second public release of my D-Bus implementation. dbus-core is an implementation of the D-Bus protocol, and dbus-client is a set of wrappers and utility computations to simplify writing basic clients. Interesting changes to dbus-core * Performance improvements: sending and receiving large structures should now be significantly faster. My thanks and appreciation go to Bryan O'Sullivan, whose excellent Criterion library made benchmarking the serialisation code much easier than it had any right to be. * Better support for byte arrays: byte strings (strict and lazy) are now directly supported types, with special cases to avoid most conversion overhead. * Implemented the TCP/IP transport, though it's untested because I can't figure out how to make the server listen on a socket. If anybody cares about remote D-Bus, and this doesn't work, drop me a mail with your configuration and I'll find out why. * Added module to represent match rules, required for full signal support. * Added module for name reservations -- this is really just moving the bulk of the code from dbus-client into dbus-core, where it belongs. * Fixed possible concurrency issue when receiving messages from a connection in multiple threads. This is still a really bad idea, and it will never work correctly, but at least now it won't corrupt the connection state. Interesting changes to dbus-client == * Fixed dumb signature to mkClient (thanks, Max). Its purpose should now be more obvious. * Shifted around some of the method call APIs -- it's now possible to send method calls without a proxy. * Uses the new MatchRule work to fully support receiving signals. Documentation = PDFs of the source; these are the most useful and complete documentation currently available: https://dl.dropbox.com/u/1947532/dbus-core_0.6.pdf https://dl.dropbox.com/u/1947532/dbus-client_0.2.pdf An API listing is also available, good for a quick overview: https://dl.dropbox.com/u/1947532/dbus-core_0.6/index.html https://dl.dropbox.com/u/1947532/dbus-client_0.2/index.html Hackage is currently experiencing some dependency conflicts with the bytestring library[1], so it's not generating its own documentation. I'll keep the dropbox pages up until Hackage is in a more usable state. Downloads = Available from the usual places: http://hackage.haskell.org/packages/archive/dbus-core/0.6/dbus-core-0.6.tar.gz http://hackage.haskell.org/packages/archive/dbus-client/0.2/dbus-client-0.2.tar.gz [1] binary uses bytestring-0.9.1.4, text uses bytestring-0.9.1.5, kaboom ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] faster compiling for ghc
Hello Evan, Thursday, November 12, 2009, 4:02:17 AM, you wrote: Recently the go language was announced at golang.org. There's not a lot in there to make a haskeller envious, except one real big one: compilation speed. The go compiler is wonderfully speedy. are you seen hugs, for example? i think that ghc is slow because it's written in haskell and compiled by itself hugs provides good interactive environment and good ghc compatibility, you can use conditional compilation to hide remaining differences. unfortunately, many haskell libs doesn't support hugs -- Best regards, Bulatmailto:bulat.zigans...@gmail.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] (state) monad and CPS
Nicolas Pouillard wrote: Excerpts from jean-christophe mincke's message of Tue Nov 10 21:18:34 +0100 2009: do acc - get put (acc+1) ... Since this pattern occurs often 'modify' is a combination of get and put: do modify (+1) ... Though the caveat about laziness applies here as well. modify is famously lazy which can lead to space leaks and stack overflows. Better would be to define and use your own strict version: modify' f = get = \x - put $! f x -- Live well, ~wren ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] faster compiling for ghc
On Thu, Nov 12, 2009 at 7:18 AM, Bulat Ziganshin bulat.zigans...@gmail.com wrote: Hello Evan, Thursday, November 12, 2009, 4:02:17 AM, you wrote: Recently the go language was announced at golang.org. There's not a lot in there to make a haskeller envious, except one real big one: compilation speed. The go compiler is wonderfully speedy. are you seen hugs, for example? i think that ghc is slow because it's written in haskell and compiled by itself If I understood, Evan is interested in ideas to speed up compilation. As far as I know, hugs is an interpreter, not a compiler. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Problem about hidden package again.
Hi, Today, when I compiled gtk2hs, I got this: cairo/Graphics/Rendering/Cairo.hs.pp:264:0: Failed to load interface for `Data.Array.Base': it is a member of the hidden package `array-0.2.0.0' Use -v to see a list of the files searched for. As usual, I searched for the resolvement. No luck. And seems like this problem (not particularly to this package) is very common. I wonder how to resolve it? -- 竹密岂妨流水过 山高哪阻野云飞 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] lambda-bot installation problem: gentoo trickery problem
When I try cabal-install lambdabot (gentoo linux/amd64, ghc installed with portage), it runs fine until compiler tries to link readline package (some template haskell?). The problem caused by dirty trick, used in gentoo: the /usr/lib64/libreadline is a fake with script, redirecting ld to /lib64 . GHC is not redirected but simply fails with message can't load .so/.DLL for: readline (/usr/lib64/libreadline.so: invalid ELF header). So, the question is: is there any workaround? Copying library look like an option, but it is very, very dirty one. Is there a way to say ghc, which libreadline.so it should load? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Least common supertype?
sterl wrote: Richard O'Keefe wrote: On Nov 12, 2009, at 9:24 AM, Sean Leather wrote: Is there a name for the following concept? [Generalising from (Int, Char) - (Char, Int) (Char, Int) - (Int, Char) to(x,y ) - (y, x )] It's the least specific generalisation, also known as anti-unification. (Because unification finds the most general specialisation.) As far as I know, it originated in this paper: Gordon D. Plotkin. A Note on Inductive Generalization. In B. Meltzer and D. Michie, editors, Machine Intelligence, volume 5, pages 153-163. Elsevier North-Holland, New York, 1970. IANTT (I am not a type theorist) but... If you're talking about supertypes and subtypes, then I think this can be classified as a least upper bound. It is a least upper bound, but only in a particular sense. The particular sense is (of course) anti-unification. To strike to the core of why it's not unification, if we try to unify Int and Char the answer is no, those do not unify because the type IntChar is overconstrained (i.e. empty). This is exactly the behavior we want for HM type inference: type variables are allowed to be specialized down to (possibly ungrounded) terms, but if they specialize down too far then there's a type error, and there's no way to un-specialize terms back up because that would let us lose track of constraints on permissible types. Unification is a variety of intersection. Antiunification is the dual notion which is a variety of unioning. If we antiunify Int and Char, the answer will be Int|Char or whatever the closest analogue is (e.g. a free type variable) if the language doesn't allow indiscriminate unions. Depending on how we think of the sortal graph, we could also say unification returns the GLB whereas antiunification returns the LUB. (Antiunification shouldn't be confused with disunification, which is the negative of unification rather than the dual. Disunification says these things are not allowed to be equal so it's a sort of symmetric difference.) -- Live well, ~wren ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What does the `forall` mean ?
Without `forall`, the ghci will complain: Not in scope: type variable `b' It is clear now. thank you! Dan Piponi-2 wrote: On Wed, Nov 11, 2009 at 4:24 PM, zaxis z_a...@163.com wrote: data Branch tok st a = forall b. Branch (PermParser tok st (b - a)) (GenParser tok st b) I have hoogled the `forall` but i cannot find any appropriate answer! That's an example of an existential type. What that line is saying is that for any type b (ie. for all b) that you could pick, the constructor called 'Branch' can take something of type 'PermParser tok st (b - a)' and something of type 'GenParser tok st b' and make something of type 'Branch tok st a' out of it. The reason it's called an existential type is something like this: once you've constructed your thing of type 'Branch tok st a' you've lost the information about what the type b was. So all you know is that inside your thing is a pair of objects of type 'PermParser tok st (b - a)' and 'GenParser tok st b' but you don't know what b is. All you know is that there exists some type 'b' that it was made of. To use these types with ghc you need to use the compilation flag -XExistentialQuantification. There's more to be found here: http://www.haskell.org/haskellwiki/Existential_type -- Dan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe - fac n = foldr (*) 1 [1..n] -- View this message in context: http://old.nabble.com/What-does-the-%60forall%60-mean---tp26311291p26314602.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Wrestling the inliner beast
I did a little bit of Data.Text benchmarking the other day, and I was shocked to find that decoding a UTF-8 stream proceeded at a sedate 3MB/sec. On investigation, the culprit was that I'd marked both the outer function and the inner (a loop) as INLINE. Because the inner loop was marked as INLINE, GHC wasn't inlining critically important leaf functions into it, so I was getting clobbered to death by boxing and unboxing. Leaving the outer function marked as INLINE, but taking the INLINE off the inner function, seems to cause *both* to get inlined as I originally hoped. This behaviour is all rather mysterious to me. The old Secrets of the Inliner paper is very much out of date now, but short of reading the source, I don't know where else to look to turn my voodoo folk intuition into something more solid. Is this all going to change in 6.12 anyway? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Least common supertype?
wren ng thornton wrote: sterl wrote: IANTT (I am not a type theorist) but... If you're talking about supertypes and subtypes, then I think this can be classified as a least upper bound. It is a least upper bound, but only in a particular sense. The particular sense is (of course) anti-unification. And part of the reason I say only in a particular sense is that it depends what graph we're talking about. There are many different varieties of relations we could draw among types. One is a parametric polymorphism relationship where some types are more polymorphic than and subsume other types. But we could also be discussing languages with a class hierarchy, or refinement types, or some other sense in which one type is bigger or contains another. Ideas like most general unifier and least specific generalization are just another relation on types. But they're particularly quirky because they take some subset of other type relations into account. Which is also to say that they may choose not to take certain other relations into account. A classic example here is the way Java generics ignore super-/subclass relations in the parameters. So the graph we draw of the MGU/LSG relation may not be coextensive with other graphs of super and sub types. Also, because of the properties of the function arrow there can be issues of contravariance to muddy the picture as well. Your intuition is on the right track, but it can be problematic to pin down in a way that adds meaningfully to the understanding of MGU/LSG. -- Live well, ~wren ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Static Linking Problem
On Wed, Nov 11, 2009 at 5:44 PM, Svein Ove Aas svein@aas.no wrote: My recommendation would be to take glibc off the list of statically linked libraries. How do you do that ? David. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe