Re: [Haskell-cafe] Unicode workaround for getDirectoryContents under Windows?
Hello Shu-yu, Sunday, June 14, 2009, 7:41:46 AM, you wrote: > It seems like getDirectoryContents applies codepage conversion based it's not a bug, but old-fashioned architecture of entire file apis you may find my Win32Files.hs module useful - it adopts UTF-16 versions of file operations http://downloads.sourceforge.net/freearc/FreeArc-0.51-sources.tar.bz2 -- Best regards, Bulatmailto:bulat.zigans...@gmail.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Unicode workaround for getDirectoryContents under Windows?
On Sat, Jun 13, 2009 at 8:41 PM, Shu-yu Guo wrote: > Hello all, > > It seems like getDirectoryContents applies codepage conversion based > on the default program locale under Windows. What this means is that > if my default codepage is some kind of Latin, Asian glyphs get > returned as '?' in the filename. By '?' I don't mean that the font is > lacking the glyph and rendering it as '?', but I mean 'show (head > (getDirectoryContents "C:\\Music"))' returns something that looks like > like "?? ". > > This is a problem as I can't get the filenames of my music directory, > some of which are in Japanese and Chinese, some of which have accents. > If I change the default codepage to Japanese, say, then I get the > Japanese filenames in Shift-JIS and I lose all the accented letters. > > I have filed this as a bug already, but is there a workaround in the > meantime (I don't know the Win32 API, but didn't see anything that > looked like it would help under System.Win32 anyways) that lets me > gets the list of files in a directory that's encoded in some kind of > Unicode? Try taking a look at the code in the following module, which uses FFI to access the Unicode-aware Win32 APIs: http://code.haskell.org/haskeline/System/Console/Haskeline/Directory.hsc Hope that helps, -Judah ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Unicode workaround for getDirectoryContents under Windows?
Hello all, It seems like getDirectoryContents applies codepage conversion based on the default program locale under Windows. What this means is that if my default codepage is some kind of Latin, Asian glyphs get returned as '?' in the filename. By '?' I don't mean that the font is lacking the glyph and rendering it as '?', but I mean 'show (head (getDirectoryContents "C:\\Music"))' returns something that looks like like "?? ". This is a problem as I can't get the filenames of my music directory, some of which are in Japanese and Chinese, some of which have accents. If I change the default codepage to Japanese, say, then I get the Japanese filenames in Shift-JIS and I lose all the accented letters. I have filed this as a bug already, but is there a workaround in the meantime (I don't know the Win32 API, but didn't see anything that looked like it would help under System.Win32 anyways) that lets me gets the list of files in a directory that's encoded in some kind of Unicode? Cheers, -- shu ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to know the build dependencies?
-BEGIN PGP SIGNED MESSAGE- Hash: SHA512 On Sat, Jun 13, 2009 at 10:22 PM, Magicloud Magiclouds wrote: > Hi, > I am learning to use cabal for my code. > Just when I start, I met a question, is there an easy way to find > out what packages my code depends? > > Thanks. Not really. The easiest way is to just build your code and add every package Cabal complains about being hid into your build-depends. (Usually this won't take more than a minute or 3 if you're toggling between a terminal and an editor.) - -- gwern -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.9 (GNU/Linux) iEYEAREKAAYFAko0arEACgkQvpDo5Pfl1oJbNACfYNB+oScSsiwF3qwZMHzu3AjM s24An3tcamliH1rJzZiNg1EqjTLLYzzo =7Fgw -END PGP SIGNATURE- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: HSH and IO ()
Dimitry Golubovsky wrote: > I'll try to write a wrapper for a forked process inside a Channel -> > IO Channel typed function. Your best bet would be to start with these instances in HSH.Command: instance ShellCommand (String, [String]) where instance ShellCommand String where and the implementation of genericCommand, which they both call. It is really not that difficult of an implementation, and as of GHC 6.10, no longer even requires the specialized POSIX items. The reason I have two bodies for genericCommand is that if the input channel is a Handle, I can pass it directly as stdin to the child process; otherwise, it is necessary to use chanToHandle to zap it over to stdin. Now, with what you're trying to do, you will probably not be able to get away without using the POSIX stuff though, since you have to dup2() stdin/stdout. I still recommend splitting this into multiple executables. With your approach, the stdin and stdout of your main executable will be messed up forever. This can and does lead to unforseen consequences. -- John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] How to know the build dependencies?
Hi, I am learning to use cabal for my code. Just when I start, I met a question, is there an easy way to find out what packages my code depends? Thanks. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: HSH and IO ()
John, On Sat, Jun 13, 2009 at 7:01 PM, John Goerzen wrote: >> where hscpid corresponds to a process that runs a Haskell function >> (hsffigMain :: a -> b -> c -> IO ()) defined within the same program, >> and gccpid runs an external program (gcc), and they are piped >> together. I am trying to avoid writing this mess using HSH. > > OK, so I should have read more before starting to reply. But why are > you writing to me about HSH if you're trying to *avoid* HSH? I'm confused. Sorry, I should have written "by using"; Jason made the right correction. I thought that forkProcess-based shell commands existed in HSH thus I could avoid all these low-level manipulations with handles that are usually done in C programming. > Integraing hsffigMain into HSH directly will be difficult because it > apparently already has its notions about where its input and output come > from; the fact that its return type is IO () implies that its output I'll try to write a wrapper for a forked process inside a Channel -> IO Channel typed function. > Your best bet is to make this a separate executable. That's not what was intended, but now I see the situation more clearly. Thanks for the explanation. If I get any working code, I'll post a link on the list. -- Dimitry Golubovsky Anywhere on the Web ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: HSH and IO ()
On Sat, Jun 13, 2009 at 05:06:41PM -0700, Jason Dagit wrote: > On Sat, Jun 13, 2009 at 4:01 PM, John Goerzen wrote: > > > Dimitry Golubovsky wrote: > > > > > where hscpid corresponds to a process that runs a Haskell function > > > (hsffigMain :: a -> b -> c -> IO ()) defined within the same program, > > > and gccpid runs an external program (gcc), and they are piped > > > together. I am trying to avoid writing this mess using HSH. > > > > OK, so I should have read more before starting to reply. But why are > > you writing to me about HSH if you're trying to *avoid* HSH? I'm confused. > > > I think Dimitry meant, "I'm trying to avoid writing this mess *by* using HSH > instead." > > At least, that's how I read it. Ah, that makes more sense. Sorry for the misparsing. -- John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: HSH and IO ()
On Sat, Jun 13, 2009 at 4:01 PM, John Goerzen wrote: > Dimitry Golubovsky wrote: > > > where hscpid corresponds to a process that runs a Haskell function > > (hsffigMain :: a -> b -> c -> IO ()) defined within the same program, > > and gccpid runs an external program (gcc), and they are piped > > together. I am trying to avoid writing this mess using HSH. > > OK, so I should have read more before starting to reply. But why are > you writing to me about HSH if you're trying to *avoid* HSH? I'm confused. I think Dimitry meant, "I'm trying to avoid writing this mess *by* using HSH instead." At least, that's how I read it. Jason ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: HSH and IO ()
Dimitry Golubovsky wrote: > John, > > Thanks for the reply. > > In this case, would the body of my function run in a separate thread > via forkProcess (that's what is needed, maybe I didn't make it clear)? No; at least not automatically. The idea is that a function that is Channel -> IO Channel should be very similar in concept to a String -> String - processing its input lazily. > In my previous project, I had to do like this (probably not very > portable, at least requires System.Posix): You are aware that HSH has built-in support for executing external commands, right? What is hssfigMain? Is it calling some other program or is it part of the current process? I would suggest that the appropriate idea is to make hsffigMain be some other executable. Then you could just: runIO $ ("hsffigMain", [args, args, ...]) -|- (fromJust $ gccPath dopt, ["-E", "-dD", ...]) > where hscpid corresponds to a process that runs a Haskell function > (hsffigMain :: a -> b -> c -> IO ()) defined within the same program, > and gccpid runs an external program (gcc), and they are piped > together. I am trying to avoid writing this mess using HSH. OK, so I should have read more before starting to reply. But why are you writing to me about HSH if you're trying to *avoid* HSH? I'm confused. > I'm just trying to find out whether this was already done. If not, > what is the best way to write the above to be integrated into HSH (I'd > be glad to contribute). Integraing hsffigMain into HSH directly will be difficult because it apparently already has its notions about where its input and output come from; the fact that its return type is IO () implies that its output either goes to stdout or to a file. This type of function cannot be generalized to pipes, because you can only dup2() your stdout once. (You couldn't have two functions like hsffigMain in your pipeline). Your best bet is to make this a separate executable. -- John ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: hledger 0.6 released
I'm pleased to announce the release of hledger 0.6. For docs, online demo etc., see http://hledger.org . Some pre-built binaries are now available at http://hledger.org/ binaries . Or, install with: cabal install hledger [-fhapps] [-fvty]. (Using the latest Haskell Platform, "cabal install hledger -fhapps" works on gnu/ linux, mac and windows. Hurrah!) I'd like to hear feedback, especially if you hit trouble getting started. Happy tracking! - Simon (sm) 2009/06/13 hledger 0.6 .. * now cabal-installable on unix, mac, and windows, with Haskell Platform * provide experimental platform binaries * parsing: fix a silly failure to open ledger file paths containing ~ * parsing: show better errors for unbalanced transaction and missing default year * parsing: allow parentheses and brackets inside account names, as ledger does * parsing: fail on empty account name components, don't just ignore * add: description passed as arguments now affects first transaction only * add: better handling of virtual postings and default amounts * print, register: show virtual accounts bracketed/parenthesised * web: improved web ui supporting full patterns & period expressions * new "stats" command reports some ledger statistics * many dev/doc/deployment infrastructure improvements * move website into darcs repo, update home page * move issue tracker to google code Release stats: * Contributors: Simon Michael * Days since last release: 21 * Commits: 94 * Lines of non-test code: 2865 * Tests: 82 * Test coverage: 53% expressions * Known errors: 3 (inconsistent eliding, vty-related failures) * Performance: similar (http://hledger.org/profs/200906131120.bench) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell Weekly News: Issue 121 - June 13, 2009
--- Haskell Weekly News http://sequence.complete.org/hwn/20090613 Issue 121 - June 13, 2009 --- Welcome to issue 121 of HWN, a newsletter covering developments in the [1]Haskell community. Announcements purely functional lazy non-deterministic programming. Sebastian Fischer [2]announced the [3]explicit-sharing library, which supports lazy functional-logic programming in Haskell. nntp 0.0.1. Maciej Piechotka [4]announced the release of [5]nntp, a library to connect to nntp (i.e. mainly USENET) servers. OpenGLRaw 1.0.0.0. Sven Panne [6]announced the release of [7]OpenGLRaw, a low-level binding for OpenGL. The eventual goal is to make the OpenGL package easier to install, more modular and a bit more flexible. pgm-0.1 on Hackage. Frederick Ross [8]announced [9]pgm, a pure Haskell library to read and write PGM images. It seamlessly handles the divide between 1 and 2 byte per pixel images; reads and writes UArrays; can handle multiple PGMs concatenated one after another in a file; and encodes and decodes all comments in the PGM header, which can be used to drop arbitrary metadata into files in a human readable manner. iteratee-0.2.1 released. John Lato [10]announced the release of [11]iteratee-0.2.1, a major update to the iteratee library. This library provides types and functions for performing enumerator/iteratee based I/O operations in Haskell, as [12]described by Oleg. The new version is a large redesign, including support for resumable exceptions and a greatly simplified interface. testrunner-0.9. Reinier Lamers [13]announced [14]testrunner, a new framework for running unit test. It can run unit tests in parallel; can run QuickCheck and HUnit tests as well as simple boolean expressions; and comes with a ready-made main function for your unit test executable. serial-0.2. Frederick Ross [15]announced version 0.2 of [16]serial, a library for working with line-oriented POSIX serial ports. hunp-0.0. Deniz Dogan [17]announced [18]hunp, a command-line utility which automagically calls the right "unpacker" program for you and works on both files and directories. Nemesis : easy task management. Jinjing Wang [19]announced a new release of [20]nemesis, a simple rake-like task management tool. Data.Reify.CSE. Sebastiaan Visser [21]announced the [22]data-reify-cse module, which implements common sub-expression elimination for graphs generated by the Data.Reify package. This package might especially be useful for optimizing simple compilers for referentially transparent domain specific languages. Hac phi accommodation: register by June 15 for reduced rate! Brent Yorgey [23]reminded anyone interested in attending [24]Hac phi that Monday 15 June is the deadline for getting a special reduced hotel rate. alloy-1.0.0 (generic programming). Neil Brown [25]announced the [26]first release of the [27]Allow generic programming library. It is intended to be a fairly fast blend of several other generics approaches, such as SYB (but without the dynamic typing) and Uniplate (but allowing an arbitrary number of target types), for performing transformations on specific types in large tree structures. StrictBench 0.1 - Benchmarking code through strict evaluation. R.A. Niemeijer [28]announced the release of [29]StrictBench, a library for timing full evaluation of values. haskeem 0.7.0 uploaded to hackage. Uwe Hollerbach [30]announced [31]haskeem, a small scheme interpreter written in Haskell. numtype 1.0 -- Type-level (low cardinality) integers. Bjorn Buckwalter [32]announced the [33]Numeric.NumType module, now released as its own package, which implements a unary type-level representation of integers, supporting addition, subtraction, multiplication, and division. Google Summer of Code Progress updates from participants in the 2008 [34]Google Summer of Code. space profiling. Gergely Patai has some [35]pretty graphs generated by his profiling library. haskell-src-exts. Niklas Broberg is [36]quite close to releasing haskell-src-exts 1.0.0, as soon as he has full and correct support for (almost) everything code-related, with only a few things left to do. He also wrote [37]a post explaining the intricacies of parsing code containing the 'forall' keyword (well, whether it is a keyword depends on which extensions are enabled...) fast darcs. Petr Rockai made a bit less progress this week, with finals and other things interfering, but [38]made some progress on some documentation, tracking down a performance regression, and other things. Discussion Adding an ignore function to Control.Monad. Gwern Branwen [39]proposed adding an
Re: [Haskell-cafe] curious about sum
Keith Sheppard wrote: Is there any reason that sum isn't strict? I can't think of any case where that is a good thing. Prelude> sum [0 .. 100] *** Exception: stack overflow As others have said, there are cases where non-strictness is what you want. And if you are using a type that is strict (the common case), GHC's optimizations will catch it. The historical reason for this is that foldl' is not Haskell 98, only foldl. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANNOUNCE: hunp-0.0
Inspired by the CLI utility "unp", which was nice but lacked some DWIM functionality, I developed hunp (or hünp, but pronounced hump because it's easier). It automagically calls the right "unpacker" program for you and works on both files and directories: $ hunp ~/download/something/ ...finds ~/download/something/hello.r00 and calls "unrar x ~/download/something/hello.r00". $ hunp ~/howdy.tar.gz ...calls "tar zxvf ~/howdy.tar.gz" Get it from http://hackage.haskell.org/package/hunp or from git://github.com/skorpan/hunp.git Enjoy! -- Deniz Dogan PS. I was unable to find the thread on how to properly announce things on the mailing lists, so I hope everyone is okay with this going only to Haskell café. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] curious about sum
You can make numeric class instances from arbitrary Applicatives [1]. I imagine a lot of them (e.g. Stream) would want at least some non-strictness. We might provide strict alternatives for sum and product. I wonder what else. [1] http://hackage.haskell.org/cgi-bin/hackage-scripts/package/applicative-numbers - Conal On Sat, Jun 13, 2009 at 7:03 AM, Keith Sheppard wrote: > Is there any reason that sum isn't strict? I can't think of any case > where that is a good thing. > > Prelude> sum [0 .. 100] > *** Exception: stack overflow > > -Keith > -- > keithsheppard.name > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Check out my photos on Facebook
2009/6/13 Rakesh Malik : > To sign up for Facebook, follow the link below: > http://www.facebook.com/p.php?i=898160075&k=Z5E62YTRPW2CUGGAX144X3&r I followed that link, in case anyone cares. -- Deniz Dogan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Check out my photos on Facebook
Hi haskell-cafe@haskell.org, I set up a Facebook profile where I can post my pictures, videos and events and I want to add you as a friend so you can see it. First, you need to join Facebook! Once you join, you can also create your own profile. Thanks, Rakesh To sign up for Facebook, follow the link below: http://www.facebook.com/p.php?i=898160075&k=Z5E62YTRPW2CUGGAX144X3&r haskell-cafe@haskell.org was invited to join Facebook by Rakesh Malik. If you do not wish to receive this type of email from Facebook in the future, please click on the link below to unsubscribe. http://www.facebook.com/o.php?k=917e28&u=531922198&mid=9dcc69G1fb47d16G0G8 Facebook's offices are located at 1601 S. California Ave., Palo Alto, CA 94304. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] curious about sum
Daniel Fischer wrote: > Am Samstag 13 Juni 2009 17:00:36 schrieb Jochem Berndsen: >> Deniz Dogan wrote: >>> 2009/6/13 Jochem Berndsen : Keith Sheppard wrote: > Is there any reason that sum isn't strict? I can't think of any case > where that is a good thing. > > Prelude> sum [0 .. 100] > *** Exception: stack overflow It is useful if the (+) is nonstrict; although I cannot think of any useful mathematical structure where (+) would be nonstrict. >>> I remember needing a non-strict sum at least once, but I do not >>> remember the exact application. But imagine having a (very) long list >>> of numbers and you want to do A if the sum exceeds a small number, >>> otherwise B. >>> >>> if sum [0..10] > 10 then A else B >>> >>> However, this idea didn't work, because of strictness. >> You can only do such things if you know that all entries of your list >> are nonnegative. That requires a custom solution anyway (not to mention >> the fact that to determine whether x > 10 or not, we need to explicitly >> compute x). > > Well, if you have lazy Peano numbers of any kind, you know that all entries > are non- > negative and you needn't evaluate x fully to determine whether it's > 10. > Isn't that the > point why one would use lazy numbers at all? Yes. (That's what I meant with 'custom solution', using Peano numbers instead of Ints or Integers.) Regards, -- Jochem Berndsen | joc...@functor.nl GPG: 0xE6FABFAB ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] curious about sum
Am Samstag 13 Juni 2009 17:00:36 schrieb Jochem Berndsen: > Deniz Dogan wrote: > > 2009/6/13 Jochem Berndsen : > >> Keith Sheppard wrote: > >>> Is there any reason that sum isn't strict? I can't think of any case > >>> where that is a good thing. > >>> > >>> Prelude> sum [0 .. 100] > >>> *** Exception: stack overflow > >> > >> It is useful if the (+) is nonstrict; although I cannot think of any > >> useful mathematical structure where (+) would be nonstrict. > > > > I remember needing a non-strict sum at least once, but I do not > > remember the exact application. But imagine having a (very) long list > > of numbers and you want to do A if the sum exceeds a small number, > > otherwise B. > > > > if sum [0..10] > 10 then A else B > > > > However, this idea didn't work, because of strictness. > > You can only do such things if you know that all entries of your list > are nonnegative. That requires a custom solution anyway (not to mention > the fact that to determine whether x > 10 or not, we need to explicitly > compute x). Well, if you have lazy Peano numbers of any kind, you know that all entries are non- negative and you needn't evaluate x fully to determine whether it's > 10. Isn't that the point why one would use lazy numbers at all? > > Regards, ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Atom - help.
Calling foreign functions that return values is problematic for the compiler -- I haven't invested enough time to come up with a good solution. The work around is to assign the result to an external variable. The drawback is the result will not be available until the rule executing the action has completed. results <- bool' "result" -- Global, external variable to capture result. action (\ [a, b, c] -> printf "result = function(%s, %s %s)" a b c) [a, b, c] -Tom On Sat, Jun 13, 2009 at 5:03 AM, Radamés Ajna wrote: > hi there, > > I've been working with haskell and atom dsl, however I'm new to haskell.. > John Van Enk inspired me with programming arduino->atmegas , with haskell, > So here is my problem. > With an action , action :: ([String] -> String) -> [UE] -> Atom () , > it's possible make calls to some precoded C functions like, > > setLED v = action (\[x] -> "setLED(" ++ x ++ ")") [v'] > where v' = ue . value $ v > > where setLed is a precode function. > > I want call a precoded C function that returns some value, but action > always give me Atom () , > that's I would like to do but I don't know how .. > > Atom (V Int8) < "int read()" > > > thanks... > related links > http://hackage.haskell.org/package/atom-0.0.5 > http://blog.sw17ch.com/wordpress/?p=111 > http://leepike.wordpress.com/2009/05/05/an-atomic-fibonacci-server-exploring-the-atom-haskell-dsl/ > > > > Radamés > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] curious about sum
Deniz Dogan wrote: > 2009/6/13 Jochem Berndsen : >> Keith Sheppard wrote: >>> Is there any reason that sum isn't strict? I can't think of any case >>> where that is a good thing. >>> >>> Prelude> sum [0 .. 100] >>> *** Exception: stack overflow >> It is useful if the (+) is nonstrict; although I cannot think of any >> useful mathematical structure where (+) would be nonstrict. > > I remember needing a non-strict sum at least once, but I do not > remember the exact application. But imagine having a (very) long list > of numbers and you want to do A if the sum exceeds a small number, > otherwise B. > > if sum [0..10] > 10 then A else B > > However, this idea didn't work, because of strictness. You can only do such things if you know that all entries of your list are nonnegative. That requires a custom solution anyway (not to mention the fact that to determine whether x > 10 or not, we need to explicitly compute x). Regards, -- Jochem Berndsen | joc...@functor.nl GPG: 0xE6FABFAB ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] curious about sum
That's an interesting example. I guess a lazy number system like that would work nicely for Deniz's use case. On Sat, Jun 13, 2009 at 10:26 AM, Stephan Friedrichs wrote: > Jochem Berndsen wrote: >> Keith Sheppard wrote: >>> Is there any reason that sum isn't strict? I can't think of any case >>> where that is a good thing. >>> >>> Prelude> sum [0 .. 100] >>> *** Exception: stack overflow >> >> It is useful if the (+) is nonstrict; although I cannot think of any >> useful mathematical structure where (+) would be nonstrict. > > What about some numeric representations? > > type MyNum = [()] > > instance Num MyNum where > (+) = (++) > > Regards, > Stephan > > -- > > Früher hieß es ja: Ich denke, also bin ich. > Heute weiß man: Es geht auch so. > > - Dieter Nuhr > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- keithsheppard.name ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] curious about sum
Jochem Berndsen wrote: > Keith Sheppard wrote: >> Is there any reason that sum isn't strict? I can't think of any case >> where that is a good thing. >> >> Prelude> sum [0 .. 100] >> *** Exception: stack overflow > > It is useful if the (+) is nonstrict; although I cannot think of any > useful mathematical structure where (+) would be nonstrict. What about some numeric representations? type MyNum = [()] instance Num MyNum where (+) = (++) Regards, Stephan -- Früher hieß es ja: Ich denke, also bin ich. Heute weiß man: Es geht auch so. - Dieter Nuhr ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] curious about sum
2009/6/13 Jochem Berndsen : > Keith Sheppard wrote: >> Is there any reason that sum isn't strict? I can't think of any case >> where that is a good thing. >> >> Prelude> sum [0 .. 100] >> *** Exception: stack overflow > > It is useful if the (+) is nonstrict; although I cannot think of any > useful mathematical structure where (+) would be nonstrict. I remember needing a non-strict sum at least once, but I do not remember the exact application. But imagine having a (very) long list of numbers and you want to do A if the sum exceeds a small number, otherwise B. if sum [0..10] > 10 then A else B However, this idea didn't work, because of strictness. -- Deniz Dogan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] curious about sum
Keith Sheppard wrote: > Is there any reason that sum isn't strict? I can't think of any case > where that is a good thing. > > Prelude> sum [0 .. 100] > *** Exception: stack overflow It is useful if the (+) is nonstrict; although I cannot think of any useful mathematical structure where (+) would be nonstrict. Regards, -- Jochem Berndsen | joc...@functor.nl GPG: 0xE6FABFAB ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] curious about sum
Is there any reason that sum isn't strict? I can't think of any case where that is a good thing. Prelude> sum [0 .. 100] *** Exception: stack overflow -Keith -- keithsheppard.name ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: HSH and IO ()
John, Thanks for the reply. In this case, would the body of my function run in a separate thread via forkProcess (that's what is needed, maybe I didn't make it clear)? In my previous project, I had to do like this (probably not very portable, at least requires System.Posix): (fd1, fd2) <- createPipe hscfd <- fileToFd hscFile hscpid <- forkProcess $ redirFd fd1 0 $ redirFd fd2 (-1) $ redirFd hscfd 1 $ hsffigMain (fromJust $ gccPath dopt) (inclDirs dopt) minusD gccpid <- forkProcess $ redirFd fd2 1 $ executeFile (fromJust $ gccPath dopt) False (["-E", "-dD"] ++ minusI ++ minusD ++ [incFile]) Nothing closeFd hscfd closeFd fd1 closeFd fd2 gccrt <- getProcessStatus True False gccpid hscrt <- getProcessStatus True False hscpid where hscpid corresponds to a process that runs a Haskell function (hsffigMain :: a -> b -> c -> IO ()) defined within the same program, and gccpid runs an external program (gcc), and they are piped together. I am trying to avoid writing this mess using HSH. I'm just trying to find out whether this was already done. If not, what is the best way to write the above to be integrated into HSH (I'd be glad to contribute). Thank you. On Sat, Jun 13, 2009 at 12:46 AM, John Goerzen wrote: > > You can replace it with a function that can take any Channel, and > produce a result as a Channel of one particular sort. In particular, > this instance: > > instance ShellCommand (Channel -> IO Channel) where > -- Dimitry Golubovsky Anywhere on the Web ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell Meetup groups in Glasgow
On Sat, Jun 13, 2009 at 5:09 AM, A Smith wrote: > Do any Haskell Meetup groups exist in or around Glasgow, an informal > get-to-gether in a pub,cafe or wherever ? > I'm in Edinburgh, and on my own have been desperately trying to rewire my > brain from Perl to Haskell without much success for most of this year. I > posted the meetup group question a few weeks ago for Edinburgh but got no > response. Sorry, I didn't see your Edinburgh message. I am also in Edinburgh and though I don't know of any Haskell meet-ups I don't think it would be hard to get critical mass for one. Edinburgh Uni teaches it to the first years (AFAIK), Philip Wadler works here, and the ICFP and Haskell Symposium are going to be held here later in the year. There must be more than just the two of us! :-) Cheers, D -- Dougal Stanton dou...@dougalstanton.net // http://www.dougalstanton.net ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Atom - help.
hi there, I've been working with haskell and atom dsl, however I'm new to haskell.. John Van Enk inspired me with programming arduino->atmegas , with haskell, So here is my problem. With an action , action :: ([String] -> String) -> [UE] -> Atom () , it's possible make calls to some precoded C functions like, setLED v = action (\[x] -> "setLED(" ++ x ++ ")") [v'] where v' = ue . value $ v where setLed is a precode function. I want call a precoded C function that returns some value, but action always give me Atom () , that's I would like to do but I don't know how .. Atom (V Int8) < "int read()" thanks... related links http://hackage.haskell.org/package/atom-0.0.5 http://blog.sw17ch.com/wordpress/?p=111 http://leepike.wordpress.com/2009/05/05/an-atomic-fibonacci-server-exploring-the-atom-haskell-dsl/ Radamés ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe