Re: [Haskell-cafe] HDF5 binding (was: why is ghci trying to load hsc file ??)
Bindings to the full hdf5 were supposed to be in the example set for bindings-DSL. It doesn't use pkg-config, though, and hdf5 developers didn't like the idea of adding support. [...] That seems strange to me - pkg-config is such a useful system, and support for it is incredibly easy to add and practically zero- maintenance. [...] I have to start asking for forgiveness. In fact, PETSc (http://www.mcs.anl.gov/petsc) developers refused pkg-config, not HDF5. I investigated several libraries for numerical and massive data processing, and most didn't had pkg-config support. I started asking about it at pkg-scicomp-devel debian list, and then Tollef (maintainer of pkg-config): http://lists.alioth.debian.org/pipermail/pkg-scicomp-devel/2009-September/004507.html http://thread.gmane.org/gmane.comp.package-management.pkg-config/345 After learning from them that pkg-config files belong to upstream packages, not distribution packages, I asked PETSc guys. Unfortunately, their petsc-maint mainling list doesn't seem to have an external archive. But Matthew Knepley, from PETSc, said that we do not use that system. It's unreliable, and in my opinion, one of the worst designs possible. They (Matthew and Satish Balay) suggested that we use the makefile targets which give the include and library information. I'm not sure how practical that is with cabal, but I gave up before trying harder and decided to focus on packages with pkg-config already available. I think 'hmatrix' package on hackage uses a script to check for dependencies, but I didn't read enough to check how portable that method can be. Currently I've got a template hdf5.pc file in the source tree which can be customized and dropped into the appropriate directory. It's a lot less manual than it ought to be, but it's at least a lot less ugly than hard-coding my development machine's include and lib paths. Maybe it's worth contacting HDF5 guys about that. Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] HDF5 binding (was: why is ghci trying to load hsc file ??)
I worked out a small hdf5 binding using cabal and bindings-DSL and sqlite3 as my example. I just wanted to add that I also started an HDF5 binding recently (using hsc2hs only). It does more than enough for me ATM, so I don't develop it actively, but if you want to pursue this (and I think it would be a useful addition to Hackage), we may share experience and code. My binding is part of a bigger project, but I meant to split it out anyway. What an interesting coincidence, that makes at least three of us. Apparently it's an idea whose time has come. Mine is also an incomplete low-level binding but is currently under semi-active development and I aim to make it cover the entire hdf5.h interface. If anyone is interested in it I've put it on github at: https://github.com/mokus0/bindings-hdf5 Bindings to the full hdf5 were supposed to be in the example set for bindings-DSL. It doesn't use pkg-config, though, and hdf5 developers didn't like the idea of adding support. I wanted reference bindings-* libraries to be free of linking problems some users might not be able to solve or understand, so I gave up. Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Existencial quantification and polymorphic datatypes
Hi, I'm trying, without success, to understand the difference between existencial quantification and polymorphic datatypes. Can you give me a hint, or an example where one is valid and the other is not? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Existencial quantification and polymorphic datatypes (actually, components...)
4294967296 :: Integer (...) In the above you can see the polymorphism of the return type of fromInteger, it returns a Int8 or a Int32. You can see the polymorphism of the argument of show, it takes an Int8 or Int32 or Integer. The latest ghc-6.10.1 also allows avoiding use of SomeNum, see impredicative-polymorphism: http://www.haskell.org/ghc/docs/latest/html/users_guide/other-type-extensions.html#impredicative-polymorphism Great, thanks! I'm enlightened :) But how is this: data SomeNum = forall a. SN a different from: data SomeNum = SN (forall a. a) ? Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Existencial quantification and polymorphic datatypes (actually, components...)
But how is this: data SomeNum = forall a. SN a different from: data SomeNum = SN (forall a. a) At a glance they look the same to me — but only the first is accepted by ghc. Following the link you pointed in the last message, I found this at 8.8.4.1: data T a = T1 (forall b. b - b - b) a If I understand properly, it can be activated with -XPolymorphicComponents. It's different from my example, but I would like to know what it does that this can't: data T a = forall b. T1 (b-b-b) a (The last one I think I understand well after the previous message, although I see no use for this particular form, since after pattern match there's no other 'b' value to which we could aply that function field.) Link for convenience: http://www.haskell.org/ghc/docs/latest/html/users_guide/other-type-extensions.html Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] What could be considered standard Haskell these days?
Hi, I would like to take some time to study Haskell properly, so that I could help others and pay my debt for the many times I had to bother with my syntax questions. And, of course, make better use of the language. My first attempt was to read the syntax description in Haskell 98 report, and that helped a lot. But I've realized that it's far from the language as used today. But just adding all available extensions would not be good, as some are very experimental e others are obsolete. I saw Haskell-prime page and a few features are marked as accepted. That mean I can trust them to be part of the next Haskell standard? So: if someone wants to learn the details of the language, what could be the subset of extensions one should learn and make regular use, and also include in code supposed to be used by others in the long term? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Type errors, would extensions help?
Hi, I have this problem trying to define a function inside a do expression. I tried this small code to help me check. This works well: --- import Data.Ratio ; main = do { printNumber - let { print :: (Num n,Show n) = n - IO () ; print n = do { putStrLn $ show n} } in return print ; print (1%5) ; print 5.0 } --- However, just removing 'Num n' gives: Ambiguous type variable `n' in the constraint: `Show n' arising from a use of `print' at teste.hs:7:16-20 Why is it ambiguous? Since I don't use numeric functions, 'Num n,Show n' doesn't seem more specific. Besides that, the real problem I have is a similar function declared inside a 'let' as col :: (WidgetClass w) = w-IO Int col wid = do {... that, after beeing used with w beeing Table (and instance WidgetClass Table do exist) refuses beeing used with DrawingArea (also with instance WidgetClass DrawingArea), but I wasn't able to simulate that in a small program, and don't know if it's related to the case I'm showing. Thanks for your kindness, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Type errors, would extensions help?
I have this problem trying to define a function inside a do expression. I tried this small code to help me check. This works well: I guess you intended to call printNumber in the quoted snippet? (...) {-# LANGUAGE RankNTypes #-} {-# LANGUAGE ImpredicativeTypes #-} After you pointed my dumb mistake, I was able to build the first example -- without any of the extensions! Haskell can be misterious some times. Strange enough, I can't get the original (and, to my eyes, equal) problem to work. This is the smallest I could get it to be: --- WARNING: wrong use of gtk, just to get an example --- import Graphics.UI.Gtk ; main = do { initGUI ; j1 - drawingAreaNew ; j2 - tableNew 1 1 True ; notebook - do { note - notebookNew ; insertInNotebook - let { colocar :: (WidgetClass w) = w - String - IO Int ; colocar wid texto = do { lb - labelNew Nothing ; labelSetMarkup lb texto ; notebookAppendPageMenu note wid lb lb } } in return $ colocar ; insertInNotebook j1 J1 ; insertInNotebook j2 J2 ; return note } ; putStrLn Finish } --- GHC says: teste.hs:15:21: Couldn't match expected type `DrawingArea' against inferred type `Table' In the first argument of `insertInNotebook', namely `j2' In a stmt of a 'do' expression: insertInNotebook j2 J2 (...) but I would like first argument of insert... to be any instance of WidgetClass, be it Drawing... or Table. Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Type errors, would extensions help?
Thanks, everything works now. What should I read to better understand the difference for the type system between using - and 'let'? That is not intuitive for me. About layout, I used to filter my code to better fit everyone taste before posting to this list. The filter stoped working due to some problems in 'Language.Haskell', but I'll rewrite it with haskell-src-exts before posting again. Thanks, Maurício I suggest you start using let in your do blocks; both of these problems are solvable with let. Binding with - instead of let makes the type system work harder, and will generally require type annotations extensions for polymorphic results. (...) Also, is there a reason you hate the layout rule and are using explicit semicolons everywhere? I have this problem trying to define a function inside a do expression. (...) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Recursive modules, GHC /= Report?
Hi, Here: http://www.haskell.org/onlinereport/modules.html I read: Modules may reference other modules via explicit import declarations, each giving the name of a module to be imported and specifying its entities to be imported. Modules may be mutually recursive. However, I get this from GHC: --- Module imports form a cycle for modules: main:Main imports: Control.Concurrent.MVar GtkMostrarConfig GtkLerECG Graphics.UI.Gtk main:GtkMostrarConfig imports: Control.Concurrent.MVar Graphics.UI.Gtk Main --- Aren't cycles of modules just recursive modules? Why wasn't that allowed? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: databases in Haskell type-safety
Mauricio No. Only sqlite3_exec with INSERT, SELECT stuff, Mauricio and saving everything that needs structure in pseudo-xml Mauricio strings. Not that efficient, but easy to change to blobs when Mauricio everything is ready and tested. I see...I'm thinking to maybe store only paths for bigger BLOBs, but still there is need to store smaller (thumbnails pics) ones... You can always uuencode the pictures. Package 'dataenc' seems nice, although I have not used it. Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: [Haskell] ANN: ghci-haskeline 0.1
Haskeline is designed to remove the readline dependency, because Windows does not have readline. So rlwrap is useless there. Ah, I hadn't considered Windows support--that makes sense. Thanks, that answers my questions. AHH One nice thing would be to write something like rlwrap that would work everywhere Haskell does. Even more sofisticated behavior could come from some comunication from the api, using standard OS facilities (like a file with an updated list of completions, or something more clever). (For those interested: rlwrap is available in cygwin. It used to work very well on old ghci, when line editing wasn't available.) Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: real haskell difficulties (at least for me)
There's a 'stability' field on cabal description files. Maybe it could appear after the name on the main listing. Or, all packages marked as 'Stable' at that field could get a beautifull color. I agree completely. There is not nearly enough documentation on packaging in haskell and too many hackage packages are broken or do not install. I know several people are working on improving this but they seem do be doing so rather quietly. Could someone briefly outline what improvements are planned and what stage the current work is at? I remember seeing some demos at anglohaskell during the summer but nothing since. Jamie On Tue, Jan 13, 2009 at 3:33 PM, Regis Saint-Paul regis.saint-p...@create-net.org wrote: Hi, I've seen many times the monad topic coming around on the cafe and plentiful tutorials on monads have been published. However, as a complete Haskell newbie coming from OOP, I felt monads were not particularly difficult to grasp, and very exciting to work with. During my experiments with Haskell so far, the main problems I kept bumping into were not related to the language but to its libraries: their compilation and installation. Unfortunately, this topic has not received nearly as much attention. I was unable to find a comprehensive tutorial on how to deal with the variety of problems I get when trying to install Hackage packages. This turned out to be (and still is) THE main source of wasted time and headaches. And worse, unlike type problems, these are not interesting ones to solve. Thus, as a beginner, the package management is what is really getting in the way of switching to Haskell--not the language. Even books like Real World Haskell (otherwise excellent) ignore entirely the topic. Cabal and Cabal-install are clearly wonderful applications that make installing most packages very straightforward. Unfortunately, whenever this standard method for package installation fails (or when it is not available as with, e.g., gtk2hs), I find myself in complete disarray. Below are some of the questions and issues I faced regarding package management: - For a number of packages, cabal-install gets stuck and has to be killed. I assume this is due to some difficulties in solving the dependencies and it is fine, not all can be automated and cabal-install is not responsible for poor packages. But the question then becomes what to do from there? Is their some method to solve dependencies? How should we proceed to debug a package installation? How do gurus deal with that? (maybe some less known command line arguments? Or ways to figure out the problem and work out its solution (cabal-install is silent in such case)? In particular, how to know why did cabal get stuck in the first place? - Some packages on Hackage are reported as not building successfully with GHC6.10 (e.g., encoding) while others do not build with 6.8 (e.g., salvia) and the later might depend on the former...What is one supposed to do in such case? For example, is it an appropriate way to proceed to compile a package with one version of GHC and then use the compiled package with another version of GHC? Is it safe? What could possibly go wrong? If it is the right way to go, how should we setup the two GHC versions? For instance, should we have a shared package configuration file and choose through the path which GHC is used or is there nicer way to set this up? - Taking for example the encoding package on Hackage. Last time I tried, the log was saying it fails to build on GHC 6.10, however, looking inside this Hackage log, I could see a successful compilation using preferred versions. So it looks as if the thing can be compiled somehow. What should one do with this information? If cabal manages to compile it using this method on Hackage, then isn't cabal install just doing it on my disk? Is it possible through some command line? Is it possible manually (without cabal-install) and, if so, how? (I tried to copy-past the build instruction as it appeared on the log...that somehow compiled, but then, I failed to figure out how to install...) - I'm primarily a windows user and lots of my initial struggles probably came from that. After many difficulties, I figured out that installing MinGW and MSys was *THE* way to get a bit more of the things working. First, a lot of time would be saved by just saying clearly on the GHC download page that MinGW and MSys are mandatory installation (or even package that with GHC for the windows distribution if license allows, who cares the extra few Mb). Even if that is not technically exact, i.e., even if ghci and many trivial command line programs can work without, MSys and MinGW turn out to be quiet necessary whenever trying to install anything producing side effect. Making it plain that these two are necessary would real come has a great time savers for newbie like me on windows (personal opinion of course). Or, if another path exists to go without these two, I'd be very glad to learn. Besides, even these
[Haskell-cafe] Re: databases in Haskell type-safety
Mauricio I've been doing a lot of low level sqlite3 lately (it's going Mauricio to be on a hackage package as soon as I finish my current Mauricio work). Have you done any work with BLOBs? No. Only sqlite3_exec with INSERT, SELECT stuff, and saving everything that needs structure in pseudo-xml strings. Not that efficient, but easy to change to blobs when everything is ready and tested. Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: System.CPUTime and picoseconds
Aren't Doubles evil? Integer is a nice type, Haskell filosofy compliant. Doubles are not CDoubles, IEEE, infinite precision or anything long term meaninfull. (Warning: non-expert opinion.) I've found the pico second accuracy useful in working with 'rate equivalent' real time systems. Systems where the individual timings (their jitter) is not critical but the long term rate should be accurate - the extra precision helps with keeping the error accumulation under control. When you are selling something (like data bandwidth) and you are pacing the data stream on a per packet basis you definitely want any error to accumulate slowly - you are in the 10^10 events per day range here. Neil On 12 Jan 2009, at 00:00, Lennart Augustsson wrote: On Sun, Jan 11, 2009 at 8:28 PM, ChrisK hask...@list.mightyreason.com wrote: An Double or Int64 are both 8 bytes and counts with picoseconds precision for 2.5 hours to 106 days. Going to 12 byte integer lets you count to 3.9 billion years (signed). Going to 16 byte integer is over 10^38 years. Lennart Augustsson wrote: A double has 53 bits in the mantissa which means that for a running time of about 24 hours you'd still have picoseconds. I doubt anyone cares about picoseconds when the running time is a day. The above is an unfounded claim about the rest of humanity. It's not really about humanity, but about physics. The best known clocks have a long term error of about 1e-14. If anyone claims to have made a time measurement where the accuracy exceeds the precision of a double I will just assume that this person is a liar. For counting discrete events, like clock cycles, I want something like Integer or Int64. For measuring physical quantities, like CPU time, I'll settle for Double, because we can't measure any better than this (this can of course become obsolete, but I'll accept that error). -- Lennart ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Computer time, independent of date
patients, I wanted to be sure not to save wrong information. It wouldn't matter if the clock is saying we are on XVII century, as long as 10 seconds would never be 10.1. What are the interval durations you need to measure? Since they are from equipment, what is the spec? I read from serial port. When the equipment was available for testing, we measured the output to be a few thowsand bytes/second. The program is supposed to run in Windows computers at physicians offices (and their only requirement is to be able to run windows and have a serial port). Errors of 1 byte per second would be acceptable, even if they accumulate. I have no equipment specs and, right now, no equipment to test. (Yes, I know this is crazy.) So, I need to know what kind of problems I may expect, so I'm able to deal with them. Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Looking for Haskellers on Windows
Hi Bulat, (...) Thus my cry for help explicitly to Haskellers on Windows. (...) It's a pitty that Windows receives so little support, but I guess if nobody has a Windows box to test with, there's not much you can do about it. I think it deserves consideration: what about a mailing list like haskell-portability? If someone asks on this haskell-cafe for some way to do, say, USB on windows using Haskell, some answers would arrive; but if one asks at this, say, haskell-portability list, I have a working Haskell USB library running everywhere except on Windows, it's likely to get the attention of people who do have deep OS understanding and are willing to do a big effort to solve a problem if that results in a new library that can be trusted at any OS. Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Computer time, independent of date
POSIX realtime extensions have been developed to be high reliable. (...) However, they offer no guarantees on interval measurements, and the correction algorithms can cause the measurement of a time interval of an hour or so duration to be off by +/- 1 sec, especially within the first few hours after a cold boot. (...) At the start of this thread, my assumption was that all computers had a 100% reliable tick counter. Well, this shows I understand nothing about hardware. My problem is that the equipment I interact with is supposed to deliver data at a constant rate. Since I don't know how much its engineers care about patients, I wanted to be sure not to save wrong information. It wouldn't matter if the clock is saying we are on XVII century, as long as 10 seconds would never be 10.1. But, as I learned from you, my PC is not to be considered as a reference. Maybe the right approach is to ask people who understand hardware if mine is actually a valid concern. Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Computer time, independent of date
benchpress also uses System.CPUTime -- is that what you are looking for? I'm writing a program that will read medical signs from many patients. It's important to have a precise measure of the time interval between some signs, and that can't depend on adjustments of time. (Supose my software is running midnight at the end of a year with leap seconds. I would get wrong time intervals.) System.CPUTime.getCPUTime is supposed to give cpu time my program have used. However, something like a platform independent way to know for how long the computer has been turned on would do all I need. Or, maybe, how much has elapsed since the program started. Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Computer time, independent of date
Both wikipedia and hackage rdtsc packages have lot of warnings regarding things I'm not able to control. It seems it doesn't work with many platforms, be it older or multi-core, hibernating computers. yes, i mean this lib but forget its name :) thank you Don't know if it might help but: http://en.wikipedia.org/wiki/RDTSC cabal install rdtsc http://hackage.haskell.org/packages/archive/rdtsc/1.1.1/doc/html/System-CPUTime-Rdtsc.html computer has been turned on would do all I need. Or, maybe, how much has elapsed since the program started. i think you should look into system counters (if you on windows). for example, task managet in vista shows time since reboot, i think that in registry it should be available in previous windowses too. at the cpu level, there is cpu ticks counter, it should be readable via special libraries ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: databases in Haskell type-safety
However options in d) do not offer, afaik, type-safety which is emblem of Haskell language, so I wonder how much this could be the problem for real-world usage? I've been doing a lot of low level sqlite3 lately (it's going to be on a hackage package as soon as I finish my current work). As long as I clearly isolate and test the marshalling of my data to SQL and back, my (personal, probably different from yours) experience using just sqlite3_exec has never got me into trouble. Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Computer time, independent of date
Linux has High-Resolution Timers (HRTs) that may be appropriate. See the manpage for clock_gettime(), which defines these HRTs: [...] CLOCK_MONOTONIC, in particular, looks suitable. Using it could be a matter of just a few quick likes in FFI. I don't know if Windows has similar features. http://msdn.microsoft.com/en-us/library/ms632592(VS.85).aspx and QueryPerformanceCounter, in detail. Going from GetProcessTimes, which I found in ghc code in libraries/base/System/CPUTime.hsc, I was just able to find this in that same site: http://msdn.microsoft.com/en-us/library/ms724408(VS.85).aspx Seems simpler. Since linux (and unix?) have clock_gettime and windows has this GetTickCount, maybe it could be possible to add getSystemCPUTime to System.CPUTime. Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Computer time, independent of date
Hi, I'm writing a program where I need to know elapsed times between some events, but I can't depende on Data.Time since ntpd or user can change that while my program is running. Is there an alternative? Something like how much time has passed since the program has started would be great. Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Computer time, independent of date
Is there an alternative? Something like how much time has passed since the program has started would be great. Have a look at benchpress on hackage. But benchpress uses Data.Time.Clock.getCurrentTime. I understand that is dependent from configuration. It's okay to benchmark a fast application, but mine will be running for days, so it would not be reliable. Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Detecting system endianness
Hi, Is there some way I can check the endianness of the machine my haskell code is running in? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Can my type be allowed as return type in FFI?
This would solve half my problem. Can I always trust that? I've been told before that everytime a C function returns a struct it is actually returning a pointer, but I wasn't able to find that written in stone That's because it isn't true. In fact one of the classical ways for a C function to return a struct is to be *GIVEN* a pointer, e.g., (...) Sure, sorry. I should have said that the C functions fill memory from a given pointer. and obviously a C compiler is entitled to return a small struct in registers if it feels like it. If a compiler is compiling code that calls a library, how is it supposed to know if a return pointer is been passed as a register or by using a pointer? The compiler may not have access to the built library to check that. (Begginer question, I never wrote assembly code.) Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Can my type be allowed as return type in FFI?
Sorry, I'm not talking about how C implements passing structures to functions. The Haskell FFI can only bind functions that pass structures by pointer, not by value. So if you've got a C function that passes them by value then you need to write a wrapper function in C and bind to that. This should definitely be in the documentation somewhere. I delayed some work for a few weeks with that :) Thanks a lot for making this clear. Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Does ghc use Language.Haskell.*?
Why can ghc read the program, but not the standard library parser? Does ghc use something else? Is it possible to use whatever ghc uses to build a prettyprinter? Language.Haskell is known to be incomplete. The haskell-src-exts package on http://hackage.haskell.org will be more useful. Haskell-src-exts understands mode features, but I just tried using it and it seems it's also not Unicode aware. Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Can my type be allowed as return type in FFI?
Hi, When I do: foreign import nameOfFunction nameOfFunction :: IO MyType I can get a function that return MyType only if it's a pointer or some of the C* type family. Is it possible to write a new MyType and make it allowed as a return type from foreign functions? Is changing the compiler the only way to do that? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Can my type be allowed as return type in FFI?
foreign import nameOfFunction nameOfFunction :: IO MyType Is it possible to write a new MyType and make it allowed as a return type from foreign functions? Is changing the compiler the only way to do that? Of course you're not really returning a MyType but a pointer to one. (...) This would solve half my problem. Can I always trust that? I've been told before that everytime a C function returns a struct it is actually returning a pointer, but I wasn't able to find that written in stone so that I can trust it to be valid anywhere Haskell will run and for any return type (like a struct containing just a char, for instance). How does that pointer work? My code didn't provide it to the C function, so, I believe I don't have to deallocate it. Where does the memory it points to live? Did Haskell FFI engine gave that pointer to the C function? How much time is it going to live? Enough so I can 'peek' it? Using raw Ptrs is not very nice, so we would usually either wrap that in a ForeignPtr or use a Storable instance to get a MyType directly. OK. I've instances of Storable for all the appropriate types. If do recommend reading the FFI spec. It's quite readable and explains a lot of the issues. Sure. It helped a lot. Actually, I've been able to do everything I needed so far with just the spec and Foreign.*. I would also add the chapter 17 of Real World Haskell. you can read it here: Nice. It shows unsafePerformIO. Some functions returning structs are side effect free. I'm writing bindings I want to put on hackage, so what do you think would fit better the taste of Haskell programmers: pure functions using unsafePerformIO or IO functions? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Problem with System.Random.randoms
Hi, I have a small problem with System.Random.randoms. I need a rather large number of random numbers but the following program consumes a huge amount of memory. I terminated it when it used up more than 2 Gb: Interesting. Well, if you don't solve this problem, I recently needed random numbers and it was very clean to use State and StateT to get them updated. Depending on your problem, this may be easier than using a list. Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Cabal: defaultMainNoRead and source file location
Hi, I've just seen this from Distribution.ModuleName (ghc 6.10): toFilePath $ ( simple A.B.C ) to which ghci answers: A.B.C. Shouldn't it say A/B/C? The reason why I'm asking is that I've just created a Setup.hs with 'defaultMainNoRead', and 'Setup build' complains it can't find A.B.C. When I copy (move doesn't work) C.hs from src_dir/A/B to src_dir/A.B.C.hs, it doesn't complain, although it fails to generate my library saying: [1 of 1] Compiling A.B.C ( src/A/B/C.hs, dist/build/A/B/C.o) /usr/bin/ar: creating dist/build/libHSabc-0.a /usr/bin/ar: dist/build/A.B.C.o: No such file or directory Thanks for your tips, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Cabal: defaultMainNoRead and source file location
(...) The reason why I'm asking is that I've just created a Setup.hs with 'defaultMainNoRead', and 'Setup build' complains it can't find A.B.C. When I copy (move doesn't work) C.hs from src_dir/A/B to src_dir/A.B.C.hs, it doesn't complain, although it fails to generate my library saying: I'm changing to normal defaultMain, but just in case someone wants to check the problem I'm appending a 'darcs whatsnew' over an empty repo. Is this the right place to report that? Does Distribution.Simple or cabal have a bug tracking of its own? Best, Maurício addfile ./Setup.hs hunk ./Setup.hs 1 +#!/usr/bin/env runhaskell + +module Main (main) where { import Distribution.Simple ; import +Distribution.PackageDescription ; import Distribution.ModuleName +hiding ( main ) ; import Distribution.PackageDescription.Check ; + + main = defaultMainNoRead pkg ; + + pkg :: PackageDescription ; + + oneLineSynopsis = + bla ble bli ; + + longDescription = \ + \blabla bleble blibli\ + \ ; + + modules = map simple [ A.B.C ] ; + + pkg = emptyPackageDescription { + package = PackageIdentifier { + pkgName = PackageName abc , + pkgVersion = Version { +versionBranch = [0] , +versionTags = [ ] + } + } , + license = PublicDomain , + maintainer = Me , + author = Me , + synopsis = oneLineSynopsis , + description = longDescription , + category = any , + buildDepends = [ Dependency ( PackageName base ) AnyVersion ] , + descCabalVersion = orLaterVersion $ Version { +versionBranch = [ 1 , 2 ] , +versionTags = [ ] + } , + buildType = Just Custom , + library = Just ( Library { + exposedModules = modules , + libExposed = True , + libBuildInfo = emptyBuildInfo { +hsSourceDirs = [ ./src ] , +extensions = [ ] + } + } ) + } + +} adddir ./src adddir ./src/A addfile ./src/A.B.C.hs hunk ./src/A.B.C.hs 1 +module A.B.C where { + + a = asdf ; + + b = qwer ; + + c = zxcv + +} adddir ./src/A/B addfile ./src/A/B/C.hs hunk ./src/A/B/C.hs 1 +module A.B.C where { + + a = asdf ; + + b = qwer ; + + c = zxcv + +} ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Sugestion for a basic Utf8 type.
Hi, I would like to sugest a new basic type in Haskell. What if we had something like this (with any other quoting character): «Je ne parle pas français. Meu nome é Maurício. ¿Hablas español?» This would be of type Utf8. I think now it is not a bad idea, since Haskell source code is supposed to be utf-8. The internal representation of this datatype would be a null terminated utf-8 byte vector. No standard operations would be defined on that type, i.e., it would be a “communication standard” between everybody, but module writers could develop different basic usage based on operations on them using Foreign. (I think it would be dificult to set default operations, since there are so many things you can do with utf-8.) Pros: * There would be no doubt you can use utf-8 when using this, since there's no conversion involved. * Cleaner code on utf8 operations, maybe. There are many utf8 modules today with different goals in mind, I thing it would be nice if they could share this common basic type and a common underline implementation. Cons: * Probably, many. I have no deep understanding of Haskell. Thanks for your attention, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Sugestion for a basic Utf8 type.
I would like to sugest a new basic type in Haskell. What if we had something like this (with any other quoting character): «Je ne parle pas français. (...) ¿Hablas español?» This would be of type Utf8. I think now it is not a bad idea, since Haskell source code is supposed to be utf-8. The internal representation of this datatype would be a null terminated utf-8 byte vector. ... Stream fusion on Haskell Unicode strings - Tom Harper http://www.wellquite.org/non-blog/AngloHaskell2008/tom%20harper.pdf (...) Actually, what I suggest is quite different, in points I see as worthwhile: * His focus is on speed and memory, my goal is more elegant and safe code. * His approach consolidates Prelude. My approach allows complete elimination of Prelude. If we had a Utf8 basic type, we could have modules with many different basic types, and many different ideas on how to 'read «something» :: sometype'. In the future, we could write a module to implement some sort of not yet invented numeral type, which other module would allow to be readed from Chinese kanji. * He wants to preserve many properties of [Char]. I think Utf8 type should have no standard properties at all. See next argument on why this would avoid some unsafe code. * He insists on the idea of text as something over char. Well, I'm probably alone there, but I think this was nice, but today we could have better approachs. Except for source code, text is a block of information, not a sequence of anything. I explicitly would like a type we could not map over, because we can't do that — text is built from so many things, there's no basic unit we can apply functions to. Even something like printing of a table of all characters and their unicode numbers is impossible, since a lot of unicode is not printable. Are these blocks of text equal? also do not work like that, since different sets of bytes can have the same meaning. If you want some piece of text to obey specific properties, you should have to extract it to a proper type. Sorry if this is insane for some reason. Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Sugestion for a basic Utf8 type.
So this proposal is more than a UTF8 type, since it encompasses a move away from text as lists. What interfaces would we have to text in this proposal? Normal users would import modules with specific interfaces, like functions or instances. One possible such module would be Streams like those sugested in the previous article. Others could offer functionality I don't know of -- maybe there's some usefull interface for japanese or greek users we (non japanese or greek) don't imagine. My first attempt would be PortugueseText, with a type that could only be built after Portuguese primitives or read from Utf8 with possible errors, and convert to Utf8 of course. That type would always convert to Utf8 with correct diacriticals, and sort with the latest Portuguese agreements. Mapping over syllables could be allowed, that makes sense in syllabic languages. Quotes, questions, parenthesis etc. could be done with functions like 'quote «Ser ou não ser»'. Other could be SimpleEnglishTextAsList, that could offer something close to what we have today, with functions for uppercasing, lowercasing and well behaved (non ambiguous) sorting. Writers of very basic modules would have to touch Utf8 using Foreign. So, maybe the only standard interface would be a (ForeignPtr?) pointer to a null terminated block of memory. This would make Foreign a new Prelude, maybe. In the end, this is just a basic block of memory that we can fill with utf-8 text, and that serves as a common denominador. Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Question about fastcgi
Hi, I'm learnng to use fastcgi and, reading the examples, I see the main loop is like this: main = runFastCGI my_work However, isn't a fastcgi program supposed to choose a port where to listen to calls? For instance, in this C example: xzdev.com/nginx_fastcgi.html doesn't the line listen_socket = FCGX_OpenSocket(:8002, 2000); says it's listening to port 8002? I read the code for fastcgi, from hackage, and I can't find anything related to ports like, for instance, a default port. Am I understanding something the wrong way? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Question about fastcgi
I was able to get this working with lighttpd, and I did had to choose a port, but only at lighttpd configuration, not at the Haskell source. Thanks, Maurício ChrisK a écrit : I have only used this, all of these are from Haskell: pamac-cek10:~ chrisk$ cat /etc/apache2/other/httpd-fastcgi.conf IfModule mod_fastcgi.c Alias /fcgi-bin/ /Library/WebServer/FastCGI-Executables/ Directory /Library/WebServer/FastCGI-Executables/ AllowOverride None Options None Order allow,deny Allow from all SetHandler fastcgi-script Options +ExecCGI /Directory FastCgiIpcDir /tmp/fastcgi FastCgiServer /Library/WebServer/FastCGI-Executables/hw.fastcgi -pass-header Cookie FastCgiServer /Library/WebServer/FastCGI-Executables/test.fastcgi -pass-header Cookie FastCgiServer /Library/WebServer/FastCGI-Executables/xwords.fastcgi -pass-header Cookie /IfModule The above is included from the main httpd.conf which has: pamac-cek10:~ chrisk$ grep -i fast /etc/apache2/httpd.conf LoadModule fastcgi_module libexec/apache2/mod_fastcgi.so ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Begginer question about alignment in Storable
Thanks! This is actually a really nice tutorial! Do you mind if I try to find a place for it in the wiki? Go right ahead (...) For reference: http://haskell.org/haskellwiki/FFI_cook_book Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Begginer question about alignment in Storable
(...) But the major advantage of hsc2hs is that if your C struct changes or you use a different C compiler, the allignment and size as well as the offsets used in peek and poke will still be correct since the compiler will calculate it for you. (...) And you wanted to write a storable instance. With hsc2hs you would write it like this: (...) Thanks! This is actually a really nice tutorial! Do you mind if I try to find a place for it in the wiki? Regarding cabal setup, that is only really needed if you are intending to build a package to distribute to other people. (...) I didn't know about hsc2hs, but I'm a big fan of cabal. I would use it even in Hello Word. (...) (I don't have a good link for learning cabal; you'll have to google around (e.g. haskell cabal) for info.) Compreensive as a reference, easy to follow as a tutorial: http://www.haskell.org/ghc/docs/latest/html/Cabal Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Begginer question about alignment in Storable
If you are using hsc2hs (if you are using Cabal this is easy; just rename the file to *.hsc and Cabal will take care of the rest), then there is a macro for making this easier and so you don't have to think about it. (...) Well, after reading FFI addendum, I'm using my loyal text editor. Am I supposed to use something else? Is there something a tool like hsc2hs or cabal setup can do that is more portable than what I could write myself? Where should I learn about that? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: What *not* to use Haskell for
I think Haskell is not nice to write general purpouse libraries that could be easily and completly wrapped by other languages. You can wrap gtk, sqlite3, gsl, opengl etc., but you can't write python bindings for Data.Graph. But, then, if you claim there's nothing else Haskell can't do, what do you need those bindings for ? :) Best, Maurício Hi everyone So I should clarify I'm not a troll and do see the Haskell light. But one thing I can never answer when preaching to others is what does Haskell not do well? Usually I'll avoid then question and explain that it is a 'complete' language and we do have more than enough libraries to make it useful and productive. But I'd be keen to know if people have any anecdotes, ideally ones which can subsequently be twisted into an argument for Haskell ;) Cheers, Dave ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: FFI documentation?
Where do I find the documentation for the FFI for GHC? I've read the FFI report, the GHC user guide and scoured haskell.org but they all gloss over what commands you actually need to give GHC and how to give them. foreign import blah blah just gives me undefined references. One well documented and compiler independent way to do that is to use Cabal packages: http://www.haskell.org/ghc/docs/latest/html/Cabal/authors.html as used on Hackage: http://hackage.haskell.org If you have never done that, you will take some time to understand the role of the setup file (which in your case will problably be something like: import Distribution.Simple; main=defaultMain) and the details of .cabal files. (The problem you are concerned with is detailed in 3.1.4: Build Information. You'll see you can also list C files to be compiled with your code, and if you are using some library that implements the pkg-config standard then everything is really, really easy. I advise you to also understand well how 'build-depends' works and how to list language features out of Haskell 98 — in your situation, at least 'extensions: ForeignFunctionInterface'.) Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Monad.Reader with updates
Hi Mauricio. What you want actually already exists in QuickCheck as the Gen monad. newtype Gen a = Gen (Int - StdGen - a) instance Monad Gen where return a= Gen (\n r - a) Gen m = k = Gen (\n r0 - let (r1,r2) = split r0 Gen m' = k (m n r1) in m' n r2) (...) Nice. I think that's exactly what I was trying to do. You could also implement this as a variation on the State monad if you wanted to avoid using split: (...) Yes. After Brent's explanation I finally realized State was the perfect option. Maybe it should also be better for QuickCheck. I just didn't know it… There are many things in the standard library that do nice things, but I don't understand them until I write a few hundred lines trying to do what they do :) Thanks for your support and patience, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Monad.Reader with updates
Hi, Is there some abstraction in current ghc library that implements something like Reader, but where the value of the environment is updated at every step? I imagine something that instead of running like this: runReader ( do ... ) environment I would run like: runReader ( do ... ) environment update_function So, when I write a monad like: do a - asks f b - asks f2 c - asks f3 f, f2 and f3 would be called with parameters environment, (update_function environment), (update_function . updatefunction $ environment) etc. Does that make sense? Is it easy to adapt something already existing to do that? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Monad.Reader with updates
Is there some abstraction in current ghc library that implements something like Reader, but where the value of the environment is updated at every step? do-it-yourself? you can start from reader definition and add what you need. you just need to make initial state consisting from state itself and update function so `run` will have just one initialization argument Sure. I've done a few versions, trying to change the way (=) is defined, and learned a lot with that. But I wanted to know if there's already the right way to do it instead of my newbie way to do it :) Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] http://www.haskell.org/ghc/docs/latest/html/libraries/Cabal/Distribution-Simple.html
Hi, According to this page: http://www.haskell.org/ghc/docs/latest/html/libraries/Cabal/Distribution-Simple.html there's an available toplevel declaration named: autoconfUserHooks in Distribution.Simple. However: ghci --version The Glorious Glasgow Haskell Compilation System, version 6.8.2 ghci Prelude :m +Distribution.Simple Prelude Distribution.Simple :t autoconfUserHooks interactive:1:0: Not in scope: `autoconfUserHooks' What would the experienced Haskell programmer do in such situation? Is there some way to ask ghci (or ghc) to list all available declarations, in a way that I could '| grep' it or save it to a file? Can I ask ghci to look for a declaration inside all available modules in all available packages? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Monad.Reader with updates
Is there some abstraction in current ghc library that implements something like Reader, but where the value of the environment is updated at every step? It doesn't quite make sense, because one step isn't well defined. How many steps is return (f x) ? how about return x = \y - return (f y) ? (...) I understand. But do you think something like the (obviously not working) code below could respect monad laws, if I could consider (environment-a) a monad over a? update = snd . next ; -- this updates a random number generator instance RandomGen environment = Monad ( environment - a ) where { -- below, f :: g1 - ( environment - g2 ) p = f = p2 where { p2 e = ( f . p $ e ) . update } ; return = const ; } Then I would do something like: getStdGen = ( return . do { a = b = c } ) So I think you'd have to make the steps explicit. (...) advance :: m () -- your primitive which changes the environment a * b = a advance b a *= f = do { r - a; advance; f r } The problem is that I need 'a' or 'b' above to sometimes also change the environment. I think with this method I could not get that. Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Making 'community' server our social network
Hello Maurício, Monday, November 3, 2008, 4:43:26 AM, you wrote: darcs add .emacs darcs get http://code.haskell.org/MauricioAntunes thank, it's a great ideas! and don't forget that you can use code.haskell.org as online backup of history of your config files Nice. Just did that, according to Duncan instructions. I can't share with those who don't know darcs, though, since hidden files (like .emacs or .xmonad directory) do not show up in the web page (code/~mauricio). So my next sugestion is that listing of files starting with dots be allowed, if that doesn't cause problems elsewhere. Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Newbie on instance of Monad
Hi, After a lot of thinking, I can't get what I am doing wrong in this code: (...) data ( RandomGen g ) = RandomMonad g a = RandomMonad (g - a) RandomGen g is considered the constraint for the application of RandomMonad constructor, but GHC does not conclude that every value of (RandomMonad g a) fulfills this constraint. Actually, 'undefined' is available for any 'g'. you need to make (RandomGen g) a constraint of the instance: instance RandomGen g = Monad (RandomMonad g) where Nice. I wasn't so wrong as I though :) I didn't understand why can't the compiler deduce that g is always going to be of type RandomGen. Even if I use 'undefined', it has to be a RandomGen undefined. Btw. RandomMonad looks like Control.Monad.Reader. You are right, I'll try that instead so I learn a little bit more. But I can't understand this syntax: class (Monad m) = MonadReader r m | m - r where What is the '|' doing there? I'll post that in a new thread since it's a different question. Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Syntax question: class (Monad m) = MonadReader r m | m - r where
Hi, I've reading Control.Monad.Reader source code and arrived here: class (Monad m) = MonadReader r m | m - r where I can't understand that syntax. Since this is not a 'data' line, what is the '|' supposed mean? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Syntax question: class (Monad m) = MonadReader r m | m - r where
Hi, I've reading Control.Monad.Reader source code and arrived here: class (Monad m) = MonadReader r m | m - r where I can't understand that syntax. Since this is not a 'data' line, what is the '|' supposed mean? It's called a functional dependency. This is not part of the Haskell-98 language standard; check the GHC manual. The documentation says There should be more documentation, but there isn't (yet). Yell if you need it. :) But I think I was able to understand everything from the examples. Thanks. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Syntax question: class (Monad m) = MonadReader r m | m - r where
It's called a functional dependency. This is not part of the Haskell-98 language standard; check the GHC manual. The documentation says There should be more documentation, but there isn't (yet). Yell if you need it. :) you probably don't found it. since 6.6 (or 6.8?) ghc includes great tutorial on fundeps derived from hugs docs It's here, on 'latest' directory: http://www.haskell.org/ghc/docs/latest/html/users_guide/type-class-extensions.html#functional-dependencies But yes, you're right, there's a lot of good examples and explanations. But that comment is still there, just in the end of the first paragraph. Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Newbie on instance of Monad
Hi, After a lot of thinking, I can't get what I am doing wrong in this code: -- data ( RandomGen g ) = RandomMonad g a = RandomMonad (g - a) instance Monad (RandomMonad g) where return = RandomMonad . const RandomMonad f1 = f2 = RandomMonad f3 where f3 a = f2f1 a (next a) RandomMonad f2f1 = f2 . f1 -- I get this error message: Could not deduce (RandomGen g) from the context (Monad (RandomMonad g)) arising from a use of `RandomMonad' at src/encherDB.hs:10:11-21 Possible fix: add (RandomGen g) to the context of the type signature for `return' In the first argument of `(.)', namely `RandomMonad' In the expression: RandomMonad . const In the definition of `return': return = RandomMonad . const but I'm not smart enough to understand what it means. Thanks a lot, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Build without install, using cabal
I would like to include a few source files as 'executable' sections in a .cabal package description. However, although I do want to use main=mainDefault features, I do not want those packages to be installed when I run 'Setup.hs install'. Yes, just use this in the executable section: buildable: False But I do want it to be built (so Setup will check dependencies, allow me to './Setup clean' etc.). However, I would like './Setup install' to install just the main library. Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: A heretic question
At first, make sure you have Bjarne Stroustrup book (very important: last edition). If there's anything good in C++, it's there. Look also at his homepage: http://www.research.att.com/~bs/homepage.html I got the third edition and read it a couple of times... It's not that I'm lacking knowledge of the language, but routine and a deeper grokking of it's essence like I have with C, Scheme, Java and I guess also Haskell. Well, one thing I miss from C++ is the idea of acquiring resources in constructors and releasing them in destructors, as explained here: http://www.research.att.com/~bs/bs_faq2.html#finally (Haskell uses that in 'with...' functions, like 'withFile', but the syntax in C++ seems cleaner to me.) So, I can sugest you to try something where dealing with external (out of your control) resources is important, and where you need graceful handling of exceptions. Also, it's very easy to write your own memory allocator and use it to manage memory under pressure, and so you can go far beyond where 'Foreign.Marshal.Pool' Haskell module can go. Here is my sugestion: write something to interface with hardware. I tried to find something more specific but failed in available time, so I sugest you to take a look at many stuff you can find in thinkgeek. Then you can try unusual uses for it. For instance, they have a USB microscope. I don't know if you can move the microscope from the computer, but if you do, you could write something to automatically find evidences of failure in some kind of material or traces of chemical dust in surfaces. Or maybe you can get some security toys and try to identify people using their faces, or allow them to type text using just the movements of their heads. All of that involves heavy processing and at the same time interaction with equipment that can behave badly (like faces that can just go away from the computer). The nice thing about this is that in the end you can write a C wrapper over the main code and we can use it from Haskell :) Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Build without install, using cabal
(...) But I do want it to be built (so Setup will check dependencies, allow me to './Setup clean' etc.). However, I would like './Setup install' to install just the main library. Just in case my response to you (in a previous thread that you started) wasn't clear, EMGM also provides an example of this feature. See the Cabal configuration file. (...) Sure, I read that. But my idea was to get something with build-time flags, not configure-time flags. But I think that was a begginer mistake. Your way seems to be the standard way of doing that. That's what I'm going to do. Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: A heretic question
What kind of things do you prefer? Databases, science, math, web? At first, make sure you have Bjarne Stroustrup book (very important: last edition). If there's anything good in C++, it's there. Look also at his homepage: http://www.research.att.com/~bs/homepage.html Bjarne is the guy who first started C++, and in a certain way still leads its development. What kind of things, barring coding on Haskell-less platforms and library interfaces would you choose to do in C++? I'm asking 'cos I'm learning C++ and can't get the proper motivation to do any program I can think of in it: If I need abstraction, I'm thinking Haskell or Scheme, and if I'm thinking performance, C itself more than suffices. Plus template programming makes me shudder because of its atrocities against clear and straightforward FP, but that's a different matter. Coming to think of it, a compiler from a clean syntax to C++ templates sounds like a fun project... which I'd do in Haskell. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Cabal package with library and tests
I'm writing a Cabal package, using main=defaultMain in Setup.hs. It has a library, and I want to also build a few executables so I can test the library. How am I supposed to do that? (...) You might consider looking at the EMGM cabal file in the source. https://svn.cs.uu.nl:12443/viewvc/dgp-haskell/EMGM/ (...) From the site: Échec de la connexion sécurisée svn.cs.uu.nl:12443 utilise un certificat de sécurité invalide. Le certificat n'est pas sûr car l'autorité délivrant le certificat est inconnue. (Code d'erreur : sec_error_unknown_issuer) The test argument to Setup seems nice. Is there some already defined on the hook for tests? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] FFI Newbie: c functions that want pointers to objects
Hi, Some functions in C changes data using pointers, like this example: void change_int (int *n) { *n ++; } What is the proper way to handle that? I guess I should wrap it like this: foreign ccall change_int change_int :: Ptr CInt - IO () Can I use that on a CInt in Haskell code? Like this obviously wrong code, but that probably shows what I want: do let myN = 5 change_int myN Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Cabal package with library and tests
You might consider looking at the EMGM cabal file in the source. https://svn.cs.uu.nl:12443/viewvc/dgp-haskell/EMGM/ (...) From the site: Échec de la connexion sécurisée svn.cs.uu.nl:12443 http://svn.cs.uu.nl:12443 utilise un certificat de sécurité invalide. Le certificat n'est pas sûr car l'autorité délivrant le certificat est inconnue. (Code d'erreur : sec_error_unknown_issuer) That looks like what I see in Firefox when I go to a site that's using a non-verified SSL certificate. (...) Right. I didn't know I could just accept that and go further... Yours is actually a very good example on how to build a customized cabal package :) Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Type safety in foreign pointer
Hi, I'm wrapping a library where functions take as parameters pointers to a few standard structs (as, well, all C libraries). I would like to ensure that only pointers of correct structs are passed to those functions. What is the Haskell way to do that? My idea is to do something like this: newtype SomeStruct = SomeStruct () and then foreign import ccall my_function myfunction :: Ptr SomeStruct - IO int Is that the proper way to do that? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Cabal package with library and tests
Hi, I'm writing a Cabal package, using main=defaultMain in Setup.hs. It has a library, and I want to also build a few executables so I can test the library. How am I supposed to do that? My attempt was to create 'executable' sections for those tests. However, I don't know how to include the main library in the modules used by those tests. I tried to insert my own package in a 'build-depends' line, but that didn't work. Thanks for your tips, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Linking and unsafePerformIO
Hi, If I have a Haskell wrapper (with unsafe...) over a function that's never going to return different values and is always side-effect free, but can change depending on compile time options of its library; my program is running, and then the version of my library is updated by my distribution smart instalation system, which does update versions of libraries in use; is it possible that I get a wrong behavior of my program? I do not understand enough about package management to understand how running programs or libraries are updated, and less about how linking works between Haskelll and libraries on other languages, so I don't know if my program is guaranteed to stay with a single version of a library for each run. (Sure this is a weird situation, but I do like to think about worst cases.) Thanks, Mauríco ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Linking and unsafePerformIO
Hi, If I have a Haskell wrapper (with unsafe...) over a function that's never going to return different values and is always side-effect free, but can change depending on compile time options of its library; my program is running, and then the version of my library is updated by my distribution smart instalation system, which does update versions of libraries in use; is it possible that I get a wrong behavior of my program? I do not understand enough about package management to understand how running programs or libraries are updated, and less about how linking works between Haskelll and libraries on other languages, so I don't know if my program is guaranteed to stay with a single version of a library for each run. (Sure this is a weird situation, but I do like to think about worst cases.) In practice that is fine, with current RTSes and so on. In principle it's not fine. A 'constant' should be constant over all time, not just constant over a particular library version or sub-version or a particular program invocation or OS or Who knows, maybe some future haskell runtime will be able to perform the trickery you describe and will cause this to break ;) What I actually want to use that way are build time configs. For instance, 'isThisLibraryThreadSafe' or 'maximumNumberOfBigObjects'. Actually, I don't know why people allow build time options at all. We always use the best set of options, and the alternatives are there just to compel us to check for them :) Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Foreign.Marshal.Error.void
Hi, Wouldn't it be nice if we had something like 'void' in Foreign.Marshal.Error in standard monad functions, so that we could use it instead of, for instance, mapM_ or sequence_? Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Interesting new user perspective
_Some_ newcommers flounder because they expect Haskell to be just another VB / C++ / Java / whatever. (Do we really want to encourage these people to be learning Haskell in the first place?) (...) I hope so. One of my most important motivations to try Haskell was that I thought it was radically drived by some ideas that were only beggining to show up in C++, and I'm happy to know I was right :) (And, really, I was scared by how much time is lost with misinformed critics about other languages.) My begginer problem: syntax was a *major* issue, and I only could overcome it with a lot of love for this language. The best reference I was able to find is this: http://www.hck.sk/users/peter/HaskellEx.htm and it's not exactly for begginers. Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Multi-line string literals are both easy /and/ elegant in Haskell
The new QuasiQuotes extension arriving with ghc 6.10 is very exciting, and handling multi-line string literals is like stealing candy from a baby. ;) (...) Cool!!! How exactly QuasiQuote behave, and what is available to handle them? (Or: can I find information already on the web?) Sugestion: what about tex like syntax, i.e., change of line is a space, blank line is a newline (so that we could reformat the string without changing content)? Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: [] vs [()]
What is the difference between empty list [] and list with one unit element [()]? Or, yet: ():[()] --is legal 10:[()] --is not One list can contain elements of a single type. Since the type of () is () (element constructors and types are allowed to have the same name), a list of type [()] can only contain elements of type (), i.e., ()s. Try this is ghci: :t [()] :t [(),(),(),()] Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Libraries in home dir
Hi, I want to use a few libraries from hackage and have already download and built them. Can I install those libraries somewhere in my home dir (I want to avoid installing as root) so that ghc can find them? If so, which options should I give to Setup.hs (with main=defaultMain) so that the libraries are going to be copy to that dir? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Libraries in home dir
Hi, I want to use a few libraries from hackage and have already download and built them. Can I install those libraries somewhere in my home dir (...) $ cabal instsll xmonad Does exactly that by default. No other flags are required. (...) Nice. Thanks for all tips. Reading them I understood defaultMain works like usual 'configure' scripts, and tried Setup.hs --help, and found the full documentation I needed. About cabal: the fact that the last versions of packages are not available in the pointed place mean I should not use cabal? For instance, utf8-string is using github.com instead of the darcs page pointed in its hackage page. Does that mean the package available in hackage is not the one I should use? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: I'll do USB in Haskell - tips?
Looking for Posix Linux API, I found www.linux-usb.org. It has a lot (I think all I need) to start in Linux. Does anyone knows where can I find related information for Windows, so I can start without writing something that would be difficult to support there? Best, Maurício Hello, I am also interested in SCSI, PCI, etc. (...) Maybe Marco should talk to the people doing the Linux implementation for the Posix API and see how viable that API is before spending a year for nothing. Or Marco maybe you can be a trailblazer and come up with a better Posix/Win32 USB APIquo t; and implement in Haskell? ;^) Very kind regards, Vasili ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] I'll do USB in Haskell - tips?
Hi, I'll need to use a lot of USB at work and, after looking around, it seems there's no general USB code done. 'libusb' and 'openusb' do not seem ready enough so that wrapping them would be easier than writing from scratch. (If you think I am wrong until here and have time to write me your opinion, I'll value it a lot.) So: I would like to (try to) write a good implementation of USB access in Haskell. I would like it to be really general, so that we could use all of USB without need to resort to something else; available to all possible environments and operating systems; allow easy testing of USB clients, maybe using fake USB devices that could simulate problems; do that using Haskell code to directly access operating system API. I've read the appropriate chapters of USB 2.0 standard reference. I'll greatly appreciate any information you can give me: sugestions on what would be the Haskell way of doing USB; good technical information on how USB is implemented in different OSes; warnings on problems I may have; wishes of good luck :) I hope in one year I'll be able to post a message here saying Haskell is the greatest language to interface with USB devices. Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Float instance of 'read'
Agree about the answer, not about the question. The correct one would be is it possible to change haskell syntax to support the international notation (...) For some sense of possible, the answer is clearly yes. However, it is perhaps misleading to call commas THE international notation. (...) You might as well ask is it possible to change Haskell syntax to support only the *real* Arabic digits ... for ... numbers. (... + evindences that there isn't one single standard) Well, utf-8 strings seemed to me a good way to initialize variables, and we could, for instance use something like [1,2,3,4] to initialize other kinds of lists besides the standard one. One example I got from gtk2hs are marked-up text on labels. So, I actually thought we could add support for arabic and japanese digits, and any other ways we get without ambiguities (continued fractions, I would like, and I also liked the idea of the raised dot). Well, after all the comments, I'm convinced changing the Show and Read classes are not the way to go. But I'll think of something like a InitializableByUFT8String class, and I'll advertize it here if I ever get something usable and interesting. Thanks for your comments, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Float instance of 'read'
No, it is not. Strings created by show are always supposed to be readable by read, no matter which system used 'show' and which system is using 'read'. Maurício Rafael C. de Almeida a écrit : Mauricio wrote: Hi, A small annoyance some users outside english speaking countries usually experiment when learning programming languages is that real numbers use a '.' instead of ','. Of course, that is not such a problem except for the inconsistence between computer and free hand notation. Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention (ie., read 1,5 would also work besides read 1.5)? I'm happy to finaly use a language where I can use words of my language to name variables, so I wonder if we could also make that step. Isn't it locale dependent? If it isn't, it should be. Try setting your locale right and see if things work. At least awk work fine that way. Although I don't like too much that kinda stuff, I usually set the locale to C so I keep all my programs behaving consistently. I have problems with that stuff before (a file generated by an awk script had , instead of . and that would confuse other computers with a different locale). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Float instance of 'read'
Maybe. Doubles 'show' function always print something after the decimal separator, so 'show [doubles]' is easy to parse but difficult for human reading. It would be nice to have a space between elements of a shown list, though. It's an annoyance, but internationalization is really great, I think it deserves the effort. Best, Maurício Tilo Wiklund a écrit : Wouldn't that make it hard to parse lists of floats? On Tue, 2008-09-16 at 09:29 -0300, Mauricio wrote: Hi, A small annoyance some users outside english speaking countries usually experiment when learning programming languages is that real numbers use a '.' instead of ','. Of course, that is not such a problem except for the inconsistence between computer and free hand notation. Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention (ie., read 1,5 would also work besides read 1.5)? I'm happy to finaly use a language where I can use words of my language to name variables, so I wonder if we could also make that step. Thanks, Maurício ___ 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] Re: Float instance of 'read'
I'm happy to finaly use a language where I can use words of my language to name variables, so I wonder if we could also make that step. Really? There is a bunch of languages (like Glagol) that use words of Russian language as keywords; AFAIK there aren't any Russian programmer who uses them. I've always felt sorry for English-speaking programmers: they HAVE to use the same words as keywords and as usual talking words at the same time. Here I totally aggree with you. It's great that I can use words in my language for variables, but the same would be really annoying if the same was true for keywords. Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Float instance of 'read'
Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention (ie., read 1,5 would also work besides read 1.5)? I'm happy to finaly use a language where I can use words of my language to name variables, so I wonder if we could also make that step. That would be quite problematic in combination with lists, is read [1,2,3,4] == [1,2,3,4] or read [1,2,3,4] == [1.2, 3.4] Or something else? As of today, at least in ghc, show ([1,2,3]::[Double]) will always produce [1.0,2.0,3.0]. Since the requirement for read is to read what is produced by show, that would not be a problem. Localized reading should be somewhere else, perhaps related to Locales. No! If we had that, string from a program would not be readable by some program running in other machine, or other locale. As, actually, you describe below. Show and Read are for programs reading, not for user reading. That's a work for Pango :) As an aside, this is one of the (many) places where Haskell has made the right choice. In other languages such as Java input functions suddenly break when the user has a different locale setting. While for user input this might be desired, in my experience much of the i/o a program does is with well defined file formats where changing '.' to ',' just shouldn't happen. Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Float instance of 'read'
As of today, show ((1,2)::(Float,Float)) would not produce that kind of output. Dan Piponi a écrit : Mauricio asked: Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention (ie., read 1,5 would also work besides read 1.5)? What would you hope the value of read (1,2,3)::(Float,Float) would be? -- Dan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Float instance of 'read'
Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention (ie., read 1,5 would also work besides read 1.5)? I'm happy to finaly use a language where I can use words of my language to name variables, so I wonder if we could also make that step. The purpose of 'read' is to read haskell notation, not to read locally-sensitive notation. So the right question to ask is should we change haskell's lexical syntax to support locally-sensitive number notation. IMO, the answer is no. (...) Agree about the answer, not about the question. The correct one would be is it possible to change haskell syntax to support the international notation (not any locally sensitive one) for decimal real numbers? Would a change in 'read' be a good first step? I know this looks difficult, but I'm sure it deserves at least some thinking. We have previous examples for less important issues: ghc does accept Windows end of line conventions, the minus and sign needs special syntax, and '.' can be used as decimal separator even if it's use as function notation. Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Float instance of 'read'
Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention (ie., read 1,5 would also work besides read 1.5)? No, as read is really intended to be a language-level tool, not something that you should expose to end users. For locale-aware number input and formatting, you'd want to do something else. Sure. What I think would be great if possible would be a language-level tool. The same way '.' can be used as decimal separator even if it's the function composition operator. If it's not possible to change the syntax, changing 'read' could be a good step (since, sometimes, 'read' is a good way to inialize some variables if proper care is taken. I know this sound weird, but it is an issue, for instance, when teaching programming. Students who face programming classes usually start writing numbers the wrong way, and sometimes this leads to confusion. A similar problem we had in the days when zeros were cut so they would be different of O, and now we have a lot of grown up people still writing 0 as if it were a greek phi. (As my father used to complain, when his students had to write something like phi=0.) Read and Show are, IMHO, a great way to initialize variables. a = read 123 is an alternative to a = 123, and maybe even a replacement. If, for instance, both show and read used some kind of delimiter, it would be easy to use reasonable ways to write constants of any kind. A big effort, but not less than is needed for unicode support in strings, and almost as usefull. Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: How to check if two Haskell files are the same?
I would like to write a Haskell pretty-printer, using standard libraries for that. How can I check if the original and the pretty-printed versions are the same? For instance, is there a file generated by GHC at the compilation pipe that is always guaranteed to have the same MD5 hash when it comes from equivalent source? Compare .hi files? That was my first thought, but can I be sure .hi files are going to be exactly the same, i.e., isn't there some kind of information (timestamps?) that can change without changes in the code? Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Float instance of 'read'
Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention (ie., read 1,5 would also work besides read 1.5)? (...) IMAO, it's bloody well stupid to use commas for either the decimal separator or the thousands separator, as it has a well established role in separating the items in a list that conflicts with this. (...) After 10 years of professional experience, I'm getting used to the fact that almost every time someone says my idea is stupid I'm going in the right direction. Linux, firefox… And know everybody in the office uses nothing else. It's stupid to use anything but Java, that's what the whole world is using, and here I am writing software in Haskell. Really, no troll intended. This is an open source world, I'll try my own Read and Show classes. If others like it, great, if not, I was wrong in the first place :) Best! Thanks for your attention, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: How to check if two Haskell files are the same?
Chaddaï Fouché a écrit : 2008/9/16 Mauricio [EMAIL PROTECTED]: Hi, I would like to write a Haskell pretty-printer, using standard libraries for that. How can I check if the original and the pretty-printed versions are the same? For instance, is there a file generated by GHC at the compilation pipe that is always guaranteed to have the same MD5 hash when it comes from equivalent source? There is not, though I have a suggestion : Am I correct in assuming that you mean equivalent source in the sense that only the formatting (and eventually {;} as a layout format consequence) differs ? Exactly! And with comments removed, since the last time I checked Language.Haskell.* used not to preserve that. Then the sequence of tokens from the source ought to do the trick as long as you delete location information (map unLoc) and transform ITvocurly (virtual braces for layout induced blocks) into ITocurly (real braces for no-layout blocks) (and same for ITvccurly) (it's just another map). If only the formatting differs, those two should be identical. Good idea. I think that's all that I need. I can write a hash function that filters and transforms like that. Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Float instance of 'read'
Hi, A small annoyance some users outside english speaking countries usually experiment when learning programming languages is that real numbers use a '.' instead of ','. Of course, that is not such a problem except for the inconsistence between computer and free hand notation. Do you think 'read' (actually, 'readsPrec'?) could be made to also read the international convention (ie., read 1,5 would also work besides read 1.5)? I'm happy to finaly use a language where I can use words of my language to name variables, so I wonder if we could also make that step. Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] How to check if two Haskell files are the same?
Hi, I would like to write a Haskell pretty-printer, using standard libraries for that. How can I check if the original and the pretty-printed versions are the same? For instance, is there a file generated by GHC at the compilation pipe that is always guaranteed to have the same MD5 hash when it comes from equivalent source? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Import qualified, inverse of hiding
Exactly! Thanks. Maurício Paulo Tanimoto a écrit : You mean like this? import Data.List (foldl', nub) Or am I misunderstanding your question? Paulo On Mon, Sep 15, 2008 at 2:26 PM, Mauricio [EMAIL PROTECTED] wrote: Hi, 'import' allows one to say 'hiding' to a list of names. Is it possible to do the opposite, i.e., list the names I want to import? Something like import Module showing x? Thanks, Maurício ___ 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] Import qualified, inverse of hiding
Hi, 'import' allows one to say 'hiding' to a list of names. Is it possible to do the opposite, i.e., list the names I want to import? Something like import Module showing x? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Should `(flip (^^))` work?
Hi, I tested the expression below and it doesn't work. Is there some way to achieve that (i.e., turning an expression inside parenthesis into an operator)? 2 `(flip (^^))` (3%4) Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Should `(flip (^^))` work?
Rafael C. de Almeida a écrit : Derek Elkins wrote: On Mon, 2008-09-15 at 18:42 -0300, Mauricio wrote: Hi, I tested the expression below and it doesn't work. Is there some way to achieve that (i.e., turning an expression inside parenthesis into an operator)? 2 `(flip (^^))` (3%4) No it shouldn't work. The fact that the opening and closing marks are the same suggests that it shouldn't. You can fake it though. x -| f = f x f |- x = f x 2 -| flip (^^) |- (3%4) Isn't naming the expression 'flip (^^)' much clearer? I think that is an interesting question about programming style. In practical code I think we should have a balance between the complexity of big expressions and the complexity of too many names. Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Haskell and Java
Sorry about this. I hit a critical mass of darcs conflicts (I look forward to giving git a try) around the same time I got really busy at work. I've been meaning to get back into it (and update it to GHC HEAD) but I haven't received sufficient nagging yet. Please yell if you're interested in LambdaVM. At the very least I should be able to help get whatever is in darcs compiling. Would it allow allow Haskell to also call Java code, besides running in JVM? I think I'm not enough to nag you alone. If you're looking for more people to nag you... I'm working on a compiler for a new declarative language. Right now we're using Haskell for a proof-of-concept interpreter, though one of the near-term goals for the compiler itself is a Java FFI/backend. Since much of the language is in the runtime engine, it'd be a shame to have to rewrite it all in Java or deal with the horror of JNI. We can use this page, already pointed on this thread: http://haskell.org/haskellwiki/Applications_and_libraries/Interfacing_other_languages#Java We could add something like if you want something working regarding the interaction between Haskell and Java, please nag Brian Alliet at [EMAIL PROTECTED] Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Haskell and Java
At this time It's not really a question of better implementation, but cooperation. I know Haskell, they know Java, and it would be nice if we could share code and work. The idea of the api, or maybe dbus, seems OK. It just would be easier if we could join everything in a single piece, but it is no big deal. Maurício Daryoush Mehrtash a écrit : Why do you want to mix haskall and Java in one VM? If there are functionality within your code that is better implemented in haskell, then why not make that into a service (run it as haskell) with some api that Java code can use. Daryoush On Tue, Sep 9, 2008 at 2:36 AM, Maurício [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hi, I use Haskell, and my friends at work use Java. Do you think it could be a good idea to use Haskell with Java, so I could understand and cooperate with them? Is there a a Haskell to Java compiler that's already ready to use? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org mailto:Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Daryoush Weblog: http://perlustration.blogspot.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Field names
(...) * Since a data constructor can be an infix operator (either spelled with backticks or a symbolic name beginning with ':' ) we can also write our patterns with infix notation. (...) (Slightly off-topic?) Do you have any reference for that use of infixing constructors by start their name with ':'? That's interesting, and I didn't know about it. Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Field names
Do you have any reference for that use of infixing constructors by start their name with ':'? (...) (...) for data constructors, go to http://haskell.org/onlinereport/lexemes.html and search for `Operator symbols'. (...) Here it is: “Operator symbols are formed from one or more symbol characters, as defined above, and are lexically distinguished into two namespaces (Section 1.4): * An operator symbol starting with a colon is a constructor.(...)” Cool! What is the syntax for using that in 'data'? Is it something like “data X = Y | Int :° Double”? Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Haskell and Java
There used to be. http://www.cs.rit.edu/~bja8464/lambdavm/ (Last darcs change log entry: Sun Oct 21 03:05:20 CEST 2007 Brian Alliet [EMAIL PROTECTED] * fix build for hsjava change ) Sorry about this. I hit a critical mass of darcs conflicts (I look forward to giving git a try) around the same time I got really busy at work. I've been meaning to get back into it (and update it to GHC HEAD) but I haven't received sufficient nagging yet. Please yell if you're interested in LambdaVM. At the very least I should be able to help get whatever is in darcs compiling. Would it allow allow Haskell to also call Java code, besides running in JVM? I think I'm not enough to nag you alone. However, anybody who allows a Haskell programmer to avoid using other languages can be sure to have brought a lot of happiness to this sad world. If you can do it, I don't know how you can resist :) Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] STM and FFI
Hi, Is it possible to use foreign function interface with STMs? If so, where can I find examples? Thanks, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Field names
abs (Pt {pointx = x, pointy = y}) = sqrt (x*x + y+y) Why is it pointx=x and not x=pointx? Your intuition is probably telling you that this is something like: abs (point) = sqrt (x*x+y*y) where {x=pointx point ; y=pointy point} Actually, it's an example of pattern matching: abs (Pt {pointx=3 , pointy=4}) = 5 abs (Pt {pointx=3 , pointy=y}) = sqrt (9+y*y) abs (Pt {pointx=z , pointy=z}) = (sqrt 2)*z etc. Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe