[Haskell-cafe] Hackathon der Frankfurt-Haskell-User-Group
the Frankfurt Haskell User Group announces its first Hackathon, if interested, see here: http://www.meetup.com/Frankfurt-Haskell-User-Group/events/138895112/ Peter Althainz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Boulder Haskell Programmers, Next Meeting July 17
The Boulder Haskell Programmer Group is getting together on July 17 at 6:30pm. All experience levels are welcome. Agenda: * 6:30--7:00: Social/beer time. * 7:00--7:30: What do we want from this group? * 7:30--8:30: Introduction to Haskell Types. * 8:30--9:00: Whatever! http://www.meetup.com/Boulder-Haskell-Programmers/events/125427022/ -- Peter Jones, Founder, Devalot.com Defending the honor of good code ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell for Programmers Workshop: Denver, Colorado
Since this is shameless self-promotion I'll keep it short. I'm teaching a Haskell workshop for imperative programmers in Denver, Colorado, September 16-18. If you want more information please take a look at the workshop website: http://www.devalot.com/workshops/haskell/index.html -- Peter Jones --- Love to Develop Devalot: http://www.devalot.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Array, Vector, Bytestring
Hi Tom, thank you for the explanation. I believe you are suggesting that there is redundancy in the implementation details of these libraries, not in the APIs they expose. I meant to say that there is redundancy in *both*. The libraries mentioned in this thread re-implement the same type internally and expose APIs to the user that are largely identical. Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Array, Vector, Bytestring
Hi Clark, How is this a problem? If you're representing text, use 'text'. If you're representing a string of bytes, use 'bytestring'. If you want an array of values, think c++ and use 'vector'. the problem is that all those packages implement the exact same data type from scratch, instead of re-using an implementation of a general-purpose array internally. That is hardly desirable, nor is it necessary. Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Frankfurt Haskell User Group meets 19.6.13, topics: Netwire, Hackathon planning
Dear All, all interested Haskellers are inivted to our Meetup on 19.6.13: http://www.meetup.com/Frankfurt-Haskell-User-Group/events/122879122/. Best regards Peter Althainz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Array, Vector, Bytestring
Hi Tom, On Tue, Jun 04, 2013 at 04:01:37PM +0200, Peter Simons wrote: How is this a problem? If you're representing text, use 'text'. If you're representing a string of bytes, use 'bytestring'. If you want an array of values, think c++ and use 'vector'. the problem is that all those packages implement the exact same data type from scratch, instead of re-using an implementation of a general-purpose array internally. That is hardly desirable, nor is it necessary. Just to clarify for those on the sidelines, the issue is duplication of implementation details, rather than duplication of functionality? I am not sure what the terms duplication of implementation details and duplication of functionality mean in this context. Could you please explain how these two concepts differ in your opinion? Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Packages in distro mentioned on hackage?
Hi Magnus, How does a distro get to be added like that? check out http://hackage.haskell.org/trac/hackage/ticket/570. Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Frankfurt Haskell User Group - Meetup on Yesod, 24.4.13
The Frankfurt Haskell User Group meets on 24.4.13 for a presentation on Yesod. http://www.meetup.com/Frankfurt-Haskell-User-Group/. Regards: Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] What happened to http://hackage.haskell.org/platform/2010.2.0.0/cabal/haskell-platform-2010.2.0.0.tar.gz?
Is it just me or have some of the old Haskell Platform releases disappeared from haskell.org? The 2010.x links from http://www.haskell.org/platform/prior.html also point to non-existent pages. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Announcement - HGamer3D - 0.2.1 - why netwire
Hi Heinrich, Hi Ertugrul thanks for all your comments so far. In last e-mail, you wrote: Heinrich Apfelmus apfel...@quantentunnel.de wrote: In the case of HGamer3D, the sink combinator would replace the need to declare a final wire which runs all the wires at each step. It feels a bit weird to me to have wires like guiSetPropW that perform side effects, i.e. where it makes a different whether you observe their results or not. That's a complexity where I feel that something has been swept under the rug. In particular imperative wires like guiSetPropW (or anything for which *set* is a sensible name) are simply wrong. A widget, e.g. a button, should look like this: type MyWire= WireM (Reader MyConfig) type MyEvent a = MyWire a a button :: MyEvent Button = A short explanation on the guiSetPropW wire: The guiSetPropW can be considered as being part of the GUI binding actually. It is in the public Api to overcome the limitation of not having all properties as single wires coded. Anyhow, if you want to act on something in the GUI (for example make a window visible or not) you will probably need something with a side effect. That is, where the guiSetPropW is used in the examples. But it is a little bit low level, the higher level wires look more nicer: for example, the button wire creation acutally looks like that: buttonW:: GUIElement - GameWire a a with the button wire having the type of: GameWire a a It is a pure event wire, which gets fired, when the button is pressed. the label wire creation staticTextW :: GUIElement - GameWire String String with the labe wire having the type of: GameWire String String the editbox wire creation: editBoxW :: GUIElement - (GameWire a String, GameWire String String) creates two wires, one for getting notified on changes of the element: type: GameWire a String and one for setting a new value to the string: type: GameWire String String Here, I would be interested in your view. Of course you can make one wire out of it, but this has different consequences: - how to check for a change in the widget, if the wire is not executed, because no input value occur? - usually you need the output of the wire in different places of your final network where the input wire is needed, if you have only one wire this might be cumbersome, to code in combining the final network - and: yes, there has been also something swept under the rug here, because since both wires refer to the same GUI element, there is the same GUI element used inside, which is a reference. Actually this is somthing more OO/Scala like then Haskell but it works fine for me so far, since it does overcome the limitations of the points above. BR Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] install cuda
yes, the installation seems to work fine now. However, doing the following test in ghci Prelude :m +Foreign.CUDA Prelude Foreign.CUDA props 0 Loading package bytestring-0.9.2.1 ... linking ... done. Loading package cuda-0.5.0.0 ... linking ... done. results in a crash. The CUDA version I am using is 4.1.28. You think there is something I could try to analyze this further ? Thanks a lot for your help Peter Am 31.03.2013 21:48, schrieb Geoffrey Mainland: You need to generate the configure script using autoconf: https://www.gnu.org/software/autoconf/manual/autoconf.html#autoconf-Invocation On 03/31/2013 08:27 PM, Peter Caspers wrote: Hmm, I get Configuring cuda-0.5.0.0... setup.exe: configure script not found. can you help ? Peter I was able to install the cuda package under 32-bit GHC 7.4.2 using the 5.0 SDK and use it from within ghci. This required using my fork of the cuda repo and following the instructions in my WINDOWS.md. Make sure nvcc is in your path (the CUDA installer should have made this so) and try 'cabal configure'. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] install cuda
indeed, not very helpful ... When I installed Cuda the latest driver (296.0) that was running on my laptop (a W520 ThinkPad) was not sufficient for version 5.0. However as I noticed today in February Lenovo released a driver update (311.0) and with that 5.0 is in fact running. :-) With that the Haskell bindings work well. Thanks again very much, Geoff Peter Am 01.04.2013 12:25, schrieb Geoffrey Mainland: That is not a very elucidating crash message, so I don't see how to proceed. After ghci print Loading package cuda-0.5.0.0 ... linking ... done. it just exits? No error dialog, nothing? Did you try building any of the examples in the cuda package that don't require ghci? Is your graphics card incompatible with CUDA 5.0, or do you just not want to update your driver? Geoff On 04/01/2013 10:33 AM, Peter Caspers wrote: yes, the installation seems to work fine now. However, doing the following test in ghci Prelude :m +Foreign.CUDA Prelude Foreign.CUDA props 0 Loading package bytestring-0.9.2.1 ... linking ... done. Loading package cuda-0.5.0.0 ... linking ... done. results in a crash. The CUDA version I am using is 4.1.28. You think there is something I could try to analyze this further ? Thanks a lot for your help Peter Am 31.03.2013 21:48, schrieb Geoffrey Mainland: You need to generate the configure script using autoconf: https://www.gnu.org/software/autoconf/manual/autoconf.html#autoconf-Invocation On 03/31/2013 08:27 PM, Peter Caspers wrote: Hmm, I get Configuring cuda-0.5.0.0... setup.exe: configure script not found. can you help ? Peter I was able to install the cuda package under 32-bit GHC 7.4.2 using the 5.0 SDK and use it from within ghci. This required using my fork of the cuda repo and following the instructions in my WINDOWS.md. Make sure nvcc is in your path (the CUDA installer should have made this so) and try 'cabal configure'. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] install cuda
Hi, thank you. I could resolve some of the problems by removing spaces from the Cuda and Haskell platform installation paths. Now I am left wiht the following error: configure:3596: checking for library containing cuDriverGetVersion configure:3627: c:\HaskellPlatform\2012.4.0.0\mingw\bin\gcc.exe -o conftest.exe -Wl,--hash-size=31 -Wl,--reduce-memory-overheads -I/c/CUDA/NVIDIA_GPU_Computing_Toolkit/CUDA/v4.1/include -L/c/CUDA/NVIDIA_GPU_Computing_Toolkit/CUDA/v4.1/lib conftest.c 5 C:\Users\Peter\AppData\Local\Temp\ccOsnsjD.o:conftest.c:(.text+0xc): undefined reference to `cuDriverGetVersion' collect2: ld returned 1 exit status In fact the library path -L/c/CUDA/NVIDIA_GPU_Computing_Toolkit/CUDA/v4.1/lib is not correct (there are two subfolders x64 and Win32 containing the lib files) and I do not see where this path is actually taken from. I defined an enviroment variable LD_LIBRARY_PATH with the correct paths (separated by a colon), but it seems to be ignored. Also copying the lib files to the path I see in the log does not help. Do you have any hint for me concerning this ? Peter Am 31.03.2013 00:56, schrieb Henk-Jan van Tuyl: On Sat, 30 Mar 2013 20:43:58 +0100, Peter Caspers pcaspers1...@gmail.com wrote: Hi, I am trying to install the cuda package on a Windows 7 enviroment. However I run into an error and can not figure out, what it is. : : configure: error: C compiler cannot create executables See `config.log' for more details : The message says it all: See `config.log' for more details The config.log file is probably in the directory where cabal-install unpacks it (%appdata%\cabal\cuda-revision); you can also use the commands: cabal unpack cuda cd cuda cabal install notepad config.log I just had the same error message for another package; from the config.log file it became clear, that the linker could not find the necessary library. Make sure, that the libraries and header files can be found by the compiler and linker, by setting the proper environment variables, see [0] Regards, Henk-Jan van Tuyl [0] http://www.haskell.org/haskellwiki/Windows#Tools_for_compilation ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] install cuda
The environment variable should probably be LIBRARY_PATH; I use a semicolon as separator. See also LD_LIBRARY_PATH vs LIBRARY_PATH[0]. yes, it's LIBRARY_PATH. The x64 version of cuda.lib is not recognized at all (same error message as if the file was not existent). The Win32 version works, but results in configure:3627: c:\HaskellPlatform\2012.4.0.0\mingw\bin\gcc.exe -o conftest.exe -Wl,--hash-size=31 -Wl,--reduce-memory-overheads -I/c/CUDA/NVIDIA_GPU_Computing_Toolkit/CUDA/v4.1/include -L/c/CUDA/NVIDIA_GPU_Computing_Toolkit/CUDA/v4.1/lib conftest.c -lcuda 5 C:\Users\Peter\AppData\Local\Temp\ccOwCQ6n.o:conftest.c:(.text+0xc): undefined reference to `cuDriverGetVersion' collect2: ld returned 1 exit status I ran nm on cuda.lib and got the entry nvcuda.dll: I .idata$4 I .idata$5 I .idata$6 T .text U _IMPORT_DESCRIPTOR_nvcuda I _imp__cuDriverGetVersion@4 T cuDriverGetVersion@4 this looks ok so far. Running nm on the x64 version of the lib file results in rubbish output (consistent with the observation above). I understand that LD_LIBRARY_PATH is used to look up to dll when running the program (is that correct?). However we are not at this point yet, are we, since the error occurs on the gcc invocation ? Try my fork: https://github.com/mainland/cuda In particular, read WINDOWS.md. I also read Geoffreys WINDOWS.md and understood that configuring dll names are only necessary when using ghci, not for compiled programs (nothing to do for this case ?) and in particular not for installing the package ? Actually the dll is not named nvcuda.dll as indicated in the nm output, but rather cudart32_41_28.dll I suppose and this file is located in the bin subfolder. I should set LD_LIBRARY_PATH to the bin folder, yes ? Should I configure this dll name for package installation already (i.e. in addition to what is mentioned in WINDOWS.md) ? If yes, how ? Thank you Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] install cuda
yes I more or less saw this in the meantime, too. Actually modifying the source code on which the error is reported from configure: failed program was: | /* confdefs.h */ | #define PACKAGE_NAME Haskell CUDA bindings | #define PACKAGE_TARNAME cuda ... | #ifdef __cplusplus | extern C | #endif | char cuDriverGetVersion (); | int | main () | { | return cuDriverGetVersion (); | ; | return 0; | } to (for example) #include stdlib.h #include stdio.h #include string.h #include cuda.h int main( int argc, char** argv) { int driverVersion = 0; cuDriverGetVersion(driverVersion); printf(version = %d\n,driverVersion); return 0; } let me compile, link and run without errors. Alright, got it now, I will try your github. Do you think it works with CUDA 4.1 ? On my laptop this is the latest version that runs due to the card driver. Thanks in any case Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] install cuda
Hmm, I get Configuring cuda-0.5.0.0... setup.exe: configure script not found. can you help ? Peter I was able to install the cuda package under 32-bit GHC 7.4.2 using the 5.0 SDK and use it from within ghci. This required using my fork of the cuda repo and following the instructions in my WINDOWS.md. Make sure nvcc is in your path (the CUDA installer should have made this so) and try 'cabal configure'. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] install cuda
Hi, I am trying to install the cuda package on a Windows 7 enviroment. However I run into an error and can not figure out, what it is. Can someone help ? Thanks a lot Peter C:\Users\Peter\_dev\haskellcabal install cuda Resolving dependencies... [1 of 1] Compiling Main ( C:\Users\Peter\AppData\Local\Temp\cuda-0.5.0.1-11856\cuda-0.5.0.1\Setup.hs, C:\Users\Peter\AppData\Local\Temp\cuda-0.5.0.1 -11856\cuda-0.5.0.1\dist\setup\Main.o ) Linking C:\Users\Peter\AppData\Local\Temp\cuda-0.5.0.1-11856\cuda-0.5.0.1\dist\setup\setup.exe ... Configuring cuda-0.5.0.1... cygwin warning: MS-DOS style path detected: C:\Users\Peter\AppData\Roaming\cabal/share/config.site Preferred POSIX equivalent is: /cygdrive/c/Users/Peter/AppData/Roaming/cabal/share/config.site CYGWIN environment variable option nodosfilewarning turns off this warning. Consult the user's guide for more details about POSIX paths: http://cygwin.com/cygwin-ug-net/using.html#using-pathnames checking for gcc... C:\Program Files (x86)\Haskell Platform\2012.4.0.0\mingw\bin\gcc.exe checking whether the C compiler works... no configure: error: in `/cygdrive/c/Users/Peter/AppData/Local/Temp/cuda-0.5.0.1-11856/cuda-0.5.0.1': configure: error: C compiler cannot create executables See `config.log' for more details cabal: Error: some packages failed to install: cuda-0.5.0.1 failed during the configure step. The exception was: ExitFailure 77 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Announcement - HGamer3D - 0.2.1 - why netwire
Hi Heinrich: Its simply the types are more cumbersome, now. In netwire you basically have one type, which is Wire with some type parameters (underlying monad, inhibition type, in-type, out-type), When underlying monad and inhibition type is choosen, you can define a type synonym and all boils done to GameWire a b in all types, events (GameWire a a), behaviours (GameWire a b), what you want. Signal inhibition makes Events and Behviours looks equal. Also the overall network has this type. And by the way, no generalized datatypes (forall t. ), which I'm also not too comfortable with. In reactive banana we have considerably more types then in netwire: - One tpye for Behaviours - One type for Events - sinks in addition: sinkoutput[text:==showNumber$result]- what is that? (I know it has something to do with feedback loops) - scary type for the network description: forallt.Frameworkst=Momentt() best regards Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Announcement - HGamer3D - 0.2.1 - featuring FRP based GUI and more
Hi Johan, you are right all libraries could be compiled at least on Linux (maybe even Mac OS) and the bindings could be too. I simply have no time currently to mainain another platform. I started on Windows, because I like it and I thought its the platform with the most gamers. I got in troubles with the linux toolchain on Windows (gcc with Mingw) for Ogre and switched to the MSVC based Ogre libraries, not considering that possibly the Ogre Linux libraries directly on Linux might work well. If there is time or sombody volunteers a Linux version can be built, I'm quite sure. regards Peter Johan Holmquist schrieb: Looks nice! I am curious as to why this is Windows only. Of the listed libraries (Ogre, CEGUI, SFML, enet, BulletPhysics, Vect, netwire) none seem to be platform specific. Regards /Johan 2013/3/20 Ivan Perez ivanperezdoming...@gmail.com: This is very cool. I've been keeping an eye on this library for a few months. Keep it on! On 19 March 2013 15:18, Heinrich Apfelmus apfel...@quantentunnel.de wrote: Peter Althainz wrote: Dear All, I'm happy to announce release 0.2.1 of HGamer3D, the game engine with Haskell API, featuring FRP based API and FRP based GUI. The new FRP API is based on the netwire package. Currently only available on Windows: http://www.hgamer3d.org. Nice work! Of course, I have to ask: what influenced your choice of FRP library in favor of netwire instead of reactive-banana ? Best regards, Heinrich Apfelmus -- http://apfelmus.nfshost.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
[Haskell-cafe] Announcement - HGamer3D - 0.2.1 - why netwire
Peter Althainz wrote: Dear All, I'm happy to announce release 0.2.1 of HGamer3D, the game engine with Haskell API, featuring FRP based API and FRP based GUI. The new FRP API is based on the netwire package. Currently only available on Windows: http://www.hgamer3d.org. Nice work! Of course, I have to ask: what influenced your choice of FRP library in favor of netwire instead of reactive-banana ? Best regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com Hi Heinrich good question, actually I need to thank you for your excellent tutorials on FRP and GUI on the WEB. I tried the version of reactive-banana without switches as the first FRP framework to have contact with and I liked its simplicity and the cool introduction around Excel cells you gave on the Web. HGamer3D is my personal way to get more insight into FP and Haskell especially and from the beginning I wanted to have a FRP API to try it with game examples. So your intro on FRP and the examples were very helpful with that. After reading a lot on the web it became clear, that currently reactive-banana and netwire are good candidates to start with. So why in the end I decided to use netwire for the binding? It's some personal things and I do not claim to have done a proper evaluation or comparison. I also cannot judge on performance or other relevant topics. Having said that, I can give you some points why I choosed netwire: - The cool simplicity of reactive-banana API seems to have suffered a little bit after the introduction of the switch functionality. - After getting around Monads and Applicative by great help of Learning a Haskell for great good I was shocked to see, there is even more to learn, when I detected Arrows. So I started to look at it and discovered some nice tutorials for Arrows. - What struck me was introduction of netwire author Ertugrul Söylemez on Arrows and the explanations of local state, which can be kept into an arrow. Since I was also curious on OOP and FP and game state handling, actually this raised some interest. So I think this Arrows keep local state argument was the killer feature. But also behaviours keep local state and maybe I got misguided here. - I then did some trials with netwire and I felt it's a quite comprehensive and nice API, so I got started with that. regards Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Streaming bytes and performance
Don Stewart don...@gmail.com writes: Here's the final program: [...] Here is a version of the program that is just as fast: import Prelude hiding ( getContents, foldl ) import Data.ByteString.Char8 countSpace :: Int - Char - Int countSpace i c | c == ' ' || c == '\n' = i + 1 | otherwise = i main :: IO () main = getContents = print . foldl countSpace 0 Generally speaking, I/O performance is not about fancy low-level system features, it's about having a proper evaluation order: | $ ghc --make -O2 -funbox-strict-fields test1 time ./test1 | 37627064 | | real 0m0.381s | user 0m0.356s | sys 0m0.023s Versus: | $ ghc --make -O2 -funbox-strict-fields test2 time ./test2 test.txt | Linking test2 ... | 37627064 | | real 0m0.383s | user 0m0.316s | sys 0m0.065s Using this input file stored in /dev/shm: | $ ls -l test.txt | -rw-r--r-- 1 simons users 208745650 Mar 19 21:40 test.txt Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Streaming bytes and performance
Hi Don, Compare your program (made lazy) on lazy bytestrings using file IO: [...] if I make those changes, the program runs even faster than before: module Main ( main ) where import Prelude hiding ( foldl, readFile ) import Data.ByteString.Lazy.Char8 countSpace :: Int - Char - Int countSpace i c | c == ' ' || c == '\n' = i + 1 | otherwise = i main :: IO () main = readFile test.txt = print . foldl countSpace 0 This gives | $ ghc --make -O2 -funbox-strict-fields test1 time ./test1 | 37627064 | | real0m0.375s | user0m0.346s | sys 0m0.028s versus: | $ ghc --make -O2 -funbox-strict-fields test2 time ./test2 | 37627064 | | real0m0.324s | user0m0.299s | sys 0m0.024s Whether getFile or getContents is used doesn't seem to make difference. Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Streaming bytes and performance
Hi Don, Using this input file stored in /dev/shm So not measuring the IO performance at all. :) of course the program measures I/O performance. It just doesn't measure the speed of the disk. Anyway, a highly optimized benchmark such as the one you posted is eventually going to beat one that's not as highly optimized. I think no-one disputes that fact. I was merely trying to point out that a program which encodes its evaluation order properly is going to be reasonably fast without any further optimizations. Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Announcement - HGamer3D - 0.2.1 - featuring FRP based GUI and more
Dear All, I'm happy to announce release 0.2.1 of HGamer3D, the game engine with Haskell API, featuring FRP based API and FRP based GUI. The new FRP API is based on the netwire package. Currently only available on Windows: http://www.hgamer3d.org. Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Overloading
In C++ it is perfectly normal to have overloaded functions like f : Int - Int - Int f : Int - Char - Int Something that may not be obvious about Haskell is that Haskell does NOT have overloaded functions/operators at all. thanks, this was the core of my question. So by example, if I define a Date type as data Date = Date Int deriving Show representing a date by its serial number and want two constructors (conditions are only examples here) -- smart constructor with serialNumber date serialNumber | serialNumber 0 = Date serialNumber | otherwise = error (invalid serialNumber ++ show serialNumber) -- smart constructor with day month year date2 day month year | month = 1 month =12 = undefined | otherwise = error (invalid month ++ show month) there is no way of naming both functions date (instead of date2 above, which compiles), right ? I still think the basic reason is that date 5 would then either refer to the first constructor (i.e. representing a date with serial number 5) or a partial application of the second constructor (i.e. representing a function taking month and year and returning the date 5th month, year). If this is the case, what would be the natural Haskell way of organizing the smart constructors ? Just number them as above ? Or naming them dateFromSerialNumber, dateFromDayMonthYear ? Or would you do it differently from the start ? Thank you Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Overloading
Hi Daniel, Instead of raising an error it's more secure to return a Maybe value. date :: Int - Maybe Date date serialNumber | serialNumber 0 = Just $ Date serialNumber | otherwise= Nothing yes, I understand (Maybe seems the equivalent of c++'s boost::optionalT). -- smart constructor with day month year date2 day month year | month = 1 month =12 = undefined | otherwise = error (invalid month ++ show month) To increase type safety it's a good idea to use as much explicit data types instead of Int values as possible: data Month = January | ... ok, I will try to change my code in that direction. The idea is clear. I would use the descriptive names but leave out the 'date', because you could still have: import qualified Date Date.fromSerialNumber also clear, yes. I think I have a better starting point now. Not impossible that I will come back later with further questions :-) Thank you for your help Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Overloading
Hi, I just started playing around a bit with Haskell, so sorry in advance for very basic (and maybe stupid) questions. Coming from the C++ world one thing I would like to do is overloading operators. For example I want to write (Date 6 6 1973) + (Period 2 Months) for some self defined types Date and Period. Another example would be (Period 1 Years) + (Period 3 Months). Just defining the operator (+) does not work because it collides with Prelude.+. I assume using fully qualified names would work, but that is not what I want. So maybe make the types instances of typeclasses? This would be Num for (+) I guess. For the first example above it will not work however, alone for it is not of type a - a - a. Also the second example does not fit, because I would have to make Period an instance of Num, which does not make sense, because I can not multiply Periods (for example). Am I missing something or is that what I am trying here just impossible by the language design (and then probably for a good reason) ? A second question concerns the constructors in own datatypes like Date above. Is it possible to restrict the construction of objects to sensible inputs, i.e. reject something like Date 50 23 2013 ? My workaround would be to provide a function say date :: Int-Int-Int-Date checking the input and returning a Date object or throw an error if the input does not correspond to a real date. I could then hide the Date constructor itself (by not exporting it). However this seems not really elegant. Also again, taking this way I can not provide several constructors taking inputs of different types, can I ? Thanks a lot Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Overloading
Thank you all for your answers, this helps a lot. To clarify my last point ... Also again, taking this way I can not provide several constructors taking inputs of different types, can I ? Sorry, didn't get what you mean here. In C++ it is perfectly normal to have overloaded functions like f : Int - Int - Int f : Int - Char - Int in coexistence, because the compiler can infer (at compile time) what function to call by looking at the arguments types. In Haskell I think this is not possible simply due to the flexibility given by partial function application, i.e. f 5 would not be well defined any more, it could be Int - Int or Char - Int. Thanks again and kind regards Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Announcement - Haskell User Group Frankfurt
Dear Haskellers, for all who are located near Frankfurt, there is a new Meetup kicked off: http://www.meetup.com/Frankfurt-Haskell-User-Group regards Peter Althainz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Announce: Leksah 0.13.1 (a bit experimental)
Hi Hamish, Features in process-leksah have been merged into process. For newer versions of GHC leksah-server just depends on process. I trust this applies to the unreleased beta version that you just announced, right? (The latest release versions still seem to depend on process-leksah.) In that case, I'll try again building Leksah once the new version is available from Hackage. Thank you for the quick response! Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Announce: Leksah 0.13.1 (a bit experimental)
Hi Hamish, would it be possible to get an update for process-leksah that works with recent versions of the 'filepath' package? I cannot build leksah-server with GCC 7.4.2 because of this issue. Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to determine correct dependency versions for a library?
Hi Tobias, A 1.1.4.0 build-depends: B ==2.5.* C ==3.7.* (overspecified) B 2.5.3.0 build-depends: C ==3.* (underspecified) C 3.7.1.0 Everything works nice until C-3.8.0.0 appears with incompatible changes that break B, but not A. Now both A and B have to update their dependencies and we have now: A 1.1.5.0 build-depends: B ==2.5.* C =3.7 3.9 B 2.5.4.0 build-depends: C =3 3.8 C 3.8.0.0 And now the following combination is still valid: A 1.1.5.0 B 2.5.3.0 (old version) C 3.8.0.0 Bang! thank you for contributing this insightful example. When such a situation has arisen in the past, it's my experience that the author of B typically releases an update to fix the issue with the latest version of C: B 2.5.4.0 build-depends: C = 3.8 So that particular conflict does hardly ever occur in practice. Note that package A would build just fine after that update of B -- if the author of A hadn't overspecified its dependencies. As it is, however, a new version of A has to released that changes no code, but only the Cabal file. Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to determine correct dependency versions for a library?
Hi Tobias, When such a situation has arisen in the past, it's my experience that the author of B typically releases an update to fix the issue with the latest version of C: B 2.5.4.0 build-depends: C = 3.8 So that particular conflict does hardly ever occur in practice. And what if the maintainer of a takes the chance to make some major updates and directly releases 2.6? Then all packages depending on 2.5.* will probably break. yes, that is true. In such a case, one would have to contact the maintainer of A, B, and C to discuss how to remedy the issue. Fortunately, pathological cases such as this one seem to happen rarely in practice. All this boils down to a system where only a combination of latest versions will be stable. So why restrict dependencies anyway? Now, I think that is an exaggeration. Do you know a single example of a package on Hackage that actually suffers from the problem you're describing? Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to determine correct dependency versions for a library?
Hi Clark. I think we just use dependencies [to specify] different things. If dependency version constraints are specified as a white-list -- i.e. we include only those few versions that have been actually verified and exclude everything else --, then we take the risk of excluding *too much*. There will be versions of the dependencies that would work just fine with our package, but the Cabal file prevents them from being used in the build. The opposite approach is to specify constraints as a black-list. This means that we don't constrain our build inputs at all, unless we know for a fact that some specific versions cannot be used to build our package. In that case, we'll exclude exactly those versions, but nothing else. In this approach, we risk excluding *too little*. There will probably be versions of our dependencies that cannot be used to build our package, but the Cabal file doesn't exclude them from being used. Now, the black-list approach has a significant advantage. In current versions of cabal-install, it is possible for users to extend an incomplete black-list by adding appropriate --constraint flags on the command-line of the build. It is impossible, however, to extend an incomplete white-list that way. In other words: build failures can be easily avoided if some package specifies constraints that are too loose. Build failures caused by version constraints that are too strict, however, can be fixed only by editing the Cabal file. For this reason, dependency constraints in Cabal should rather be underspecified than overspecified. Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to determine correct dependency versions for a library?
Hi Janek, How to determine proper version numbers? if you know for a fact that your package works only with specific versions of its dependencies, then constrain the build to exactly those versions that you know to work. If *don't* know of any such limitations, then *don't* specify any constraints. Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to determine correct dependency versions for a library?
Hi Clark, It's not restrictive. how can you say that by adding a version restriction you don't restrict anything? I just don't like to claim that my package works with major versions of packages that I haven't tested. Why does it not bother you to claim that your package can *not* be built with all those versions that you excluded without testing whether those restrictions actually exist or not? Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] more sharing in generated code
Hi, I have a question about sharing at the Haskell run-time level. Suppose we have a record update r { x = f (r x)} and suppose that most of the time f returns it's argument unchanged. I have the following questions: 1. Does the generated code for the record update build an identical record when f returns it's argument unchanged instead of sharing the old one? (I guess yes.) 2. Can we prevent building identical records? Recently I've heard about Q-combinators. Central idea: Change (f :: a - a) to (f' :: a - Maybe a) returning Nothing when the value didn't change. Then we can replace the record update with smarter code which preserves more sharing. My question is: Can (or could) we enable more sharing without changing the source code? Ideally the compiler would generate record update code which checks poiter-equality of the updated field value to decide whether a copy of the original record is needed or it can be shared (given an optimisation flag enabled). Thanks, Peter Background info: There was a discussion on the Agda mailing list about decreasing the Agda compiler memory-usage with more sharing[^1]. (The Agda compiler is written in Haskell.) I had the above idea and I was advised to ask about it on some Haskell mailing list. [^1]: https://lists.chalmers.se/pipermail/agda/2012/004485.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] more sharing in generated code
On 03/11/2012 10:47, Andreas Abel wrote: On 03.11.12 10:05 AM, Peter Divianszky wrote: Suppose we have a record update r { x = f (r x)} and suppose that most of the time f returns it's argument unchanged. Recently I've heard about Q-combinators. Central idea: Change (f :: a - a) to (f' :: a - Maybe a) returning Nothing when the value didn't change. Then we can replace the record update with smarter code which preserves more sharing. Just adding a remark here: I actually played with these Q-combinators, they actually worsened performance of Agda. The problem is that they make the code strict. The performance loss due to strictness outweighted the potential performance gain by increased sharing. Q-combinators were developed by John Harrison in the context of ML, which is strict anyway. I guess a compiler support for smart record update would not have the strictness penalty. Yes, for that we need a copy first and an update later. This can be implemented by replacing every record update r' = r { x = y } with r' = r { x = unsafePerformIO (cond-update r r' (x r) y) } where we keep the current record update mechanism and implement cond-update like cond-update :: r - r - x - IO x cond-update r_old r_new x_old x_new = do b - x_old === x_new when b (replace r_new r_old) return x_new where (===) is pointer-equality and replace is a low-level function which replaces thunks in the heap. Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] more sharing in generated code
On 03/11/2012 11:20, Peter Divianszky wrote: On 03/11/2012 10:47, Andreas Abel wrote: On 03.11.12 10:05 AM, Peter Divianszky wrote: Suppose we have a record update r { x = f (r x)} and suppose that most of the time f returns it's argument unchanged. Recently I've heard about Q-combinators. Central idea: Change (f :: a - a) to (f' :: a - Maybe a) returning Nothing when the value didn't change. Then we can replace the record update with smarter code which preserves more sharing. Just adding a remark here: I actually played with these Q-combinators, they actually worsened performance of Agda. The problem is that they make the code strict. The performance loss due to strictness outweighted the potential performance gain by increased sharing. Q-combinators were developed by John Harrison in the context of ML, which is strict anyway. I guess a compiler support for smart record update would not have the strictness penalty. Yes, for that we need a copy first and an update later. This can be implemented by replacing every record update r' = r { x = y } with r' = r { x = unsafePerformIO (cond-update r r' (x r) y) } where we keep the current record update mechanism and implement cond-update like cond-update :: r - r - x - IO x cond-update r_old r_new x_old x_new = do b - x_old === x_new when b (replace r_new r_old) return x_new where (===) is pointer-equality and replace is a low-level function which replaces thunks in the heap. a small correction on cond-update: cond-update :: r - r - x - IO x cond-update r_old r_new x_old x_new = do eval x_new b - x_old === x_new when b (replace r_new r_old) return x_new Evaluation of x_new should be OK because we need x_new eventually. With this change, nested record updates with identical values behave like an identical function with sharing I think. Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] more sharing in generated code
Hi Dennis, I think you mean this: r { x = f (x r) } Yes, I made a typo. Thanks for advising ghc-vis. In GHC: In your example a new record is built, but all its entries (x in this case) are shared. The problem is, that in case of nested records, if an inner record is updated, the whole path to that record is copied. Of course copying just the path to the inner data is a lot better than copying the whole tree of data, but my proposal is about to optimize it further: don't copy of the path if the updated value is identical to the original one. The Agda compiler may benefit by this optimization for example. In fact, the last version of the proposal[^1] will copy the path to keep laziness properties, but it does it in such a way that the GC can collect the copied path instead of trying to collect the old path (which will if it is shared). [^1]: http://www.haskell.org/pipermail/haskell-cafe/2012-November/104311.html Does this make sense to you? Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC maintenance on Arch
Hi Vagif, I fail to see how a fringe bleeding edge linux distro undermines a haskell platform. Arch Linux does not comply to the Haskell Platform. That fact communicates to users of the distribution: We, the maintainers, don't believe that HP is relevant. Clearly, this undermines the Haskell Platform, doesn't it? Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC maintenance on Arch
Hi Timothy, the Haskell community is not the right audience to be addressing these complaints to. Instead, you should be talking to the ArchLinux developers, who are responsible for packaging Haskell-related software in the [core] and [extra] repositories. I am no expert in these matters, but my guess is that the mailing list https://mailman.archlinux.org/mailman/listinfo/arch-dev-public is more appropriate than haskell-cafe for this thread. Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] extensible-exceptions no longer a part of GHC 7.6.1?
Hi, 'extensible-exceptions' used to be a part of GHC, but it appears that the package has been dropped from 7.6.1. Yet, the release notes on haskell.org don't say anything about this subject (other than TODO). Was that change intentional? Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Wanted: Haskell binding for libbdd (buddy)
On 20/08/2012, at 11:19 PM, Johannes Waldmann wrote: Are there any Haskell bindings for BDD libraries (reduced ordered binary decision diagrams)? E.g., it seems buddy is commonly used http://packages.debian.org/squeeze/libbdd-dev and it has an Ocaml binding. My hBDD bindings are on Hackage. I once had a binding to buddy but found CUDD to have superior performance for my application. cheers peter -- http://peteg.org/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Which ghc binary does ghc-mod use?
Hi Brandon, I think you'd have to install a separate ghc-mod binary for each one, then, as it looks to me like ghc-mod is using ghc-as-a-library. That is, it actually has the compiler linked into itself. I see, thank you for the clarification. One more thing: I would like to configure search paths for extra libraries that ghc-mod won't find without help. Does anyone know a way to configure the set of flags that's being passed to GHC/ghc-mod? Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Which ghc binary does ghc-mod use?
Hi, I am a happy user of Emacs with ghc-mod for Haskell programming. There is just one issue I've run into: I have multiple versions of GHC installed on my machine. Now, ghc-mod seems to use the GHC binary that was used to compile ghc-mod itself, but that is not the version I want it to use for syntax checking, etc. In fact, I want to be able to switch ghc-mod between different GHC binaries depending on which project I'm working on, but I have no idea how to do that. Is there maybe some Elisp guru reading this list who can help me out? Can I somehow configure which GHC binary ghc-mod uses? Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] System.Win32.Registry... Help?
The Registry module has code that will be helpful, as it includes a helper function for the common use case of setting String values. regSetStringValue :: HKEY - String - String - IO () regSetStringValue hk key val = withTString val $ \ v - regSetValueEx hk key rEG_SZ v (length val * sizeOf (undefined::TCHAR)) http://www.haskell.org/ghc/docs/7.4.2/html/libraries/Win32-2.2.2.0/src/System-Win32-Registry.html On Sun, Jul 22, 2012 at 7:11 AM, Anonymous Void bitsofch...@gmail.com wrote: Hi, I'm working on a project that will require me to create and possibly set registry keys. I don't have much experience with programming on Windows either, but I'm having to learn as you don't get many *nix PCs at a computer repair shop, lol. I found a mailing list post showing how to read registry keys and was able to make a function based off of it, but I have no idea what to put into some of the arguments for regSetValueEx or regCreateKeyEx, so I'm stuck. Also, what's the best way to recursively traverse trees in the registry, are there any functions for it? Can someone please help me out with this? Thank you. {-# LANGUAGE ForeignFunctionInterface #-} import System.Win32.Types import System.Win32.Registry import Foreign.Ptr (castPtr) import Foreign.Marshal.Alloc (allocaBytes) import Foreign.C.String (peekCWString, withCWString) import Control.Exception (bracket, throwIO) -- // parse a string from a registry value of certain type parseRegString :: RegValueType - LPBYTE - IO String parseRegString ty mem | ty == rEG_SZ= peekCWString (castPtr mem) | ty == rEG_EXPAND_SZ = peekCWString (castPtr mem) = expandEnvironmentStrings | otherwise = ioError (userError Invalid registry value type) -- // FFI import of the ExpandEnvironmentStrings function needed -- // to make use of the registry values expandEnvironmentStrings :: String - IO String expandEnvironmentStrings toexpand = withCWString toexpand $ \input - allocaBytes 512 $ \output - do c_ExpandEnvironmentStrings input output 256 peekCWString output foreign import stdcall unsafe windows.h ExpandEnvironmentStringsW c_ExpandEnvironmentStrings :: LPCTSTR - LPTSTR - DWORD - IO DWORD get_key :: HKEY - String - String - IO String get_key cat loc key = bracket op regCloseKey $ \x - allocaBytes 512 $ \mem - do ty - regQueryValueEx x key mem 512 parseRegString ty mem where op = regOpenKeyEx cat loc kEY_QUERY_VALUE set_key :: HKEY - String - String - IO () set_key cat loc key = regSetValueEx cat loc rEG_SZ??? LPTSTR? What do I put here? magic_win32_number_here? where op = regOpenKeyEx cat loc kEY_SET_VALUE main = get_key hKEY_CURRENT_USER loc key = print where loc = Software\\7-Zip key = Test ___ 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] How do I marshall a pointer over SendMessage LPARAM or WPARAM?
Sorry Yuras, I missed this. It turns out that I made a mistake when trying to pinpoint my problem. I had started out using WM_COPY_DATA and COPYDATASTRUCT, but upon facing issues, tried simple sending of a C string and a WM_APP message. However, that simplifying resulted in me losing the memory mapping needed for copying data. (for anyone facing similar woes) The use of WM_COPY_DATA and COPYDATASTRUCT in combination are essential, since Windows performs memory mapping to ensure the data being copied is available to the receiving process: WM_COPY_DATA message is received by Windows. It's handled as a special case, and COPYDATASTRUCT is inspected. cbData worth of bytes are memory mapped for the lpData content. A WM_COPY_DATA message will be received in your wndProc function, with an appropriate COPYDATASTRUCT for the memory mapped content. It's fine to use withTString (and similar) in combination with sendMessage, since the IO will be syncronous. cbData for a TString can be calculated by string length * size of a System.Win32.Types.TCHAR, accounting for end of string sentinel. withTStringLen can also be used, but be aware that the zero terminator will not be present, and I'm not sure if the Len given by that function is string length, or byte count. I wanted a regular terminated c string, and so haven't tried it. On Wed, Jul 18, 2012 at 7:29 PM, Yuras Shumovich shumovi...@gmail.com wrote: On Wed, 2012-07-18 at 18:22 +0200, Simon Peter Nicholls wrote: Some sending code: Foreign.C.String.withCWString frustrator $ \s - do let wParam = System.Win32.Types.castPtrToUINT s :: System.Win32.Types.WPARAM Graphics.Win32.sendMessage wnd Graphics.Win32.wM_APP wParam 0 wndProc receiving code: | wmsg == Graphics.Win32.wM_APP = do s - peekCWString $ System.Win32.Types.castUINTToPtr wParam putStrLn s return 0 From the docs ( http://hackage.haskell.org/packages/archive/base/4.5.1.0/doc/html/Foreign-C-String.html#v:withCWString ): the memory is freed when the subcomputation terminates (either normally or via an exception), so the pointer to the temporary storage must not be used after this I'm noy a windows guru, but I assume that `sendMessage` just puts the message into a queue and exits. So, you receive a pointer to already deallocated memory. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] System.Win32.Registry... Help?
Glad I could help. Win32 / FFI examples are indeed thin on the ground. As it's a null terminated string in that code, you'll need to add 1 to the length of A when calculating the byte count. Actually, speaking of Win32 examples, I'll drop a general Win32 UI hint into the mailing list. I quickly arrived at the need to reflect state in my Win32 app, but I can only see one Japanese guy out there with an example of what I discovered by rooting around in Haskell source. Here is the elusive secret to Win32 UI programming. Graphics.Win32.setWindowClosure. Aye, with that function to hand, your wndProc can have access to your most current application values, just like regular recursive functions. An example: wndProc fileList hwnd wmsg wParam lParam ... blah ... setWindowClosure hwnd (wndProc $ FileInfo fileName : fileList) Here I construct an extra FileInfo from a file name, cons it onto the fileList which was passed into my wndProc as the first parameter, partially apply that new list to wndProc, set it as the window closure, and I'll have it when processing the next message. On Sun, Jul 22, 2012 at 4:05 PM, Anonymous Void bitsofch...@gmail.com wrote: Thank you! I looked over a lot of the api docs, but not the source ones... The snippit you found showed me exactly what I needed to do. *Main k - regOpenKey hKEY_CURRENT_USER Software\\7-Zip Loading package bytestring-0.9.2.1 ... linking ... done. Loading package Win32-2.2.2.0 ... linking ... done. *Main withTString A $ \v - regSetValueEx k foo rEG_SZ v (length foo * s izeOf(undefined :: TCHAR)) Works perfectly, so I can copy binary values too. Didn't think to look at the helper functions to see how the regular version is used from them... Haven't programmed in a while, must be pretty rusty... LOL. My project is now saved from going .py! :D .. not anything against python, I'm using django on another project and it's great, but haskell comes to mind for this app Thanks. On Sun, Jul 22, 2012 at 4:33 AM, Simon Peter Nicholls si...@mintsource.org wrote: The Registry module has code that will be helpful, as it includes a helper function for the common use case of setting String values. regSetStringValue :: HKEY - String - String - IO () regSetStringValue hk key val = withTString val $ \ v - regSetValueEx hk key rEG_SZ v (length val * sizeOf (undefined::TCHAR)) http://www.haskell.org/ghc/docs/7.4.2/html/libraries/Win32-2.2.2.0/src/System-Win32-Registry.html On Sun, Jul 22, 2012 at 7:11 AM, Anonymous Void bitsofch...@gmail.com wrote: Hi, I'm working on a project that will require me to create and possibly set registry keys. I don't have much experience with programming on Windows either, but I'm having to learn as you don't get many *nix PCs at a computer repair shop, lol. I found a mailing list post showing how to read registry keys and was able to make a function based off of it, but I have no idea what to put into some of the arguments for regSetValueEx or regCreateKeyEx, so I'm stuck. Also, what's the best way to recursively traverse trees in the registry, are there any functions for it? Can someone please help me out with this? Thank you. {-# LANGUAGE ForeignFunctionInterface #-} import System.Win32.Types import System.Win32.Registry import Foreign.Ptr (castPtr) import Foreign.Marshal.Alloc (allocaBytes) import Foreign.C.String (peekCWString, withCWString) import Control.Exception (bracket, throwIO) -- // parse a string from a registry value of certain type parseRegString :: RegValueType - LPBYTE - IO String parseRegString ty mem | ty == rEG_SZ= peekCWString (castPtr mem) | ty == rEG_EXPAND_SZ = peekCWString (castPtr mem) = expandEnvironmentStrings | otherwise = ioError (userError Invalid registry value type) -- // FFI import of the ExpandEnvironmentStrings function needed -- // to make use of the registry values expandEnvironmentStrings :: String - IO String expandEnvironmentStrings toexpand = withCWString toexpand $ \input - allocaBytes 512 $ \output - do c_ExpandEnvironmentStrings input output 256 peekCWString output foreign import stdcall unsafe windows.h ExpandEnvironmentStringsW c_ExpandEnvironmentStrings :: LPCTSTR - LPTSTR - DWORD - IO DWORD get_key :: HKEY - String - String - IO String get_key cat loc key = bracket op regCloseKey $ \x - allocaBytes 512 $ \mem - do ty - regQueryValueEx x key mem 512 parseRegString ty mem where op = regOpenKeyEx cat loc kEY_QUERY_VALUE set_key :: HKEY - String - String - IO () set_key cat loc key = regSetValueEx cat loc rEG_SZ??? LPTSTR? What do I put here? magic_win32_number_here? where op = regOpenKeyEx cat loc kEY_SET_VALUE main = get_key hKEY_CURRENT_USER loc key = print where loc = Software\\7-Zip key = Test ___ Haskell-Cafe mailing list Haskell-Cafe
[Haskell-cafe] How do I marshall a pointer over SendMessage LPARAM or WPARAM?
Cross-posted from Haskell-beginners. Apologies for not posting in the right place (though I am a beginner and have probably made a simpleton error). I'm new to Haskell, and have had some good success with FFI so far, but using Win32's sendMessage to send a pointer in LPARAM or WPARAM is resulting in access violations at the other end. Is there some issue with my pointer conversions? Am I hitting some restriction, or missing some compiler options? It's driving me pretty crazy, after a very nice start to using Haskell. Some sending code: Foreign.C.String.withCWString frustrator $ \s - do let wParam = System.Win32.Types.castPtrToUINT s :: System.Win32.Types.WPARAM Graphics.Win32.sendMessage wnd Graphics.Win32.wM_APP wParam 0 wndProc receiving code: | wmsg == Graphics.Win32.wM_APP = do s - peekCWString $ System.Win32.Types.castUINTToPtr wParam putStrLn s return 0 The string will not be seen. Some extra notes: I can get wndProc messages and integral data generally. The pointer values match textually at both ends when shown to stdout. At the sending side I can pass the CWString to a regular FFI function call just fine, and castUINTToPtr will give me back a functioning Ptr for that call. I have also tried sending to receiving from a working C++ program, without success. Access violations are reported when receiving, though again the address matches up. Silence from Haskell as before, when C++ is sending. I found someone else having an issue here: http://osdir.com/ml/haskell-cafe@haskell.org/2009-11/msg00731.html but no solution unfortunately. UPDATE since prior posting: Seems if I call out via FFI on the sending side, and set the WPARAM to Lhardcoding FTW in a wrapper C function, the SendMessage I then invoke will work. The C code sees both the original string and the new one, but only the second works when used. I must be missing something obvious, but have toasted my grey cells at this point! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ghc-7.4 on CentOS-5.8 ?
Hi Johannes, ghc-7.0 is working but when I use it to compile 7.4, it breaks with some linker error (relocation R_X86_64_PC32 ...) it also suggests recompile with -fPIC but I don't see how. I seem to remember that this is a problem with the old version of GCC that's used to build the compiler. It can we avoided, though, by disabling optimizations. Try adding the following lines to a file called mk/build.mk before running the build: GhcLibWays = v SRC_HC_OPTS= -H64m -O0 -fasm# -O -H64m GhcStage1HcOpts= -O -fasm GhcStage2HcOpts= -O0 -fasm # -O2 -fasm GhcLibHcOpts = -O -fasm # -O2 -XGenerics GhcHcOpts = -Rghc-timing # GhcLibWays += p # GhcLibWays += dyn NoFibWays = STRIP_CMD = : I attached the RPM spec file that I used to build GHC 7.0.4 on CentOS. It's quite likely that you can use it to automate the 7.4.x build after editing some version numbers and file paths in it. Good luck! :-) Peter Name: ghc Version:7.0.4 Release:1 Summary:Glorious Haskell Compiler License:BSD Group: Compiler URL:http://haskell.org/ghc Prefix: /opt/ghc/7.0.4 BuildArch: x86_64 ExclusiveArch: x86_64 ExclusiveOS:Linux Source: %{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRequires: ghc == 6.12.3 BuildRequires: make BuildRequires: perl BuildRequires: python BuildRequires: gmp-devel BuildRequires: ncurses-devel BuildRequires: zlib-devel BuildRequires: gcc Requires: gmp-devel Requires: ncurses-devel Requires: zlib-devel Requires: gcc %description Glorious Haskell Compiler %clean %{__rm} -rf %{buildroot} %prep %setup %build cat mk/build.mk EOF GhcLibWays = v SRC_HC_OPTS= -H64m -O0 -fasm# -O -H64m GhcStage1HcOpts= -O -fasm GhcStage2HcOpts= -O0 -fasm # -O2 -fasm GhcLibHcOpts = -O -fasm # -O2 -XGenerics GhcHcOpts = -Rghc-timing # GhcLibWays += p # GhcLibWays += dyn NoFibWays = STRIP_CMD = : EOF ./configure --prefix=%{prefix} --with-ghc=/opt/ghc/6.12.3/bin/ghc make %install %{__rm} -rf %{buildroot} make DESTDIR=%{buildroot} install %files %defattr(644,root,root,755) %dir %{prefix} %attr(755,root,root) %{prefix}/bin/ghc %attr(755,root,root) %{prefix}/bin/ghc-%{version} %attr(755,root,root) %{prefix}/bin/ghc-pkg %attr(755,root,root) %{prefix}/bin/ghc-pkg-%{version} %attr(755,root,root) %{prefix}/bin/ghci %attr(755,root,root) %{prefix}/bin/ghci-%{version} %attr(755,root,root) %{prefix}/bin/haddock %attr(755,root,root) %{prefix}/bin/haddock-ghc-%{version} %attr(755,root,root) %{prefix}/bin/hp2ps %attr(755,root,root) %{prefix}/bin/hpc %attr(755,root,root) %{prefix}/bin/hsc2hs %attr(755,root,root) %{prefix}/bin/runghc %attr(755,root,root) %{prefix}/bin/runhaskell %{prefix}/lib %{prefix}/share %attr(755,root,root) %{prefix}/lib/ghc-%{version}/ghc %attr(755,root,root) %{prefix}/lib/ghc-%{version}/ghc-pkg %attr(755,root,root) %{prefix}/lib/ghc-%{version}/haddock %attr(755,root,root) %{prefix}/lib/ghc-%{version}/hsc2hs %attr(755,root,root) %{prefix}/lib/ghc-%{version}/runghc %attr(755,root,root) %{prefix}/lib/ghc-%{version}/unlit %changelog ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Why does (++ !) bla return bla! and not !bla?
Hilco, On 22/06/2012, at 2:54 PM, Hilco Wijbenga wrote: I'm going through the excellent http://learnyouahaskell.com tutorial. So far it's been pretty easy to follow but now I ran into something that (when I later started reading about maps) do not seem to fully grasp. I think I'm close to understanding why (++ !) bla returns bla! instead of !bla but I seem to be missing the last step. :-) I noticed that ((++) !) bla does indeed return !bla. So it seems to be related to the infix property of ++? The types of (++) !, ((++) !), and (++ !) are all the same so that doesn't tell me much. This stuff is in a beginner's tutorial? (!?) This is purely a syntactic issue. These things are called sections. It might be more obvious if we put in some lambda abstractions, which I hope your tutorial has already introduced: (++ !) = (\x. x ++ !) (! ++) = (\y. ! ++ y) Yes, it is related to the infix property of ++. You can get similar things going with arbitrary binary (two argument) functions like so: app = (++) -- or whatever (`app` !) = (\x. x `app` !) = (\x. app x !) (and the other way around) cheers peter -- http://peteg.org/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] JustHub 'Sherkin' Release
Hi Chris, I'm also wondering about this issue: - How do you handle packages that depend on system libraries? hsdns, for example, requires the adns library to build. Does Hub know about this? Does Hub know about system-level libraries that Haskell packages need to build, like Gtk, ADNS, Avahi, etc.? Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] JustHub 'Sherkin' Release
Hi Chris, hub save project project.har I am curious to see what this file looks like. Could you please post a short example of one? Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] JustHub 'Sherkin' Release
Hi Chris, There is a worked out example at the bottom of the overview up on the web site: http://justhub.org/overview thank you for the pointer, I think I found it: ^=7.4.1 List-0.4.2 fgl-5.4.2.4 hexpat-0.20.1 mtl-2.1.1 regex-base-0.93.2 regex-compat-0.95.1 regex-posix-0.95.2 text-0.11.2.1 transformers-0.3.0.0 utf8-string-0.3.7 Very nice, this looks quite straightforward. I wonder about two things: - Is it possible to pass configure-time flags to those libraries? For example, I would like to build haskeline with -fterminfo. Can Hub do this? - How do you handle packages that depend on system libraries? hsdns, for example, requires the adns library to build. Does Hub know about this? Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] JustHub 'Sherkin' Release
Hi Chris, How much time, approximately, did you spend working with Nix? 1 hour? 10 hours? 10 days? 10 months? You know that it is not 10 months. actually, no. I don't know that, which is why I asked. I find it hard to get an answer from you, though. It seems strange that you keep such trivial information to yourself like some super personal secret. The point of this discussion is to compare the respective properties of Nix and Hub. In that context, it seems natural that I might be curious how much actual working experience you have with Nix. JustHub [and Nix] have some similarities -- mostly around the idea of allowing multiple tool chains to co-exist; the way they go about it is very different. I'm not sure what differences you are referring to. Could you please be a little bit more specific? How exactly do Nix and Hub differ in the way they install multiple tool-chains? I also know that I have been adding things that a generic package manager is most unlikely to be covering [...]. What you mean is: you really don't know, but you are speculating. To take just one example, I provide a mechanism that allows developers to archive the configuration of their Haskell development environment and check it into a source management system. The developer can check it out on a another system and if the build process invokes the recovery mechanism it will automatically rebuild the environment on the first run [...]. Yes, is Nix we solve that problem as follows. Configurations are lazily evaluated functions. The function that builds Hub, for example, looks like this: | { cabal, fgl, filepath, hexpat, regexCompat, utf8String }: | | cabal.mkDerivation (self: { | pname = hub; | version = 1.1.0; | sha256 = 0vwn1v32l1pm38qqms9ydjl650ryic37xbl35md7k6v8vim2q8k3; | isLibrary = false; | isExecutable = true; | buildDepends = [ fgl filepath hexpat regexCompat utf8String ]; | meta = { | homepage = https://justhub.org;; | description = For multiplexing GHC installations and providing development sandboxes; | license = self.stdenv.lib.licenses.bsd3; | platforms = self.ghc.meta.platforms; | }; | }) When Nix runs that build, it's executed in a temporary environment that contains exactly those package that have been declared as build inputs, but nothing else. Since all built-time dependencies of this package are arguments of the function, it's possible to instantiate that build with any version of GHC, Cabal, fgl, filepath, etc. If I pass GHC 6.12.3, Hub will be built with GHC 6.12.3. If I pass GHC 7.4.2, Hub will be built with GHC 7.4.2 instead. Now, in my home directory there is a file ~/.nixpkgs/config.nix that works like the 'main' function in a Haskell program insofar as that it ties all those individual functions together into an user configuration: | let | haskellEnv = pkgs: pkgs.ghcWithPackages (self: with pkgs; [ | # Haskell Platform | haskellPlatform | # other packages | cmdlib dimensional funcmp hackageDb hledger hledgerLib hlint hoogle | HStringTemplate monadPar pandoc smallcheck tar uulib permutation | criterion graphviz async | ]); | in | { | packageOverrides = pkgs: | { | ghc704Env = haskellEnv pkgs.haskellPackages_ghc704; | ghc741Env = haskellEnv pkgs.haskellPackages_ghc741; | ghc742Env = haskellEnv pkgs.haskellPackages_ghc742; | }; | } I can copy that file to every other machine, regardless of whether it's a Linux host, a Mac, or a BSD Unix, and run nix-env -iA ghc704Env to have Nix build my GHC 7.0.4 development environment with exactly those extra libraries that I configured. How would I do something like that in Hub? Maybe Nix provides such a mechanism -- I don't know. It does. :-) Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] JustHub 'Sherkin' Release
Hi Chris, Where is this functionality provided by Nix? simply run these commands # Haskell Platform 2009.2.0.2 nix-env -p ~/ghc-6.10.4 -iA haskellPackages_ghc6104.haskellPlatform # Haskell Platform 2010.2.0.0 nix-env -p ~/ghc-6.12.3 -iA haskellPackages_ghc6123.haskellPlatform # Haskell Platform 2012.2.0.0' nix-env -p ~/ghc-7.4.1 -iA haskellPackages_ghc741.haskellPlatform and you'll have profiles that contain the appropriate binaries and libraries defined by the corresponding platform. Nix can do this without any superuser privileges on Linux, Darwin, and BSD Unix, although I have to say that BSD support is limited because there seem to be very few people using Nix on BSD. (I reckon the BSD people are happy with their BSD ports and aren't interested in a third-party package manager.) Furthermore, Nix can many different versions of *any* package simultaneously, not just Haskell: nix-env -p ~/python-2.6.7 -iA python26 nix-env -p ~/python-2.7.3 -iA python27 nix-env -p ~/python-3.2.3 -iA python3 Anyone who's interested in Nix can find lots of information on the web site http://nixos.org/. There's also the IRC channel #nixos on irc.freenode.org where some Nix developers hang out. Last but not least, there is the developer mailing list nix-...@cs.uu.nl. I'll be happy to answer any further questions that may arise. Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] JustHub 'Sherkin' Release
Hi Chris, I cannot see how it can address any of the user-level Haskell package database management and sandboxing mechanisms that I mentioned in the announcement and subsequent emails. have you ever actually used Nix? Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Haskell] JustHub 'Sherkin' Release
Hi Chris, I deatiled some of my trials with Nix -- I wasn't making it up! of course, I didn't mean to imply that you were. My question was phrased poorly, I am sorry. What I meant to ask is: how much time, approximately, did you spend working with Nix? 1 hour? 10 hours? 10 days? 10 months? Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Installing REPA
Hi Ben, I've just pushed Repa 3 onto Hackage, which has a much better API than the older versions, and solves several code fusion problems. when using the latest version of REPA with GHC 7.4.1, I have trouble building the repa-examples package: | Building repa-examples-3.0.0.1... | Preprocessing executable 'repa-volume' for repa-examples-3.0.0.1... | [1 of 1] Compiling Main ( examples/Volume/Main.hs, dist/build/repa-volume/repa-volume-tmp/Main.o ) | Linking dist/build/repa-volume/repa-volume ... | Preprocessing executable 'repa-sobel' for repa-examples-3.0.0.1... | [1 of 2] Compiling Solver ( examples/Sobel/src-repa/Solver.hs, dist/build/repa-sobel/repa-sobel-tmp/Solver.o ) | Loading package ghc-prim ... linking ... done. | Loading package integer-gmp ... linking ... done. | Loading package base ... linking ... done. | Loading package array-0.4.0.0 ... linking ... done. | Loading package bytestring-0.9.2.1 ... linking ... done. | Loading package deepseq-1.3.0.0 ... linking ... done. | Loading package containers-0.4.2.1 ... linking ... done. | Loading package binary-0.5.1.0 ... linking ... done. | Loading package bmp-1.2.1.1 ... linking ... done. | Loading package old-locale-1.0.0.4 ... linking ... done. | Loading package old-time-1.1.0.0 ... linking ... done. | Loading package extensible-exceptions-0.1.1.4 ... linking ... done. | Loading package time-1.4 ... linking ... done. | Loading package random-1.0.1.1 ... linking ... done. | Loading package pretty-1.1.1.0 ... linking ... done. | Loading package template-haskell ... linking ... done. | Loading package QuickCheck-2.4.2 ... linking ... done. | Loading package primitive-0.4.1 ... linking ... done. | Loading package vector-0.9.1 ... linking ... done. | Loading package repa-3.0.0.1 ... linking ... done. | Loading package repa-io-3.0.0.1 ... linking ... done. | Loading package repa-algorithms-3.0.0.1 ... linking ... done. | [2 of 2] Compiling Main ( examples/Sobel/src-repa/Main.hs, dist/build/repa-sobel/repa-sobel-tmp/Main.o ) | Linking dist/build/repa-sobel/repa-sobel ... | Preprocessing executable 'repa-mmult' for repa-examples-3.0.0.1... | | examples/MMult/src-repa/Main.hs:3:8: | Could not find module `Solver' | Use -v to see a list of the files searched for. When I attempt to use repa 3.1.x, the build won't even get past the configure stage, because Cabal refuses these dependencies. Is that a known problem, or am I doing something wrong? Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Subscriber-only lists as Maintainer contacts of Cabal packges
Hi Joachim, Please make sure the list is not set to subscriber only; it is an unreasonable burden to subscribe for people who just want to send you one question, and possibly have to contact dozends of different package authors, e.g. as a distribution packager. +1 I have had that problem, too. Maintainers give contact details, but then I have to jump through hoops before I can actually contact them. I see why people want to protect themselves from spam, but this approach seems counter-productive to me. (Who really thinks that using the subscriber-only setting of mailman as an anti-spam-measure is an abuse of the feature, and that mailman should offer a “non-subscribers get a bounce that allows them to approve the message themselves“ feature which would give the same spam protection but much less hassle for the users.) The way to accomplish that is to configure the list as moderated, and to set all list subscribers as unmoderated. This makes postings from subscribers go right through, and everyone else's message are forwarded to the list moderator for approval. It's not quite the same as a challenge-response scheme that empowers casual posters to confirm their honest intentions (i.e. the correctness of their mail envelope address), but it's still a lot better than just dropping every mail from anyone who isn't subscribed. Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Installing REPA
Hi Ben, Please try again now. thank you very much for the quick update! Everything installs fine now. I've also packaged the latest versions for NixOS. Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is this a correct explanation of FRP?
On Mon, 2012-04-02 at 04:03 +0200, Ertugrul Söylemez wrote: Peter Minten peter.min...@orange.nl wrote: As I see FRP it has three components: the basic concepts, the underlying theory and the way the libraries actually work. As far as I understand FRP (which is not very far at all) the basic concepts can, simplified, be formulated as: * There are things which have a different value depending on when you look at them. (behaviors) That's already specific to traditional FRP. In AFRP the value mutates. It's not a function of some notion of time. It is similar to a list. That list contains the current value as well as a description of the future of the value: newtype SF a b = SF (a - (b, SF a b)) The current value and the future depend on a momentary input value of type 'a' (which usually comes from another SF). I think I understand what you're saying now. Basically instead of behaviors netwire has signal functions which are basically the same idea as simplified conduits/enumeratees. When you step (run) a signal function you get two things: an output value and a replacement for the signal function. Because the signal functions can be replaced a system of signal functions can change between steps. Netwire doesn't actually have a notion of time as such. If you need to know the current time you'll have to supply that yourself. Wires also don't run continuously, only when stepped explicitly. Where in traditional FRP you (in some libraries) could ask for the value of a behavior at any time in netwire you can only get the equivalent value (the output value of a signal function) by stepping. The big difference between netwire and traditional AFRP libraries are ArrowChoice instances which allow if-then-else and case constructions in proc notation. This simplifies programming greatly as it requires less thinking in FRP terms. When you say Event a b = SF a (Maybe b) you're basically saying that for netwire events are the same thing as behaviors: they're both signal functions. Events can be expressed as signal functions that sometimes have a value. If they have a value during a step the event occurs during that step. The whole system is very discrete, time isn't a primitive at all. If time plays a role it's just as an input, it's not built into something. To get something return 1 but from second 10 onward return 2 you pass time as an input and once you see that the time is greater than 10 you can change the signal function to arr (const 2) to fix it to return 2, whatever the new time is. Greetings, Peter Minten ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is this a correct explanation of FRP?
On Fri, 2012-03-30 at 02:30 +0200, Ertugrul Söylemez wrote: Peter Minten peter.min...@orange.nl wrote: I've been trying to get my head around Functional Reactive Programming by writing a basic explanation of it, following the logic that explaining something is the best way to understand it. Am I on the right track with this explanation? You are explaining a particular instance of FRP. Functional reactive programming is not a single concept, but a whole family of them. Traditional FRP as implemented by reactive-banana (and older libraries like Elerea, Fran and Reactive) is based on behaviors and events. It uses the notion of a time-dependent value in a direct fashion. Conceptionally traditional FRP is this: Behavior a = Time - a Event a= [(Time, a)] -- The current time at even seconds and half the current time at odd -- seconds: alterTime = fullTime fullTime = switch (after 1) currentTime halfTime halfTime = switch (after 1) (fmap (/ 2) currentTime) fullTime There is a second instance of FRP though called AFRP. The A stands for arrowized, but in modern times I prefer to think of it as applicative. The underlying control structure is now a category and the concept of a time-varying value is changed to a time-varying function (called signal function (SF)), which is just an automaton and there is an arrow for it. This simplifies implementation, makes code more flexible and performance more predictable. The libraries Animas and Yampa implement this concept (Animas is a fork of Yampa). Conceptionally: SF a b= a - (b, SF a b) Event a b = SF a (Maybe b) alterTime = fullTime fullTime = switch (after 1) currentTime halfTime halfTime = switch (after 1) ((/ 2) ^ currentTime) fullTime Sorry, I don't understand this. Would it be correct to say that AFRP shares the basic ideas of FRP in that it has behaviors and events/signals and that the main difference comes from the way AFRP is implemented? As I see FRP it has three components: the basic concepts, the underlying theory and the way the libraries actually work. As far as I understand FRP (which is not very far at all) the basic concepts can, simplified, be formulated as: * There are things which have a different value depending on when you look at them. (behaviors) * It is possible to express that something has occured at a certain point in time. (events/signals) * Behaviors can change in response to events/signals. * A behavior's value may be different on different points in time even if no event has come in. Normal FRP theory expresses behaviors as Time - a and events as [(Time,a)]. AFRP uses some kind of signal function to express behaviors, or behaviors are signal functions and those functions interact with events. Anyway AFRP uses a completely different theoretical way of thinking about events and behaviors. The reactive-banana library uses some internal representation which exposes an API using applicative functors. The theory behind it, as shown in the haddock comments, is Normal FRP. The reactive library uses monads and not just applicative functors. It uses the Normal FRP style. Yampa/Animas use arrows and have a different underpinning in math. However the basic concepts of FRP are shared with all the other libraries. Netwire also uses AFRP but extends the theory with something called signal inhibition. Like everything else it shares the basic concepts of FRP. FRP concepts - FRP- reactive - reactive-banana - AFRP - Yampa - Animas - wired AFRP - Netwire Is this a correct way to summarize the differences? Greetings, Peter Minten ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is this a correct explanation of FRP?
On Fri, 2012-03-30 at 09:15 +0300, Michael Snoyman wrote: First you state that we shouldn't use `union` for the `ePitch` Event, and then you used it for `bOctave`. Would it be more efficient to implement bOctave as someting like: eOctave :: Event t (Int - Int) eOctave = filterJust toStep $ eKey where toStep '+' = Just (+ 1) toStep '-' = Just (subtract 1) toStep _ = Nothing bOctave :: Behavior t Octave bOctave = accumB 0 eOctave Yes. Though it's slightly less bad, the case with ePitch was something like 6 appends. It was mostly a case of badly copying the style from the examples and not realizing the examples use event streams from different outside sources. I've adapted the example to use something similar to your eOctave. Also, I'm left wondering: how would you create a new event stream in the first place? You're telling us to just rely on `eKey`, which is fair, but a great follow-up would demonstrate building it. Looking through the docs I found `newEvent`, but I'm not quite certain how I would combine it all together. The updated document, which now lives at http://www.haskell.org/haskellwiki/FRP_explanation_using_reactive-banana contains a Making the example runnable section which shows how connect the example with the outside world. The short version, regarding the creation of new events, is that you have to do it in two parts. You need newAddHandler in the IO monad to get a (a - IO ()) function that fires the event as well as something called an AddHandler and fromAddHandler in the NetworkDescription monad to get an event from that AddHandler. It's not possible to get values out of the NetworkDescription monad (without IORef tricks) and events can only be created within a NetworkDescription monad. The newEvent function looks like what you'd want, but because you can't get the event firing function out of NetworkDescription its use is limited. Greetings, Peter Minten ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Is this a correct explanation of FRP?
Hi, I've been trying to get my head around Functional Reactive Programming by writing a basic explanation of it, following the logic that explaining something is the best way to understand it. Am I on the right track with this explanation? Greetings, Peter Minten P.S. Sorry about the long mail, the explanation ended up a little longer than I originally expected. :) Document (with markdown formatting) follows: --8--8--8--8--8--8--8--8--8--8--8--8--8--8--8--8-- This is an attempt to explain Functional Reactive Programming (FRP) enough to give a reader with no previous exposure to FRP an intuition what FRP is about. After reading this you should hopefully understand enough of FRP to understand the [reactive-banana](http://www.haskell.org/haskellwiki/Reactive-banana) examples. FRP has certain terms such as behavior, event and time-varying that can be confusing for people unfamiliar with it. I'll avoid these terms at first and will focus on spreadsheets and a generalization of spreadsheet cells (which I will call boxes). Later, once the most important concepts are explained, reactive-banana syntax will be introduced along with an example that demonstrates how to work with behaviors and events in reactive-banana. Finally some theory about time-varying functions and how events and behaviors can be implemented using pure functions by making time explicit should provide the necessary background to understand reactive-banana's haddock comments. The version of reactive-banana used here is [0.5.0.0](http://hackage.haskell.org/package/reactive-banana-0.5.0.0). Reactive Programming for the Masses: The Spreadsheet Spreadsheets are something we all (for certain values of we) know about. Let's talk about a typical, simplified, spreadsheet. We have a list of products that we sell and want to compute their price with the Value Added Tax (VAT) added. We might have cells A1 to A10 contain the raw prices of our products and cell B1 contain the current VAT rate (say 19 for a 19% VAT). In cells C1 to C10 we'd like to see the prices including VAT. In cell C1 we'd have a formula: `=A1*(1+B1/100)`, in cell C2 `=A2*(1+B1/100)`, etc. So if A1 contains $100 C1 would contain $119. But what if the government, in it's eternal quest to reduce the budget deficit, raises the VAT rate? We'd adjust cell B1, just change it to 20. And like magic all the C cells are updated. Though this may seem mundane what we've just seen is actually a very good example of reactive programming. We didn't tell the C cells to update; they updated on their own because a value they depend on changed. From Cells to Boxes: Generalizing the Spreadsheet = Spreadsheets are nice, but if we want to truly get a feel for FRP we'll have to think beyond them. If we look at a spreadsheet at an abstract level it pretty much consists of cells of two types: value cells (`19`) and formula cells (`=A1*(1+B1/100)`). Let's lose the reference to spreadsheets and talk about boxes. Say, for now, that there are two kinds of boxes: formula boxes and value boxes. Both support a get operation that returns a value. Value boxes additionally support a set operation that sets the value. Formula boxes can contain any kind of pure function. They can also refer to the values of other boxes (both formula and value boxes). Value boxes don't have a function inside them, they have a value. The translation of our VAT spreadsheet would be something like a formula box *fIncl1* containing the expression `get(vExcl1) * (1 + get(vVat) / 100)`. This expression uses two value boxes: *vExcl1* and *vVat*. We could also write *fIncl1* using a helper formula box *fVat*. Let *fVat* have the formula `1 + get(vVat) / 100` and *fIncl1* have the formula `get(vExcl1) * get(vVat)`. I'll use `:=` for this kind of definition, the `:=` is there to remind you that this isn't Haskell. It's important to note that any kind of value may be put into value boxes, including IO actions and functions. Try doing this with a spreadsheet: `fIncls := [get(ve) * get(vVat) | ve - vExcls]`. Or this: `fIncl1 := apply(get(vVatFunc), get(vExcl1))`. If you're wondering why I'm not using Haskell syntax, it's to focus on the meaning of boxes rather than what the functions and combinators mean. That said, this pseudo-imperative syntax is on its way out as it's getting too clunky (that `apply` function is really just ugly). For a quick peek ahead the last few examples would be something like this in reactive-banana: fIncls = map (\ve - (*) $ ve * fVat) vExcls fIncl1 = fVatFunc * vExcl1 Events == Let's say we want to build the worlds worst synthesizer. We have 7 buttons: a, b, c, d, e, f and g. Our output is generated by sampling a box twice per second and playing the frequency in the box until the next sample is taken. This can't be expressed with the crude formula and value boxes system we've had so far
Re: [Haskell-cafe] Theoretical question: are side effects necessary?
Christopher, On 16/03/2012, at 11:23 PM, Christopher Svanefalk wrote: there is a question I have been thinking about a bit. In short, we could simply formulate it like this: Are there any problems which cannot be solved a side effect-free language (such as Haskell)? In other words, are there problems that would explicitly demand semantics that can only be provided by a language allowing direct modification of external state variables, such as Java and C++? If not, are there problems which are simply infeasible to solve with a side effect-free language? Start here: http://www.cs.ox.ac.uk/people/geraint.jones/morehaste.html and dig through their references. I don't think a logarithmic factor is ever going to make the difference between feasible and infeasible. :-) cheers peter -- http://peteg.org/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] haskell platform - mac lion - installation error
Hello - I'm a new user, having some trouble installing the Haskell Platform (2011.4.0.0 64bit.pkg) on a Macbook Pro (10.7.3). I installed Xcode 4.3.1 (4E1019), then the Haskell Platform. When I double-click on the Platform package icon, I get an installation dialogue with an error message reading Developer Tools Missing - Please install Xcode developer tools first. Are Xcode developer tools something distinct from Xcode itself? I'm mystified by this error message. Any assistance would be greatly appreciated - thank you. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Functor in terms of Arrow
Tom, On 19/02/2012, at 3:21 AM, Tom Schouten wrote: Does AFunctor below have a standard name? It's a generalization of the Functor class in terms of Arrow instead of (-): fmap :: Functor f = (i - o) - f i - f o afmap :: Arrow a, AFunctor f = a i o- a (f i) (f o) It pops up in less general form (AFunctor = []) in iterated functions (difference equations / state space models), where the arrow is the update function parameterized by state type: data Iter s i o = Iter ((s,i) - (s,o)) instance Arrow (Iter s) I think you can work with Arrow transformers instead. See: http://hackage.haskell.org/packages/archive/arrows/latest/doc/html/Control-Arrow-Transformer-Stream.html#t:StreamArrow It may be that you can generalise to arbitrary functors, but satisfying the Arrow laws may require some care. cheers peter -- http://peteg.org/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to make asynchronous I/O composable and safe?
Hi guys, I'm not happy with asynchronous I/O in Haskell. It's hard to reason about, and doesn't compose well. Async I/O *is* tricky if you're expecting threads to do their own writes/reads directly to/from sockets. I find that using a message-passing approach for communication makes this much easier. yes, that is true. I've always felt that spreading IO code all over the software is a choice that makes the programmers live unnecessarily hard. The (IMHO superior) alternative is to have one central IO loop that generates buffers of input, passes them to callback a function, and receives buffers of output in response. I have attached a short module that implements the following function: type ByteCount= Word16 type Capacity = Word16 data Buffer = Buf !Capacity !(Ptr Word8) !ByteCount type BlockHandler st = Buffer - st - IO (Buffer, st) runLoop :: ReadHandle - Capacity - BlockHandler st - st - IO st That setup is ideal for implementing streaming services, where there is only one connection on which some kind of dialog between client/server takes place, i.e. an HTTP server. Programs like Bittorrent, on the other hand, are much harder to design, because there's a great number of seemingly individual I/O contexts (i.e. the machine is talking to hundreds, or even thousands of other machines), but all those communications need to be coordinated in one way or another. A solution for that problem invariably ends up looking like a massive finite state machine, which is somewhat unpleasant. Take care, Peter {-# LANGUAGE DeriveDataTypeable #-} {- | Module : BlockIO License : BSD3 Maintainer : sim...@cryp.to Stability : provisional Portability : DeriveDataTypeable 'runLoop' drives a 'BlockHandler' with data read from the input stream until 'hIsEOF' ensues. Everything else has to be done by the callback; runLoop just does the I\/O. But it does it /fast/. -} module BlockIO where import Prelude hiding ( catch, rem ) import Control.Exception import Control.Monad.State import Data.List import Data.Typeable import System.IO import System.IO.Error hiding ( catch ) import Foreign hiding ( new ) import System.Timeout -- * Static Buffer I\/O type ReadHandle = Handle type WriteHandle = Handle type ByteCount = Word16 type Capacity = Word16 data Buffer= Buf !Capacity !(Ptr Word8) !ByteCount deriving (Eq, Show, Typeable) -- |Run the given computation with an initialized, empty -- 'Buffer'. The buffer is gone when the computation -- returns. withBuffer :: Capacity - (Buffer - IO a) - IO a withBuffer 0 = fail BlockIO.withBuffer with size 0 doesn't make sense withBuffer n = bracket cons dest where cons = mallocArray (fromIntegral n) = \p - return (Buf n p 0) dest (Buf _ p _) = free p -- |Drop the first @n = size@ octets from the buffer. flush :: ByteCount - Buffer - IO Buffer flush 0 buf = return buf flush n (Buf cap ptr len) = assert (n = len) $ do let ptr' = ptr `plusPtr` fromIntegral n len' = fromIntegral len - fromIntegral n when (len' 0) (copyArray ptr ptr' len') return (Buf cap ptr (fromIntegral len')) type Timeout = Int -- |If there is space, read and append more octets; then -- return the modified buffer. In case of 'hIsEOF', -- 'Nothing' is returned. If the buffer is full already, -- 'throwDyn' a 'BufferOverflow' exception. When the timeout -- exceeds, 'ReadTimeout' is thrown. slurp :: Timeout - ReadHandle - Buffer - IO (Maybe Buffer) slurp to h b@(Buf cap ptr len) = do when (cap = len) (throw (BufferOverflow h b)) timeout to (handleEOF wrap) = maybe (throw (ReadTimeout to h b)) return where wrap = do let ptr' = ptr `plusPtr` fromIntegral len n= cap - len rc - hGetBufNonBlocking h ptr' (fromIntegral n) if rc 0 then return (Buf cap ptr (len + fromIntegral rc)) else hWaitForInput h (-1) wrap -- * BlockHandler and I\/O Driver -- |A callback function suitable for use with 'runLoop' -- takes a buffer and a state, then returns a modified -- buffer and a modified state. Usually the callback will -- use 'slurp' to remove data it has processed already. type BlockHandler st = Buffer - st - IO (Buffer, st) type ExceptionHandler st e = e - st - IO st -- |Our main I\/O driver. runLoopNB :: (st - Timeout)-- ^ user state provides timeout - (SomeException - st - IO st) -- ^ user provides I\/O error handler - ReadHandle -- ^ the input source - Capacity -- ^ I\/O buffer size - BlockHandler st-- ^ callback - st -- ^ initial callback state - IO st -- ^ return final callback state runLoopNB mkTO errH hIn cap f initST = withBuffer cap (`ioloop` initST) where ioloop buf st = buf `seq` st `seq` handle (`errH` st) $ do rc - slurp (mkTO st) hIn buf
Re: [Haskell-cafe] How to make asynchronous I/O composable and safe?
Hi Daniel, I've been trying to write networking code in Haskell too. I've also come to the conclusion that channels are the way to go. isn't a tuple of input/output channels essentially the same as a stream processor arrow? I found the example discussed in the arrow paper [1] very enlightening in that regard. There also is a Haskell module that extends the SP type to support monadic IO at [2]. Take care, Peter [1] http://www.ittc.ku.edu/Projects/SLDG/filing_cabinet/Hughes_Generalizing_Monads_to_Arrows.pdf [2] http://hackage.haskell.org/package/streamproc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: wxHaskell 0.13.2
Hi guys, I am please to announce that wxHaskell 0.13.2 has just been uploaded to Hackage. when I try to build the latest version on Linux/x86_64 running NixOS, I get the following error at configure time: Setup: Missing dependency on a foreign library: * Missing C library: wx_gtk2u_media-2.8 I searched my hard disk for that library, and apparently my installed copy of wxGTK-2.8.12 doesn't have it. There are plenty of libwx_gtk2u_* libraries, but none of them is called media. Does anyone know how wxGtk must be built in order to make sure that library exists? Is there some special configure flag, maybe? Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Announce: The Haskell Platform 2011.4
Hi guys, We're pleased to announce the release of the Haskell Platform: a single, standard Haskell distribution for everyone. Haskell Platform 2011.4 is fully supported on NixOS http://nixos.org/. Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to get a file path to the program invoked?
Hi I was running into a similar problem while working on GHC not long ago - short version is that it's not even possible to find out the executable path portably from C [1]. Using argv[0] just gave me the path of the GHC wrapper script, for example - as it uses exec without -a. The whole thing is easiest if you're on Linux: getExePath = readSymbolicLink /proc/self/exe On all other operation system, one needs to start mucking around with custom kernel calls. Or, more realistically, try to find a way around requiring it... Greetings, Peter Wortmann [1] http://stackoverflow.com/questions/1023306 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [ANNOUNCEMENT] xmobar 0.14
Hi Jose, Peter, would using parsec 3.x be an acceptable solution to you? well, we can link xmobar with parsec 3.x on NixOS. The situation is tricky, though, because the latest version of parsec that we have, 3.1.2, doesn't compile with GHC 6.10.4 anymore, so we'd have to use some older version to work around that problem. That kind of setup somewhat complicated to maintain, which is why I would prefer to compile xmobar with parsec 2 2 if at all possible. Generally speaking, though, GHC 6.10.4 support is not a high priority. I just thought it might be worth pointing out that backwards compatibility has been lost in the 0.14 release, because earlier versions worked just fine. Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [ANNOUNCEMENT] xmobar 0.14
Hi Antoine, What errors are you getting compiling with GHC 6.10.4? If its a small thing I certainly don't mind patching things. I am sorry, my previous statement was inaccurate. Parsec 3.1.2 compiles fine, but the 'text' library -- on which Parsec depends -- does not. We can probably avoid that issue by downgrading text to version 0.11.0.6 for GHC 6.10.4, which builds fine. It's not a pretty solution, but it seems to work fine. So, the good news is that we now have Parsec 3 available for GHC 6.10.4 in NixOS after all. :-) Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [ANNOUNCEMENT] xmobar 0.14
Hi Jose, I'm happy to announce the release of xmobar 0.14. previous versions of xmobar used to compile fine with GHC 6.10.4, but the new version no longer does: src/Parsers.hs:163:52: Couldn't match expected type `Char' against inferred type `[Char]' Expected type: GenParser Char st Char Inferred type: GenParser Char st String In the second argument of `($)', namely `wrapSkip $ string Run' In a stmt of a 'do' expression: notFollowedBy $ wrapSkip $ string Run The complete log is at http://hydra.nixos.org/build/1603134/nixlog/1/raw, just in case there happens to be an easy fix for that error. Thank you very much for your efforts! Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Job Opportunity at Parallel Scientific
Parallel Haskell Programmers Parallel Scientific, LLC is a Boulder, CO based early stage, but funded startup company working in the area of scalable parallelization for scientific and large data computing. We are implementing radically new software tools for the creation and optimization of parallel programs benefiting applications and leveraging modern systems architecture. We build on our mathematical knowledge, cutting edge programming languages and our understanding of systems software and hardware. We are currently working with the Haskell development team and major HPC laboratories world wide on libraries and compiler extensions for parallel programming. Parallel Scientific was founded by Peter Braam in 2010. Peter formerly taught mathematics and computer science at Oxford and Carnegie Mellon. Then he contributed file systems to Linux and invented Lustre (which provides storage to 9 of the top 10 systems in the world). He ran several successful startups, and Parallel Scientific is run by an very experienced management team and board. Successful candidates can in some cases work remotely and will work in a modern virtual environment. We provide training in advanced processes for software design and implementation and domain specific knowledge. Required skills: - Very strong background in computer science or mathematics - Experience with Haskell - Knowledge of systems programming and operating systems functionality - Knowledge of system architectures, such as high performance networking, memory architectures, multi and manycore CPUs and GPGPUs - Experience with performance tuning of parallel or concurrent algorithms - Experience designing and implementing concurrent or parallel programs Experience in one or more of the following areas is desirable: - Experience with Haskell compiler technology - In depth knowledge of core Haskell libraries for parallel programming (NDP, REPA etc) - Experience in the area of middleware algorithms for data flow programming, graphs, cloud based data analytics, or sparse matrices - Domain specific knowledge in scientific programming areas related to irregular and sparse problems, e.g. data analytics using graph analysis, genomics, tightly connected numerical analysis - Experience with performance tuning for parallel applications on multi core systems (e.g. with the Intel toolkit), for GPGPU's using Cuda/OpenCL or with MPI/OpenMP on clusters of SMPs To apply, please send a resume to j...@parsci.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Quicksort in Haskell
You can narrow down the problem by commenting out the part of the file that's giving you problems, and trying out the other functions in ghci. In your case, the main function is causing a parsing error. If you comment it out, you can verify that quicksort works correctly. Then look at your main function and see where it's broken. Try this out, and compare with what you wrote: module Main (main) where quicksort [] = [] quicksort (s:xs) = quicksort [x | x - xs, x s] ++ [s] ++ quicksort [x | x - xs, x = s] main = do putStr Ingrese la lista\n line - getLine let xs = read line :: [Int] print (quicksort xs) -Peter On Mon, Nov 7, 2011 at 3:41 PM, yrazes yra...@gmail.com wrote: Sorry, but I got this error while I compile it. * * *[yulys@yulys haskell]$ ghc -o quick quick.hs* *[1 of 1] Compiling Main ( quick.hs, quick.o )* * * *quick.hs:7:11: parse error on input `-'* *[yulys@yulys haskell]$ * On Mon, Nov 7, 2011 at 4:23 PM, KC kc1...@gmail.com wrote: What is your question? On Mon, Nov 7, 2011 at 9:45 AM, yrazes yra...@gmail.com wrote: module Main (main) where quicksort [] = [] quicksort (s:xs) = quicksort [x|x - xs,x s] ++ [s] ++ quicksort [x|x - xs,x = s] main = putStr Ingrese la lista\n [xs] - getLine ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- -- Regards, KC ___ 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] Implementing a New primop
Have you tried rebuilding GHC completely after the change? I tried your change and the error went away after I rebuilt from scratch. The build system probably just didn't pick up all files that needed rebuilding. Might be worth reporting? Not sure. Greetings, Peter Wortmann ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Question: Lazy Incremental Evaluation and Haskell?
Ben, On 07/10/2011, at 8:55 AM, Benjamin Redelings I wrote: My question is, roughly, is there already an existing framework for incremental evaluation in Haskell? Margnus Carlsson did something monadic several years ago. http://dl.acm.org/citation.cfm?doid=581478.581482 Perhaps there is an implementation on Hackage or on his website. This stuff also goes by the moniker adaptive computation. See the references and citations of that paper for more on this. cheers peter -- http://peteg.org/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ghc 7.2.1 and super simple DPH
Super helpful, thanks! Peter On Mon, Oct 3, 2011 at 12:54 AM, Erik de Castro Lopo mle...@mega-nerd.comwrote: Erik de Castro Lopo wrote: The code you posted had some wrapping issues and was missing an import. I should have also mentioned how I figured out what the missing import was. Firstly, I tried hoogle [0] but couldn't find it. I then realised that it must be part of DPH and that I had a copy of the DPH sources on my machine. Going to the DPH source tree I did: find . -name \*.hs | xargs grep ^fromPArrayP which showed up this: dph-common/Data/Array/Parallel.hs:fromPArrayP :: PArray a - [:a:] Cheers, Erik [0] http://www.haskell.org/hoogle/ -- -- Erik de Castro Lopo http://www.mega-nerd.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] ghc 7.2.1 and super simple DPH
Hi - I'm trying to compile DotP.hs from http://www.haskell.org/haskellwiki/GHC/Data_Parallel_Haskell#A_simple_example (see below) The compiler complains and says (twice in fact): DotP.hs:17:33: Not in scope: `fromPArrayP' Could someone help me out please? Thanks a lot! Peter {-# LANGUAGE ParallelArrays #-}{-# OPTIONS_GHC -fvectorise #-} module DotP (dotp_wrapper)where import qualified Preludeimport Data.Array.Parallel.Preludeimport Data.Array.Parallel.Prelude.Double dotp_double :: [:Double:] - [:Double:] - Double dotp_double xs ys = sumP [:x * y | x - xs | y - ys:] dotp_wrapper :: PArray Double - PArray Double - Double{-# NOINLINE dotp_wrapper #-} dotp_wrapper v w = dotp_double (fromPArrayP v) (fromPArrayP w) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] problem with cabal install MissingH-1.1.1.0
Hi Mariano, I'm with mac OS X lion, ghc version 7.2.1 and when a i try to install MissingH version 1.1.1.0 it fails with [...] that version of MissingH compiles fine on Linux, so I reckon the problem you're seeing is in some way specific to Darwin. Your best bet of getting a fix would be to report that error to the author, i.e. by submitting a bug report at https://github.com/jgoerzen/missingh/issues Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: cabal-ghci 0.1
Hi Etienne, Here is a helpful package I wrote to ease the development of projects using cabal. thank you very much for this helpful tool! I notice that Haddock has trouble parsing the documentation: http://hackage.haskell.org/packages/archive/cabal-ghci/0.1/logs/failure/ghc-7.2 Is that error hard to fix? Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Off-topic: Mathematics
Hi Andrew, I know of several places where I can ask maths questions and half a dozen people will take guesses at what the correct solution might be. I haven't yet found anywhere where I can say when would a chi-squared test be more appropriate than a KS test? and get an informed, knowledgeable answer. (Answers from people who /know/ what they're talking about rather than just /think/ they know.) I believe this phenomenon is quite natural and easily explained. When you're asking a non-trivial question, hardly anyone just knows the correct answer -- especially when it comes to math. In order to answer your question, people have to dedicate time and effort to study the problem you're asking about. (Furthermore, formulating a coherent response is usually be a bit of an effort, too.) Now, a person who has profound knowledge of the subject you're asking about is not very likely to do this, because he is probably not going to learn anything in the process. Dedicating time and effort to studying your particular problem is not an appealing prospect. A person who has superficial understanding of the subject, however, is more likely to be fascinated by the problem, and consequently he is more likely to dedicate time and effort into formulating a response. In other words, even if Donald Knuth himself is reading the forum you're posting to, it doesn't mean that he is actually going to respond. On the other hand, if you're asking the right question, Donald Knuth just might respond to it, but not necessarily in the forum that you were originally asking in. Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Distributions link on Hackage
Hi, the home page of a package on Hackage links to various distributions to show which versions are available, i.e. Fedora, Debian, FreeBSD, etc. In NixOS, we have fairly up-to-date package set, and I would like to see that distribution included on Hackage. Now I wonder how to get that done? Can anyone advice on the procedure to add support for a distribution to Hackage? Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Crypto-api performance
Hi Matthew, While I haven't investigated myself, from seeing haskell build processes in the past this is almost certainly not crypto-api's fault and is in fact your linker's fault. If you are not using it already, try switching to gold over ld, it may help. well, memory consumption sky-rockets while compiling Crypto.CPoly. That behavior is probably not related to the linker. Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Crypto-api performance
Also, it appears that crypto-api needs vast amounts of memory when compiled with optimization enabled. The latest version 0.6.1 is effectively unbuildable on my EeePC, which has only 1GB RAM. That property is fairly undesirable for a library package. Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is Harper right that Haskell cannot model the natural numbers?
On 03/05/2011, at 1:25 PM, Richard O'Keefe wrote: In one of his blog posts, Robert Harper claims that the natural numbers are not definable in Haskell. SML datatype nat = ZERO | SUCC of nat Haskell data Nat = Zero | Succ Nat differ in that the SML version has strict constructors, and so only finite instances of nat can be constructed, whereas Haskell has lazy constructors, so inf = Succ inf is constructible, but that's not a natural number, and it isn't bottom either, so this is not a model of the natural numbers. Fair enough, but what about data Nat = Zero | Succ !Nat where the constructors *are* strict? It's perfectly good Haskell 98 as far as I can see. Now Nat itself isn't _quite_ a model of the naturals because it includes bottom, but then an SML function returning nat can also fail, so arguably SML's nat could or should be thought of as including bottom too. What am I missing? Do read the comments attached to the blog post (and also maybe at reddit). I believe the traditional model for ML-like languages in denotational semantics is to lift the type returned by a function. So ML's Nat type is taken to be an inductively-defined set (with the discrete order) and your divergent ML function really has type a - Nat_{lift} for whatever type a you had in mind. I think Moggi's encoding into monads makes this clear - you use the Maybe/Evaluation/Strict monad to handle divergent arguments. cheers peter -- http://peteg.org/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to keep cabal and ghci package versions in sync?
On 27/04/2011, at 3:04 AM, Rogan Creswick wrote: At the moment, cabal-dev ghci just uses the -package-conf and -no-user-package-conf flags to restrict ghci to the sandboxed and global package dbs. It's difficult to do more without parsing the content of the project's cabal file, and that parser isn't exposed through a library api (it's in cabal-install), which makes it a little difficult to use. Can't you use cabal as a library to do this? I had a crack at figuring out a ghci command line in TBC (testing by convention): https://github.com/peteg/TBC while waiting for this cabal feature to be implemented: http://hackage.haskell.org/trac/hackage/ticket/382 Apparently there's a GSoC project that will nail this. You can fire up TBC with the verbose flag and it will give you a very long ghc invocation line that is strongly similar to what cabal uses to compile your project. It doubtlessly is incomplete, and probably bit rotten. I will try to make it work with the latest Haskell Platform release in the coming weeks. I welcome patches, but you're better off fixing cabal itself. cheers peter -- http://peteg.org/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Asynchronous Arrows need Type Specialization - Help!
David, On 21/03/2011, at 4:18 PM, David Barbour wrote: I was giving Control.Arrow a try for a reactive programming system. The arrows are agents that communicate by sending and returning time-varying state. Different agents may live in different 'vats' (event-driven threads) to roughly model distributed computing. For the most part, the state varies asynchronously - i.e. a file updates at a different rate than the mouse position. Anyhow, I ran into a problem: The (***) and () operations, as specified in Control.Arrow, are inherently synchronization points. Indeed. Take a look here: http://www.haskell.org/haskellwiki/Research_papers/Monads_and_arrows#Arrows In particular, ProdArrows -- Arrows for Fudgets by Magnus Carlsson. cheers peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] order of arguments matters
Why does only tr2 work, although the only difference between tr1 and tr2 is the order of arguments? import Data.Tree (Tree(..)) data Type a where Tree:: Type a - Type (Tree a) Int :: Type Int String :: Type String type Traversal1 = forall a.a - Type a - a type Traversal2 = forall a.Type a - a - a tr1 :: Traversal1 tr1 (Node _ (t:_)) (Tree Int) = Node 1 [t] tr1 n Int = n+n tr1 s String = s++s tr2 :: Traversal2 tr2 (Tree Int) (Node _ (t:_)) = Node 1 [t] tr2 Int n = n+n tr2 String s = s++s Couldn't match expected type `a' against inferred type `Tree Int' `a' is a rigid type variable bound by the type signature for `tr1' at tratest.hs:9:25 In the pattern: Node _ (t : _) In the definition of `tr1': tr1 (Node _ (t : _)) (Tree Int) = Node 1 [t] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] makeTokenParser + LanguageDef
Hi Klaus, for what it's worth, you might want to consider using this package instead of Parsec: http://hackage.haskell.org/package/BNFC Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is there something better than tags?
On 02/22/2011 11:45 AM, Magnus Therning wrote: 1. Fully functional go-to-definition. With that I mean that go-to-definition is aware of local definitions introduced in 'let' and 'where' clauses and ideally also for names bound in 'do' clauses. I've found there are several ways to generate a tags file, GHCi can generate them, and there are two tools for it, hasktags and hothasktags. haskellmode currently uses GHCi to generate tags. However, the limitation seems to be inherent in the tags format itself. AFAICS there is no way to get a fully functional go-to-definition with that format. Last time I checked (about a year ago), the file scope was the smallest scope supported by vim in tag files. So you are out of luck here. You would need to extend vim (either by extending the tag file format or by your own scripts handling this separately) and also your favourite tags generator. 2. Retrieve type information for local defintions ('let', 'where', 'do'), and ideally also for sub expressions (like ':t filter (== 1)'. I believe haskellmode uses GHCi to get the type information out, but it is only able to get it for top-level definitions. This is because ghci shows you this information only for the top level symbols (the ones available in :browse). Ghci would need to be extended first. Maybe it is there in GHC 7.0? I hope I'm wrong somewhere and it could be done somehow more easily. Peter. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is there something better than tags?
On 02/22/2011 12:26 PM, Marc Weber wrote: learn about gd and gD those are not perfect though. Also keep in mind that # * start searches on words. They all are not language aware so they are only bad replacements for what you're looking for. When we are talking about such simple helpers then you may want to check out: Mark : Highlight several words in different colors simultaneously. http://www.vim.org/scripts/script.php?script_id=2666 I also like showmarks to highlight interesting places: ShowMarks : Visually shows the location of marks. http://www.vim.org/scripts/script.php?script_id=152 2. Retrieve type information for local defintions ('let', 'where', 'do'), and ideally also for sub expressions (like ':t filter (== 1)'. I believe haskellmode uses GHCi to get the type information out, but I only know about scion which comes closest to what you ask for. (http://github.com/MarcWeber/scion-backend-vim) Is this a correct summary? * can load cabal components (all files of the component) * can do type checking on buffer write * can show type of any symbol under cursor if the file type checks ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Why is there no splitSeperator function in Data.List
Hi Evan, The reason it's not in Data.List is because there are a bazillion different splits one might want (when I was pondering the issue before Brent released it, I had collected something like 8 different proposed splits), so no agreement could ever be reached. It is curious though that the Python community managed to agree on a single implementation and include that in the standard library… So it is possible :) This is sometimes cited as the advantage of a benevolent dictator-for-life. I remember there was lots of argument when 'join' was added as a string method (vs. should it be a list method). In the end, Guido decided on one and that's what went in. having a dictator is not a necessary prerequisite for the ability to make decisions. It's quite possible to decide controversial matters without a dictator -- say, by letting people vote. Take care, Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Storing passwords securely
The usual advice on how to store passwords securely is use bcrypt, but since there seem to be no Haskell bindings for bcrypt, the other good option is to iterate a salted hash function at least 1000 times. In order for people to get this right, there should be a library with a really simple API that makes it Just Work. I think I have such an API, but I'd like to hear if anybody else has suggestions before I go releasing it onto Hackage. The code is here: https://github.com/PeterScott/pwstore The part of the API that people have to care about is two functions. makePassword creates a hashed, salted password that you can store in a database. verifyPassword takes this hashed, salted password and a user's password input, and tells you if it matches. Like this: makePassword (B.pack hunter2) 12 sha256|12|lMzlNz0XK9eiPIYPY96QCQ==|1ZJ/R3qLEF0oCBVNtvNKLwZLpXPM7bLEy/Nc6QBxWro= verifyPassword (B.pack wrong guess) passwordHash False verifyPassword (B.pack hunter2) passwordHash True There's also a function for increasing the number of hash iterations on stored password hashes, to compensate for Moore's law. Does this sound reasonable? Also, I have a pure-Haskell version and a version which depends on some C code, for speed (about 25x difference). Does anybody care about the pure Haskell version, or should I just drop it and require the faster C/Haskell mixed version? Thanks, -Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Storing passwords securely
On Sat, Feb 5, 2011 at 10:54 PM, Jeremy Shaw jer...@n-heptane.com wrote: Have you seen the PBKDF2 library? http://hackage.haskell.org/package/PBKDF2 http://hackage.haskell.org/package/PBKDF2 Does that look like a reasonable way to store passwords securely? Yes, I looked at it before I started on pwstore. The code does indeed calculate the PBKDF2 key derivation function, and the documentation is terse but descriptive. It's usable, but it's not *trivial* to use. With the PBKDF2 library, a user has to: 1. Understand what PBKDF2 is, at least well enough to know what the documentation is talking about when it mentions things like length of prf output. 2. Convert passwords to and from [Word8], which is not a very common type to have immediately on hand. 3. Generate unique salts for each user. Easy, but it would be nice if the library handled this for you. 4. Manage the salt and the hashed password separately. Again easy, but a small hassle. 5. Store the salt and hashed password as byte vectors. Some storage methods may have trouble with data that may contain (for example) the '\NUL' character. This is why my library uses base64 encoding. Some more problems are that the library is slow (thanks to the unoptimized hash functions in Crypto) and the documentation is not as clear as it could be about what a newbie needs to do. Also, if you want to extend a bunch of existing hashed passwords with more iterations as hardware gets faster, there's no obvious easy way to do that with PBKDF2. In other words, while the PBKDF2 library is technically correct, it's not as slick and easy-to-use as a password storage library should be, and *must* be, if we want everyone to store passwords properly. One of the aphorisms of cryptography is don't roll your own, but as long as the existing code feels like it's not quite what the users are looking for, there will still be the temptation to ignore this advice and roll your own anyway. I want to make something that people can use in ten minutes and say there, I'm done. -Peter ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe