Re: [Haskell-cafe] borked windows environment, want to start over
On 18 November 2010 00:37, Henk-Jan van Tuyl hjgt...@chello.nl wrote: If you use MinGW, your compiled program depends on mingwm10.dll (depending on the version of MinGW). Is this true in general or only when you have bindings pulling it in? The MinGW site and other places found in a search indicate that this lib is only necessary for C++ exception handling. I've probably only ever delivered compiled Windows Haskell apps that had no FFI bindings so I haven't noticed either way. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: a simple question about types
Daniel Fischer daniel.is.fisc...@web.de writes: On Wednesday 17 November 2010 19:09:16, Jerzy M wrote: Hallo, let me take this simple function: (2*). If I check its type :t (2*) I'll obtain (2*) :: (Num a) = a - a But now it suffices to write g = (2*) and check :t g to obtain g :: Integer - Integer One more combination, now I write h x = (2*) x and check once more :t h to get h :: (Num a) = a - a So my question is: why (in this second example) Integer is inferred? What makes a difference? The monomorphism restriction. And default. If you load this into ghci module Main where default (Int) g = (2*) main = putStrLn foo and type :t g you'll get Int - Int -- Jón Fairbairn jon.fairba...@cl.cam.ac.uk ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] [ANNOUNCE] A Haskell interface to Lego Mindstorms NXT
Hi! I have just published my library which provides Haskell interface to Lego Mindstorms NXT over Bluetooth. http://hackage.haskell.org/package/NXT So take your NXTs out of your closets or out of your children hands and try it out! ;-) Feel free to contribute additional features, interfaces for more sensors and propose or write other (example) programs. I also more than welcome any comments as it is my first library in Haskell. So if you have any suggestion about code improvements or some other best practices, I would really like to hear them. Currently haddock documentation does not compile because of this bug: http://hackage.haskell.org/trac/hackage/ticket/656 Can anybody help with fixing this bug? It would be much nicer to see all documentation on HackageDB I made. Mitar ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Printing of asynchronous exceptions to stderr
Hi! On Wed, Nov 17, 2010 at 12:00 PM, Simon Marlow marlo...@gmail.com wrote: That's hard to do, because the runtime system has no knowledge of exception types, and I'm not sure I like the idea of baking that knowledge into the RTS. But currently it does have a knowledge of interruptible and uninterruptible exceptions? So adding another which would ctrl-c interrupt? The point of maskUninterruptible is for those hoefully rare rare cases where (a) it's really inconvenient to deal with async exceptions and (b) you have some external guarantee that the critical section won't block. But is it possible to make an uninterruptible code section which can timeout? Because once you enter maskUninterruptible probably System.Timeout does not work anymore? I see uses of maskUninterruptible (or some derivation of it, preferably) if: - user would still be able to interrupt it - you could specify some timeout or some other condition after which the code section would be interrupted, so you could try for example to deal with some cleanup code (and you do not want interrupts there) but if this cleanup code hangs you still want some way to kill it then Currently, with this absolute/all approach maskUninterruptible is really not useful much because it masks too much. But I would see a lot more useful something which would still allow me (and only me, as a programmer) to interrupt it or user (because user should know what he/she does). And this is why I argue for some way of being able to specify which interrupts you still allow: like mask everything except... (user interrupts, my special exception meant for cleanup code hanging conditions...). Mitar ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to generalize executing a series of commands, based on a list?
On 2010-11-17 21:03, Peter Schmitz wrote: I am wondering how to generalize this to do likewise for a series of commands, where the varying args (filenames, in this case) are in a list ('inOutLeafs'). The 'sequence' function is handy for combining a series of actions, such as [system cmd1, system cmd2, ...]. I will also want to accumulate some results; probably just a failure count at this time. 'sequence' hangs on to the results. That may be what you need. For control over accumulating results the good stuff is in Data.Foldable. Any advice or pointers to examples would be much appreciated. Thanks in advance, -- Peter run :: ... - IO (Int)-- will return a fail count run -- some args to this function here... = do -- ... set up: inputLeafs, outputLeafs, etc. -- zip two lists of filenames: let inOutLeafs = zip inputLeafs outputLeafs -- the first pair for the first command: let (inFile1,outFile1) = head inOutLeafs -- build 1st command using 1st pair of filenames: let cmd1 = ... exitCode - system cmd1 case (exitCode) of ExitSuccess - do putStrLn $ -- OK. return 0 ExitFailure failCnt - do putStrLn $ -- Failed: ++ show failCnt return 1 ___ 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: How to generalize executing a series of commands, based on a list?
1. Write one routine, which does all the work for just one command. 2. use sequence or mapM, mapM_ from Control.Monad (depending on your needs), to apply your function to a list of commands accumulating results you may want to process the output of sequence or use the WriterT Monad Transformer. If you want to stop processing the rest of the list on error, either write a recursive function yourself or use foldM or use ErrorT Monad Transformer. On Nov 18, 3:03 am, Peter Schmitz ps.hask...@gmail.com wrote: I am able to use System.Cmd (system) to invoke a shell command and interpret the results. Please see the code below that works okay for one such command. (I invoke a program, passing two args.) I am wondering how to generalize this to do likewise for a series of commands, where the varying args (filenames, in this case) are in a list ('inOutLeafs'). I will also want to accumulate some results; probably just a failure count at this time. Any advice or pointers to examples would be much appreciated. Thanks in advance, -- Peter run :: ... - IO (Int) -- will return a fail count run -- some args to this function here... = do -- ... set up: inputLeafs, outputLeafs, etc. -- zip two lists of filenames: let inOutLeafs = zip inputLeafs outputLeafs -- the first pair for the first command: let (inFile1,outFile1) = head inOutLeafs -- build 1st command using 1st pair of filenames: let cmd1 = ... exitCode - system cmd1 case (exitCode) of ExitSuccess - do putStrLn $ -- OK. return 0 ExitFailure failCnt - do putStrLn $ -- Failed: ++ show failCnt return 1 ___ Haskell-Cafe mailing list haskell-c...@haskell.orghttp://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] Printing of asynchronous exceptions to stderr
On 18/11/2010 11:31, Mitar wrote: Hi! On Wed, Nov 17, 2010 at 12:00 PM, Simon Marlowmarlo...@gmail.com wrote: That's hard to do, because the runtime system has no knowledge of exception types, and I'm not sure I like the idea of baking that knowledge into the RTS. But currently it does have a knowledge of interruptible and uninterruptible exceptions? So adding another which would ctrl-c interrupt? The RTS knows when a thread is blocked, which is when it becomes interruptible. It doesn't need to know about different kinds of exeptions. In fact, when an exception is thrown it might well be unevaluated. The point of maskUninterruptible is for those hoefully rare rare cases where (a) it's really inconvenient to deal with async exceptions and (b) you have some external guarantee that the critical section won't block. But is it possible to make an uninterruptible code section which can timeout? then it isn't uninterruptible, because the timeout can interrupt it. If you can tolerate a timeout exception, then you can tolerate other kinds of async exception too. Because once you enter maskUninterruptible probably System.Timeout does not work anymore? I see uses of maskUninterruptible (or some derivation of it, preferably) if: - user would still be able to interrupt it - you could specify some timeout or some other condition after which the code section would be interrupted, so you could try for example to deal with some cleanup code (and you do not want interrupts there) but if this cleanup code hangs you still want some way to kill it then Currently, with this absolute/all approach maskUninterruptible is really not useful much because it masks too much. But I would see a lot more useful something which would still allow me (and only me, as a programmer) to interrupt it or user (because user should know what he/she does). And this is why I argue for some way of being able to specify which interrupts you still allow: like mask everything except... (user interrupts, my special exception meant for cleanup code hanging conditions...). My main question is then, why do you want to use maskUninterruptible rather than just mask? Can you give a concrete example? Cheers, Simon ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Space not reclaimed by GC
Hi, I have a program which runs, then calls performGC multiple times. I'd expect all (or nearly all) of the memory to be freed by that point. But it isn't. Given this program: import Language.Haskell.Exts.Annotated -- from haskell-src-exts import System.Mem main :: IO () main = do let src = fromParseResult $ parseFileContents $ data C = C {a :: F {- ++ replicate 40 'd' ++ -} } putStrLn $ Total length is: ++ show (length $ show $ src) performGC performGC performGC I run with: ghc --make Temp.hs -rtsopts Temp.exe +RTS -G1 -S (the use of 1 generation is to make sure all GC's clear up everything, the leak still happens without it). I am using GHC 7.0.1 I get the output: AllocCopied LiveGCGC TOT TOT Page Flts bytes bytes bytes user elapuserelap ... lots of values ... 16187336 9598808 9600428 0.05 0.060.470.6600 (Gen: 0) 19513288 11571104 11572724 0.06 0.070.550.7700 (Gen: 0) 23519176 13948292 13949912 0.09 0.080.670.8900 (Gen: 0) Total length is: 4226 24645752 548 2091128 0.00 0.000.750.9800 (Gen: 0) 20 540 2091120 0.00 0.000.750.9900 (Gen: 0) 0 540 2091120 0.00 0.000.751.0000 (Gen: 0) 1288 844 3028 0.00 0.000.751.0100 (Gen: 0) 0 0.00 0.00 162,592,312 bytes allocated in the heap 81,004,756 bytes copied during GC 13,949,912 bytes maximum residency (30 sample(s)) 226,344 bytes maximum slop 63 MB total memory in use (6 MB lost due to fragmentation) Generation 0:30 collections, 0 parallel, 0.48s, 0.51s elapsed INIT time0.02s ( 0.02s elapsed) MUT time0.25s ( 0.47s elapsed) GCtime0.48s ( 0.51s elapsed) EXIT time0.00s ( 0.00s elapsed) Total time0.75s ( 1.01s elapsed) %GC time 64.6% (50.6% elapsed) Alloc rate613,093,182 bytes per MUT second Productivity 33.3% of total user, 24.7% of total elapsed QUESTION 1: My reading of this report is that performGC leaves 2091120 of live data. However, the program seems to run a GC on termination, when only 3028 bytes of data are left. Why is all the data not released on performGC? QUESTION 2: It seems that the haskell-src-exts parser has some kind of space leak in data C = C {a :: F {- d -} }, but not in data C = C {a :: F} {- d -}. That's fair enough, but is it because it's a space leak that performGC doesn't get the data? If I change to the second form then the in use memory after performGC is about 3Kb. I found that if I did the parseFileContents/print bit once I get 2Mb of leak, if I do it twice I get 2Mb, and if I do it three times I get 1Mb of leak, which really confused me. Thanks, Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] About Fun with type functions example
Hello, I am trying to understand and use the Nat n type defined in the aforementioned article. Unfortunately, the given code does not compile properly: Here is the code: module Naturals where data Zero data Succ a class Nat n where toInt :: n - Int instance Nat Zero where toInt _ = 0 instance (Nat n) = Nat (Succ n) where toInt _ = 1 + toInt (undefined :: n) type One = Succ Zero type Two = Succ One And here is the error: D:\projets\sequencerghc Naturals.hs Naturals.hs:16:18: Ambiguous type variable `n' in the constraint: `Nat n' arising from a use of `toInt' at Naturals.hs:16:18-39 Probable fix: add a type signature that fixes these type variable(s) I use 6.12.3 on Windows XP. I am most probably missing an option but does not know which one. Thanks in advance for any advice, Arnaud ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] About Fun with type functions example
On Thu, Nov 18, 2010 at 20:17, Arnaud Bailly arnaud.oq...@gmail.com wrote: Hello, I am trying to understand and use the Nat n type defined in the aforementioned article. Unfortunately, the given code does not compile properly: [snip] instance (Nat n) = Nat (Succ n) where toInt _ = 1 + toInt (undefined :: n) [snip] And here is the error: Naturals.hs:16:18: Ambiguous type variable `n' in the constraint: `Nat n' arising from a use of `toInt' at Naturals.hs:16:18-39 Probable fix: add a type signature that fixes these type variable(s) You need to turn on the ScopedTypeVariables extension (using {-# LANGUAGE ScopedTypeVariables #-} at the top of your file, or -XScopedTypeVariables at the command line). Otherwise, the 'n' in the class declaration and in the function definition are different, and you want them to be the same 'n'. Erik ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] About Fun with type functions example
Thanks a lot, that works perfectly fine! Did not know this one... BTW, I would be interested in the fromInt too. Arnaud On Thu, Nov 18, 2010 at 8:22 PM, Erik Hesselink hessel...@gmail.com wrote: On Thu, Nov 18, 2010 at 20:17, Arnaud Bailly arnaud.oq...@gmail.com wrote: Hello, I am trying to understand and use the Nat n type defined in the aforementioned article. Unfortunately, the given code does not compile properly: [snip] instance (Nat n) = Nat (Succ n) where toInt _ = 1 + toInt (undefined :: n) [snip] And here is the error: Naturals.hs:16:18: Ambiguous type variable `n' in the constraint: `Nat n' arising from a use of `toInt' at Naturals.hs:16:18-39 Probable fix: add a type signature that fixes these type variable(s) You need to turn on the ScopedTypeVariables extension (using {-# LANGUAGE ScopedTypeVariables #-} at the top of your file, or -XScopedTypeVariables at the command line). Otherwise, the 'n' in the class declaration and in the function definition are different, and you want them to be the same 'n'. Erik ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to generalize executing a series of commands, based on a list?
Thank you very much for the help. -- Peter On Thu, Nov 18, 2010 at 4:48 AM, Scott Turner 1hask...@pkturner.org wrote: On 2010-11-17 21:03, Peter Schmitz wrote: I am wondering how to generalize this to do likewise for a series of commands, where the varying args (filenames, in this case) are in a list ('inOutLeafs'). The 'sequence' function is handy for combining a series of actions, such as [system cmd1, system cmd2, ...]. I will also want to accumulate some results; probably just a failure count at this time. 'sequence' hangs on to the results. That may be what you need. For control over accumulating results the good stuff is in Data.Foldable. Any advice or pointers to examples would be much appreciated. Thanks in advance, -- Peter run :: ... - IO (Int)-- will return a fail count run -- some args to this function here... = do -- ... set up: inputLeafs, outputLeafs, etc. -- zip two lists of filenames: let inOutLeafs = zip inputLeafs outputLeafs -- the first pair for the first command: let (inFile1,outFile1) = head inOutLeafs -- build 1st command using 1st pair of filenames: let cmd1 = ... exitCode - system cmd1 case (exitCode) of ExitSuccess - do putStrLn $ -- OK. return 0 ExitFailure failCnt - do putStrLn $ -- Failed: ++ show failCnt return 1 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: How to generalize executing a series of commands, based on a list?
Thank you very much for the help. Good tips for improving my code design. I'm new to sequence, mapM, and mapM_; I've seen mapM a lot while reading code and wanted to learn it; now I have a reason! Thanks. -- Peter On Thu, Nov 18, 2010 at 5:40 AM, steffen steffen.sier...@googlemail.comwrote: 1. Write one routine, which does all the work for just one command. 2. use sequence or mapM, mapM_ from Control.Monad (depending on your needs), to apply your function to a list of commands accumulating results you may want to process the output of sequence or use the WriterT Monad Transformer. If you want to stop processing the rest of the list on error, either write a recursive function yourself or use foldM or use ErrorT Monad Transformer. On Nov 18, 3:03 am, Peter Schmitz ps.hask...@gmail.com wrote: I am able to use System.Cmd (system) to invoke a shell command and interpret the results. Please see the code below that works okay for one such command. (I invoke a program, passing two args.) I am wondering how to generalize this to do likewise for a series of commands, where the varying args (filenames, in this case) are in a list ('inOutLeafs'). I will also want to accumulate some results; probably just a failure count at this time. Any advice or pointers to examples would be much appreciated. Thanks in advance, -- Peter run :: ... - IO (Int)-- will return a fail count run -- some args to this function here... = do -- ... set up: inputLeafs, outputLeafs, etc. -- zip two lists of filenames: let inOutLeafs = zip inputLeafs outputLeafs -- the first pair for the first command: let (inFile1,outFile1) = head inOutLeafs -- build 1st command using 1st pair of filenames: let cmd1 = ... exitCode - system cmd1 case (exitCode) of ExitSuccess - do putStrLn $ -- OK. return 0 ExitFailure failCnt - do putStrLn $ -- Failed: ++ show failCnt return 1 ___ Haskell-Cafe mailing list haskell-c...@haskell.orghttp:// 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] GUI Designer
There's a tutorial on how to use qtDesigner with qtHaskell ? Or how to use XRC files with wxHaskell? -- View this message in context: http://haskell.1045720.n5.nabble.com/GUI-Designer-tp3271441p3271441.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: borked windows environment, want to start over
On Tue, Nov 16, 2010 at 4:39 PM, Michael Litchard mich...@schmong.org wrote: I think I may have borked things good using cygwin. I want to remove it and do a clean install of haskell platform w/out cygwin. What do I need to do to make sure all configuration files have been removed? Hmm, I wasn't precise enough in my question. My concern is there are configuration files related to the windows haskell-platform install that I don't know about , that need to be removed prior to doing a clean install. Or is it just a matter of doing a standard windows uninstall, will that take care of things? ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] borked windows environment, want to start over
On Thu, 18 Nov 2010 09:45:54 +0100, Stephen Tetley stephen.tet...@gmail.com wrote: On 18 November 2010 00:37, Henk-Jan van Tuyl hjgt...@chello.nl wrote: If you use MinGW, your compiled program depends on mingwm10.dll (depending on the version of MinGW). Is this true in general or only when you have bindings pulling it in? The MinGW site and other places found in a search indicate that this lib is only necessary for C++ exception handling. I've probably only ever delivered compiled Windows Haskell apps that had no FFI bindings so I haven't noticed either way. I don't know; I installed an application that used wxHaskell on a different computer and got a message about missing the mingwm10.dll Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html -- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: How to generalize executing a series of commands, based on a list?
On Thu, 18 Nov 2010 21:20:10 +0100, Peter Schmitz ps.hask...@gmail.com wrote: Thank you very much for the help. Good tips for improving my code design. I'm new to sequence, mapM, and mapM_; I've seen mapM a lot while reading code and wanted to learn it; now I have a reason! Thanks. -- Peter You can find explanations, with usage examples, of these functions at http://members.chello.nl/hjgtuyl/tourdemonad.html Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html -- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] About Fun with type functions example
The best you can do with fromInt is something like Int - (forall n. (Nat n) = n - r) - r, since the type isn't known at compile time. On Thu, Nov 18, 2010 at 2:52 PM, Arnaud Bailly arnaud.oq...@gmail.comwrote: Thanks a lot, that works perfectly fine! Did not know this one... BTW, I would be interested in the fromInt too. Arnaud On Thu, Nov 18, 2010 at 8:22 PM, Erik Hesselink hessel...@gmail.com wrote: On Thu, Nov 18, 2010 at 20:17, Arnaud Bailly arnaud.oq...@gmail.com wrote: Hello, I am trying to understand and use the Nat n type defined in the aforementioned article. Unfortunately, the given code does not compile properly: [snip] instance (Nat n) = Nat (Succ n) where toInt _ = 1 + toInt (undefined :: n) [snip] And here is the error: Naturals.hs:16:18: Ambiguous type variable `n' in the constraint: `Nat n' arising from a use of `toInt' at Naturals.hs:16:18-39 Probable fix: add a type signature that fixes these type variable(s) You need to turn on the ScopedTypeVariables extension (using {-# LANGUAGE ScopedTypeVariables #-} at the top of your file, or -XScopedTypeVariables at the command line). Otherwise, the 'n' in the class declaration and in the function definition are different, and you want them to be the same 'n'. Erik ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: borked windows environment, want to start over
Hi Michael, On Thu, Nov 18, 2010 at 4:02 PM, Michael Litchard mich...@schmong.org wrote: On Tue, Nov 16, 2010 at 4:39 PM, Michael Litchard mich...@schmong.org wrote: I think I may have borked things good using cygwin. I want to remove it and do a clean install of haskell platform w/out cygwin. What do I need to do to make sure all configuration files have been removed? Hmm, I wasn't precise enough in my question. My concern is there are configuration files related to the windows haskell-platform install that I don't know about , that need to be removed prior to doing a clean install. Or is it just a matter of doing a standard windows uninstall, will that take care of things? I'm no Windows expert, but I think by default all packages you install locally go under: /Documents and Settings/username/Application Data/cabal /Documents and Settings/username/Application Data/ghc So you if you didn't install things globally, you may not need to reinstall the Haskell Platform. You just move those directories and they will be recreated. One of the first things I do after installing GHC is: $ ghc-pkg check to make sure things look sane. If they don't it will tell you to run: $ ghc-pkg recache Is this what you're asking? Paulo ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: How to generalize executing a series of commands, based on a list?
Thanks very much for the url; helpful site. I got mapM to do what I wanted (first time I've used it); cool function; now I understand it. At your note for mapM I noticed (mapM print); I've been using (show [list]) so much, (mapM print) will be nice for formatting while debugging, etc. Thanks again! -- Peter On Thu, Nov 18, 2010 at 3:44 PM, Henk-Jan van Tuyl hjgt...@chello.nlwrote: On Thu, 18 Nov 2010 21:20:10 +0100, Peter Schmitz ps.hask...@gmail.com wrote: Thank you very much for the help. Good tips for improving my code design. I'm new to sequence, mapM, and mapM_; I've seen mapM a lot while reading code and wanted to learn it; now I have a reason! Thanks. -- Peter You can find explanations, with usage examples, of these functions at http://members.chello.nl/hjgtuyl/tourdemonad.html Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://van.tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html -- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Reply-To: Header in Mailinglists (was: About Fun with type functions example)
Hi there, I just put an answer two this in beginn...@haskell.org. It was not on purpose to move the topic. It's just that questions I feel I can answer are usually beginner level questions and so I'm not often writing in the cafe itself. It would make my life a little bit more easy if the mailing lists on haskell.org would add a Reply-To: header automatically to each message containing the address of the mailing list, the message was sent to. Usually that's the place where others would want to sent the answers to, I would suppose. Is there a reason that that's not the case? Am I missing something? Or am I supposed to install a more cleaver mail client which can do that for me? Is there one? Probably written in Haskell ;-) Cheers, Bastian On Nov 19, 2010, at 1:07, Daniel Peebles wrote: The best you can do with fromInt is something like Int - (forall n. (Nat n) = n - r) - r, since the type isn't known at compile time. On Thu, Nov 18, 2010 at 2:52 PM, Arnaud Bailly arnaud.oq...@gmail.comwrote: Thanks a lot, that works perfectly fine! Did not know this one... BTW, I would be interested in the fromInt too. Arnaud On Thu, Nov 18, 2010 at 8:22 PM, Erik Hesselink hessel...@gmail.com wrote: On Thu, Nov 18, 2010 at 20:17, Arnaud Bailly arnaud.oq...@gmail.com wrote: Hello, I am trying to understand and use the Nat n type defined in the aforementioned article. Unfortunately, the given code does not compile properly: [snip] instance (Nat n) = Nat (Succ n) where toInt _ = 1 + toInt (undefined :: n) [snip] And here is the error: Naturals.hs:16:18: Ambiguous type variable `n' in the constraint: `Nat n' arising from a use of `toInt' at Naturals.hs:16:18-39 Probable fix: add a type signature that fixes these type variable(s) You need to turn on the ScopedTypeVariables extension (using {-# LANGUAGE ScopedTypeVariables #-} at the top of your file, or -XScopedTypeVariables at the command line). Otherwise, the 'n' in the class declaration and in the function definition are different, and you want them to be the same 'n'. Erik ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] About Fun with type functions example
Just after hitting the button send, it appeared to me that fromInt was not obvious at all, and probably impossible. Not sure I understand your answer though: What would be the second parameter (forall n . (Nat n) = n - r) - r) ? Thanks Arnaud On Fri, Nov 19, 2010 at 1:07 AM, Daniel Peebles pumpkin...@gmail.com wrote: The best you can do with fromInt is something like Int - (forall n. (Nat n) = n - r) - r, since the type isn't known at compile time. On Thu, Nov 18, 2010 at 2:52 PM, Arnaud Bailly arnaud.oq...@gmail.com wrote: Thanks a lot, that works perfectly fine! Did not know this one... BTW, I would be interested in the fromInt too. Arnaud On Thu, Nov 18, 2010 at 8:22 PM, Erik Hesselink hessel...@gmail.com wrote: On Thu, Nov 18, 2010 at 20:17, Arnaud Bailly arnaud.oq...@gmail.com wrote: Hello, I am trying to understand and use the Nat n type defined in the aforementioned article. Unfortunately, the given code does not compile properly: [snip] instance (Nat n) = Nat (Succ n) where toInt _ = 1 + toInt (undefined :: n) [snip] And here is the error: Naturals.hs:16:18: Ambiguous type variable `n' in the constraint: `Nat n' arising from a use of `toInt' at Naturals.hs:16:18-39 Probable fix: add a type signature that fixes these type variable(s) You need to turn on the ScopedTypeVariables extension (using {-# LANGUAGE ScopedTypeVariables #-} at the top of your file, or -XScopedTypeVariables at the command line). Otherwise, the 'n' in the class declaration and in the function definition are different, and you want them to be the same 'n'. Erik ___ 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