Re: [Haskell-cafe] Proposal: Non-recursive let
On 17.07.13 9:46 PM, Edward Kmett wrote: FWIW, I maintain, according to wc and sloccount, 220841 lines worth of Haskell code at present. Thanks, this is great service to our community. And you produce excellent quality! I have been bitten this error one time, so it affects me .45% of the time and that was only because it was in the only package I was not using -Wall on. -Edward On Wed, Jul 17, 2013 at 12:23 PM, Andreas Abel andreas.a...@ifi.lmu.de mailto:andreas.a...@ifi.lmu.de wrote: Here, again, is your ACTUAL CODE, commented, deployed, looping, and maybe linked into your projects, if you are not careless about the cabal constraints: http://hackage.haskell.org/__packages/archive/mtl/2.1/doc/__html/src/Control-Monad-State-__Class.html#state http://hackage.haskell.org/packages/archive/mtl/2.1/doc/html/src/Control-Monad-State-Class.html#state -- | Embed a simple state action into the monad. state :: (s - (a, s)) - m a state f = do s - get let ~(a, s) = f s put s return a Have fun with it, Andreas On 17.07.2013 02:20, Richard A. O'Keefe wrote: Brian Marick sent me a couple of his stickers. The one I have on my door reads to be less wrong than yesterday. The other one I keep free to bring out and wave around: An example would be handy about now. All of the arguing to and fro -- including mine! -- about non-recursive let has been just so much hot air. I could go on about how the distinction between 'val' and 'val rec' in ML was one of the things I came to dislike intensely, and how Haskell's single coherent approach is one of the things that attracted me to Haskell. But why should anyone else care? When presented with a difficulty, it is very common for some functional language users to propose adding just one more feature from some other language, commonly an imperative one (which ML, Caml, and F# arguably are). Typically this is something that _would_ solve the immediate problem but would create worse problems elsewhere, and there is some other solution, either one already available in the language, or a better one that would solve additional problems or cause fewer ones. The best help for any discussion is A CONCRETE EXAMPLE OF REAL CODE. Not little sketches hacked up for the purpose of discussion, but ACTUAL CODE. The person who initially proposes a problem may think some details are not relevant, whereas someone else may see them as the key to the solution. For example, looking at some code in another mostly- functional language, which had been presented as reason why we needed a new construct, I rewrote it in less than half the number of lines using existing constructors, using only existing features. Without seeing THE ACTUAL CODE that prompted this thread, it is impossible to tell whether that might be the case here. In this specific case, we are seeing state being threaded through a bunch of updates, and IN THE ABSENCE OF THE ACTUAL CODE, it seems to me that monad notation is the most intention-revealing notation available for the purpose in Haskell, and if Haskell did have non-recursive let it would STILL be best to write such code using a state monad so that human beings reading the Haskell code would have some idea of what was happening, because that's how state changes are supposed to be expressed in Haskell, and anything else counts as obfuscation. But THE ACTUAL CODE might show that this case was different in some important way. _ Haskell-Cafe mailing list Haskell-Cafe@haskell.org mailto:Haskell-Cafe@haskell.org http://www.haskell.org/__mailman/listinfo/haskell-cafe http://www.haskell.org/mailman/listinfo/haskell-cafe -- Andreas AbelDu bist der geliebte Mensch. Theoretical Computer Science, University of Munich Oettingenstr. 67, D-80538 Munich, GERMANY andreas.a...@ifi.lmu.de mailto:andreas.a...@ifi.lmu.de http://www2.tcs.ifi.lmu.de/~__abel/ http://www2.tcs.ifi.lmu.de/~abel/ _ Haskell-Cafe mailing list Haskell-Cafe@haskell.org mailto:Haskell-Cafe@haskell.org http://www.haskell.org/__mailman/listinfo/haskell-cafe http://www.haskell.org/mailman/listinfo/haskell-cafe -- Andreas AbelDu bist der geliebte Mensch. Theoretical Computer Science, University of Munich Oettingenstr. 67, D-80538 Munich, GERMANY andreas.a...@ifi.lmu.de http://www2.tcs.ifi.lmu.de/~abel/
[Haskell-cafe] Why are field selectors functions? [was: ghc-users A possible alternative to dot notation for record access]
No! This isn't more bikeshedding about notation. It's a bit of Haskell archaeology. On Sun, Jun 30, 2013 at 2:59 AM, Judah Jacobson wrote: [This isn't exactly what Judah wrote.] ... Instead of `x f` (to access field x of record f), maybe we could write `f{x}` as the record selection. The more I thought about that ... We use { ... } to declare records, build them, update them. We use { ... } in pattern matching to access named fields. Why don't we use { ... } to access named fields in terms? The syntax `e{ foo }` is unused in H98. (Or at least it was in 1998.) Can someone who was there at the time (1994?, TRex?) remember if that was ever considered? In the declaration, the build/update, and pattern match: data R = MkR { foo :: Int } r = MkR { foo = 7 } \ (MkFoo { foo }) - ... -- using NamedFieldPuns `foo` is clearly bound to an Int. So why is there this `foo` thing that isn't an Int? AntC ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimization flag changing result of code execution
On 17.07.2013 16:11, Brian Lewis wrote: On 2013.07.17, at 08:03, Jan-Willem Maessen wrote: This has all the marks of a 64-bit-only code running on a 32 bit machine. This discussion is interesting, but I'm not sure why so much of it is taking place here instead of on the mwc-random issue tracker: https://github.com/bos/mwc-random/issues It's way past time to file an issue and/or talk to the maintainer. Issue turned out to be GHC bug. Here are relevant tickets https://github.com/bos/mwc-random/issues/25 http://ghc.haskell.org/trac/ghc/ticket/8072 No workaround for mwc-random yet ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] what is wrong w my IORef Word32 ?
All, what is wrong w the below code? I get an type error related to the operation shiftL import Data.Bits import Data.Word import Data.IORef data Word32s = Word32s { x :: IORef Word32 } bitfield :: Word32 bitfield = 0 mkbitfield :: Word32 - IO Word32s mkbitfield i = do the_bf - newIORef i return (Word32s the_bf) sLbitfield :: Integer - Word32s - IO () sLbitfield i (Word32s bf) = do modifyIORef bf (shiftL i) main::IO() main = do oper_bf - mkbitfield bitfield sLbitfield 2 oper_bf bf_003.hs:15:48: Couldn't match type `Int' with `Word32' Expected type: Word32 - Word32 Actual type: Int - Word32 In the return type of a call of `shiftL' In the second argument of `modifyIORef', namely `(shiftL i)' In a stmt of a 'do' block: modifyIORef bf (shiftL i) bf_003.hs:15:55: Couldn't match expected type `Word32' with actual type `Integer' In the first argument of `shiftL', namely `i' In the second argument of `modifyIORef', namely `(shiftL i)' In a stmt of a 'do' block: modifyIORef bf (shiftL i) Thanks, --Joerg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what is wrong w my IORef Word32 ?
shiftL has the wrong type: Bits a = a - Int - a so it is expecting the value in the IORef to be an Int. Edward Excerpts from Joerg Fritsch's message of Thu Jul 18 10:08:22 -0700 2013: All, what is wrong w the below code? I get an type error related to the operation shiftL import Data.Bits import Data.Word import Data.IORef data Word32s = Word32s { x :: IORef Word32 } bitfield :: Word32 bitfield = 0 mkbitfield :: Word32 - IO Word32s mkbitfield i = do the_bf - newIORef i return (Word32s the_bf) sLbitfield :: Integer - Word32s - IO () sLbitfield i (Word32s bf) = do modifyIORef bf (shiftL i) main::IO() main = do oper_bf - mkbitfield bitfield sLbitfield 2 oper_bf bf_003.hs:15:48: Couldn't match type `Int' with `Word32' Expected type: Word32 - Word32 Actual type: Int - Word32 In the return type of a call of `shiftL' In the second argument of `modifyIORef', namely `(shiftL i)' In a stmt of a 'do' block: modifyIORef bf (shiftL i) bf_003.hs:15:55: Couldn't match expected type `Word32' with actual type `Integer' In the first argument of `shiftL', namely `i' In the second argument of `modifyIORef', namely `(shiftL i)' In a stmt of a 'do' block: modifyIORef bf (shiftL i) Thanks, --Joerg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what is wrong w my IORef Word32 ?
Can I easily fix the modifyIORef statement by swapping something ? --Joerg On Jul 18, 2013, at 7:19 PM, Edward Z. Yang ezy...@mit.edu wrote: shiftL has the wrong type: Bits a = a - Int - a so it is expecting the value in the IORef to be an Int. Edward Excerpts from Joerg Fritsch's message of Thu Jul 18 10:08:22 -0700 2013: All, what is wrong w the below code? I get an type error related to the operation shiftL import Data.Bits import Data.Word import Data.IORef data Word32s = Word32s { x :: IORef Word32 } bitfield :: Word32 bitfield = 0 mkbitfield :: Word32 - IO Word32s mkbitfield i = do the_bf - newIORef i return (Word32s the_bf) sLbitfield :: Integer - Word32s - IO () sLbitfield i (Word32s bf) = do modifyIORef bf (shiftL i) main::IO() main = do oper_bf - mkbitfield bitfield sLbitfield 2 oper_bf bf_003.hs:15:48: Couldn't match type `Int' with `Word32' Expected type: Word32 - Word32 Actual type: Int - Word32 In the return type of a call of `shiftL' In the second argument of `modifyIORef', namely `(shiftL i)' In a stmt of a 'do' block: modifyIORef bf (shiftL i) bf_003.hs:15:55: Couldn't match expected type `Word32' with actual type `Integer' In the first argument of `shiftL', namely `i' In the second argument of `modifyIORef', namely `(shiftL i)' In a stmt of a 'do' block: modifyIORef bf (shiftL i) Thanks, --Joerg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] what is wrong w my IORef Word32 ?
Joerg Fritsch, Thu 2013-07-18 @ 19:22:46+0200: Can I easily fix the modifyIORef statement by swapping something ? --Joerg Replace `shiftL` with `flip shiftL` and change the type signature of `sLbitfield` to take an Int instead of an Integer. signature.asc Description: Digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell Programmers for Distributed Systems
Parallel Scientific, Inc. is a Boulder, CO based, funded startup company with a presence around the globe, working in the cutting edge area of scalable parallelization. We seek experienced Haskell programmers to build a sophisticated, ultra-scalable high availability framework to be used in conjunction with scientific applications, big data applications and I/O systems. Successful candidates will work in a modern, virtual environment, with a distributed international team. All candidates are welcome to apply no matter their location. However, for this particular position, preference may be given to someone residing in or willing to relocate to the UK. Responsibilities include design, implementation in Haskell and in C, testing, infrastructure development, and optionally formal verification. We provide training in advanced processes for software design and implementation, as well as domain specific knowledge. Required skills: - Very strong background in computer science or mathematics. - Experience with Haskell, or network and cluster programming in other functional languages (e.g. Erlang, OCaml, Clojure). - Knowledge of systems programming and operating systems. Experience in one or more of the following areas is desirable: - Experience in distributed and/or parallel programming. - Knowledge of sophisticated distributed algorithms (fault tolerance, consensus, distributed transactions, etc). - Experience with delivering quality products on time and within budget. To apply, please send a resume to j...@parsci.com. About Parallel Scientific Parallel Scientific was founded by Dr Peter Braam in 2010. Peter formerly taught mathematics and computer science at Oxford and Carnegie Mellon. He then contributed file systems to Linux and invented Lustre (which provides storage to 9 of the top 10 systems in the world). He ran several successful startups, and Parallel Scientific is run by a very experienced management team and board. Our expertise is in the areas of distributed scientific parallel computing, compilers, domain specific languages, scalable computing for cloud and HPC, and the synthesis of hardware appliances. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Not working examples in GHC API documentation
Hi! Please take a look here: http://www.haskell.org/haskellwiki/GHC/As_a_library The examples are not working. Even the simpelst one: import GHC import GHC.Paths ( libdir ) import DynFlags ( defaultLogAction ) main = defaultErrorHandler defaultLogAction $ do runGhc (Just libdir) $ do dflags - getSessionDynFlags setSessionDynFlags dflags target - guessTarget test_main.hs Nothing setTargets [target] load LoadAllTargets throws: $ ghc -package ghc Main.hs [1 of 1] Compiling Main ( Main.hs, Main.o ) Main.hs:6:25: Couldn't match type `DynFlags' with `[Char]' Expected type: DynFlags.FatalMessager Actual type: DynFlags.LogAction In the first argument of `defaultErrorHandler', namely `defaultLogAction' In the expression: defaultErrorHandler defaultLogAction In the expression: defaultErrorHandler defaultLogAction $ do { runGhc (Just libdir) $ do { dflags - getSessionDynFlags; setSessionDynFlags dflags; } } Main.hs:7:7: Couldn't match expected type `DynFlags.FlushOut' with actual type `IO SuccessFlag' In a stmt of a 'do' block: runGhc (Just libdir) $ do { dflags - getSessionDynFlags; setSessionDynFlags dflags; target - guessTarget test_main.hs Nothing; setTargets [target]; } In the second argument of `($)', namely `do { runGhc (Just libdir) $ do { dflags - getSessionDynFlags; setSessionDynFlags dflags; } }' In the expression: defaultErrorHandler defaultLogAction $ do { runGhc (Just libdir) $ do { dflags - getSessionDynFlags; setSessionDynFlags dflags; } } ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Not working examples in GHC API documentation
I filed a bug a while back: http://ghc.haskell.org/trac/ghc/ticket/7752 Someone that understands the API needs to fix the doc. :) On Thu, Jul 18, 2013 at 7:58 PM, John Blackbox blackbox.dev...@gmail.com wrote: Hi! Please take a look here: http://www.haskell.org/haskellwiki/GHC/As_a_library The examples are not working. Even the simpelst one: import GHC import GHC.Paths ( libdir ) import DynFlags ( defaultLogAction ) main = defaultErrorHandler defaultLogAction $ do runGhc (Just libdir) $ do dflags - getSessionDynFlags setSessionDynFlags dflags target - guessTarget test_main.hs Nothing setTargets [target] load LoadAllTargets throws: $ ghc -package ghc Main.hs [1 of 1] Compiling Main ( Main.hs, Main.o ) Main.hs:6:25: Couldn't match type `DynFlags' with `[Char]' Expected type: DynFlags.FatalMessager Actual type: DynFlags.LogAction In the first argument of `defaultErrorHandler', namely `defaultLogAction' In the expression: defaultErrorHandler defaultLogAction In the expression: defaultErrorHandler defaultLogAction $ do { runGhc (Just libdir) $ do { dflags - getSessionDynFlags; setSessionDynFlags dflags; } } Main.hs:7:7: Couldn't match expected type `DynFlags.FlushOut' with actual type `IO SuccessFlag' In a stmt of a 'do' block: runGhc (Just libdir) $ do { dflags - getSessionDynFlags; setSessionDynFlags dflags; target - guessTarget test_main.hs Nothing; setTargets [target]; } In the second argument of `($)', namely `do { runGhc (Just libdir) $ do { dflags - getSessionDynFlags; setSessionDynFlags dflags; } }' In the expression: defaultErrorHandler defaultLogAction $ do { runGhc (Just libdir) $ do { dflags - getSessionDynFlags; setSessionDynFlags dflags; } } ___ 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] Not working examples in GHC API documentation
Great, but how can we learn the API, when examples are not working? -.- 2013/7/18 Johan Tibell johan.tib...@gmail.com I filed a bug a while back: http://ghc.haskell.org/trac/ghc/ticket/7752 Someone that understands the API needs to fix the doc. :) On Thu, Jul 18, 2013 at 7:58 PM, John Blackbox blackbox.dev...@gmail.com wrote: Hi! Please take a look here: http://www.haskell.org/haskellwiki/GHC/As_a_library The examples are not working. Even the simpelst one: import GHC import GHC.Paths ( libdir ) import DynFlags ( defaultLogAction ) main = defaultErrorHandler defaultLogAction $ do runGhc (Just libdir) $ do dflags - getSessionDynFlags setSessionDynFlags dflags target - guessTarget test_main.hs Nothing setTargets [target] load LoadAllTargets throws: $ ghc -package ghc Main.hs [1 of 1] Compiling Main ( Main.hs, Main.o ) Main.hs:6:25: Couldn't match type `DynFlags' with `[Char]' Expected type: DynFlags.FatalMessager Actual type: DynFlags.LogAction In the first argument of `defaultErrorHandler', namely `defaultLogAction' In the expression: defaultErrorHandler defaultLogAction In the expression: defaultErrorHandler defaultLogAction $ do { runGhc (Just libdir) $ do { dflags - getSessionDynFlags; setSessionDynFlags dflags; } } Main.hs:7:7: Couldn't match expected type `DynFlags.FlushOut' with actual type `IO SuccessFlag' In a stmt of a 'do' block: runGhc (Just libdir) $ do { dflags - getSessionDynFlags; setSessionDynFlags dflags; target - guessTarget test_main.hs Nothing; setTargets [target]; } In the second argument of `($)', namely `do { runGhc (Just libdir) $ do { dflags - getSessionDynFlags; setSessionDynFlags dflags; } }' In the expression: defaultErrorHandler defaultLogAction $ do { runGhc (Just libdir) $ do { dflags - getSessionDynFlags; setSessionDynFlags dflags; } } ___ 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] Generating Haskell Code out of Haskell AST (GHC API)
Hi! I dont know GHC API very well, but I want to generate AST of a program using GHC API. Is there any standard method to generate Haskell code out of it? (something like print_this_for_me_please function? :D ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hoogle problems?
Hoogle has returned to live, thanks to the efforts to the new haskell.org admins. Thanks, Neil On Tue, Jul 16, 2013 at 4:33 PM, Neil Mitchell ndmitch...@gmail.com wrote: No idea why it has gone down, my guess is that the Apache rule that says treat it as a CGI script got changed to serve it as a file. In the meantime you can use a copy of Hoogle at: https://www.fpcomplete.com/hoogle Thanks, Neil On Mon, Jul 15, 2013 at 5:19 PM, Niklas Hambüchen m...@nh2.me wrote: OK, but why does it need to go down for migration? On Mon 15 Jul 2013 23:52:02 SGT, Daniel F wrote: The web site is migrating. IRC says: Topic for #haskell: haskell.org in the middle of migration; expect turbulence; use www.haskell.org ___ 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] HaskellWiki images disappeared
L.S., It looks like the HaskellWiki images have disappeared; can anybody repair this? (See for example http://www.haskell.org/haskellwiki/Special:MostLinkedFiles ) Regards, Henk-Jan van Tuyl -- Folding@home What if you could share your unused computer power to help find a cure? In just 5 minutes you can join the world's biggest networked computer and get us closer sooner. Watch the video. http://folding.stanford.edu/ http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming -- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ghc and jump table generation
I've been looking at the assembly code that ghc generates for simple pattern matching for situations like: foo :: Int - Int foo 1 = 3 foo 2 = 10 foo 3 = 2 foo 4 = 42 -- ... other random assignments and I noticed that it doesn't seem to generate a jump table (or even a table lookup) like, for instance, gcc would for this switch statement: int foo(int x) { switch (c) { case 1: return 3; case 2: return 10; case 3: return 2; case 4: return 42; // ... etc. } } Under -O3 ghc seems to produce a binary-search of the cases. Questions: Would generating a jump/lookup table for pattern matches like this (i.e. with a suitable density of cases) be beneficial? And, if so, would it be difficult to add to ghc? And would it be a good first project for someone who wants to get into the ghc code base (perhaps with some mentoring from the community?) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] catching IO errors in a monad transformer stack
Hello, I am writing a small application that uses a monad transformer stack, and I'm looking for advice on the best way to handle IO errors. Ideally I'd like to be able to perform an action (such as readFile file_that_does_not_exist), catch the IOError, and then convert it to a string error in MonadError. Here's an example of what I'm doing now: {-# LANGUAGE FlexibleContexts #-} import Control.Monad.Error import Control.Monad.State import System.IO.Error (tryIOError) catcher :: (MonadIO m, MonadError String m) = IO a - m a catcher action = do result - liftIO $ tryIOError action case result of Left e - throwError (show e) Right r - return r This does work as expected, but I get the nagging feeling that I'm missing an underlying pattern here. I have tried catch, catchError, and several others, but (unless I misused them) they don't actually help here. The tryIOError function from System.IO.Error is the most helpful, but I still have to manually inspect the result to throwError or return to my underlying monad. Since this has come up for me a few times now, I welcome any advice or suggestions on alternative approaches or whether this functionality already exists somewhere. Thanks! Eric ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [web-devel] Automatic error traces
Hi Greeg, All I created a repository in gitHub with the necessary code for generating execution traces in case of error: https://github.com/agocorona/control-monad-supervisor/blob/master/Demos/TraceExample.hs the code is {-# OPTIONS -F -pgmF MonadLoc #-} module Demos.TraceExample ( ) where import Control.Monad.Loc import Control.Monad.Supervisor.Trace import Control.Monad.Trans main= runTrace $ do liftIO $ print hello example example= if True then do liftIO $ print world liftIO $ undefined else liftIO $ print not there run It with runghc Demos/TraceExample.hs hello world TraceExample.hs: TRACE (error in the last line): main, Demos.TraceExample(Demos\TraceExample.hs): (23, 18) main, Demos.TraceExample(Demos\TraceExample.hs): (26, 4) example, Demos.TraceExample(Demos\TraceExample.hs): (30, 13) example, Demos.TraceExample(Demos\TraceExample.hs): (32, 15) exception: Prelude.undefined to show the generated trace. It is necessary to install the monadloc-pp and the monadloc packages. It uses Control.Monad.Supervisor which is the monad that execute the backtracking that generate the error trace after the error. ( I will upload it to Hackage soon). It uses also Control.Monad.Supervisor.Trace, that has a MonadLoc instance for the Supervisor monad. You can create a MonadLogger instance taking as example the MonadLoc one. 2013/7/17 Alberto G. Corona agocor...@gmail.com Hi Greeg. Nice I will publish the mechanism in a separate package once I clean it up At first sight, It is possible to use file-location and monad-logger with the traces instead of monadloc. In the meantime, I will advance to you a copy of the details in a separate mail. 2013/7/16 Greg Weber g...@gregweber.info That's great. We should collaborate on this. I wrote the file-location package and Michael Snoyman wrote monad-logger: both of these give file location information. I also added command tracing to Shelly (which could also benefit from this kind of thing) and recently released rollbar for error notification and would like to have as much line info as possible for that. On Tue, Jul 16, 2013 at 5:45 AM, Alberto G. Corona agocor...@gmail.comwrote: It is important to have execution traces in case of error. specially in server applications that run 24/7 such are web applications Thanks to the wonderful package monadloc by Pepe Iborra, now MFlow can generate a complete execution trace in case of error. The control-monad-exception uses monadLoc to generate stack traces, but MFlow makes use of his backtracking mechanism to generate a complete execution trace. Here I explain what and how: http://haskell-web.blogspot.com.es/2013/07/automatic-error-trace-generation-in.html The MFlow version that implements this is in gitHub. Not in hackage yet. https://github.com/agocorona/MFlow I´m quite proud of it since it is one of the things closest to magic that I have done. Feedback? I do not want to keep MFlow as a single person development. I think that it has many unique and nice features not available in other languages and frameworks, and it can be raised to a serious exploitation level by the Haskell community. This will attract people working in Industrial Web development to Haskell thanks to the edge in expressiveness and safety necessary for creating industrial solutions that Haskell has over other languages. It uses most other Haskell web developments blaze, wai, hamlet etc and there are many other things to come. monadLoc : http://hackage.haskell.org/package/monadloc -- Alberto. ___ web-devel mailing list web-de...@haskell.org http://www.haskell.org/mailman/listinfo/web-devel -- Alberto. -- Alberto. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ghc and jump table generation
Hi! 2013/7/18 Erik Rantapaa eranta...@yahoo.com I've been looking at the assembly code that ghc generates for simple pattern matching for situations like: foo :: Int - Int foo 1 = 3 foo 2 = 10 foo 3 = 2 foo 4 = 42 -- ... other random assignments and I noticed that it doesn't seem to generate a jump table (or even a table lookup) like, for instance, gcc would for this switch statement: int foo(int x) { switch (c) { case 1: return 3; case 2: return 10; case 3: return 2; case 4: return 42; // ... etc. } } Under -O3 ghc seems to produce a binary-search of the cases. Questions: Would generating a jump/lookup table for pattern matches like this (i.e. with a suitable density of cases) be beneficial? And, if so, would it be difficult to add to ghc? And would it be a good first project for someone who wants to get into the ghc code base (perhaps with some mentoring from the community?) I was just digging around in the native code generator so I have a few leads for you. GHC can already generate jump tables, look at genSwitch in compiler/nativeGen/X86/CodeGen.hs, and it is what a CmmSwitch gets compiled into. Follow that into the codeGen and you see CmmSwitch is only created in emitSwitch in StgCmmExpr.hs. You can follow that farther and see when that is invoked. I have no clue if it's a worthwhile thing to do. Try it and measure the impact. Niklas ___ 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] catching IO errors in a monad transformer stack
Hi Eric: The pattern may be the MonadCatchIO class: http://hackage.haskell.org/package/MonadCatchIO-transformers 2013/7/18 Eric Rasmussen ericrasmus...@gmail.com Hello, I am writing a small application that uses a monad transformer stack, and I'm looking for advice on the best way to handle IO errors. Ideally I'd like to be able to perform an action (such as readFile file_that_does_not_exist), catch the IOError, and then convert it to a string error in MonadError. Here's an example of what I'm doing now: {-# LANGUAGE FlexibleContexts #-} import Control.Monad.Error import Control.Monad.State import System.IO.Error (tryIOError) catcher :: (MonadIO m, MonadError String m) = IO a - m a catcher action = do result - liftIO $ tryIOError action case result of Left e - throwError (show e) Right r - return r This does work as expected, but I get the nagging feeling that I'm missing an underlying pattern here. I have tried catch, catchError, and several others, but (unless I misused them) they don't actually help here. The tryIOError function from System.IO.Error is the most helpful, but I still have to manually inspect the result to throwError or return to my underlying monad. Since this has come up for me a few times now, I welcome any advice or suggestions on alternative approaches or whether this functionality already exists somewhere. Thanks! Eric ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Alberto. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Generating Haskell Code out of Haskell AST (GHC API)
The package haskell-src-exts is a lot less intimidating if all you are trying to do is programmatically generate Haskell source: http://hackage.haskell.org/package/haskell-src-exts The base types are here: http://hackage.haskell.org/packages/archive/haskell-src-exts/1.13.5/doc/html/Language-Haskell-Exts-Syntax.html#t:Module This module has some helper function for generating parts of the AST: http://hackage.haskell.org/packages/archive/haskell-src-exts/1.13.5/doc/html/Language-Haskell-Exts-Build.html On Thu, Jul 18, 2013 at 1:11 PM, John Blackbox blackbox.dev...@gmail.com wrote: Hi! I dont know GHC API very well, but I want to generate AST of a program using GHC API. Is there any standard method to generate Haskell code out of it? (something like print_this_for_me_please function? :D ___ 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] Monad Transformer Space Leak
Did you file this as a bug? On Tue 23 Apr 2013 23:16:03 JST, Clark Gaebel wrote: I'm on 7.6.2, and it does. Oh no. - Clark On Tuesday, April 23, 2013, Tom Ellis wrote: On Tue, Apr 23, 2013 at 09:36:04AM +0200, Petr Pudlák wrote: I tested it on GHC 6.12.1, which wasn't affected by the recent ackermann bug, but still it leaks memory. I tested it on GHC 7.4.1 and I don't see any space leak. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org javascript:; 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] Monad Transformer Space Leak
No I haven't. - Clark On Thu, Jul 18, 2013 at 10:07 PM, Niklas Hambüchen m...@nh2.me wrote: Did you file this as a bug? On Tue 23 Apr 2013 23:16:03 JST, Clark Gaebel wrote: I'm on 7.6.2, and it does. Oh no. - Clark On Tuesday, April 23, 2013, Tom Ellis wrote: On Tue, Apr 23, 2013 at 09:36:04AM +0200, Petr Pudlák wrote: I tested it on GHC 6.12.1, which wasn't affected by the recent ackermann bug, but still it leaks memory. I tested it on GHC 7.4.1 and I don't see any space leak. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org javascript:; 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] Monad Transformer Space Leak
Sounds like a Real Good Thing to do :) On Fri 19 Jul 2013 11:10:25 JST, Clark Gaebel wrote: No I haven't. - Clark On Thu, Jul 18, 2013 at 10:07 PM, Niklas Hambüchen m...@nh2.me wrote: Did you file this as a bug? On Tue 23 Apr 2013 23:16:03 JST, Clark Gaebel wrote: I'm on 7.6.2, and it does. Oh no. - Clark On Tuesday, April 23, 2013, Tom Ellis wrote: On Tue, Apr 23, 2013 at 09:36:04AM +0200, Petr Pudlák wrote: I tested it on GHC 6.12.1, which wasn't affected by the recent ackermann bug, but still it leaks memory. I tested it on GHC 7.4.1 and I don't see any space leak. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org javascript:; 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] Monad Transformer Space Leak
Then I will. Going to double check on 7.6.3, first. Thanks for bringing this back to my attention. I forgot about it. :P Regards, - Clark On Thu, Jul 18, 2013 at 10:12 PM, Niklas Hambüchen m...@nh2.me wrote: Sounds like a Real Good Thing to do :) On Fri 19 Jul 2013 11:10:25 JST, Clark Gaebel wrote: No I haven't. - Clark On Thu, Jul 18, 2013 at 10:07 PM, Niklas Hambüchen m...@nh2.me wrote: Did you file this as a bug? On Tue 23 Apr 2013 23:16:03 JST, Clark Gaebel wrote: I'm on 7.6.2, and it does. Oh no. - Clark On Tuesday, April 23, 2013, Tom Ellis wrote: On Tue, Apr 23, 2013 at 09:36:04AM +0200, Petr Pudlák wrote: I tested it on GHC 6.12.1, which wasn't affected by the recent ackermann bug, but still it leaks memory. I tested it on GHC 7.4.1 and I don't see any space leak. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org javascript:; 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] Monad Transformer Space Leak
https://github.com/patperry/hs-monte-carlo/issues/9 On Thu, Jul 18, 2013 at 10:20 PM, Clark Gaebel cgae...@uwaterloo.ca wrote: Then I will. Going to double check on 7.6.3, first. Thanks for bringing this back to my attention. I forgot about it. :P Regards, - Clark On Thu, Jul 18, 2013 at 10:12 PM, Niklas Hambüchen m...@nh2.me wrote: Sounds like a Real Good Thing to do :) On Fri 19 Jul 2013 11:10:25 JST, Clark Gaebel wrote: No I haven't. - Clark On Thu, Jul 18, 2013 at 10:07 PM, Niklas Hambüchen m...@nh2.me wrote: Did you file this as a bug? On Tue 23 Apr 2013 23:16:03 JST, Clark Gaebel wrote: I'm on 7.6.2, and it does. Oh no. - Clark On Tuesday, April 23, 2013, Tom Ellis wrote: On Tue, Apr 23, 2013 at 09:36:04AM +0200, Petr Pudlák wrote: I tested it on GHC 6.12.1, which wasn't affected by the recent ackermann bug, but still it leaks memory. I tested it on GHC 7.4.1 and I don't see any space leak. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org javascript:; 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] catching IO errors in a monad transformer stack
Hi! The exception handling is a difficult thing. It is usually simple enough but sometimes it can be very difficult, especially when using continuations within the monadic computation. To feel it, I often remember how the exceptions are handled in the F# async workflow (the sources are open), but their approach should be slightly adopted for Haskell what I did in one my simulation library (as far as I understand, the IO exception cannot arise in a pure value; therefore IOException should be caught in another place, namely in the liftIO function). I'm not sure whether there is a common pattern for handling the exceptions (the mentioned MonadCatchIO instance contains a warning regarding ContT). Therefore it is reasonable to allow the programmer himself/herself to define these handlers through the type class. Thanks, David 19.07.2013, в 3:23, Alberto G. Corona написал(а): Hi Eric: The pattern may be the MonadCatchIO class: http://hackage.haskell.org/package/MonadCatchIO-transformers 2013/7/18 Eric Rasmussen ericrasmus...@gmail.com Hello, I am writing a small application that uses a monad transformer stack, and I'm looking for advice on the best way to handle IO errors. Ideally I'd like to be able to perform an action (such as readFile file_that_does_not_exist), catch the IOError, and then convert it to a string error in MonadError. Here's an example of what I'm doing now: {-# LANGUAGE FlexibleContexts #-} import Control.Monad.Error import Control.Monad.State import System.IO.Error (tryIOError) catcher :: (MonadIO m, MonadError String m) = IO a - m a catcher action = do result - liftIO $ tryIOError action case result of Left e - throwError (show e) Right r - return r This does work as expected, but I get the nagging feeling that I'm missing an underlying pattern here. I have tried catch, catchError, and several others, but (unless I misused them) they don't actually help here. The tryIOError function from System.IO.Error is the most helpful, but I still have to manually inspect the result to throwError or return to my underlying monad. Since this has come up for me a few times now, I welcome any advice or suggestions on alternative approaches or whether this functionality already exists somewhere. Thanks! Eric ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Alberto. ___ 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