haskell-cafe

Syndicate content Gmane
Updated: 49 weeks 5 days ago

Why does this blow the stack?

Fri, 12/21/2007 - 5:13pm
Given this function: dropTest n = head . drop n $ [1..] I get a stack overflow when n is greater than ~ 550,000 . Is that inevitable behavior for large n? Is there a better way to do it? Justin
Categories: Offsite Discussion

FFI"pointer" data types question

Fri, 12/21/2007 - 5:11pm
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

nice simple problem for someone struggling....

Fri, 12/21/2007 - 2:36pm
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

Applying a Dynamic function to a container ofDynamics

Fri, 12/21/2007 - 11:24am
Hi all, dynApp allows to apply a Dynamic function to a Dynamic argument: dynApp :: Dynamic -> Dynamic -> Dynamic I don't seem to find a way (without modifying Data.Dynamic itself) to code this function import Data.Typeable import Data.Dynamic import Data.Foldable dynApp1 :: (Typeable1 container, Foldable container) => Dynamic -> container Dynamic -> Dynamic dynApp1 f -- originally of type :: container a -> b val --- all its values _must_ have type :: b
Categories: Offsite Discussion

Smart Constructor Puzzle

Fri, 12/21/2007 - 4:39am
I'm playing around with smart constructors, and I have encountered a weird puzzle. My goal is to do vector arithmetic. I'm using smart constructors so that I can store a vector as a list and use the type system to staticly enforce the length of a vector. So my first step is to define Peano numbers at the type level. > data PZero = PZero deriving (Show) > data PSucc a = PSucc a deriving (Show) > > type P1 = PSucc PZero > type P2 = PSucc P1 > type P3 = PSucc P2 > -- etc Next, I define a vector type and tag it with a Peano number. > data Vec s t = Vec [t] deriving (Eq, Ord, Show, Read) Now I can define a few smart constructors. > vec0 :: Vec PZero t > vec0 = Vec [] > > vec1 :: t -> Vec P1 t > vec1 x = Vec [x] > > vec2 :: t -> t -> Vec P2 t > vec2 x y = Vec [x, y] > > vec3 :: t -> t -> t -> Vec P3 t > vec3 x y z = Vec [x, y, z] Now here's the puzzle. I want to create a function "vecLength" that accepts a vector and returns its length. The catch is that I want to calculate the le
Categories: Offsite Discussion

upgrading regex in GHC 6.8.2

Fri, 12/21/2007 - 3:28am
Hello, I have an application that uses/used Text.Regex and have just updated GHC from 6.6.1 to 6.8.2 and it seems that Text.Regex is gone, so I'm trying to install the replacement from Hackage. First of all, the procedure is quite tedious as one has to install the hierarchy of dependencies manually but apparently there are moves to automate this process. The procedure stalled on regex-base-0.92. I fixed the build-depends in regex-base.cabal to: Build-Depends: base >= 2.0, mtl, containers >= 0.1.0.1, bytestring, array following information I found via an internet search but on runghc Setup.hs install it says: Setup.hs: Error: Could not find module: Text.Regex.Base with any suffix: ["hi"] It seems that it is necessary to remove the Text.Regex.Base and Text.Regex.Base.Impl entries from the Exposed-Modules: line but then regex-posix build complains that it can't find Text.Regex.Base. I tried various hackery like compiling Text/Regex/Base.hs manually but even when Text/Regex/Base.hi exists,
Categories: Offsite Discussion

Optimizing cellular automata & the beauty ofunlifted types

Thu, 12/20/2007 - 11:07pm
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

Is there some place where I can find the hs-cursesdoc ?

Thu, 12/20/2007 - 10:21pm
It seems I can't find it. David.
Categories: Offsite Discussion

instance Monad Either?

Thu, 12/20/2007 - 9:35pm
According to this Either is an instance of class Monad, but when I try to use the do notation I get a compiler error. What's going on? E.
Categories: Offsite Discussion

Class/Instance : what am I doing wrong in thisexample ?

Thu, 12/20/2007 - 3:47pm
I'm really inexperienced at this : ----------- {-# OPTIONS_GHC -fglasgow-exts -funbox-strict-fields -fallow-undecidable-instances -O2 #-} class Gadget g where fInit :: g -> a -> g data FString = FString !Int !String deriving Show instance Gadget FString where fInit (FString n _) s = FString n (take n s) ------------- I get the error message : Couldn't match expected type `String' against inferred type `a' `a' is a rigid type variable bound by the type signature for `fInit' at Gadget.hs:4:17 In the second argument of `FString', namely `s' In the expression: FString n s In the definition of `fInit': fInit (FString n _) s = FString n s
Categories: Offsite Discussion

Storable types

Thu, 12/20/2007 - 2:46pm
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

[RFC] Preliminary benchmark graphs

Thu, 12/20/2007 - 10:57am
I added Don's three benchmarks and redid all my benchmarks with: ghc 6.6.1 ghc 6.8.2 ghc 6.8.2 + bytestring 0.9.0.2 ghc 6.9.20071119 ghc 6.9.20071119 + bytestring 0.9.0.2 ghc head-as-of-yesterday-around-noon ghc head-as-of-yesterday-around-noon + bytestring 0.9.0.2 I tried to get the draft emails with intro, methodology, discussion, and conclusion completed yesterday but my brain simply wasn't up to it. Unfortunately, it still isn't quite up to it :( Since the perfect is the enemy of the good, I'll post the graphs for all the above 7 runs now. The rest will be forthcoming when I can think straight again, hopefully some time in the evening. I have scripts to help me install precisely the ghc version I want (and to make it easy to duplicate my results). I also have scripts to run the benchmarks, get correct memory measurements (-sstderr doesn't seem trustworthy), check the validity of each timing measurement, generate I/O traces, generate reports, and finally merging reports from different
Categories: Offsite Discussion

Dynamic typing of polymorphic functions

Thu, 12/20/2007 - 10:47am
Alfonso Acosta wrote: It seems the compiler's complaint is reasonable. The signature of the mapSY function says that mapSY may only be applied _provided_ that type variables 'a' and 'b' are instantiated to the types that are members of Typeable. That is, mapSY has a condition on its use. When you write the condition is satisfied: 'a' and 'b' are instantiated to Int, and Int is a member of Typeable. The definition of mapSnd has no constraint. The compiler is upset: mapSY requires a condition, and mapSnd does not provide any, and there is no obvious way how an obligation Typeable a could have been satisfied otherwise. So, writing is the logical thing to do. Perhaps the latter is the real problem. If one switches to dynamic typing, the type errors show up as run-time errors. I believe the typing of eval is a bit odd (and also not very useful). The following code seems to work. It also shows how to apply a polymorphic function, pairing, to to signals of any type. Here's a test: *Foo> :t signal3 s
Categories: Offsite Discussion

Class deriving in GHC 6.8

Thu, 12/20/2007 - 10:18am
Hello all! How come in GHC 6.6 I could to write but in GHC 6.8.2 I get the error Thanks, / Emil
Categories: Offsite Discussion

type trickery

Thu, 12/20/2007 - 9:34am
_______________________________________________ Haskell-Cafe mailing list Haskell-Cafe< at >haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Categories: Offsite Discussion

FFI question -- was: New slogan for haskell.org

Thu, 12/20/2007 - 3:01am
Don, I am a newbie on FFI, but have been interested in looking into it. If I google on "haskell FFI", what I find is typically: 1. The official Haskell 98 FFI 1.0 2. The FFI preprocessor -- greencard on haskell.org, where several other preprocessors are listed (in the Link section): HaskellDirect, C to Haskell, hsc2hs (included in GHC distributions), QForeign, KDirect. The FFI 1.0 API is certainly the most robust tool. However, the existence of preprocessors seem to suggest (at least very enticing) that the use of a preprocessor would make life easier. But when I dig deeper, several of them have not had any release in (more than) 3 years. The only exception seem to be "C to Haskell", which is part of gtk2hs, and hsc2hs, being part of GHC. It immediately becomes confusing which tool I should use if I were to work on a FFI project... Can you shed some light on this? Thanks, Steve
Categories: Offsite Discussion

ANN: SearchPath v0.9

Wed, 12/19/2007 - 8:22pm
SearchPath v0.9 does recursive module chasing accross the internet using a combination of mapfiles you provide and the default map file, caching the downloaded modules in a local directory. Searchpath can handle modules in module hierarchies based at a URLs, in tgz archives accessible via URL, and in accessible darcs/svn/cvs etc repos at particular tags. New in v0.9 * handling tagged darcs/svn repos * handling .tgz archives * massive code cleanup * substantially faster * easier/better command line options * better usage documentation * handling non-local haskell files Check it out at http://searchpath.org. -Alex-
Categories: Offsite Discussion

Knowledge

Wed, 12/19/2007 - 7:26pm
I'm new to functional programming and Haskell and I love its expressive ability! I've been trying to formalize the following function for time. Given people and a piece of information, can all people know the same thing? Anyway, this is just a bit of fun... but can anyone help me reduce it or talk about strictness and junk as I'd like to make a blog on it? contains :: Eq a => [a]->a->Bool contains [] e = False contains (x:xs) e = if x==e then True else contains xs e perfectcomm :: Bool perfectcomm = undefined knowself :: Bool knowself = undefined allKnow :: Eq a => [a]->String->Bool allKnow _ "" = True allKnow [] k = False allKnow (x:[]) k = knowself allKnow (x:xs) k = comm x xs k && allKnow xs k where comm p [] k = False comm p ps k = if contains ps p then knowself else perfectcomm
Categories: Offsite Discussion

DSL question -- was: New slogan for haskell.org

Wed, 12/19/2007 - 6:03pm
Thanks for the explanation on DSL. It helped me understand how Haskell works compared to other popular languages out there. It is a programming methodology change. Or what is called paradigm change on how to design a software with Haskell. Haskell has its general-purpose features. Yet its strength is the ability and ease of defining DSL by utilizing the higher order \"stuff\" (like type class, composite function, monads, and arrows), which to say the least, can be quite abstract and challenging. I do come aross a question while reading the DSL page on Wikipedia. http://en.wikipedia.org/wiki/Domain-specific_programming_language In the Disadvantage section (near the end), there is an item -- hard or impossible to debug. Can anybody explain why or what it means? And how does it apply to Haskell?
Categories: Offsite Discussion

How to make Prelude.read: no parse more verbose ...

Wed, 12/19/2007 - 4:53pm
Hi, I try to debug some existing Haskell-Code. Out of the blue I get a 'progname: Prelude.read: no parse' error message from GHC. Great. Well, the code includes # grep '\' *| wc -l 23 (sic!) calls to the read fn. Well, how do I compile a Haskell program in such a way, that I get a useful error message from read? I mean, like the filename/linenumber of the calling expression for starters. Really crazy would be the possibility to print out a backtrace, if some (library) function calls error ... Best regards Georg
Categories: Offsite Discussion