[Haskell-cafe] Improving GHC's LLVM Backend
Hello, I'm interested in improving the LLVM backend of GHC by using the existing Haskell LLVM bindings to the C API, as suggested by option 1 in the LLVM FAQ: http://llvm.org/docs/FAQ.html#i-d-like-to-write-a-self-hosting-llvm-compiler-how-should-i-interface-with-the-llvm-middle-end-optimizers-and-back-end-code-generators At the moment, the backend uses the option 2: emitting LLVM assembly code which is then assembled to LLVM bitcode, optimised, and compiled to machine code by standard LLVM tools. Changing this to use the Haskell FFI bindings to the LLVM C API would allow better tracking of any changes to the LLVM IR, and hopefully a reasonable speed increase by avoiding the overhead of first emitting LLVM Assembly to be assembled. In his bachelor's thesis, David Terei considered this approach when initially writing the LLVM backend, but dismissed it due to the existing Haskell bindings being too large and high level to use with GHC. I have not personally looked at the high level Haskell bindings in much depth, but the low level (llvm-base) bindings appear to be somewhat incomplete with respect to LLVM 3.3. Therefore, I plan to extend the FFI bindings to cover more or all of the C API, and then to modify the GHC LLVM backend to use these bindings to call into the LLVM libraries directly. http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/Backends/LLVMcontains a link to David's thesis, as well as documentation of the LLVM backend. I'd really appreciate it if anyone who knows about the Haskell LLVM bindings or about the GHC LLVM backend could give any advice regarding what sort of work needs to be done with the LLVM bindings to make them more appropriate for use within GHC, or how to approach modifying the existing LLVM backend. Many thanks, Alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Is OpenAL unqueueBuffers implemented correctly?
Hi, there's no maintainer listed for the OpenAL package, so I'm posting here in hopes of finding the right person. The unqueueBuffers function in Sound.OpenAL.AL.Source has the type Source - [Buffer] - IO () but I think the type should be Source - Int - IO [Buffer] This wraps the function alSourceUnqueueBuffers which uses the array of buffers as an output argument. With the current implementation, it's impossible to get the list of buffers that were unqueued. This implementation works the way I expect: unqueueBuffers :: AL.Source - Int - IO [AL.Buffer] unqueueBuffers source nbuffers = allocaArray nbuffers $ \ptr - do alSourceUnqueueBuffers source (fromIntegral nbuffers) ptr peekArray nbuffers ptr I just started using OpenAL, so I might be misunderstanding how this is supposed to work. Thanks, Alex Midgley ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Strange behavior with listArray
On Wed, Nov 14, 2012 at 07:39:33AM -, o...@okmij.org wrote: dimensional memo table. Luckily, our case is much less general. We do have a very nice dynamic programming problem. The key is the observation k' : solveR (i+1) k' After a new element, k', is produced, it is used as an argument to the solveR to produce the next element. This leads to a significant simplification: solve2 :: String - Array Int Int solve2 w = pI where h = length w - 1 wa = listArray (0, h) w pI = listArray (0,h) $ 0 : [ solveR i (pI!(i-1)) | i - [1..] ] solveR :: Int - Int - Int solveR i k = let c = wa!i in if k 0 wa!k /= c then solveR i (pI!(k-1)) else let k' = if wa!k == c then k + 1 else k in k' t2s1 = solve2 the rain in spain t2s2 = solve2 t2s3 = solve2 abbaabba My hat's off to you, sir. This is kind of interesting -- I would normally consider this indexing transformation as an approach for defeating memoization, yet in this case it serves as the key that makes the broader memoization possible, lifting it up a level. Thanks! Alex P.S. A side benefit of this approach is that it's easy to switch from listArray to array, since we already have the index handy. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Strange behavior with listArray
On Tue, Nov 13, 2012 at 08:06:59AM -, o...@okmij.org wrote: Alex Stangl posed a problem of trying to efficiently memoize a function without causing divergence: ... But the problem can be fixed: after all, f k is a list of integers. A list is an indexable collection. Let us introduce the explicit index: import Data.Array((!),Array,elems,listArray) import Data.List(intercalate) solve = (intercalate . map show . elems) a where a :: Array Int Int a = listArray (0, 3) (0 : [f 0 i | i - [0..]]) f 0 0 = 0 f 0 i = f 1 (i-1) f k i = f (a!0) i This converges. Here is a bit related problem: http://okmij.org/ftp/Haskell/AlgorithmsH.html#controlled-memoization Hi Oleg, That works well for the trivial toy test case that I reduced it down to, however it's not clear that it works well for the general case in which significant state is carried across the generation of the successive list elements. To make this concrete, here is the real solve function, which computes a border array (Knuth-Morris-Pratt failure function) for a specified string, before the broken memoization modification is made: solve :: String - String solve w = let h = length w - 1 wa = listArray (0, h) w pI = 0 : solveR (tail w) 0 solveR :: String - Int - [Int] solveR [] _ = [] solveR cl@(c:cs) k = if k 0 wa!k /= c then solveR cl (pI!!(k-1)) else let k' = if wa!k == c then k + 1 else k in k' : solveR cs k' in (intercalate . map show) pI Here solveR corresponds to f in the toy program and pI is the list I would like to memoize since references to earlier elements could get expensive for high values of k. It is not obvious to me how to apply your index transformation to this, such that what you end up with isn't worse than what we started with. Thanks, Alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Strange behavior with listArray
On Mon, Nov 12, 2012 at 08:36:49AM +0100, Bas van Dijk wrote: On 12 November 2012 04:50, Alex Stangl a...@stangl.us wrote: I'm stymied trying to figure out why the program below blows up with loop when I use f 0 If you replace the a!0 in f by its value 0, f is equivalent to: f k = if k 0 then f 0 else 0 : f 1 Do you see the loop now? I realize it loops/recurses, just like h does, or any instance of building lazy infinite data structures. It works fine when you only extract a finite number of elements from the infinite structure. It's not clear why that is not happening here, as if there is a failure of laziness. f 0 should effectively yield [0, 0, ...], correct? Maybe you meant f to be: f k = if k 0 then f (a!k) else 0 : f 1 Actually it was that way in the original program. I switched it to 0 the process of trying to distill it down to a simplest test. Either way yield the same result, loop. If you take the array reference out, this code works fine, as it obviously should. But with the array reference intact, it appears listArray isn't accessing the list lazily enough. Thanks, Alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Strange behavior with listArray
On Mon, Nov 12, 2012 at 02:52:28PM +0100, Daniel Fischer wrote: The problem, Alex, is that f k = if k 0 then f (a!0) else 0 : f 1 is strict, it needs to know the value of (a!0) to decide which branch to take. But the construction of the array a needs to know how long the list (0 : f 0) is (well, if it's at least four elements long) before it can return the array. So there the cat eats its own tail, f needs to know (a part of) a before it can proceed, but a needs to know more of f to return than it does. g and h are not strict, they simply let the construction write thunks into the array elements, and those can then later be evaluated after the construction of a has returned. Thanks for the thoughtful, detailed answer. If you have a function like f that has conditional logic, and accesses earlier elements in the list stream, can this be memoized? It appears that constructing an array via array or listArray won't work, nor does an IntMap. I can layer my list index [1] on top to speed up the list access, but this isn't as good as using an array. Thanks, Alex [1] http://github.com/astangl/list-index ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Strange behavior with listArray
I'm stymied trying to figure out why the program below blows up with loop when I use f 0 for building the array, but if I substitute g or h in place of f, they work fine. Is this a bug or am I overlooking something? I am using GHC 7.4.2. Thanks, Alex P.S. Forgive the seemingly pointless program; I distilled this test from a longer actual program that was exhibiting this behavior. import Data.Array((!),Array,elems,listArray) import Data.List(intercalate) solve = let a :: Array Int Int a = listArray (0, 3) (0 : f 0) f k = if k 0 then f (a!0) else 0 : f 1 g k = k : a!(k+1) : a!(k+1) : a!(k+2) : a!(k+3) : [] h k = a!k : h (k+1) in (intercalate . map show . elems) a main = putStrLn solve ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Building all possible element combinations from N lists.
On Fri, Oct 26, 2012 at 12:44:31AM +0400, dokondr wrote: I am looking for the algorithm and code better then the one I wrote (please Build all possible element combinations from N lists. Valid combination consists of k = N elements. Where each element of a single combination is taken from one of the N lists. combos [] = [[]] combos ([]:ls) = combos ls combos ((h:t):ls) = map (h:) (combos ls) ++ combos (t:ls) Drop last element if you don't want to include the empty set. It wouldn't be as elegant, but you can translate this to Java. Alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Building all possible element combinations from N lists.
On Thu, Oct 25, 2012 at 06:34:53PM -0400, Jake McArthur wrote: I golfed a bit. :) sequence = filterM (const [False ..]) I was thinking of golfing this myself tonight, but probably wouldn't have come up with this. Thanks for sparing me the effort. Bravo! Alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] testing if values can be applied to polymorphic functions
Hi all, A while ago I made an unusual visual front-end for Haskell: http://www.youtube.com/watch?v=5KtFlGEVFGE https://github.com/yaxu/texture It applies functions that are both proximal in Euclidean space, and type-compatible. It 'compiles' to Haskell, piped into ghci, but I (probably unwisely) wrote it in C, and ended up having to implement some crazed version of the Haskell type system there to get it working. Now I have idea for making this more interesting and practical (for live music-making, if nothing else), and would like to re-write it all in Haskell. Testing type compatibility of expressions is foxing me though. For example, say I have (++) and [1,2,3]. I then want to see if a value of type (Num a = [a]) can be applied to a function of type ([a] - [a] - [a]). I've been looking at Data.Typeable.funResultTy to do this, e.g.: funResultTy (typeOf ((++) :: [a] - [a] - [a])) (typeOf ([1,2,3] :: Num a = [a])) But I get this: Ambiguous type variable `a0' in the constraint: (Typeable a0) arising from a use of `typeOf' Being a bit more specific doesn't help: funResultTy (typeOf ((++) :: Typeable a = [a] - [a] - [a])) (typeOf ([1,2,3] :: (Typeable a, Num a) = [a])) I guess funResultTy doesn't work when polymorphism is involved.. Perhaps I could just use the ghc-as-a-library stuff to parse and typecheck code - would that be the way forward? Any pointers much appreciated! Best wishes alex -- http://yaxu.org/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Long pauses / idle time in a Haskell TCP server
Thanks for the tip Jamie! Setting NODELAY on the *client* resolved the problem; setting it on the server (both sockets) didn't make a difference. I'll see if I can figure out more about how this was going wrong - I did check the network traffic and the delay was at the server. But now I have a good setup to work with further. I did have your code from github, but from a while back, not long after you posted 0.2.2 to Hackage. I tinkered it a fair amount - stuff like where queues and worker threads are used, there are lots of options with that, especially given that thread creation is cheap so one doesn't necessarily need to use thread pools like in some other languages. Now I can play with those variations without distraction from long pauses. And I'll grab your latest from github and try that out. Thanks! Alex On Mon, Oct 8, 2012 at 6:41 PM, Jamie Turner ja...@bu.mp wrote: I'm seeing long pauses in a server based on the 'scalable-server' package from Hackage, version 0.2.2 [1]. It normally performs very well, about 100-150 micro-secs client latency over the loopback interface, but a fair number of requests are much slower, 38-40 milli-secs, making the mean latency and throughput quite bad. Hi Alex--author of scalable-server here. 38ms sounds like Nagle's algorithm. (http://en.wikipedia.org/wiki/Nagle's_algorithm) In short, the socket is waiting on sending a small amount of data to see if the application wants to send more data. If so, the kernel can repack the data together so that it all can be switched in one TCP packet. You need to set NoDelay (TCP_NODELAY) if you want to disable this behavior; scalable-server doesn't currently have a flag to configure this, but I'm open to pull requests! (Also, are you using hackage scalable-server, or the new scalable server based on conduit on github? I'd recommend switching to the github version if not. A few key bugs exist in the older implementation.) - Jamie ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Long pauses / idle time in a Haskell TCP server
Hello, I'm seeing long pauses in a server based on the 'scalable-server' package from Hackage, version 0.2.2 [1]. It normally performs very well, about 100-150 micro-secs client latency over the loopback interface, but a fair number of requests are much slower, 38-40 milli-secs, making the mean latency and throughput quite bad. The server is a simple version of a memory cache, with operations to put a key-value mapping, and to get the value for a key, using a data map. I've tried with the strict versions of 'unordered-containers' and the 'containers' package for the data map implementation, with similar results. I've tried it with ghc 7.4.1 and with 7.6.1 with similar results. Runtime info I got shows: - GC report: GC time is much less than the total time of the slow responses, so does not explain them. - CPU profile: Idle time is very high, and would explain the slow responses. By idle time I mean the part of wall time which is not included in the profile report's total time. For example, when running a test for 5 minutes, the profile report has total time = 0.05 secs. 'top' output is consistent - quite low CPU usage during such a test. Apart from this there is nothing notable in the profile, most time is spent in the network input and output processing (network-enumerator etc.). One observation is that the pauses seem correlated with overwriting entries in the data map. If I'm mostly adding new keys (as well as reading), the throughput is much better, and the idle time in the CPU profile is lower (though the time spent in GC increases a lot). I've removed all concurrency from the program (including my version of scalable-server) to eliminate that factor, but the problem persists. I tried it on two fairly different Linux machines, with similar results. The client I use to benchmark is a simple C program, so I don't suspect it of causing the pauses. Looking at the timestamps on the network traffic confirms that the pauses are at the server. Any idea what might be causing the idle time? The long pauses are consistently 38-40ms, maybe that points to some aspect of CPU scheduling, leaving the program idle for some time? I can put the code on github if it would help. Many thanks! Alex [1] http://hackage.haskell.org/package/scalable-server-0.2.2 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] List indexer
On Mon, Sep 17, 2012 at 10:24:07AM +0200, Edgar Klerks wrote: I find it useful. I benchmarked it with criterion and your test file (see below) and it is a *lot* faster: Maybe an elevator list is a nice name? Hi Edgar, Thanks for your input. I made a separate unit test and benchmark (using Criterion) and put it all on github, along with the latest version of the list index code. http://github.com/astangl/list-index Regards, Alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
On Fri, Sep 14, 2012 at 12:13:15PM -0400, Andrew Pennebaker wrote: I've gotten mixed feedback from Reddit for my tutorial. It provides an overview of how functional and declarative programming in Haskell empower baddies, increasing the accuracy and efficiency of their atomic superweapons. What do you guys think of my tutorial, Haskell for the Evil Genius http://www.yellosoft.us/evilgenius/? Hopefully you'll get more feedback here, although my recent post here soliciting feedback netted me nothing. FWIW, my feedback is below. Alex Under Declarative, you aren't creating a named expression, 2 + 2, really. You are redefining (+). Under Lazy, your example of binding fib 30 is not a good example of memoization. With memoization you typically call the underlying computation the first time, and memoize it for repeated retrieval later, not hardwire in values at compile time. Here you never ever call the real fib at all. On top of everything else, it'd be too easy to introduce a typo into one of your hardwired constant values. Under Infinite, you should use sieve (n:ns) pattern matching instead of calling head. Under Type-Safe Subtle distinction, but returning () is not the same as returning nothing at all. s/ommitted/omitted/ You've got an unusual indentation scheme. Consider adopting a more standard one for your tutorial. In general, monotonically decreasing is not sufficient to prove you will hit a base case. For example, decreasing by 5 would still be monotonically decreasing, and could jump right over your base cases. (Not arguing that the code is incorrect, but rather than your explanation is a little misleading/incomplete.) Again, further confusion about what memoization really is. Under Records Functions are already defined by their data structures; they are already semantically bundled... doesn't seem to make sense. ... acts on the specific constructor, blasting fools, murdering crowds... makes it sound like fireOn actually has side effects. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Tutorial: Haskell for the Evil Genius
is with Nat. But this type doesn't seem available out-of-the-box for Haskell users. It's not unusual for a function to be partially defined this way. You could equally well express the Fibonacci (or any) sequence as an infinite list. You can only use non-negative values for your list lookup, so if you view this as a deficiency, then the ubiquitous list shares the same deficiency. Noted and reflected... I'm trying to convey to an audience largely composed of Java and C++ fanatics how Haskell records are much better than OOP, how GADTs are more intuitive, robust, ... OOP doesn't even compare! That's what I'm trying to get across in that bit. And it's hard to do this in just a few sentences, especially when the reader isn't even familiar with GADTs in the first place. I meant to also mention in my previous email, your section on Records doesn't actually deal with what the Haskell community considers records (e.g., algebraic datatype with labelled fields.) You're just using a simple algebraic datatype, so it'd be better not to call it a record, as that's bound to lead to confusion. Now, besides the code and the description of the code, I know we're not English majors, but what do you think of the overall tone, pacing, etc.? Is it entertaining? Is it humorous? Is it boring? Is it offensive? Is it too brief or too laborious? Very subjective, but the evil genius thing doesn't work for me. I like the launch missiles analogy when discussing side-effects, but I don't care for it as the entire basis to wind a tutorial around. It is humorous, not boring. I find the pacing OK, but it's hard for me to put myself into the mindset of somebody encountering the material for the first time. Putting an appropriate quote under headings is a nice touch. Alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] List indexer
Hi, I have written a small wrapper to speed random-access to a list. The usage scenario I have in mind is a stream computation yielding an infinite list, and I want to randomly access elements w/o having to traverse the entire list from the beginning for each access. I suspected something similar must already exist, but nothing I looked at seemed to do the trick. IntMap seems to want a finite input list. Ditto for the various array types, except possibly dynamic array. Attached is the list indexer I came up with, and a small test program (I swap the commented-out lines to switch btw. list list index tests). I am interested to hear any feedback on this -- whether it duplicates something that already exists, or whether there's a better approach, and comments on the code, etc. Also if somebody can suggest a better name (so as not to overlay the word index too much.) I'll publish it on hackage (or at least github) if people think it's useful. It sped up the program I initally wrote it for enormously. Thanks, Alex {- | Module : ListIndex Description : list indexer, providing fast random list lookup Copyright : (c) Alex Stangl 2012 License : BSD3 Maintainer : a...@stangl.us Stability : unstable Portability : portable Wrap a list, providing faster access, like a skip-list. This was primarily written to wrap an infinite list, lazily building the index as the list is accessed. For finite lists, an array is probably a better choice. Fanout controls how much each level of the index jumps, or fans out from the previous level. 4, 8, 16, or 32 would be a good default choice for this, but feel free to experiment. Memory usage should be roughly proportional to accessed list size / (fanout - 1) -} module ListIndex (fromList, (!), LI) where -- | Type of index wrapping an underlying list data LI a = LI Int [LInode a] data LInode a = LiNonLeaf (LInode a) (LInode a) | LiLeaf (LInode a) [a] -- | Constructs index from specified list and fanout fromList :: [a] - Int - LI a fromList l fo = let topLevel = mkTopLevelNode l mkTopLevelNode l = LiLeaf (mkTopLevelNode (drop fo l)) l mkLevel plv = let lv = mkMidLevelNode plv in lv : mkLevel lv mkMidLevelNode l = LiNonLeaf (mkMidLevelNode (nodeDrop fo l)) l in LI fo (topLevel : mkLevel topLevel) -- drop i nodes from a linear node stream nodeDrop :: Int - LInode a - LInode a nodeDrop 0 n = n nodeDrop i n = let i' = i - 1 in case n of LiNonLeaf n' _ - nodeDrop i' n' LiLeafn' _ - nodeDrop i' n' -- | access specified element of underlying list using index to speed access (!) :: LI a - Int - a (!) (LI fo ns) i = let getLevel k (n : ns) = let (q,r) = k `quotRem` fo l = if q == 0 then n else parent $ getLevel q ns in nodeDrop r l parent (LiNonLeaf _ p) = p (q, r) = i `quotRem` fo (LiLeaf _ l) = getLevel q ns in l !! r -- Simple tests to check efficiency of ListIndex vs. direct -- list access for sequential access (via !!) and pseudorandom -- access. -- -- Alex Stangl import System.Random import ListIndex a = [1..] b = fromList a 4 testSequential = [(!) b n | n - [1,3..10]] --testSequential = [a!!n | n - [1,3..10]] randAccess = let seed = 12345813 g = mkStdGen seed hi = 1000 lst = [1,3..hi] lst' = fromList lst 32 nIter = 1000 randR _ 0 = [] randR g n = let (a,g') = randomR (0, hi `div` 2 - 1) g n' = n - 1 --in (lst!!a) : randR g' n' in (lst'!a) : randR g' n' in sum $ randR g nIter main = putStrLn $ show $ randAccess ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Using syntactic to implement the lambda calculus
(This is intended as a simplification of the problem I actually need to solve.) I'm trying to implement the lambda calculus (with CBV evaluation) using the syntactic package, in such a way that a simple extension is also simple to implement. I am stuck on the fact that it seems that the Value type needs to be parametrized over the Expr type and I can't seem to figure out how to do it. I've read this posthttp://www.haskell.org/pipermail/haskell-cafe/2011-May/091770.htmlfrom the archives, but I still seem to be missing something. Does anyone have any suggestions? -- Lambda calculus type Ident = String data Value = VLam Ident Expr data Expr = Var Ident | Lam Ident Expr | App Expr Expr eval :: Expr - Value eval e = case e of Var _ - error not closed Lam i e' - VLam i e' App e1 e2 - case eval e1 of Lam i e' - subst e' (eval e2) i _ - error illegal application -- Lambda calculus with integers and addition data Value = VLam Ident Expr | VInt Integer data Expr = Var Ident | Lam Ident Expr | App Expr Expr | Plus Expr Expr eval e = case e of ... Plus e1 e2 - case (eval e1, eval e2) of (VInt x1, VInt x2) - VInt $ x1 + x2 _ - error illegal addition -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] [Announce] AusHac 2012 - The Aussie Haskell Hackathon
We know many of you have been holding your breaths for this (hopefully none of you have passed out though!) for quite a while... but we’re pleased to announce that we’re finally getting around to announcing AusHac 2012! This year, we’re moving AusHac to Sydney proper: Atlassian has kindly offered the use of their offices next to Darling Harbour, so there’s more places to stay and eat than in previous years! It’s right across the harbour from Google’s headquarters where FP-Syd is hosted, and we’re starting on the Friday after next month’s FP-Syd. When: Friday 20th - Sunday 22nd of July Where: Atlassian 173/185 Sussex Street Sydney NSW 2000, Australia (02) 9262 1443 Map: http://goo.gl/maps/JoNg If you're looking for places to stay, check out AirBnB (http://www.airbnb.com), the prices are very reasonable (around $100/night within walking distance of Atlassian if you’re lucky). This year we’d like to see a few more talks on interesting things people are working on (Yes, the stuff you are working on IS interesting, and we want to hear about it!). If you’d like to give a talk, please let us know in the sign up sheet. Speaking of which, here it is: http://tinyurl.com/AusHac2012SignUp Please let us know if you’re considering coming along, so we can organise things like adequate power etc. We’d love for you to come along for the whole time or just a few hours, we’re happy for people to drop in when they want, on any day. The more people we have come along, the more awesome it will be. We hope to see you there! Cheers, Alex Mason and Ivan Miljenovic ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Using Data Types a la Carte
I'm trying to implement a set of languages with a large overlap between them. From what I understand, there are 3 main ways to do this: Finally Tagless, Data Types a la Carte, or manually. I'm currently leaning toward DTalaC, but not strongly. There seem to be two packages which implement the DTalaC style: syntactic and compdata. Alternatively, I can write the common code myself. Does anyone have recommendations for which one to use, and any materials for learning to use them? -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Loading a texture in OpenGL
It's possible ResourceT from the yesod guys could be quite useful. It allows you to manually release things, but also ensures that things are released in case of exceptions. It also supports, from what I can tell, some kind of reference counting for use with multiple threads (the deallocator isn't called unless all threads have released it, I think). Cheers, Alex On 8 February 2012 15:02, Clark Gaebel cgae...@csclub.uwaterloo.ca wrote: Sounds hairy. Is there any way to get reference counting garbage collection in Haskell? On Tue, Feb 7, 2012 at 9:26 AM, L Corbijn aspergesoe...@gmail.com wrote: On Tue, Feb 7, 2012 at 5:23 AM, Austin Seipp mad@gmail.com wrote: Just to clarify, this guarantee possibly could be made, ghc just doesn't do it now. In the past ghc never guaranteed a finalizer would ever be run. Regardless I would be wary of trusting finalizers to clean up very scarce resources. A malloc'd buffer is probably fine to have a finalizer for, texture objects or file descriptors are a different matter. Predictability matters in those cases. Sent from my iPhone^H^H^H^H^HPortable Turing machine On Feb 6, 2012, at 10:16 PM, Austin Seipp mad@gmail.com wrote: It's a precise GC of course (conservative collection would be madness considering how much memory Haskell programs chew through.) That still doesn't ensure your finalizer will run during the next GC even if all the references are gone by then. Sent from my iPhone^H^H^H^H^HPortable Turing machine On Feb 6, 2012, at 10:09 PM, Clark Gaebel cgae...@csclub.uwaterloo.ca wrote: Is the Haskell garbage collector conservative, or precise? If it's conservative, then this will only usually work. If it's precise, it should always work. On Mon, Feb 6, 2012 at 10:56 PM, Ben Lippmeier b...@ouroborus.net wrote: On 07/02/2012, at 2:50 PM, Clark Gaebel wrote: I would be running the GC manually at key points to make sure it gets cleaned up. Mainly, before any scene changes when basically everything gets thrown out anyways. From the docs: newForeignPtr :: FinalizerPtr a - Ptr a - IO (ForeignPtr a)Source Turns a plain memory reference into a foreign pointer, and associates a finalizer with the reference. The finalizer will be executed after the last reference to the foreign object is dropped. There is no guarantee of promptness, however the finalizer will be executed before the program exits. No guarantee of promptness. Even if the GC knows your pointer is unreachable, it might choose not to call the finaliser. I think people have been bitten by this before. Ben. ___ 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 You have to be really careful with automatic cleanup using finalizers. Not only to the mentioned not cleaning up of resources but also to deleting it too early. What could happen is that you code doesn't explicitly use (= call a GL function with it) an object after binding it. Then it could be seen as a dead pointer and be deleted by it's finalizer. But thereby it might unbind the object from the binding point. Maybe a (more) realistic example is using only one shader program, you create it once, call usePorgram with it and never change it after that. As there is no other program to use you don't have to reactivate the program with useProgram or have to change anything about it. So in effect it's not used by Haskell anymore and the finalizer is run for it deleting the program. For a program this is not a big problem as the OpenGL spec tells you that it isn't deleted immediately so you can use it afterwards. With textures it's different, the are deleted immediately, so you may think you have a texture bound but in reality the finalizer might have run and deleted the texture for you. So watch doing the OpenGL memory management using the references in Haskell, as you might accidentally delete objects ahead of time. Lars, P.S. To make it worse, the bound objects (programs, textures, etc.) can also be queried and thereby there are non dead objects automatically, but there is no Haskell reference to them so the GC cannot now this. ___ 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 -- Alex Mason ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] [ANNOUNCE] CoreErlang-0.0.2 + maintainer change
Hello, With the authors blessing, I'm taking over maintenance for http://hackage.haskell.org/package/CoreErlang, a parser/printer for an intermediate language for the Erlang VM. Changes in 0.0.2: - fixed float parse bug - added Data,Typeable instances to AST Package is rather esoteric, but it's nice for static source analysis - and when someone decides they want to compile a new language to the ERTS, the package is ready... Regards, Alex Kropivny ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Message
Short answer: no, and what it gives is quite different. Long answer: Erlang gives me two things that are hard to replicate: 1. firm-realtime performance, even at high load: the distributed GC is very nice 2. a very well defined model for handling, and recovering from failure Hot code reload is nice, but is mostly used as a bandaid for the multitude of bugs present with dynamic typing and a let it crash (minimal defensive programming, let process isolation handle bad cases by failing) approach. So it's absence in Haskell doesn't bother me. 1 is a personal preference that's been useful in a couple of projects. It's application specific and probably not a factor for most people, I just had a chance to enjoy it. 2 is solved in Erlang via techniques and know-how built up from years of practice and testing. High level abstractions like supervision trees, restart types, and gen_servers are well known. Most importantly, the correct way to use them to build robust systems is well known. This is definitely duplicateable, it just needs some time and lots of testing to reach the same level of trust I've got for Erlang. My Haskell code is mostly total, and avoids failure-in-the-small (stupid bugs) amazingly well. My Erlang code is an onion of recovery points, and avoids failure-in-the-large (hardware/link failures, nasty corner cases) amazingly well. CloudHaskell looks like it provides the fundamental abstractions needed to start building the onion, and bring Erlang's robustness to Haskell. Getting to the same point will take time and effort, but I think is possible. On Thu, Nov 3, 2011 at 9:09 PM, Ryan Newton rrnew...@gmail.com wrote: I have interfaced Erlang and Haskell... And delivered it as a product. I just came up with a dead-simple text based communication syntax from Erlang to Haskell that was very easily testable. It allowed for complete isolation Interesting. I can't imagine there are too many people who have done this. So I must ask -- given the explicit attempt to imitate Erlang in recent CloudHaskell work, does that come close to giving you everything you would have wanted in this app? (Hot code update being the big missing piece.) Cheers, -Ryan ___ 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] New CoreErlang maintainer + patch
Hello, I've got a patch [1] for the CoreErlang package. It fixes a parsing bug and adds Typeable+Data instances to the syntax tree. I was unable to contact the developers/maintainers via provided email. (No response in ~3 weeks.) The package hasn't been touched for three years, since first uploaded. I would like to take over maintenance of the package, and upload the fix ASAP. Regards, Alex Kropivny [1] https://github.com/amtal/CoreErlang/tree/0.0.2 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Message
Let's look at this from a high, project management level. Twitter ran on... Ruby initially? Facebook ran on PHP. Immediately this tells me that programming language choice wasn't a factor in their success. One succeeded in building a large throughput system with a slow language, the other succeeded in building a massively popular website with a bad one. What hard problems did they have to solve? Twitter had to deal with scalability, distribution, and massive throughput. These are hard problems on their own, and are non-trivial even in languages tailor made to handle them. (Although using Erlang would make things a good deal easier.) Facebook is not a technical problem at all. There are interesting challenges hidden within (ad targeting and friend feed optimization) but they're tiny, isolated components. Rapid development and prototyping of features help Facebook, but if the features are easy CRUD stuff it's perfectly cost effective to hire a pile of PHP developers to do them. One has problems that are hard regardless of tool choice, the other has no hard problems at all. No Haskell needed, use whatever language you can outsource overseas. With that in mind. Using Haskell gives you an edge, for most problems, even the ones with poor libraries. If you can get the programmer manpower you need, it is a clear advantage over your competition. Your startup may not need that advantage - as Facebook retrospectively didn't - but you don't know that when just starting out. If Facebook went deep into user behaviour analysis and newsfeed optimization, the way OkCupid has with dating, Haskell would suddenly stand out. If you need every advantage you can get, you use the best tools for the job. Haskell is one of the best and shiniest - I personally would use Erlang for any embarrassingly parallel parts of the service and do the rest in Haskell. On Fri, Oct 21, 2011 at 1:00 AM, Matti Oinas matti.oi...@gmail.com wrote: I don't think I'm going to write next twitter or facebook but yes, it is on my TODO list. If such an applications can be written with languages like PHP then why not. Can't think of any language that is worse than PHP but still there are lots of web applications written with that. Even I have written many using PHP. Why I would use Haskell? To see if it is better option to that problem than other languages. I have allready installed Yesod but for now I don't have enough time to work on this project. After 6 months the situation should be different. 2011/10/21 Michael Snoyman mich...@snoyman.com: This is clearly a job for node.js and the /dev/null data store, since they are so web scale~ Less sarcasm: I think any of the main Haskell web frameworks (Yesod, Happstack, Snap) could scale better than Ruby or PHP, and would use any of those in a heartbeat for such a venture. I'd personally use Yesod. I think data store would be a trickier issue. I'd likely use one of the key/value stores out there, possibly Redis, though I'd really need to do more research to give a real answer. Michael On Fri, Oct 21, 2011 at 9:42 AM, Yves Parès limestr...@gmail.com wrote: Wow, controversial point I guess... I would add: and if yes, what would you use and why? 2011/10/21 Goutam Tmv vo1d_poin...@live.com Would you ever see yourself write a web application like Twitter or Facebook in Haskell? ___ 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 -- /***/ try { log.trace(Id= + request.getUser().getId() + accesses + manager.getPage().getUrl().toString()) } catch(NullPointerException e) {} /***/ This is a real code, but please make the world a bit better place and don’t do it, ever. * http://www.javacodegeeks.com/2011/01/10-tips-proper-application-logging.html* ___ 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] Message
Yes I did, in detail. There are two trivial solutions I like: 1. The BERT library (http://bert-rpc.org/) uses Erlang terms for the protocol, and has straightforward mappings to Haskell equivalents. - Pros: trivial on both sides, Erlang terms are really good primitives to build a protocol from - Cons: Erlang likes using large (5 to 10 size) tuples and Haskell doesn't, protocol needs to take that into account 2. JSON over HTTP, Erlang's the server Haskell's the client. - Pros: discoverable, flexible, readable, language agnostic. - Cons: I don't really know how to use Haskell JSON libraries + which ones are good, and good REST API design can be tricky. For higher performance there are other options, but these are the ones I like most. I used 1 to decent effect when using QuickCheck to test an Erlang system. On Fri, Oct 21, 2011 at 8:02 AM, Yves Parès limestr...@gmail.com wrote: That's interesting, have you ever worked on interfacing Erlang with Haskell? BTW, Twitter switched to Scala, so obviously their initial choice of Ruby end up invalidated. 2011/10/21 Alex Kropivny alex.kropi...@gmail.com Let's look at this from a high, project management level. Twitter ran on... Ruby initially? Facebook ran on PHP. Immediately this tells me that programming language choice wasn't a factor in their success. One succeeded in building a large throughput system with a slow language, the other succeeded in building a massively popular website with a bad one. What hard problems did they have to solve? Twitter had to deal with scalability, distribution, and massive throughput. These are hard problems on their own, and are non-trivial even in languages tailor made to handle them. (Although using Erlang would make things a good deal easier.) Facebook is not a technical problem at all. There are interesting challenges hidden within (ad targeting and friend feed optimization) but they're tiny, isolated components. Rapid development and prototyping of features help Facebook, but if the features are easy CRUD stuff it's perfectly cost effective to hire a pile of PHP developers to do them. One has problems that are hard regardless of tool choice, the other has no hard problems at all. No Haskell needed, use whatever language you can outsource overseas. With that in mind. Using Haskell gives you an edge, for most problems, even the ones with poor libraries. If you can get the programmer manpower you need, it is a clear advantage over your competition. Your startup may not need that advantage - as Facebook retrospectively didn't - but you don't know that when just starting out. If Facebook went deep into user behaviour analysis and newsfeed optimization, the way OkCupid has with dating, Haskell would suddenly stand out. If you need every advantage you can get, you use the best tools for the job. Haskell is one of the best and shiniest - I personally would use Erlang for any embarrassingly parallel parts of the service and do the rest in Haskell. On Fri, Oct 21, 2011 at 1:00 AM, Matti Oinas matti.oi...@gmail.comwrote: I don't think I'm going to write next twitter or facebook but yes, it is on my TODO list. If such an applications can be written with languages like PHP then why not. Can't think of any language that is worse than PHP but still there are lots of web applications written with that. Even I have written many using PHP. Why I would use Haskell? To see if it is better option to that problem than other languages. I have allready installed Yesod but for now I don't have enough time to work on this project. After 6 months the situation should be different. 2011/10/21 Michael Snoyman mich...@snoyman.com: This is clearly a job for node.js and the /dev/null data store, since they are so web scale~ Less sarcasm: I think any of the main Haskell web frameworks (Yesod, Happstack, Snap) could scale better than Ruby or PHP, and would use any of those in a heartbeat for such a venture. I'd personally use Yesod. I think data store would be a trickier issue. I'd likely use one of the key/value stores out there, possibly Redis, though I'd really need to do more research to give a real answer. Michael On Fri, Oct 21, 2011 at 9:42 AM, Yves Parès limestr...@gmail.com wrote: Wow, controversial point I guess... I would add: and if yes, what would you use and why? 2011/10/21 Goutam Tmv vo1d_poin...@live.com Would you ever see yourself write a web application like Twitter or Facebook in Haskell? ___ 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
[Haskell-cafe] Is there a DFA library?
I couldn't find one on hackage that isn't better described as a RegEx library. I'm looking for things like minimization, completion, etc. kinda like http://www.cis.upenn.edu/~cis639/docs/xfst.html However, I may have just missed it. -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Regular Expression Parsing via derivatives
Hi Haskell people, I've been snooping through various mailing lists and the current Haskell implementation of regular expressions and I was wondering if there has been a discussion about implementing regex parsing with derivatives. If so, I haven't seen it. If not, I'd like to have a discussion about it -- if for no other reason than to decide whether I should implement it as a library, or (to attempt to implement it) as a core feature. For those of you who don't know, recent work by Might and Daraishttp://arxiv.org/abs/1010.5023indicates that parsing CFGs can be done better ( *i.e.*, significantly faster) than more traditional approacheshttp://swtch.com/%7Ersc/regexp/regexp1.html. Might's presenting at ICFP later in September about it. I guess the first thing I should ask is, which mailing list is actually the right place to field this inquiry. I considered dropping it in the main haskell list, but wasn't sure how people would respond. -- Alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Regular Expression Parsing via derivatives
Hmm. Not sure how I missed that. And, I also inquired about developing a core featre instead of a library -- implying disparity where in retrospect there doesn't appear to be any. That's too bad, but thanks for the helpful response! On Mon, Aug 1, 2011 at 12:26 PM, Antoine Latter aslat...@gmail.com wrote: On Mon, Aug 1, 2011 at 10:51 AM, Alex Clemmer clemmer.alexan...@gmail.com wrote: Hi Haskell people, I've been snooping through various mailing lists and the current Haskell implementation of regular expressions and I was wondering if there has been a discussion about implementing regex parsing with derivatives. If so, I haven't seen it. If not, I'd like to have a discussion about it -- if for no other reason than to decide whether I should implement it as a library, or (to attempt to implement it) as a core feature. For those of you who don't know, recent work by Might and Darais indicates that parsing CFGs can be done better (i.e., significantly faster) than more traditional approaches. Might's presenting at ICFP later in September about it. I guess the first thing I should ask is, which mailing list is actually the right place to field this inquiry. I considered dropping it in the main haskell list, but wasn't sure how people would respond. This is probably the right list to ask. I don't know much about the topic, a a quick Google search turned up: http://hackage.haskell.org/package/regex-pderiv which has the right keywords. More discussion on related (or not!) here: http://www.google.com/search?q=Regular+Expression+derivative+haskellie=utf-8oe=utf-8aq=trls=org.mozilla:en-US:unofficialclient=firefox-a Antoine -- Alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] yi + cabal-dev
From looking at Yi's code, there seems to be a hard-coded list of arguments to pass to ghc. A hack would be to recompile Yi with the arguments to use a different package database... On Wed, Jun 22, 2011 at 2:32 AM, Rogan Creswick cresw...@gmail.com wrote: On Tue, Jun 21, 2011 at 6:55 PM, Alex Rozenshteyn rpglove...@gmail.com wrote: More precisely, I'm trying to run yi in its own sandbox, created by cabal-dev. yi uses dyre to recompile its config file. Unsurprisingly, this fails, since ghc doesn't know anything about the yi install unless pointed to a separate package database. I'm not familiar with dyre, is there any way to tell it to use a specific package database? That *sounds* like it's the problem (since that's the bulk of what cabal-dev does... it establishes a fresh package db and hides the user db). --Rogan Has anyone gotten a similar setup to work, or does anyone have any suggestions? -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] yi + cabal-dev
Experimentation with that idea and the use of the strings command suggest that the full path to the ghc binary is used and is stored in the compiled Yi executable. I'd rather not replace the ghc binary with a shell script that determines if it's being called by Yi or not and then behaves differently. While amusing, I'd rather not. On Wed, Jun 22, 2011 at 3:42 AM, Rogan Creswick cresw...@gmail.com wrote: On Tue, Jun 21, 2011 at 11:59 PM, Alex Rozenshteyn rpglove...@gmail.com wrote: From looking at Yi's code, there seems to be a hard-coded list of arguments to pass to ghc. A hack would be to recompile Yi with the arguments to use a different package database... You may be able to create a 'ghc' shell script that invokes (the real) ghc with the correct --package-conf for Yi, then make a Yi script that sets up a custom path so that it finds your ghc script first. Lots of ifs, but at least you wouldn't have to maintain a Yi fork :) --Rogan On Wed, Jun 22, 2011 at 2:32 AM, Rogan Creswick cresw...@gmail.com wrote: On Tue, Jun 21, 2011 at 6:55 PM, Alex Rozenshteyn rpglove...@gmail.com wrote: More precisely, I'm trying to run yi in its own sandbox, created by cabal-dev. yi uses dyre to recompile its config file. Unsurprisingly, this fails, since ghc doesn't know anything about the yi install unless pointed to a separate package database. I'm not familiar with dyre, is there any way to tell it to use a specific package database? That *sounds* like it's the problem (since that's the bulk of what cabal-dev does... it establishes a fresh package db and hides the user db). --Rogan Has anyone gotten a similar setup to work, or does anyone have any suggestions? -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Alex R -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] yi + cabal-dev
I'm trying to run yi. More precisely, I'm trying to run yi in its own sandbox, created by cabal-dev. yi uses dyre to recompile its config file. Unsurprisingly, this fails, since ghc doesn't know anything about the yi install unless pointed to a separate package database. Has anyone gotten a similar setup to work, or does anyone have any suggestions? -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Category theory as a design tool
Funny, I didn't hear anyone say Candlejack. What abou ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] AusHac2011 - The Australasian Haskell Hackathon - July 8-10
It's almost that time of year again! Next month is the second annual AusHac event, at UNSW in Sydney, and you are invited! But if you want to come, we need to hear from you soon, as we need to organise access to the university network for you. If you're an Australian Haskell hacker, enthusiast, newbie or professional, we would love to see you there. Below is the announcement, if you have any questions, please just hit reply, and Ivan or I will get back to you. We would absolutely love to see you there if you can make it, we'd love for this year to be even more awesome than last year. -- Alex Mason -- Attention all Australasian Haskellers! After last year’s fantastic turnout for the first Australian Haskell Hackathon - AusHac 2010 - we’ve decided to organise another. As it’s rather boring to have a Hackathon with only two people, we encourage and welcome anyone interested in Haskell in Australia, New Zealand and surrounding areas (or further afield if you want!) to come and join us. Last year we had more than 25 Haskellers come from Brisbane, Canberra, Melbourne, Sydney and even two from as far away as New Zealand. AusHac 2011 will be held from Friday July 8th until Sunday July 10th, again at UNSW’s Computer Science building in Sydney. There’s no need to come for the entire weekend, just for whenever you’re able to. Last year, people worked on several projects including: • Accelerate: a high performance library for array computations using various backends (CUDA, LLVM, etc.) being written at UNSW. • Leksah: the Haskell IDE written in Haskell • DDC: the compiler for the Haskell-like language Disciple, which has strict evaluation by default, region, effect and closure typing and other interesting language features. • Hubris: the Haskell/Ruby bridge for calling Haskell from Ruby and vice-versa. • haskell-mpi: bindings to MPI, the message passing interface used frequently on high performance super-computers to allow programs to run on many nodes in parallel with easy communication. • There was even some work on LLVM to produce HTML output showing register allocations (as an aid to those writing new code generators etc.), which has now been included upstream. This work did not use Haskell, but it did happen at AusHac 2010. • And much more! This is a great chance to collaborate with others and get feedback on your work, while having heaps of fun and meeting other Haskellers, to verify they do actually exist! And don’t worry if you can’t think of a project to work on; just come along and pitch in with whatever strikes your fancy! If you’re interested in coming and have a project you’d like to work on, check out the wikipage http://www.haskell.org/haskellwiki/AusHac2011 where you can add your project ideas, or just take a look and see what others will be working on that you can help out with. People of all skill levels are welcome, from complete beginners to Oleg-level sage masters. We’re more than happy to help you learn Haskell if you’re just starting out or help you solve that little niggly bit in your code. If you’re interested in coming along, fill out our registration form http://axman6.wufoo.com/forms/aushac-2011-sign-up/. Registration is required so we know numbers and for you to get access to the university Wifi. Even if you’re not sure, fill it in to express your interest, obligation free. We’d rather know we have room for too many people than not enough. So come along! And if for some reason you don’t enjoy yourself, registration comes with a money-back guarantee! Hope to see you there, -- Alex Mason and Ivan Miljenovic, AusHac organisers -- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Erlang's module discussion
Regardless of how crazy it sounds, an idea from Joe Armstrong is worth seriously thinking over. This has bugged me before: think about how we design and write code as project size, or programmer skill grows. You start with composing statements inside a single function; later, you start to compose functions inside a single file; later you move on to composing modules; subsystems; systems... Different techniques, doing the same thing in different ways, depending on the level of complexity. Surely there's some unified approach that can replace them all? Erlang has the advantage of functions being the basic, composeable building block. Packages and modules are merely means to organize them, and mediocre means at that, so a better system is definitely a possibility. Haskell has the complication of having type definitions in addition to functions. On Sat, May 28, 2011 at 1:09 AM, Dmitry Vyal akam...@gmail.com wrote: On 28.05.2011 07:10, Tom Murphy wrote: Hi All, I sure love Hackage, but there's a very interesting discussion going on, on the Erlang mailing list, about completely restructuring the module-model. Before you dismiss it as crazy, know that the topic was brought up by Joe Armstrong, one of the creators of the language. Here's the archive: http://erlang.org/pipermail/erlang-questions/2011-May/058769.html Food for thought... Tom Hi Tom, sounds interesting! But seems to me this will raise current package dependencies problems on a new level. Now one sees modules and packages as some kind of aggregates, black boxes which supply useful functionality and hide non relevant complexity and tight dependencies. Moving to functions all the way down looks to me like a lowering level of abstraction. The meta information about the overall program structure would inevitably be lost. Dmitry ___ 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] Erlang's module discussion
Since no-one has yet mentioned it, and I think it might be relevant, http://types.bu.edu/seminar-modularity/first-class-modules-for-haskell.pdf I haven't read it with any degree of understanding, but I don't think it's tractable to remove modules from haskell, nor desirable. On Sat, May 28, 2011 at 6:17 AM, Brandon Allbery allber...@gmail.comwrote: On Sat, May 28, 2011 at 05:12, Alex Kropivny alex.kropi...@gmail.com wrote: Regardless of how crazy it sounds, an idea from Joe Armstrong is worth seriously thinking over. Possibly, but this is just another manifestation of a general problem that nobody has yet managed to solve very nicely. Admittedly, the way Erlang handles its function namespace, it's both easier to consider this (due to the only metadata being function name and arity) and somewhat sensible to do so (because of the relative lack of organization methods, coupled to the lack of metadata). This won't work for any language which needs to use type information in its metadata; it's a bad idea for Haskell and an absolute terror to contemplate for C++. This has bugged me before: think about how we design and write code as project size, or programmer skill grows. You start with composing statements inside a single function; later, you start to compose functions inside a single file; later you move on to composing modules; subsystems; systems... Different techniques, doing the same thing in different ways, depending on the level of complexity. Surely there's some unified approach that can replace them all? I'd start poking from the direction of (a generalization of) ML modules, to be honest. Said generalization would be a hierarchical, parameterizeable namespace, which you could operate on with (possibly meta-versions of) the usual Haskell morphisms: map/fmap, folds, zippers, etc. Or arrows if you prefer that way. Unfortunately, probably because I'm still pretty much a beginner at higher order thinking, when I try to make this notion concrete I end up with something rather Template Haskell-ish. This suggests that I should hand it off to someone named Oleg or Simon to chew on and see if it can be turned into something useful, usable, and practical ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parallel compilation and execution?
Hi Michael, OpenMP is a very different beast, and was developed to help get over the shortcomings that languages like C and FORTRAN have with respect to parallel and concurrent programming (pthreads were about all there was before OpenMP). OpenMP lets you specify regions of code that should be run in multiple threads at once, each with a unique ID. Here is an example of (part of) a parallel merge sort I've been working on static void pmergesort(long int * in, long int * tmp, long int n, int nthread) { long int nhalf = n/2; if(n = N_small) { insertsort1(in, n); return; } if(nthread 1) { #pragma omp parallel num_threads(2) { if(omp_get_thread_num() == 0) pmergesort(tmp, in, nhalf, nthread1); else pmergesort(tmp+nhalf, in+nhalf, n-nhalf, nthread1); } } else { mergesort3(tmp, in, nhalf); mergesort3(tmp+nhalf, in+nhalf, n-nhalf); } merge( tmp, in, nhalf, n); } The approach that Control.Concurrent takes is very different, preferring a style where the programmer says what things might be advantageous to run in parallel, but the runtime makes no guarantees that they will be, allowing the programmer to break work down into smaller chunks, and letting the runtime sort out which parts should be run concurrently. This allows for a much easier style of parallel programming, but is only really possible in a pure language like Haskell. On a side note, the Cilk language, which adds a small number of keywords like fork and sync to the C language takes an approach closer to what Control.Parallel does, but it's not a graceful, and IMO not as easy to use. Hope that helps. I've been having a lot of fun over the last few weeks playing with OpenMP for a university assignment, and I've got to say I greatly prefer the haskell way of doing things. Cheers, Alex Mason On 27/05/2011, at 10:23, michael rice wrote: Are the tools of Control.Parallel comparable to OpenMP? Michael --- On Thu, 5/26/11, michael rice nowg...@yahoo.com wrote: From: michael rice nowg...@yahoo.com Subject: Re: [Haskell-cafe] Parallel compilation and execution? To: David Virebayre dav.vire+hask...@gmail.com Cc: Daniel Fischer daniel.is.fisc...@googlemail.com, haskell-cafe@haskell.org Date: Thursday, May 26, 2011, 9:32 AM Fair question. I copied the parallel version from: http://www.haskell.org/ghc/docs/6.6/html/users_guide/lang-parallel.html but pulled the non-parallel version from a text. Michael --- On Thu, 5/26/11, David Virebayre dav.vire+hask...@gmail.com wrote: From: David Virebayre dav.vire+hask...@gmail.com Subject: Re: [Haskell-cafe] Parallel compilation and execution? To: michael rice nowg...@yahoo.com Cc: haskell-cafe@haskell.org, Daniel Fischer daniel.is.fisc...@googlemail.com Date: Thursday, May 26, 2011, 8:56 AM 2011/5/26 michael rice nowg...@yahoo.com Thank, Daniel Multiple threads are in evidence in my system monitor, but I wonder why I'm getting two different answers, one twice the other. The first is the parallel solution and the second is the non. Why do you add n1+n2+1 in the parallel program, but only n1+n2 in the non-parallel one ? Michael === {- import Control.Parallel nfib :: Int - Int nfib n | n = 1 = 1 | otherwise = par n1 (pseq n2 (n1 + n2 + 1)) where n1 = nfib (n-1) n2 = nfib (n-2) -} nfib :: Int - Int nfib n | n = 1 = 1 | otherwise = nfib (n-1) + nfib (n-2) main = do putStrLn $ show $ nfib 39 = [michael@hostname ~]$ ghc --make -threaded nfib.hs [1 of 1] Compiling Main ( nfib.hs, nfib.o ) Linking nfib ... [michael@hostname ~]$ ./nfib +RTS -N3 204668309 [michael@hostname ~]$ ghc --make nfib.hs [1 of 1] Compiling Main ( nfib.hs, nfib.o ) Linking nfib ... [michael@hostname ~]$ ./nfib 102334155 [michael@hostname ~]$ -Inline Attachment Follows- ___ 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] ANNOUNCE: iterIO-0.1 - iteratee-based IO with pipe operators
Hi All, I really love the look of this package, but if this is going be *the* iteratee package, I would absolutely love to see it fix some of the biggest mistakes in the other iteratee packages, soecifically naming. A change in naming for the terms iteratee, enumerator and enumeratee would go a hell of a long way here; Peaker on #haskell suggested Consumer/Producer/Transformer, and there is a lot of agreement in the channel that these are vastly better names. They’re also far less intimidating to users. I personally feel that maybe Transformer isn't such a great name (being closely associated with monad transformers), and that maybe something like Mapper would be better, but I'm by no means in love with that name either. More people in #haskell seem to like Transformer, and I don't think my argument against it is very strong, so the hivemind seems to have settled on the Producer/Transformer/Consumer trilogy. I'd love to hear thoughts on the issue, especially from David. Cheers, Alex Mason On 06/05/2011, at 20:17, Maciej Marcin Piechotka wrote: On Thu, 2011-05-05 at 21:15 -0700, David Mazieres wrote: Hi, everyone. I'm pleased to announce the release of a new iteratee implementation, iterIO: http://hackage.haskell.org/package/iterIO IterIO is an attempt to make iteratees easier to use through an interface based on pipeline stages reminiscent of Unix command pipelines. Particularly if you've looked at iteratees before and been intimidated, please have a look at iterIO to see if it makes them more accessible. Some aspects of iterIO that should simplify learning and using iteratees are: * Every aspect of the library is thoroughly document in haddock including numerous examples of use. * Enumerators are easy to build out of iteratees. * There is no difference between enumerators and enumeratees (i.e., inner pipeline stages). The former is just a type-restricted version of the latter. * Parsing combinators provide detailed error reporting and support LL(*) rather than LL(1) parsing, leading to fewer non-intuitive parsing failures. A couple of tricks avoid consuming excessive memory for backtracking. * Super-fast LL(1) parsing is also available through seamless integration with attoparsec. * A universal exception mechanism works across invocations of mtl monad transformers, thereby unifying error handling. * All pipe operators have uniform semantics, eliminating corner cases. In particular, if the writing end of a pipe fails, the reading end always gets EOF, allowing it to clean up resources. * One can catch exceptions thrown by any contiguous subset of stages in a pipeline. Moreover, enumerator exception handlers can resume downstream stages that haven't failed. * The package is full of useful iteratees and enumerators, including basic file and socket processing, parsec-like combinators, string search, zlib/gzip compression, SSL, HTTP, and loopback enumerator/iteratee pairs for testing a protocol implementation against itself. Please enjoy. I'd love to hear feedback. David 1. It looks nice - however it causes problem as we have 3 iteratees packages, all of which have some advantages. 4 if we count coroutine. (I don't count original implementations). 2. What is the reason of using Inum/Onum instead of Iteratee/Enumerator/Enumeratee. The latter seems to be a standard naming in the community? Regards ___ 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] Announcing AusHac 2011 - The second annual Australian Haskell Hackathon (July 8-10)
Attention all Australasian Haskellers! After last year’s fantastic turnout for the first Australian Haskell Hackathon - AusHac 2010 - we’ve decided to organise another. As it’s rather boring to have a Hackathon with only two people, we encourage and welcome anyone interested in Haskell in Australia, New Zealand and surrounding areas (or further afield if you want!) to come and join us. Last year we had more than 25 Haskellers come from Brisbane, Canberra, Melbourne, Sydney and even two from as far away as New Zealand. AusHac 2011 will be held from Friday July 8th until Sunday July 10th, again at UNSW’s Computer Science building in Sydney. There’s no need to come for the entire weekend, just for whenever you’re able to. Last year, people worked on several projects including: • Accelerate: a high performance library for array computations using various backends (CUDA, LLVM, etc.) being written at UNSW. • Leksah: the Haskell IDE written in Haskell • DDC: the compiler for the Haskell-like language Disciple, which has strict evaluation by default, region, effect and closure typing and other interesting language features. • Hubris: the Haskell/Ruby bridge for calling Haskell from Ruby and vice-versa. • haskell-mpi: bindings to MPI, the message passing interface used frequently on high performance super-computers to allow programs to run on many nodes in parallel with easy communication. • There was even some work on LLVM to produce HTML output showing register allocations (as an aid to those writing new code generators etc.), which has now been included upstream. This work did not use Haskell, but it did happen at AusHac 2010. • And much more! This is a great chance to collaborate with others and get feedback on your work, while having heaps of fun and meeting other Haskellers, to verify they do actually exist! And don’t worry if you can’t think of a project to work on; just come along and pitch in with whatever strikes your fancy! If you’re interested in coming and have a project you’d like to work on, check out the wikipage http://www.haskell.org/haskellwiki/AusHac2011 where you can add your project ideas, or just take a look and see what others will be working on that you can help out with. People of all skill levels are welcome, from complete beginners to Oleg-level sage masters. We’re more than happy to help you learn Haskell if you’re just starting out or help you solve that little niggly bit in your code. If you’re interested in coming along, fill out our registration form http://axman6.wufoo.com/forms/aushac-2011-sign-up/. Registration is required so we know numbers and for you to get access to the university Wifi. Even if you’re not sure, fill it in to express your interest, obligation free. We’d rather know we have room for too many people than not enough. So come along! And if for some reason you don’t enjoy yourself, registration comes with a money-back guarantee! Hope to see you there, -- Alex Mason and Ivan Miljenovic, AusHac organisers P.S: If you have received this email directly, it is because you have shown previous interest in AusHac by signing up via the previous signup. If you do not wish to receive any more email regarding AusHac, please email me (axm...@gmail.com) and I'll be sure to take you off the list of interested people. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Parsing Haskell in Parsec
Thank you, everyone, for the suggestions. On Mon, Mar 21, 2011 at 12:28 PM, Johannes Waldmann waldm...@imn.htwk-leipzig.de wrote: Alex Rozenshteyn rpglover64 at gmail.com writes: as part of a larger project of porting http://www.cs.jhu.edu/~scott/pl/book/dist/ from ocaml to Haskell. Nice idea. I was using a similar approach (interpreters for various semantic domains) in a course on semantics(+ compilation). I modelled it after the Turbak/Gifford book http://mitpress.mit.edu/catalog/item/?ttype=2tid=11656 (in fact after the book had been praised in this here mailing list, about two years ago). In fact the contents of these two books seem largely similar, and the following remark holds true: Using Haskell as an implementation language, you get a very nice addition: you can model the semantics domains by Monads, and it's very natural, (Identity monad = naive interpreter, Maybe monad = for exceptions e.g. division by zero, State monad = for assignment, Continuation passing monad = for CPS style programming). Now, neither of the books dare to use the M-word. Although Turbak is really doing monads: he is clearly defining several bind and return, he's just not naming them as such. You may browse my source code (quite unpolished) here http://dfa.imn.htwk-leipzig.de/cgi-bin/gitweb.cgi?p=ws10-cb/.git;a=tree and there's a parser as well (in the Exp directory). I'd be happy to get comments on my code as well. Would it look better with Monad transformers? And there's some amount of (tree walking) boilerplate that could perhaps be replaced by some template haskell magic. But then, magic is no good in teaching... Best regards, J.W. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Parsing Haskell in Parsec
I'm trying to write a parser for a small functional language in Parsec, as part of a larger project of porting thishttp://www.cs.jhu.edu/%7Escott/pl/book/dist/from ocaml to Haskell. I was wondering if there was a parser for Haskell written in Parsec that I could use as a reference. -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] X11 package bug: XClientMessageEvent long data
Does anyone know the current maintenance status of the X11 package? I emailed Spencer Janssen a number of months ago and never heard back. So, I'll put this here in case any one else runs into it or can get it to the right place. This is a proposed bug fix for a problem I ran into using xmonad client messages to send remote commands on 64LP architectures (i.e., amd64), wherein the C X11 library and Haskell's disagree about the size of client message arguments. Tue Nov 16 23:41:49 EST 2010 Dylan Simon dy...@dylex.net * change XClientMessageEvent long data The XClientMessageEvent.data.l field is actually a long, not an int, so it must be interpreted as such, even though format is set to 32 in this case. Ostensibly this is an Xlib bug, but it is unlikely to be fixed there. diff -rN -u old-src/Graphics/X11/Xlib/Extras.hsc new-src/Graphics/X11/Xlib/Extras.hsc --- old-src/Graphics/X11/Xlib/Extras.hsc2011-03-15 22:40:39.687844812 -0400 +++ new-src/Graphics/X11/Xlib/Extras.hsc2011-03-15 22:40:39.724522814 -0400 @@ -601,7 +601,7 @@ 16 - do a - peekArray 10 datPtr return $ map fromIntegral (a::[Word16]) 32 - do a - peekArray 5 datPtr - return $ map fromIntegral (a::[Word32]) + return $ map fromIntegral (a::[CLong]) _ - error X11.Extras.clientMessage: illegal value return $ ClientMessageEvent { ev_event_type= type_ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Abstracting a Genetic Algorithm
I've copied this from http://stackoverflow.com/questions/5010267/haskell-abstracting-a-genetic-algorithm as someone suggested that it might spark an interesting discussion I'm new to the world of Haskell programming and I'm cutting my teeth on a simple genetic algorithm for finding good solutions to the Travelling Salesman problem. I am representing the solutions as permutations on Integers and so I have this type synonym type Genome = [Int] The algorithm itself is a set of functions which operate on the solutions: mutation :: Genome - Genome selectParents :: [Genome] - [Genome] - [Genome] crossover :: Genome - Genome - (Genome, Genome) selectSurvivors :: [Genome] - [Genome] - [Genome] I'm not sure how much of my code is relevant to my question so please ask if more details are needed. One thing that might be worth mentioning is that the type signatures above are actually simplified, I am in fact using the State monad to carry around an StdGen so all of these functions actually return stateful computations. There are several things which I would like to do with this but can't quite get my head around. I want to make it possible to choose different representations for the solutions, it seems to me that this would be a natural place to use a type class, so that Genome would be the type class and [Int] a specific instance of this Genome. Now, I want to be able to experiment with the implementations, and I want to be able to use the code in other projects. Using a type class like this would require that every new algorithm I create would require me to create another instance of Genome, is this a good way to go about creating a library? One bonus question, just a thing that's been bothering me, is there any way to create something like a type synonym for a function so that if I'm writing a function which takes functions as arguments I can write the synonym rather than the whole type signature of the function i.e so that something like the following would work. type someFunc = [Int] - [Int] - Int someOtherFunc :: someFunc - [Int] - Int Right, hopefully that's a lucid enough explanation of the problem, feel like I've missed the really obvious answer but it hasn't jumped out at me. Cheers ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] parsing exercise
You might want to check out parsec, and the chapter related to it in RWH. http://book.realworldhaskell.org/read/using-parsec.html On Sun, Jan 23, 2011 at 12:09 AM, Sebastian Fischer fisc...@nii.ac.jpwrote: Hello, I need a function and wonder whether I can copy some existing code so I don't have to write it myself. It should split a string into a list of strings: splitAtTopLevelCommas :: String - [String] I need something similar to `splitOn ,` from the Text package with the property intercalate , . splitAtTopLevelCommas = id But it should split the string only on a few commas, not all. You can think of the result list as representations of Haskell values, for example splitAtTopLevelCommas True,(1,(2,[3,4])),Just ('a',\)\) should yield [True, (1,(2,[3,4])), Just ('a',\)\)] I expect writing this function to be quite tedious (ignore commas in parens, ignore parens in strings, quotation, ...) and would prefer to copy code from some parsing library. Do you have an idea what I could use? Or how to solve it from scratch in a few lines? Sebastian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] problem with haskell-mode mailing list?
Hello all Sorry for writing into this mailing list, but I couldn't get answer from supp...@community.haskell.org address because my mails are returned with errors. And I couldn't found The problem is that if I send mail to haskellmode-em...@projects.haskell.org my mails are not delivered to mailing list with error that google mail server couldn't connect to haskell.org's mail server. If somebody could help me with this problem, please contact me - I'll provide more details on this issue -- With best wishes, Alex Ott, MBA http://alexott.blogspot.com/http://alexott.net/ http://alexott-ru.blogspot.com/ Skype: alex.ott ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] What's the best seed for random API ?
Admittedly, I don't know much about this from the haskell end or about the particular api. If you want statistical randomness, your seed doesn't matter; just the PRNG. I might even have seeded with a constant or taken the seed from the user. Seeding from urandom will make your output more random for some unquantifiable meaning of the phrase. If you want cryptographic randomness, you probably shouldn't be writing your own library if you can avoid it. On Wed, Jan 5, 2011 at 7:21 PM, z_axis z_a...@163.com wrote: picoSec :: IO Integer picoSec = do t - ctPicosec `liftM` (getClockTime = toCalendarTime) return t rollDice :: Int - IO Int rollDice n = do ps - picoSec return $ (take 1 $ randomRs (1,n) $ mkStdGen $ fromInteger ps) !! 0 The above code uses `ctPicosec` as seed. Is it better to use the output of /dev/urandom as seed ? Sincerely! - e^(π.i) + 1 = 0 -- View this message in context: http://haskell.1045720.n5.nabble.com/What-s-the-best-seed-for-random-API-tp3329807p3329807.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 -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How about Haskell Golf just like vimgolf.com
Could a subreddit of some kind be used for this, or is a new site necessary? I can see a subreddit where people vote for problems they'd like to see elegant solutions to, then solutions are in the replies and get voted on. Might be tricky for larger solutions (you'd have to move them to git/gist or whatever) but would be amazing for learning good Haskell if it got off the ground! On Mon, Jan 3, 2011 at 8:19 AM, Ertugrul Soeylemez e...@ertes.de wrote: Alex Kropivny alex.kropi...@gmail.com wrote: Could something like code abstraction be done instead? Haskell lends itself to solving problems in really generic, high level ways that reveal a LOT about the underlying problem structure. Through some combination of descriptive data types, generic type classes, and generic helper functions... You get an extremely clear problem description. Example: https://github.com/amtal/snippets/blob/master/Key.hs (Haskell) versus http://siyobik.info/index.php?module=pastebinid=543 (C++) Clarity is a lot harder to score for, so you'd probably need to score things via votes. (Unless there's a way to measure how generic/high-level code is?) Such a site would fill a very nice role, that the programming language shootout definitely does not fill. Currently the only way to figure out what good Haskell code looks like is to browse lots of blogs, and dig through hackage until you find beautifully written packages. I really like this idea. New concepts in Haskell come up from time to time. Now if there was a competition for code quality and good ideas, they may become more frequent. Greets, Ertugrul -- nightmare = unsafePerformIO (getWrongWife = sex) http://ertes.de/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How about Haskell Golf just like vimgolf.com
Could something like code abstraction be done instead? Haskell lends itself to solving problems in really generic, high level ways that reveal a LOT about the underlying problem structure. Through some combination of descriptive data types, generic type classes, and generic helper functions... You get an extremely clear problem description. Example: https://github.com/amtal/snippets/blob/master/Key.hs (Haskell) versus http://siyobik.info/index.php?module=pastebinid=543 (C++) Clarity is a lot harder to score for, so you'd probably need to score things via votes. (Unless there's a way to measure how generic/high-level code is?) Such a site would fill a very nice role, that the programming language shootout definitely does not fill. Currently the only way to figure out what good Haskell code looks like is to browse lots of blogs, and dig through hackage until you find beautifully written packages. On Sun, Jan 2, 2011 at 9:20 AM, Brandon S Allbery KF8NH allb...@ece.cmu.edu wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 1/2/11 02:48 , C K Kashyap wrote: I found this site called http://vimgolf.com/ ... the idea there is that people come up with challenges and try to come up with the least number of keystrokes to get it done. Code golf in any language is generally a recipe for obfuscation. Interesting, certainly, but I don't think I'd recommend it as a service or feature. - -- brandon s. allbery [linux,solaris,freebsd,perl] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.11 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk0gs90ACgkQIn7hlCsL25XOAACfQhq2bb18442MYAROhnqZ3jJ6 b7kAoIaJ8LNsAdjlEHZDftAspWtUgJ43 =zjuv -END PGP SIGNATURE- ___ 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] Weird error during derive-2.3.0.2 build
Hi all. I am trying to install the yi editor using cabal-install, which in turns installs the package 'derive-2.3.0.2'. I get the following error during derive's compilation: [53 of 58] Compiling Data.Derive.Internal.Traversal ( Data/Derive/Internal/Traversal.hs, dist/build/Data/Derive/Internal/Traversal.o ) Data/Derive/Internal/Traversal.hs:34:0: Illegal instance declaration for `Applicative (Writer w)' (All instance types must be of the form (T t1 ... tn) where T is not a synonym. Use -XTypeSynonymInstances if you want to disable this.) In the instance declaration for `Applicative (Writer w)' cabal: Error: some packages failed to install: derive-2.3.0.2 failed during the building phase. The exception was: ExitFailure 1 Of course, I tried to build it with --ghc-option=-XTypeSynonymInstances, which in turn gives another compilation error. I am using ubuntu maverick 32-bit, with ghc-6.12.1 and cabal-install 0.8.2. The ghc was installed from the package repository. Cabal was installed using: cabal-install cabal Alex. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Question about TagSoup
I really wouldn't use tag soup for this. Haskell has libraries specifically for XML processing which might be better suited to your needs. On Fri, Dec 3, 2010 at 5:59 AM, David Virebayre dav.vire+hask...@gmail.comdav.vire%2bhask...@gmail.com wrote: Hello café, I have seen tutorials about extracting information from a tag soup, but I have a different use case: I want to read a xml file, find a tag, change its content, and write the xml file back. This is an example of the files ?xml version=1.0 encoding=UTF-8 standalone=yes? idPkg:Story xmlns:idPkg= http://ns.adobe.com/AdobeInDesign/idml/1.0/packaging; DOMVersion=7.0 Story Self=ub9fad AppliedTOCStyle=n TrackChanges=false StoryTitle=$ID/ AppliedNamedGrid=n StoryPreference OpticalMarginAlignment=false OpticalMarginSize=12 FrameType=TextFrameType StoryOrientation=Horizontal StoryDirection=LeftToRightDirection/ InCopyExportOption IncludeGraphicProxies=true IncludeAllResources=false/ ParagraphStyleRange AppliedParagraphStyle=ParagraphStyle/prix CharacterStyleRange AppliedCharacterStyle=CharacterStyle/$ID/[No character style] Contentzzznba5/Content /CharacterStyleRange /ParagraphStyleRange /Story /idPkg:Story Assuming I want to change the content of the Content tag, this is what I came up with (simplified), I'm using direct recursion. Is there a better way ? ts = do soup - parseTags `fmap` readFile idml/h00/Stories/Story_ub9fad.xml writeFile test $ renderTagsOptions renderOptions{optMinimize = const True} $ modif soup modif [] = [] modif (x@(TagOpen Content []):TagText _m : xs) = x : TagText modified : modif xs modif (x:xs) = x : modif xs David. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] date parsing and formatting
I've been working with Haskell's Date.Time modules to parse a date like 12-4-1999 or 1-31-1999. I tried: parseDay :: String - Day parseDay s = readTime defaultTimeLocale %m%d%Y s And I think it wants my months and days to have exactly two digits instead of 1 or 2... What's the proper way to do this? Also, I'd like to print out my Day in this format: 12/4/1999 what's the Haskell way to? Thanks for the help. Alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Layered maps
This came up as I was doing homework for natural language processing. I'm constructing a trigram model from training data, but I also need the bigram and unigram counts. I could, for each triple of characters, add the 3 tuple to a trigram map and increment its count (I know I'm not actually mutating anything), add the last two letters to a bigram map, and add the last character to a unigram map. But this looks very much like a tree... each node contains the character (the key) and list of characters that can appear after it. (I think this is a trie, but I don't know very much about tries.) The problem is that lookup is more horribly inefficient than I can stand, if I use lists. As for what constitutes convenient, I haven't thought about it that much; I just noted that my naive attempt was full of boilerplate and decided that since there was already python code provided I used that. I'm planning to port the code *after* I have the assignment finished. On Fri, Oct 8, 2010 at 11:18 PM, wren ng thornton w...@freegeek.org wrote: On 10/8/10 5:46 PM, Thomas DuBuisson wrote: Alex, The containers library can do this already - there are no constraints on the elements of a Map. For example: type TripleNestedMap a = Map Int (Map Char (Map String a)) But this is rather silly as you can just do: type MapOfTriples a = Map (Int ,Char, String) a for most uses. However, Map is a lot less efficient than IntMap when dealing with Ints. And the IntMap (IntMap ... a) type requires you to write (lookup m = ... = lookup n) instead of just one lookup. Unfortunately, when you're interested in performance issues, the standard tricks for implementing polyvariadic functions aren't very useful. FWIW, the monadic combinators are usually sufficient to create your own functions legiblely (e.g., using (=) for lookup), but it's still a lot noiser than it could be--- especially if you want a trie instead of a product map, since you have to add fst and snd everywhere. I've been playing around with some ad-hoc tries like these a lot lately, both for HMM tagging and for hunting down performance issues in bytestring-trie. -- Live well, ~wren ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Layered maps
Hmm. It seems that both the trie packages I found just provide a standard map-like interface, without exposing their trie-ness. Makes sense, but limits usefulness for me. Thanks. On Sat, Oct 9, 2010 at 3:08 PM, Jake McArthur jake.mcart...@gmail.comwrote: What you describe sounds like a perfect job for a trie, so that's what I think you should look into. - Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Layered maps
Does there exist a library which allows me to have maps whose elements are maps whose elements ... with a convenient syntax. Alternatively, does there exist a library like Data.Tree where forests are sets rather than lists? -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANNOUNCE: atomo 0.1, a simple, adventurous programming language
Over the past few months I've been designing and implementing a new language called Atomo. The idea is to build up a very expressive language from as few parts as possible, akin to Io or Scheme. But first, the fundamentals: prototype-based object-orientation with multiple dispatch and pattern-matching. Still here? Great! Being object-oriented and dynamic, I expect a few boos and hisses, but if you want to dive in, it's a lot of fun. :) An immense amount of progress has been made in a short amount of time. It already sports a powerful documentation system (similar to Racket's Scribble), and a package manager is in the works (it's functional, but it's local-only). For a while I had atomo-lang.org serving up a site powered by Atomo itself, with Snap underneath via Atomo's Haskell interface. It's down at the moment (it was wrestling with darcsden over my VPS's resources), but the docs are always available: Documentation: http://atomo-lang.org/docs/ (work-in-progress) Repository: http://darcsden.com/alex/atomo Examples: http://darcsden.com/alex/atomo/browse/examples I recommend the generators example if you want some mind-bending, or html.atomo for a nice EDSL, or web.(atomo|hs) for an example of Haskell interop. On Hackage: http://hackage.haskell.org/package/atomo Installation: `cabal install atomo` should just work, though I haven't worked out the appropriate version numbers for all of its dependencies yet. Hackage shows a build failure, but that seems to be caused by Haddock; I still haven't figured that out. If you want to get involved, you can find me on freenode in #atomo (and #haskell); my nick is alexsuraci. Or, you can fork the repository on darcsden. I'd just like to put this out there to see if anyone else is interested in playing with this. -- Alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Memoization/call-by-need
I feel that there is something that I don't understand completely: I have been told that Haskell does not memoize function call, e.g. slowFib 50 will run just as slowly each time it is called. However, I have read that Haskell has call-by-need semantics, which were described as lazy evaluation with memoization I understand that fib50 = slowFib 50 will take a while to run the first time but be instant each subsequent call; does this count as memoization? (I'm trying to understand Purely Functional Data Structures, hence this question) -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Google AI Challenge: Planet Wars - Accepting Haskell Submissions
The previous AI challenge (tron) was a lot of fun. I suspect the experience they gained from running the last one, will make this an exciting contest. Haskell fared well in the last contest, despite it favouring fast C/C++ implementations due to a focus on classic minimax/pruning. The current challenge looks more open-ended as far as solutions go, so hopefully there'll see even more Haskell submissions! :) On Fri, Sep 10, 2010 at 4:11 PM, Jake McArthur jake.mcart...@gmail.com wrote: Just wanted to let everybody know that there is an AI contest [1] that started today. Everybody has about two months to create bots that compete against each other 1-on-1 in a game based on Galcon [2]. A couple issues to mention for full disclosure: There is some sponsorship by Google, but unfortunately they aren't running the hardware, so the site is getting pretty hammered right now. We (it's all open source and open for contributions) are working to get it optimized to better handle the load. Also, the version of GHC on the server is very old (6.8.2) and isn't likely to get updated. I'm working to allow binary submissions though. If that goes through, you guys will be able to submit 64-bit Linux binaries rather than Haskell code to be compiled on the server. Just letting everybody know so the Haskell community can represent! - Jake [1] http://ai-contest.com [2] http://galcon.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] random-fu confusion
Okay, I figured the immutability bit out and I got the IORef example working, but I can't get it to work with state. put (pureMT 0) = runRVar flipCoin gives me two type errors: No instance for (MonadState PureMT m) and No instance for (RandomSource m ()) runState $ put (pureMT 0) = runRVar flipCoin runState $ put (pureMT 0) get = runRVar flipCoin put (pureMT 0) get = runRVar flipCoin and other desperate attempts, some of which in hindsight are too embarrassing to list give me similar errors. I'm trying to do figure out how to do this without going to the IO monad (so I can run it with the same seed to replicate results). On Tue, Sep 7, 2010 at 3:14 PM, James Andrew Cook mo...@deepbondi.netwrote: A PureMT generator is immutable, so must be threaded through the monad in which you are sampling. There are RandomSource instances provided for a few special cases, including IORef PureMT in the IO monad. For example: main = do mt - newPureMT src - newIORef mt flips - runRVar (replicateM 20 flipCoin) src print flips Alternatively, the functions in the module you mentioned can be used to define additional instances, such as: instance MonadRandom (State PureMT) where supportedPrims _ _ = True getSupportedRandomPrim = getRandomPrimFromPureMTState And RandomSource instances look almost the same. See the Data.Random.Source.PureMT source for examples. (I thought I had included this particular instance in the distribution but I apparently missed it. The next release will probably include this as well as corresponding instances for the 'transformers' package, possibly separated out into 'random-fu-mtl' and 'random-fu-transformers' packages). The StdRandom type is a convenient RandomSource designating this instance in the State PureMT monad. Personally, I prefer to use the sample function for this purpose, as well as the sampleFrom function in place of runRVar/runRVarT. GHCi does not display the sample functions' types properly - they are defined for RVarT as well as for all Distribution instances. Sorry it took so long responding. -- James On Sep 2, 2010, at 10:01 AM, Alex Rozenshteyn wrote: I seem to be having confusion at the runRVar level of random-fu. I can't figure out how to use the Data.Random.Source.PureMT module to get a meaningful random source (I can't get my code to type-check). I wrote a [trivial] flipCoin function flipCoin = uniform False True and am trying to fill in the final place of runRVar :t runRVar (replicateM 20 flipCoin) runRVar (replicateM 20 flipCoin) :: (RandomSource m s) = s - m [Bool] -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] random-fu confusion
I seem to be having confusion at the runRVar level of random-fu. I can't figure out how to use the Data.Random.Source.PureMT module to get a meaningful random source (I can't get my code to type-check). I wrote a [trivial] flipCoin function flipCoin = uniform False True and am trying to fill in the final place of runRVar :t runRVar (replicateM 20 flipCoin) runRVar (replicateM 20 flipCoin) :: (RandomSource m s) = s - m [Bool] -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Partial Signatures with Implicit Parameters
I would like to specify that a function takes implicit parameters, without specifying its full return type. My main motivation for this is my xmonad config file and the attempt to remove the need for NoMonomorphismRestriction and some of the code smell associated with global variables that wafts in with implicit parameters. I have read this: http://okmij.org/ftp/Haskell/partial-signatures.lhs and even somewhat understood it; however, I tried to apply it to my config file with an implicit parameter in the signature, and I couldn't get it to compile. Is there something inherently different about using this approach with implicit parameters, or am I probably just doing something wrong? P.S. I decided to ask this here instead of in the xmonad mailing list because I feel like this is a question about haskell that was only slightly inspired by my use of xmonad. -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Deprecated gtk2hs functions
I think that's a wonderful idea. {pe'i le sibdo ku xmagu} (pardon me if my lojban is horrible; I'm practicing). On Mon, Aug 16, 2010 at 8:19 AM, Andrew U. Frank fran...@geoinfo.tuwien.ac.at wrote: may i suggest that the description of the package, where it lists the depreciated functions, give also a hint, how the function should be replaced. i often hit the wall of depreciated functions when i try to use a packaged not having been compiled for a while and i have to replace the functions. then the searching starts... - if the information were included in the package description (automatically produced with haddock from a bit of text in the source code, written by somebody that did the change and has the information at his fingertips), it would save a lot of searching and failing upgrade experiences. gtk2hs is just a point in case, but it applies generally. any comments? andrew On Fri, 2010-07-16 at 17:44 -0400, Alex Rozenshteyn wrote: More like buttonActivated [1]. Has it been decided that button-specific events are going to be deprecated in favor of their general widget equivalents, with buttonActivated being an (IMO) awkward title for buttonClicked? [1] http://www.haskell.org/gtk2hs/docs/current/Graphics-UI-Gtk-Buttons-Button.html#v%3AbuttonActivated On Fri, Jul 16, 2010 at 3:20 PM, Thomas DuBuisson thomas.dubuis...@gmail.com wrote: You mean something like buttonPressEvent [1]? on button buttonPressEvent You can define signals, the constructor is exposed. [1] http://www.haskell.org/gtk2hs/docs/current/Graphics-UI-Gtk-Abstract-Widget.html#v%3AexposeEvent On Fri, Jul 16, 2010 at 11:36 AM, Alex Rozenshteyn rpglove...@gmail.com wrote: I recently started playing around with gtk2hs. I noticed that `onClicked`, `afterClicked`, etc. functions have been deprecated, presumably in favor of the `on` and `after` functions in the Glib signals module, but I couldn't find a collection of the appropriate signals to replace the functionality. Am I simply being blind? -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Alex R ___ 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 -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Couple of questions about *let* within *do*
On Tue, Aug 10, 2010 at 11:01:28AM -0700, michael rice wrote: Hi all, Then, do s1 s2 let x1 = e1 x2 = e2 s3 s4 let x3 = e3 x4 = e4 s5 s6 becomes do s1 s2 let x1 = e1 x2 = e2 in do s3 s4 let x3 = e3 x4 = e4 in do s5 s6? do s1 s2 let x1 = e1 x2 = e2 in do s3 s4 let x3 = e3 x4 = e4 in do s5 s6 HTH, Alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Suggestions For An Intro To Monads Talk.
On Fri, Aug 06, 2010 at 10:17:26AM -0500, aditya siram wrote: From my vantage point they are (in no particular order) : Reader, Writer, State, IO, ST, STM, Parsec (have I missed any?) and of course the transformer versions. I am debating whether or not to add [] to the bunch. Not sure how much time you have budgeted, but I'd start with a simple one like Maybe, actually show how to implement it, then move on to list, and then finally talk about Reader, Writer, State, etc. from a more high level perspective. Hopefully people would grok the monad concept by that point, and should realize how useful it is to add logging, or state, etc. Then they may wonder about mixing in more than 1, so that could lead to transformers. To explain monads (now that I have Timothy's awesome blog post to reference) I'll be drawing the parallel between monads and interfaces in Java. And thanks to Tillman for showing me where the analogy breaks down. Are there any such parallels in other languages like Perl and Python? I get the type class / Java interface analogy, but trying to draw a parallel between Java interface and monads seems likely to just create confusion IMHO. I'm still a little iffy on why the monad concept isn't used in other languages. From where I sit it seems as though monads really let you play with the order of evaluation - just because one statement is executed after another doesn't mean they are executed in that order. I think other languages don't make this easy. I first encountered monads in OCaml. And the concept exists in other languages, although maybe not always explicitly by that name. Good luck, should be a good talk, Alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Can we come out of a monad?
Here is my understanding with respect to the question. In the general case, you cannot come out of a monad, because the monad typeclass does not include any functions without of the form (m a - a). Also, as a category theoretic construct, a monad does not have to have an exit function. (caveat: I have a very limited grasp of what that means). I also found myself thinking about list as a monad in terms of this discussion. I think it's an interesting case: it's pure, but it doesn't really make sense to come out of it. Head, indexing, and last all break out of it, but none of them can be the default, and all of them require you to consider it as something more than its monad-ness. On Fri, Jul 30, 2010 at 3:11 PM, Stefan Holdermans ste...@vectorfabrics.com wrote: Martijn, In fact, I would argue that a monad which you cannot escape from is not very useful at all. IO is the only exception I know of. And that's only because, at least the runtime system allows for execution of a computation inside the IO monad at top-level. Cheers, Stefan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Heavy lift-ing
On Fri, Jul 23, 2010 at 11:43:08AM -0700, michael rice wrote: What does it mean to promote a function to a monad? It would seem that the monad values must understand the function that's being promoted, like Ints understand (+). Prelude Control.Monad liftM2 (+) (Just 1) (Just 1) Just 2 But how does one add [0,1] and [0,2] to get [0,2,1,3]? It depends upon the semantics of the particular monad. List monads represent nondeterminism. So, for example, [0,1] represents a 0 or 1, and [0,2] represents a 0 or 2. When you add 0 or 1 to 0 or 2, your possible answers are [0,2,1,3]. Alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Heavy lift-ing
On Fri, Jul 23, 2010 at 09:12:44PM -0500, aditya siram wrote: Lists are non-deterministic, but the function taken by liftM2 does not necessarily generate all possible outcomes. In the case of (+) it does, not in the case of (-): liftM2 (-) [0,1] [2,3] = [0-1,0-2,1-2,1-3] = [-2,-3,-1,-2] if all possible cases were generated between the two lists we have to include also: [2-0,2-1,3-0,3-1] If I have a - b where a and b are both non-deterministic, I wouldn't expect to also include in my solution set all the results of b - a. What if you have a / b? Would you try to include b / a, too, even though some values of a may be zero? Alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Deprecated gtk2hs functions
I recently started playing around with gtk2hs. I noticed that `onClicked`, `afterClicked`, etc. functions have been deprecated, presumably in favor of the `on` and `after` functions in the Glib signals module, but I couldn't find a collection of the appropriate signals to replace the functionality. Am I simply being blind? -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Deprecated gtk2hs functions
More like buttonActivated [1]. Has it been decided that button-specific events are going to be deprecated in favor of their general widget equivalents, with buttonActivated being an (IMO) awkward title for buttonClicked? [1] http://www.haskell.org/gtk2hs/docs/current/Graphics-UI-Gtk-Buttons-Button.html#v%3AbuttonActivated On Fri, Jul 16, 2010 at 3:20 PM, Thomas DuBuisson thomas.dubuis...@gmail.com wrote: You mean something like buttonPressEvent [1]? on button buttonPressEvent You can define signals, the constructor is exposed. [1] http://www.haskell.org/gtk2hs/docs/current/Graphics-UI-Gtk-Abstract-Widget.html#v%3AexposeEvent On Fri, Jul 16, 2010 at 11:36 AM, Alex Rozenshteyn rpglove...@gmail.com wrote: I recently started playing around with gtk2hs. I noticed that `onClicked`, `afterClicked`, etc. functions have been deprecated, presumably in favor of the `on` and `after` functions in the Glib signals module, but I couldn't find a collection of the appropriate signals to replace the functionality. Am I simply being blind? -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Comments on Haskell 2010 Report
On Wed, Jul 14, 2010 at 12:10:48PM +0100, Simon Marlow wrote: it is returning undefined:undefined:undefined, which is different from [undefined,undefined,undefined]. My mistake. I should have read more carefully. 25. In section 41.4.4, bullet before isPermissionError isn't rendered correctly. I can't see that - perhaps it has been fixed already. Check the failure codes for hSeek. It was still there in the HTML version, at least, when I checked this morning. Thanks, Alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Comments on Haskell 2010 Report
On Sat, Jul 10, 2010 at 12:12:15AM +0200, Julian Fleischer wrote: 8. [...] Saying 0**0 is undefined seems reasonable, but why 0**y? I agree on 0**y being 0 (not undefined), but why should 0**0 be undefined? x**0 := 1, by convention. Of course this is a still ongoing debate (regarding analysis of functions etc.), but the most usefull approach for /any/ programming language (and BTW for many mathematical proofs, too). Hi Julian, Glad somebody responded about something other than e.g. and i.e. I wasn't arguing that 0**0 *ought* to be undefined, but that it is a reasonable policy, since, as you point out, it's a matter of ongoing debate. What I don't understand is why for y /= 0, 0**y would be undefined. Maybe the discontinuity at zero is undesirable. Alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Comments on Haskell 2010 Report
based upon final version PDF created 7/6/2010 11:44:27 1. I.E. and e.g. should be followed by commas -- unless UK usage differs from US standards. (Page 3 and elsewhere, although FFI chapter seems to have the commas.) Also, inconsistent mix of British and American usage throughout (-ize and -ise, flavour, behaviour, behavior, analyse, color, colour, finaliser, finalizer, etc.) 2. Inconsistent spelling (lowercase/uppercase in section 1.4; lower-case/upper-case in section 2.4) 3. In section 3.11, boolean misspelled boolen. 4. LaTeX macros involving @ showing up in text. See sects 3.12, 6.4.2, 11.1, and in Chapter 9. 5. In section 3.15.2, reference to third bullet seems like it should be fourth bullet. 6. In section 3.17.2, the example that is supposed to return [undefined,undefined,undefined] seems like it really ought to return undefined, although I can see in the description above for ~apat matching where the other interpretation would hold. I actually tried this in GHC 10.4.2, binding the result to a variable and then applying the function length to it, and it comes back with undefined, whereas performing length [undefined,undefined,undefined] returns 3. So it appears that in this case, at least GHC 10.4.2 is returning undefined rather than [undefined,undefined,undefined]. 7. In section 6.3.4, [LT..] needs whitespace in the middle to parse correctly. 8. I'm curious about last part of section 6.4.3 that says 0**y is undefined. It seems to work reasonably under GHC, returning 0 in every case except 0**0, which returns 1 (the ^0 == 1 rule taking precedence, apparently.) Saying 0**0 is undefined seems reasonable, but why 0**y? 9. In section 6.4.6, statement about b^(d-1) = m b^d doesn't seem to hold when m 0. Should it be |m| in the equation, rather than m? 10. Section 7.1 uses function in places where it ought to use action. It seems more correct to describe print as returning an action that outputs a value. Most of the Input Functions (e.g., getChar, getLine, getContents, readLn) should be described as actions, not functions. It switches to using the term operation, which seems better, but then reverts back to function. 11. In section 8.4, variable misspelled varibale. 12. In section 8.5.1, in we require that chname ends on .h, on should be in. 13. Also in section 8.5.1, dependent misspelled dependant. 14. Last paragraph of section 8.5,1 has extra a -- ... defined to a accept a Following sentence has a semicolon where it should have a comma. 15. In section 10.3, (i.e. the programmer... has no closing paren. 16. In section 10.4, ... other lines are comment, comments sounds better. This occurs twice. 17. Also in section 10.6, anything misspelled anyything. 18. In Chapter 15, it would be more clear to describe bit i as producing a value with the ith bit set, and all other bits clear. 19. In section 20.3.1, caveats about finiteness of lists similar to ones given for and and or could also apply to any and all. Ditto for elem, notElem, etc. Maybe a single paragraph could summarize this short-circuiting behavior for all of them. 20. In heading for 20.9.2, quotes around Set are not balanced. Both are closing quotes. Ditto for 20.10.1, 20.10.2. 21. In section 29.1.1, finaliser and finalizer used in same paragraph. 22. In section 38.2, first occurrence of 'dual' has mismatched quotes. 23. In section 41.1, quotes around perform are mismatched. Word function is mildly misused again here. 24. In section 41.3.1, it would be nice to document what happens if act terminates abnormally, and then a secondary exception occurs during the closing of the handle. Oftentimes systems lose the primary exception and propagate out the secondary exception, whereas in reality we may be more interested in the original primary exception. 25. In section 41.4.4, bullet before isPermissionError isn't rendered correctly. Alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] AusHac2010, the first Australian Haskell Hackathon is growing near, and we need you!
AusHac2010 will be held from the 16th to the 18th of July at UNSW, where we'll be working on various haskell projects such as: The LLVM backend for GHC (I'm going to see if we can somehow get in contact with David T during the hackathon so we can discuss what can be done) A Generic graph class The Accelerate and Repa libraries for fast array computations Hubris, the Ruby-Haskell bridge (Mark's done some really awesome work here, but I'm sure could use some help) Leksah, the Haskell IDE written in Haskell MPI bindings, to either bring the previous package alive from its bitrotten state, or create a new one from scratch A Notification library for things like Growl and libnotify A Library re-builder, extending haskell-updater for use with cabal-install, Arch, etc. If you can come for any of the days we'll be hacking, we'd love to see you! But you'll need to sign up first (so you can get access to the UNSW wireless network). If you're not sure if you can make it, sign up anyway, you're not obliged to come, but mark yourself as only possibly being able to come. The signup page can be found at: Sign up!: [http://axman6.wufoo.com/forms/aushac-2010-sign-up-20/] See the AusHac2010 wiki page [http://www.haskell.org/haskellwiki/AusHac2010] for more details on what we'll be doing, and various other details. We've already got 20-30 people coming hopefully, but the more we have the better. If you've already signed up using the previous form, you we still need you to fill out this new 2.0 version of the sign up form If you have questions, please feel free to email me or Ivan (our addresses are the reply-to addresses for this email... I hope), or talk to us (Axman6, ivanm) on #haskell. Cheers, Alex Mason___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell on Debian
Anyone? On Wed, Mar 31, 2010 at 9:18 PM, Alex Rozenshteyn rpglove...@gmail.comwrote: $ ghc-pkg check outputs nothing $ ghc-pkg list unix /var/lib/ghc-6.12.1/package.conf.d unix-2.4.0.0 /home/alex/.ghc/x86_64-linux-6.12.1/package.conf.d unix appears to be in the build-depends of the Library, but not in the build-depends of Executable lambdabot Adding unix to the second build-depends appears to fix the error (but now it complains that base is hidden). On Wed, Mar 31, 2010 at 8:48 PM, Ivan Miljenovic ivan.miljeno...@gmail.com wrote: On 1 April 2010 11:42, Alex Rozenshteyn rpglove...@gmail.com wrote: Main.hs:11:7: Could not find module `System.Posix.Signals': It is a member of the hidden package `unix-2.4.0.0'. Perhaps you need to add `unix' to the build-depends in your .cabal file. Interesting, because unix _is_ listed in build-depends in the .cabal file for lambdabot. Does ghc-pkg check complain about unix? Does ghc-pkg list unix say it's there? I have a feeling this has something to do with the interaction between cabal and apt... Highly unlikely unless there's an inconsistency in the packages on your system. -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com -- Alex R -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell on Debian
I did try that; after adding a bunch of packages to the .cabal file and trying to build i get this: [ 1 of 81] Compiling Plugin.Dict.DictLookup ( Plugin/Dict/DictLookup.hs, dist/build/lambdabot/lambdabot-tmp/Plugin/Dict/DictLookup.o ) Plugin/Dict/DictLookup.hs:33:4: Ambiguous type variable `e' in the constraint: `GHC.Exception.Exception e' arising from a use of `handle' at Plugin/Dict/DictLookup.hs:33:4-42 Probable fix: add a type signature that fixes these type variable(s) cabal: Error: some packages failed to install: lambdabot-4.2.2.1 failed during the building phase. The exception was: ExitFailure 1 On Mon, Apr 5, 2010 at 11:25 AM, Daniel Fischer daniel.is.fisc...@web.dewrote: Am Montag 05 April 2010 17:19:35 schrieb Alex Rozenshteyn: Anyone? base isn't listed among the build-depends of the executable, so the obvious thing is to add base to the build-depends and see what happens then (might also be necessary for some other packages). I'm not sure whether iterating that strategy will get lambdabot to build or it's too bit-rotted, so prepare to dive into the sources if you really want it to build. On Wed, Mar 31, 2010 at 9:18 PM, Alex Rozenshteyn rpglove...@gmail.comwrote: $ ghc-pkg check outputs nothing $ ghc-pkg list unix /var/lib/ghc-6.12.1/package.conf.d unix-2.4.0.0 /home/alex/.ghc/x86_64-linux-6.12.1/package.conf.d unix appears to be in the build-depends of the Library, but not in the build-depends of Executable lambdabot Adding unix to the second build-depends appears to fix the error (but now it complains that base is hidden). On Wed, Mar 31, 2010 at 8:48 PM, Ivan Miljenovic ivan.miljeno...@gmail.com wrote: On 1 April 2010 11:42, Alex Rozenshteyn rpglove...@gmail.com wrote: Main.hs:11:7: Could not find module `System.Posix.Signals': It is a member of the hidden package `unix-2.4.0.0'. Perhaps you need to add `unix' to the build-depends in your .cabal file. Interesting, because unix _is_ listed in build-depends in the .cabal file for lambdabot. Does ghc-pkg check complain about unix? Does ghc-pkg list unix say it's there? I have a feeling this has something to do with the interaction between cabal and apt... Highly unlikely unless there's an inconsistency in the packages on your system. -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com -- Alex R -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] True Random Numbers
Does haskell have a way of using /dev/random to generate random *things*? Currently I'm just reading the data into a byte string, converting it into bits, and keeping track of it in the state monad. -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: True Random Numbers
The Rand monad you linked seems to be a step in the right direction for what I want, but it uses getStdGen, which appears to end up using cpu time to seed the generator. On Sat, Apr 3, 2010 at 9:21 AM, Ertugrul Soeylemez e...@ertes.de wrote: Matthew Hayden mrehay...@googlemail.com wrote: What's wrong with the System.Random.StdGen implementation of RandomGen?[1] (I'm not sure if it's cryptographically safe) It's a poor PRNG. And no, it's not anywhere near suitable for cryptographic applications. Someone (Cale IIRC) has already implemented a Rand monad[2] which is like a state monad but it keeps a RandomGen instead. http://hackage.haskell.org/package/MonadRandom by Cale Gibbard and others Greets, Ertugrul -- nightmare = unsafePerformIO (getWrongWife = sex) http://blog.ertes.de/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: True Random Numbers
Looking over the random-fu package, I think it might have what I'm looking for (and a lot that I'm not). On Sat, Apr 3, 2010 at 6:27 PM, Gökhan San g...@stillpsycho.net wrote: Alex Rozenshteyn rpglove...@gmail.com writes: The Rand monad you linked seems to be a step in the right direction for what I want, but it uses getStdGen, which appears to end up using cpu time to seed the generator. There's the random-stream package but looks like it's subject to code rot. Its RandomGen instance lacks the split functionality but I guess it could be used with MonadRandom. -- Gökhan San ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell on Debian
I tend to install haskell packages from apt whenever possible. One such package is unix, which appears to come provided by the ghc6 debian package. I'm trying to cabal install lambdabot and getting the following: $ cabal install lambdabot Resolving dependencies... Configuring lambdabot-4.2.2.1... Preprocessing executables for lambdabot-4.2.2.1... Building lambdabot-4.2.2.1... Main.hs:11:7: Could not find module `System.Posix.Signals': It is a member of the hidden package `unix-2.4.0.0'. Perhaps you need to add `unix' to the build-depends in your .cabal file. Use -v to see a list of the files searched for. cabal: Error: some packages failed to install: lambdabot-4.2.2.1 failed during the building phase. The exception was: ExitFailure 1 I have a feeling this has something to do with the interaction between cabal and apt... Does anyone have any advice for fixing this issue other than just adding unix to the lambdabot.cabal file? -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell on Debian
$ ghc-pkg check outputs nothing $ ghc-pkg list unix /var/lib/ghc-6.12.1/package.conf.d unix-2.4.0.0 /home/alex/.ghc/x86_64-linux-6.12.1/package.conf.d unix appears to be in the build-depends of the Library, but not in the build-depends of Executable lambdabot Adding unix to the second build-depends appears to fix the error (but now it complains that base is hidden). On Wed, Mar 31, 2010 at 8:48 PM, Ivan Miljenovic ivan.miljeno...@gmail.comwrote: On 1 April 2010 11:42, Alex Rozenshteyn rpglove...@gmail.com wrote: Main.hs:11:7: Could not find module `System.Posix.Signals': It is a member of the hidden package `unix-2.4.0.0'. Perhaps you need to add `unix' to the build-depends in your .cabal file. Interesting, because unix _is_ listed in build-depends in the .cabal file for lambdabot. Does ghc-pkg check complain about unix? Does ghc-pkg list unix say it's there? I have a feeling this has something to do with the interaction between cabal and apt... Highly unlikely unless there's an inconsistency in the packages on your system. -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] existentially quantified data types - restrictions
I think type witnesses *might* be relevant to your interests. On Thu, Mar 25, 2010 at 11:13 AM, andy morris a...@adradh.org.uk wrote: Can you have Typeable as an extra constraint? If so: {-# LANGUAGE ExistentialQuantification #-} import Data.Typeable data Baz = forall a. (Eq a, Typeable a) = Baz a instance Eq Baz where Baz x == Baz y = case cast y of Just y' - x == y' Nothing - False ghci Baz 4 == Baz 4 True ghci Baz 4 == Baz 5 False ghci Baz 4 == Baz 'a' False On 25 March 2010 15:07, Ozgur Akgun ozgurak...@gmail.com wrote: Dear Cafe, I need to use a language feature which is explicitly documented to be a restriction, and -even worse- I think I reasonably need to use it. f2 (Baz1 a b) (Baz1 p q) = a==q It's ok to say a==b or p==q, but a==q is wrong because it equates the two distinct types arising from the two Baz1 constructors. [from 7.4.4.4. Restrictions at http://www.haskell.org/ghc/docs/latest/html/users_guide/data-type-extensions.html ] To simplify, let's say Baz is the only constructor of a data type, data Baz = forall a. Eq a = Baz a -- | this cannot be done: instance Eq (Baz a) where (Baz x) == (Baz y) = x == y I am quite tempted to use show functions for this equality comparison, but after trying to have a nicely type framework I really don't want to do that. What I simply want is, haskell to be able to compare them if they belong to the same type, and return False otherwise. (not that haskelly way of doing things, I know.) Any suggestions better than the following are very welcome: (==) = (==) `on` show Regards, -- Ozgur Akgun ___ 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 -- Alex R ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANNOUNCE: AusHac2010
G'day all, Over the last few days, Ivan Miljenovic and I have been gauging interest in having an Australian Haskell Hackathon. After some rather encouraging interest, we've decided to get the ball rolling by making a wiki page that we can use to organise the event: [http://www.haskell.org/haskellwiki/AusHac2010]. If you're interested in coming, please put your name down on the list (or email me and I'll do it for you if you don't have an account). The more people we can get, the better it will be, and the more productive our work will be. So if you want to come along, play with some cool code, help out the community, and just meet an awesome bunch of like minded people, then we want to hear from you! Cheers, Alex Mason___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Proposal: Australian Hackathon
* A plotting library using Ben's newly released Gloss library (for people who can't or won't install Gtk2Hs to get Chart working; Alex Mason is interested in this) * Various graph-related project (graphviz, generic graph class, etc.; this assumes someone else apart from me cares about this stuff) * Hubris if Mark Wotton comes along * LLVM if David Terei comes I'd suggest focusing on core Haskell infrastructure, like compilers and tools, rather than individual libraries -- though it all depends on who wants to come along. I'm not interested too much in organising what we will get done until people get there. We'll spend an hour or two discussing which projects people would like to work on, and then probably split off into groups of like minded people. The projects mentioned above are just ones that Ivan and I could think of, to give others ideas of the sorts of things they could work on. If people have new projects they want to start and have input from others on design and coding, then that's fine by me. If they want to hack GHC and make it twice as fast, then they're more than encouraged to do so! Basically, we're just aiming to get a bunch of like minded people together, who want to hack on projects with some other people, possibly with the authors of the projects (for example, I might want help to work on the Accelerate library that Manuel, Gabriele and Sean have been working on, and being able to talk to them directly to find out how the code is all laid out and organised would be much much easier than trying to do the same thing over IRC for example.) So, at least as an initial listing, we'd need to have a listing of: 1) Who's interested 2) What dates are good 3) What projects people want to work on 4) Where we can host this You'll also want to consider how a proposed OzHaskell might align and/or combine with other events such as SAPLING[1] and fp-syd[2]. There is also the ICFP programming contest in a few months that many people will be interested in... The more people we can get in touch with, the better, we'd like to hear from all these groups, if for no better reason than to get the word out that such a thing might be happening... maybe, and to help gauge interest. The more people that know, the more pressure we can bring upon ourselves to get something organised. I was planning on forwarding this onto the FP-Syd list, but maybe I could ask you to do that Ben? These mailing list things are before my time, and I wouldn't have a clue what to do -_- Hosting is not a problem. If people want to come to Sydney then I'm sure we can organise a room at UNSW. We were kind of hoping that you or Manuel would say something like that ;) Not sure what more to say, other than if you're in Australia, and like Haskell, we'd really _really_ love to meet you. Cheers, -- Alex Mason Ben. [1] http://plrg.ics.mq.edu.au/projects/show/sapling [2] http://groups.google.com/group/fp-syd [3] http://www.icfpconference.org/contest.html ___ 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] Proposal: Australian Hackathon
Would other Australians be interested in having our own Hackathon (why should all those northerners have all the fun)? I'm thinking about organising it to be in the July break between university semesters. There was a previous consideration a few years back to have an OzHaskell group (http://www.haskell.org/haskellwiki/OzHaskell) but nothing seems to have eventuated out of it. In terms of projects, here are some ideas: * A plotting library using Ben's newly released Gloss library (for people who can't or won't install Gtk2Hs to get Chart working; Alex Mason is interested in this) * Various graph-related project (graphviz, generic graph class, etc.; this assumes someone else apart from me cares about this stuff) * Hubris if Mark Wotton comes along I'm keen. Would be be elated to have some help on Hubris, but happy to hack on other stuff too. Like Erik, weekends are probably better. Yeah we're aiming for a weekend, possibly a Friday-Sunday meet (so that people who are free on Friday can get started early, and those who have work etc. can just be there for the weekend. If there was a nicely placed long weekend coming up, we'd aim for that, but there isn't :( Also, it might be a good time to bring some interested rubyists along, and show them what we can get done in Haskell, and show them why they might want to use Hubris. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Prelude.undefined
2010/3/3 Tom Hawkins tomahawk...@gmail.com On Wed, Mar 3, 2010 at 6:07 AM, Ivan Miljenovic -Wall only complains about shadow bindings, defined but not used, and no type signature. But no unmatched patterns. If you can run your code through the ghc debugger you can get it to break when an undefined exception is raised. The options are :set -fbreak-on-exception or -fbreak-on-error. More info in the documentation at http://www.haskell.org/ghc/docs/latest/html/users_guide/ghci-debugger.html#ghci-debugger-exceptions Hope that helps, Alex MDC ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Simple but interesting (for me) problem
Hallo, On 10/21/09, Tim Wawrzynczak inforichl...@gmail.com wrote: Here's an example in the IO monad: import Data.IORef import System.IO.Unsafe counter = unsafePerformIO $ newIORef 0 next = do modifyIORef counter (+1) readIORef counter Naturally, this uses unsafePerformIO, which as you know, is not kosher... This is different because counter is global. Cheers, -- -alex http://www.ventonegro.org/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Creating an alias for a function
Hallo, On Tue, Oct 6, 2009 at 11:01 PM, michael rice nowg...@yahoo.com wrote: How do I create an alias for a function, like giving CAR the same functionality as HEAD. I know I can do it by creating a definition (see below), but is there a better way, like Scheme's (define head car) car :: [a] - a car x = head x The reason for doing this is to more closely mirror legacy code. Just do: car = head -- -alex http://www.ventonegro.org/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell for Physicists
Hallo, On 9/30/09, ed...@ymonad.com ed...@ymonad.com wrote: Hi, I will give a seminar to physicists at USP (Universidade de São Paulo, Brazil) university and they asked me for a good title, something that can attract physicists. Anyone has some suggestions? (Will be a seminar about the use of Haskell to substitute C or Fortran in a lot of tasks, and how it can be used in some problems instead of Matlab, Mathematica, etc.) Haskell for physicists ? -- -alex http://www.ventonegro.org/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] why does the binary library require so much memory?
Hi Don, I was wondering if perhaps this might be a slightly better instance for Binary [a], that might solve a) the problem of having to traverse the entire list first, and b) the list length limitation of using length and Ints. My version is hopefully a little more lazy (taking maxBound :: Word16 elements at a time), and should potentially allow infinite lists to be stored: import Data.Binary import Data.Binary.Get import Data.Binary.Put import Data.Word newtype List a = List [a] deriving (Show,Eq) instance Binary a = Binary (List a) where put (List xs) = do let (hd,num,tl) = btake maxBound xs putWord16be num if num == 0 then return () else do mapM_ put hd put (List tl) get = do num - getWord16be if num 0 then do xs - sequence (replicate (fromIntegral num) get) List ys - get return (List (xs ++ ys)) else return (List []) btake :: Word16 - [a] - ([a],Word16,[a]) btake n xs = btake' n n xs btake' :: Word16 - Word16 - [a] - ([a],Word16,[a]) btake' 0 m xs = ([],m,xs) btake' n m [] = ([],m-n,[]) btake' !n m (x:xs) = (x:xs',n',ys) where (xs',n',ys) = btake' (n-1) m xs My testing of this version shows that it's terribly bad when it comes to memory usage, but I'm sure someone can find a more efficient way to do what I'm trying here. -- Axman On 01/08/2009, at 07:27, Don Stewart wrote: bos: On Fri, Jul 31, 2009 at 1:56 PM, Jeremy Shaw jer...@n-heptane.com wrote: Using encode/decode from Binary seems to permamently increase my memory consumption by 60x fold. I am wonder if I am doing something wrong, or if this is an issue with Binary. It's an issue with the Binary instance for lists, which forces the entire spine of the list too early. This gives you a gigantic structure to hold onto. This is the current instance instance Binary a = Binary [a] where put l = put (length l) mapM_ put l get= do n - get :: Get Int getMany n -- | 'getMany n' get 'n' elements in order, without blowing the stack. getMany :: Binary a = Int - Get [a] getMany n = go [] n where go xs 0 = return $! reverse xs go xs i = do x - get -- we must seq x to avoid stack overflows due to laziness in -- (=) x `seq` go (x:xs) (i-1) It used to be this, though, xs - replicateM n get -- now the elems. -- Don ___ 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] What would be required to make a LLVM backend for GHC
Hi all, I've been talking to one of the LLVM developers, who's working on an operating system called AuroraUX, which, among other things, is trying to use LLVM as much as possible in the system (using clang as the default compiler, compiler-rt [libgcc replacement from the LLVM team], etc.). He would like to know exactly what would need to be implemented in LLVM to allow ghc to be ported to LLVM, and he would do his best to get these features implemented. I know the LLVM guys are quite open to suggestions, and want to get people using it as much as possible, so if we can let them know what we need, hopefully they can help make life easier for us. Thanks, Alex Mason ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANN: TernaryTrees-0.1.1.1 - An efficient ternary tree implementation of Sets and Maps
TernaryTrees is a package that extends Data.Set ad Data.Map with some ternary tree structures, based on the article [http://www.pcplus.co.uk/node/3074/ ] . So far there are three modules: Data.Set.TernarySet, Data.Map.TernaryMap and Data.Set.StringSet, which can hold `Ord a = [a]`, Ord a = [a] keys with b values, and Strings respectively. The interfaces for these types are very much like those of Data.{Set,Map}, though not wuite as featurefull. Later releases will also have a StringMap, and I'll update the TernaryMap to match the Set implementations more closely in a not too distant update. Ternary trees are supposed to be one of the more efficient ways of storing strings in a set, and my testing of this package seems to support this (being able to insert 230,000+ words, check that all those words are actually in the set, write the set out to disk using the Data.Binary instance, reading them back in, and checking the old and new sets are equal takes about 3.5 seconds on my machine). Included is a small example program that runs through the above sequence, and then asks the user to enter words to see if they're in the set, called tdict. Please give it a try and let me know what you think, it's my first (hopefully) useful hackage package, and I'd love some feedback. There is also a darcs repo [http://random.axman6.com/darcs/TernaryTrees/], and any patches are welcome. Cheers, Alex Mason (Axman6) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] problem with inf-haskell + ghci?
Hello all I recently found strange problem in use of inf-haskell + ghci on my Mac OS X Tyger. I haven't used inf-haskell for a some time, and several days ago i found, that it stopped to work - when I run C-c C-l (load file) it signal error, and when I perform C-c C-b (start interpreter) it load it, but entering of any text in it, leads to message: Leaving GHCi. Process haskell finished In terminal ghci works fine, but I couldn't find why ghci terminates when it called from Emacs. May be somebody had such problem with ghci? P.S. I use Carbon Emacs 22 + ghc 6.10.1 installed from macports -- With best wishes, Alex Ott, MBA http://alexott.blogspot.com/http://xtalk.msk.su/~ott/ http://alexott-ru.blogspot.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell programmers in São Carlo s - SP - Brazil?
Hallo, On 5/20/09, Diego Souza paravinic...@yahoo.com.br wrote: Not exactly São Carlos: São Paulo - SP. Me too, Sao Paulo - SP. Cheers, -- -alex http://www.ventonegro.org/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] displaying conetents of a list
2009/5/11 applebiz89 applebi...@hotmail.com I know to use show and putStrLn but I just don't know how to put them into the function correctly Well I hope we're not doing your homework for you but... As putStrLn is in the IO monad, listFilms should at least have a signature like this: listFilms :: [Film] - IO () Now you know you want to call putStrLn on each item in the list. That means you want to join a bunch of functions return IO (). That sounds like a job for sequence_: listFilms films = sequence_ $ map (putStrLn.show) films Or the same thing more verbosely: listFilms [] = return () listFilms (film:films) = do putStrLn (show film) listFilms films Hope that helps, Alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] compilation to C, not via-C
Hallo, On 4/24/09, Bulat Ziganshin bulat.zigans...@gmail.com wrote: so, if you just need haskell-C++ interaction, you may look into using FFI [1,2]. if you believe that you can compile some java/ruby/haskellwhatever code down to C++ and incorporate it into your function - sorry, they all have too different computing model Actually some Scheme compilers have a c-declare form that lets you create C functions, which can be called from C, Haskell, Java, Ruby etc. Cheers, -- -alex http://www.ventonegro.org/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Re[2]: [Haskell-cafe] compilation to C, not via-C
Hallo, On 4/24/09, Bulat Ziganshin bulat.zigans...@gmail.com wrote: and it supports lazy lists? :) all compiled languages has some FFI, the problem is that FFI limited to common subset of all those languages - i.e. primitive types and pointers I am not saying that Scheme is Haskell. I am just refuting your assertion that one cannot compile whatever code to C and incorporate it into your function. Cheers, -- -alex http://www.ventonegro.org/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] compilation to C, not via-C
Hallo, On 4/24/09, Donn Cave d...@avvanta.com wrote: Quoth Alex Queiroz asand...@gmail.com, Actually some Scheme compilers have a c-declare form that lets you create C functions, which can be called from C, Haskell, Java, Ruby etc. That would be like what you get with Haskell FFI export? When I do this with nhc98, I need a nhc98 main, and I would expect the same with GHC. Part of the deal would be smuggling in and initializing the Haskell runtime. Also figuring out storage, if returning any values from the exported Haskell function (as opposed to poking them into address parameters.) I can see how this would not be suitable for a library. Incurring the risk of being too much off-topic, I'll just say that I use the Gambit-C Scheme compiler to produce C code that I link with my C driver code. I need to write the driver (main and friends) in C because my software is compiled as a Windows service or POSIX daemon, which requires special care. But of course you must link in the Scheme runtime, with the garbage collector, Scheme data types etc. Cheers, -- -alex http://www.ventonegro.org/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Converting IO [XmlTree] to [XmlTree]
Hallo, On 4/14/09, rodrigo.bonifacio rodrigo.bonifa...@uol.com.br wrote: Dear Sirs, I guess this is a very simple question. How can I convert IO [XmlTree] to just a list of XmlTree? The short answer is: You cannot. The longer answer is: Only put things in the IO monad when you need to interact with the outside, i. e., reading, displaying etc. Cheers, -- -alex http://www.ventonegro.org/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] SoC idea: interactive profiling
Hello PG == Patai Gergely writes: PG Hello all, I entered a little proposal in the issue tracker: PG http://hackage.haskell.org/trac/summer-of-code/ticket/1570 PG As I see it, the graphical part could be a warm-up exercise with an PG already useful product, and interaction with the rts would be the PG actual challenge. Reasoning about laziness is far from trivial (at PG least I often feel lost when trying to grok all the interaction within PG Reactive ;), and being able to browse profiler output on the spot is PG something I felt the need for a few times already. Eventually, this PG could be a contribution to an IDE project, even though it could as PG well remain a standalone application for all the emacs/vi folk. PG Profiling tools for parallel programs are in the make already, but I PG haven't seen anything more convenient than hp2ps and little add hoc PG solutions for analysing resource usage patterns. How do you all go PG about profiling? May be providing profiling information for kcachegrind will be a good solution? For example, there are tools for PHP, that allow to view collected information in kcachegrind, and get interactive zooming, etc. -- With best wishes, Alex Ott, MBA http://alexott.blogspot.com/http://xtalk.msk.su/~ott/ http://alexott-ru.blogspot.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Against cuteness
Hallo, On Fri, Mar 13, 2009 at 1:23 PM, Benjamin L. Russell dekudekup...@yahoo.com wrote: On Fri, 13 Mar 2009 12:29:25 +0100, Achim Schneider bars...@web.de Water overcomes stone: Shapeless, it requires no opening: The benefit of taking no action. Yet benefit without action, And experience without abstraction, Are practiced by very few. Nice poem. Did you write it yourself, or can you document the source? If I remember correctly, this is from the Daodejing. Cheers, -- -alex http://www.ventonegro.org/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [ANN] Working with HLint from Emacs
Hello On Wed, Jan 28, 2009 at 12:30 PM, Colin Paul Adams co...@colina.demon.co.uk wrote: Alex == Alex Ott alex...@gmail.com writes: Alex Hello For Emacs users it could be interesting - I wrote Alex small module for more comfortable work with HLint from Alex Emacs. It has same functionality as compilation-mode - Alex navigation between errors, etc. I've done that. Now how do you get it to do anything? In your source file, opened in Emacs, just press C-c l, and it will run HLint and you'll able to navigate between suggestions with C-x ` combination. P.S. Today i released the second version of package, that allows to apply suggestions to source code - see more details at http://alexott.blogspot.com/2009/02/second-version-of-hs-lint-package.html -- With best wishes,Alex Ott, MBA http://alexott.blogspot.com/ http://alexott-ru.blogspot.com/ http://xtalk.msk.su/~ott/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: WYSIWYG literate programming
G == Gour writes: Massimiliano == Massimiliano Gubinelli m.gubine...@gmail.com writes: Massimiliano As far as Haskell is concerned, a good interface, would Massimiliano allow to bypass programs like lhs2tex or in general allow Massimiliano for beautyful editing Of course not everyone has the Massimiliano same concerns... G Have you tried Emacs with Pretty Lambda for Haskell-mode? G http://haskell.org/haskellwiki/Emacs#Unicodifying_symbols_.28Pretty_Lambda_for_Haskell-mode.29 At http://xtalk.msk.su/~ott/common/emacs/rc/emacs-rc-pretty-lambda.el.html you can find slightly modified version of version of pretty lambda code from haskell wiki - i added several symbols, and fix regex to work properly with symbols like ===, etc. -- With best wishes, Alex Ott, MBA http://alexott.blogspot.com/ http://xtalk.msk.su/~ott/ http://alexott-ru.blogspot.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe