Re: [Haskell-cafe] Empty Input list

2012-03-13 Thread Dmitry Olshansky
Look also at safe package http://hackage.haskell.org/package/safe 2012/3/13 Chris Wong chrisyco+haskell-c...@gmail.com On Tue, Mar 13, 2012 at 12:24 PM, Chris Smith cdsm...@gmail.com wrote: On Mon, Mar 12, 2012 at 3:14 PM, Kevin Clees k.cl...@web.de wrote: Now my function looks like this:

[Haskell-cafe] Inecxact map?

2012-03-13 Thread Morten Olsen Lysgaard
I'm running a project where i want to generate a map of a rather large data collection. The map is if the form: Data.Map.Map String a I'd like to be able to do inexact lookups on the map. Firstly, ignore the difference between upper lower case, that's easy. But secondly, have a function:

Re: [Haskell-cafe] Empty Input list

2012-03-13 Thread Ketil Malde
Kevin Clees k.cl...@web.de writes: Now my function looks like this: tmp:: [(Int, Int)] - Int - (Int, Int) tmp [] y = (0,0) ^ tmp xs y = xs !! (y-1) If the function returns (0,0) it will blocked by another function. Personally, I think using special values like this is

Re: [Haskell-cafe] Inecxact map?

2012-03-13 Thread Holger Siegel
Am 13.03.2012 um 09:15 schrieb Morten Olsen Lysgaard: I'm running a project where i want to generate a map of a rather large data collection. The map is if the form: Data.Map.Map String a I'd like to be able to do inexact lookups on the map. Firstly, ignore the difference between upper

[Haskell-cafe] An idea to document inter department dependencies in Haskell

2012-03-13 Thread C K Kashyap
My dear Haskell folks, I work in a software company where I develop components that go into a really complex system that's built of several components developed by different teams that are geographically distributed. The components themselves run in a distributed manner across client and several

[Haskell-cafe] ANNOUNCE: join (UHac $ DHD)

2012-03-13 Thread Sean Leather
You can still join us at the DHD = UHac, but the time is running out. http://www.haskell.org/haskellwiki/DHD_UHac Deadline: April 1 (no fooling!) We've also have a few updates: * We put the DHD program up, at least as much of it as we have.

[Haskell-cafe] cabal test-suite library recompilation

2012-03-13 Thread Ozgur Akgun
Hi all, I've recently started to move my tests to use the new cabal test-suite framework. Old setup: The cabal file compiles one library + a few executables. The library contains almost all of the code and exposes the necessary modules for use by the executables. The executables mainly consist

Re: [Haskell-cafe] cabal test-suite library recompilation

2012-03-13 Thread Antoine Latter
On Tue, Mar 13, 2012 at 11:16 AM, Ozgur Akgun ozgurak...@gmail.com wrote: While waiting for a build to finish [ :) ], I just wanted to write an email and check if this is intentional or only an oversight. Or maybe a technical limitation for the time being? If your library code and test code

Re: [Haskell-cafe] cabal test-suite library recompilation

2012-03-13 Thread Ozgur Akgun
On 13 March 2012 16:22, Antoine Latter aslat...@gmail.com wrote: If your library code and test code are in separate sub-directories and you reference your library as a package dependency for your test then Cabal won't re-build your library. Yay! That was it. Thanks. Somehow I altered the

Re: [Haskell-cafe] Inecxact map?

2012-03-13 Thread Sterling Clover
On Tue, Mar 13, 2012 at 6:14 AM, Holger Siegel holgersiege...@yahoo.de wrote: Am 13.03.2012 um 09:15 schrieb Morten Olsen Lysgaard: I'd like to be able to do inexact lookups on the map. Firstly, ignore the difference between upper lower case, that's easy. But secondly, have a function:

[Haskell-cafe] Polymorphic addition function with variable number of arguments?

2012-03-13 Thread Some One
Dear Haskellers, I'm trying to define a polymorphic add function which takes a variable number of arguments (instance of Num) and returns their sum. I don't want to specify the types of the arguments while calling the function, I just want to , at most, specify the return type (*it should infer

Re: [Haskell-cafe] Polymorphic addition function with variable number of arguments?

2012-03-13 Thread Johannes Waldmann
Can someone tell me why this is not working that someone is actually ghci: Prelude instance (Num a, Add a b) = Add (a - b) where add x y = add (x + y) interactive:8:30: Expecting one more argument to `Add (a - b)' In the instance declaration for `Add (a - b)'

Re: [Haskell-cafe] Polymorphic addition function with variable number of arguments?

2012-03-13 Thread Some One
I'm sorry this was a typo. Here's the correct one: {-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-} class Add a b where add :: a - b instance Num a = Add a a where add = id instance (Num a, Add a b) = Add a (a - b) where add x y = add (x + y) I'm trying to use the printf

Re: [Haskell-cafe] Polymorphic addition function with variable number of arguments?

2012-03-13 Thread Johannes Waldmann
The problem seems to be that numeric literals are polymorphic. With your code, this works: *Main let x = 8 :: Int *Main add x x x :: Int 24 *Main add x x :: Int 16 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

[Haskell-cafe] Prettier pretty-printing of data types?

2012-03-13 Thread Johan Tibell
Hi all, The derived Show instance is useful, but I sometimes wish for something that's easier to read for big data types. Does anyone have an implementation of show that draws things in a hierarchical manner? Example: Given data Tree a = Leaf | Bin Int a (Tree a) (Tree a) and value =

Re: [Haskell-cafe] Prettier pretty-printing of data types?

2012-03-13 Thread Austin Seipp
It's not exactly hierarchical, but Groom most certainly should help with getting much prettier output: http://hackage.haskell.org/package/groom On Tue, Mar 13, 2012 at 5:33 PM, Johan Tibell johan.tib...@gmail.com wrote: Hi all, The derived Show instance is useful, but I sometimes wish for

Re: [Haskell-cafe] Prettier pretty-printing of data types?

2012-03-13 Thread Vincent Hanquez
On 03/13/2012 10:33 PM, Johan Tibell wrote: value = Bin 1 (Bin 2 Leaf Leaf) (Bin 3 Leaf Leaf) I'm usually using the following snippet which is a tweak of the gshow function from syb. However everything need to be a member of Data/Typeable, and also list are not particularly well handled with

Re: [Haskell-cafe] Prettier pretty-printing of data types?

2012-03-13 Thread Ozgur Akgun
I prefer pretty-show rather than groom as it's output is hierarchical. http://hackage.haskell.org/package/pretty-show Ozgur On 13 March 2012 22:37, Austin Seipp mad@gmail.com wrote: It's not exactly hierarchical, but Groom most certainly should help with getting much prettier output:

Re: [Haskell-cafe] Prettier pretty-printing of data types?

2012-03-13 Thread Christopher Done
Maybe an Emacs script to expand the nodes nicely: http://www.youtube.com/watch?v=6ofEZQ7XoEA I don't find mere pretty printing that useful compared to the “expanding” paradigm I'm used to in Chrome and Firebug. To try it just M-x eval-buffer on these two files,

Re: [Haskell-cafe] An idea to document inter department dependencies in Haskell

2012-03-13 Thread Alberto G. Corona
Hi, Just thinking aloud : A way to start is to define concrete workflows for concrete events. What It is necessary to do if. This may make things more explicit and to clarify the problems. .Later, .maybe. these concrete workflows can be abstracted away from procedural/imperative to declarative

Re: [Haskell-cafe] Is there a better way to subtyping?

2012-03-13 Thread Ryan Ingram
data Common = ... data A = ... data B = ... data C = ... data Super = SubA { commonFields :: Common, getA :: A } | SubB { commonFields :: Common, getB :: B } | SubC { commonFields :: Common, getC :: C } foldWithSubtype :: (A - r) - (B - r) - (C - r) - Super - r foldWithSubtype k _ _

Re: [Haskell-cafe] Is there a better way to subtyping?

2012-03-13 Thread John Meacham
Why not data Super = SuperA { commonFields :: () aFields :: () } | SuperB { commonFields :: () bFields :: () } | SuperC { commonFields :: ()

Re: [Haskell-cafe] using mutable data structures in pure functions

2012-03-13 Thread Ryan Ingram
On Sun, Mar 11, 2012 at 8:38 PM, E R pc88m...@gmail.com wrote: A pure function can allocate and modify memory as long as a) it never returns a reference to the memory or b) it never again modifies the memory once it returns (i.e. it returns an immutable object). That's a reasonable first