[Haskell-cafe] Re: defining last using foldr

2007-08-16 Thread Jon Fairbairn
"Chaddaï Fouché" <[EMAIL PROTECTED]> writes: > > so you need an f so that c `f` x is c (for any c and x) and > > yet (b `f` c) is c for any c and b -- this is impossible (or > > I'm asleep). > > Well, it isn't "impossible" but quite hard (and not even standard H98 > if I'm not mistaken) If it is

Re: [Haskell-cafe] Re: defining last using foldr

2007-08-16 Thread Chaddaï Fouché
16 Aug 2007 10:11:24 +0100, Jon Fairbairn <[EMAIL PROTECTED]>: > snip my quote > > I certainly wouldn't count such a thing as a valid > solution. It's always amazed me that C uses as standard a > mechanism of ending strings that is so obviously an > error-prone hack. I'm completely with you on tha

Re: [Haskell-cafe] Syntax for lambda case proposal could be "\of"

2007-08-16 Thread Bertram Felgenhauer
Duncan Coutts wrote: > On Wed, 2007-08-15 at 11:06 -0700, Stefan O'Rear wrote: > > > foo = getSomethingCPS $ \ arg -> > > moreStuff > > > > is now a syntax error (\ { varid -> } matches no productions). > > I'm not sure I follow. > > The patterns would have to match up in a column, so > >

Re: [Haskell-cafe] Haskell for the Enterprise (topic for a MSc dissertation?)

2007-08-16 Thread Hans van Thiel
On Wed, 2007-08-15 at 15:04 +0200, Lars Oppermann wrote: > Hi All, > > This is my first post here, so I'll start with a quick introduction... > I live and work in Hamburg, Germany. My day job is as a software > engineer at Sun Microsystems at the OpenOffice.org development team > where I'm mostly

Re: [Haskell-cafe] Erlang VM in Haskell

2007-08-16 Thread Neil Bartlett
Joel, This sounds like an extremely interesting (but very ambitious!) project, which I would like to get involved with if I have the time. However, wouldn't it be rather difficult, given that there doesn't seem to be a publicly available specification for the Erlang VM or the BEAM file format --

Re: [Haskell-cafe] Erlang VM in Haskell

2007-08-16 Thread Joel Reymont
On Aug 16, 2007, at 1:36 PM, Neil Bartlett wrote: However, wouldn't it be rather difficult, given that there doesn't seem to be a publicly available specification for the Erlang VM or the BEAM file format Very difficult, correct. I use Erlang daily, in fact Erlang is what brings bread to my

Re: [Haskell-cafe] Erlang VM in Haskell

2007-08-16 Thread Lennart Augustsson
I think Haskell is the right language to nail down the semantics of Erlang and to prototype an implementation. For performance, I think Haskell is probably not the right language, because you need high performing low level code. This isn't impossible in Haskell, but the implementations are not gear

[Haskell-cafe] trouble building 6.7 on ubuntu

2007-08-16 Thread Thomas Hartman
I have gotten ghc 6.7 to compile, but not with extra libs. I'm on linux x86, ubuntu. Can someone suggest a download date that worked for them, or how to fix one or more of the problems described below? When I build from source (this is for august 2, unknown linux, as conal spoke well of it :)

[Haskell-cafe] Re: Problem installing GHC6.6

2007-08-16 Thread Christian Maeder
ok wrote: > Trying to install GHC 6.6 on a Solaris 2.9 box (do I have the last > 2.9 box in captivity? I've asked for 2.10, really and truly I have) > I ran into two problems. Is it Solaris for Sparc or x86? Did you try to install one of the binary dists from the download pages? http://www.haskel

Re: [Haskell-cafe] Explaining monads

2007-08-16 Thread Kim-Ee Yeoh
Paul Hudak wrote: > > [I]n the one-of-many ways that I view monads, a monad is just a high-order > function that abstracts away function composition. In particular, if I > have an action f, and an action g, I can think of them as recipes, because > I can combine them via f >>= g. It's only aft

[Haskell-cafe] Re: trouble building 6.7 on ubuntu

2007-08-16 Thread Stefan O'Rear
On Thu, Aug 16, 2007 at 01:01:12PM -0400, Thomas Hartman wrote: > I repeated the install attempt described below using darcs head, including > the extra libs. > > I got the exact same error as before. > > Setup: Warning: Unknown fields: nhc98-options (line 173) and then a > cryptic error

Re: [Haskell-cafe] defining last using foldr

2007-08-16 Thread Kurt Hutchinson
On 8/15/07, Alexteslin <[EMAIL PROTECTED]> wrote: > I am really sorry, but i still can't define the function. The chapter the > exercise is in precedes algebraic types or Maybe a types. And is seems that > must being easy to define. > I answered some exercises on using foldr such as summing for e

[Haskell-cafe] Re: defining last using foldr

2007-08-16 Thread Al Falloon
Kurt Hutchinson wrote: On 8/15/07, Alexteslin <[EMAIL PROTECTED]> wrote: I am really sorry, but i still can't define the function. The chapter the exercise is in precedes algebraic types or Maybe a types. And is seems that must being easy to define. I answered some exercises on using foldr suc

[Haskell-cafe] The problem with abstraction (Was: monte carlo trouble)

2007-08-16 Thread Al Falloon
Chad Scherrer wrote: I'm starting to think the power of abstraction is a blessing and a curse. Haskell's abstraction mechanisms are so powerful that it's generally possible to come up with a way to solve a given problem elegantly and efficiently. On the other hand, if a problem isn't so well stud

[Haskell-cafe] Re: trouble building 6.7 on ubuntu

2007-08-16 Thread Esa Ilari Vuokko
On 8/16/07, Thomas Hartman <[EMAIL PROTECTED]> wrote: > > > I repeated the install attempt described below using darcs head, including > the extra libs. > > I got the exact same error as before. > > Setup: Warning: Unknown fields: nhc98-options (line 173) and then a > cryptic error involving

[Haskell-cafe] Re: Pattern matching articles/explanations

2007-08-16 Thread Al Falloon
Ian Duncan wrote: Hello everyone, I've been working on improving my Haskell knowledge, and in doing so, I have read a little about as-patterns as well as some form of pattern that uses "~" that I don't really understand. I suspect there are even more lesser-known pattern matching expressions th

Re: [Haskell-cafe] monte carlo trouble

2007-08-16 Thread Chad Scherrer
I'm using ListT now, trying to do this: type Sample a = ListT (State StdGen) a randomStreamR :: (RandomGen g, Random a) => (a,a) -> g -> ([a], g) randomStreamR bds g =(randomRs bds g1, g2) where (g1,g2) = split g sample :: [a] -> Sample a sample [] = ListT (State f) where f s = case next s o

Re: [Haskell-cafe] Hints for Euler Problem 11

2007-08-16 Thread Kim-Ee Yeoh
Aaron Denney wrote: > > On 2007-08-15, Pekka Karjalainen <[EMAIL PROTECTED]> wrote: >> A little style issue here on the side, if I may. You don't need to use >> (++) to join multiline string literals. >> >> text = "If you want to have multiline string literals \ >>\in your source code, y

Re: [Haskell-cafe] Hints for Euler Problem 11

2007-08-16 Thread Lennart Augustsson
But if the strings are all constant it's perfectly feasible to concatenate them at compile time. On 8/16/07, Kim-Ee Yeoh <[EMAIL PROTECTED]> wrote: > > > > Aaron Denney wrote: > > > > On 2007-08-15, Pekka Karjalainen <[EMAIL PROTECTED]> wrote: > >> A little style issue here on the side, if I may.

[Haskell-cafe] Re: hyperlinked haskell 98 grammar

2007-08-16 Thread Peter Hercek
Hi Neil, For haskell-cafe members: This is what we are talking about: http://www.hck.sk/users/peter/ I'm glad somebody liked it. I do not understand what you mean by the extension request. Would you want to see the number of references of a production head even without opening the popup list

[Haskell-cafe] Re: Hints for Euler Problem 11

2007-08-16 Thread Aaron Denney
On 2007-08-16, Kim-Ee Yeoh <[EMAIL PROTECTED]> wrote: > > > Aaron Denney wrote: >> >> On 2007-08-15, Pekka Karjalainen <[EMAIL PROTECTED]> wrote: >>> A little style issue here on the side, if I may. You don't need to use >>> (++) to join multiline string literals. >>> >>> text = "If you want to ha

[Haskell-cafe] Collada, FBX, XML schemas and Haskell?

2007-08-16 Thread Peter Verswyvelen
I wanted to do some experiments with HOpenGL, and one of the things I tried is importing 3D models. So I searched for a library that could do that, but besides Frag, who uses the limited MD3 format, I did not find anything useful. Has any work been done on supporting that? Maybe just converting

[Haskell-cafe] Pattern matching articles/explanations

2007-08-16 Thread Ian Duncan
So what I noticed that "A Gentle Introduction to Haskell" mentioned that wild-cards are useful in constructors. For example: head (x:_) = x So, does that offer any performance benefits over: head (x:xs) = x Or is it primarily to indicate to the coder that xs is useless? I get the impressio

Re: [Haskell-cafe] Pattern matching articles/explanations

2007-08-16 Thread Neil Mitchell
Hi > So what I noticed that "A Gentle Introduction to Haskell" mentioned > that wild-cards are useful in constructors. For example: > > head (x:_) = x > > So, does that offer any performance benefits over: > > head (x:xs) = x No. They are exactly the same. _ simply means "a new unique name". > O

[Haskell-cafe] Re: Pattern matching articles/explanations

2007-08-16 Thread Aaron Denney
On 2007-08-16, Neil Mitchell <[EMAIL PROTECTED]> wrote: > Hi > >> So what I noticed that "A Gentle Introduction to Haskell" mentioned >> that wild-cards are useful in constructors. For example: >> >> head (x:_) = x >> >> So, does that offer any performance benefits over: >> >> head (x:xs) = x > > N

Re: [Haskell-cafe] Syntax for lambda case proposal could be "\of"

2007-08-16 Thread Thomas Schilling
On 16 aug 2007, at 13.46, Bertram Felgenhauer wrote: Duncan Coutts wrote: On Wed, 2007-08-15 at 11:06 -0700, Stefan O'Rear wrote: foo = getSomethingCPS $ \ arg -> moreStuff is now a syntax error (\ { varid -> } matches no productions). I'm not sure I follow. The patterns would have

[Haskell-cafe] Diagnosing stack overflow

2007-08-16 Thread Justin Bailey
I am trying to determine why my stack overflows in my medium sized program (it has several modules but maybe only 1000 LOC total). On Windows, at least, the ghcprof visualization tool doesn't work. Any suggestions besides an output trace? It may be the function below, which tries to determine if a

Re: [Haskell-cafe] Re: trouble building 6.7 on ubuntu

2007-08-16 Thread Duncan Coutts
On Thu, 2007-08-16 at 22:22 +0300, Esa Ilari Vuokko wrote: > On 8/16/07, Thomas Hartman <[EMAIL PROTECTED]> wrote: > Setup: Warning: Unknown fields: nhc98-options (line 173) > and then a cryptic error involving HsColour > I think you run into Cabal bug - you need to remove (

Re: [Haskell-cafe] Diagnosing stack overflow

2007-08-16 Thread Matthew Brecknell
Justin Bailey: > I am trying to determine why my stack overflows in my medium sized > program [...snip...] > > prefixesAtLeast :: Int -> [S.ByteString] -> Int > prefixesAtLeast !0 !ss > | null ss = 0 > | all S.null ss = 0 > | otherwise = -1 > prefixesAtLeast !n !ss = prefixesAtLeast' n ss >

[Haskell-cafe] I'm stuck in my thought experiment

2007-08-16 Thread Levi Stephen
Hi, Apologies for a long post that may not be totally clear. I was thinking through a problem and how the data might be represented in Haskell. I'm now stuck and frustrated. Now, I'm not even sure whether I'm on the right track (I might still be thinking too OO). Suggestions/ideas would be much a

[Haskell-cafe] Looking at program execution

2007-08-16 Thread Ian Duncan
Is there any way to view the steps that a haskell program goes through step by step? I'm thinking something similar to what I've seen in things I've been reading. For example: foldl (+) 0 [1..10] => (0+1) => ((0+1)+2) => (((0+1)+2)+3) => etc. I've seen these sorts of line-by-line execution ste

Re: [Haskell-cafe] Looking at program execution

2007-08-16 Thread Brent Yorgey
On 8/16/07, Ian Duncan <[EMAIL PROTECTED]> wrote: > > Is there any way to view the steps that a haskell program goes > through step by step? > I'm thinking something similar to what I've seen in things I've been > reading. For example: > foldl (+) 0 [1..10] > => (0+1) > => ((0+1)+2) > => (((0+1)+2)

Re: [Haskell-cafe] Re: Bathroom reading

2007-08-16 Thread ok
Someone mentioned the "Blow your mind" page. One example there really caught my attention. "1234567" => ("1357","246") foldr (\a ~(x,y) -> (a:y,x)) ([],[]) I've known about lazy match since an early version of the Haskell report, but have never actually used it. Last night, looking at that exa

Re: [Haskell-cafe] defining last using foldr

2007-08-16 Thread ok
Let's start by reminding ourselves what foldr does. foldr f z [x1,x2,...,xn] = f x1 (f x2 ... (f xn z) ...) Now let's ask about last: last [] = error ... last [x1,...,xn] = xn We're going to have to keep track of whether we have a last element or not. The obvious candidate for this is Maybe x

Re: [Haskell-cafe] I'm stuck in my thought experiment

2007-08-16 Thread Matthew Brecknell
Levi Stephen: > [...] > I was imagining a drag and drop web page designer. There are a bunch of > Widgets (e.g., BlogWidget, TextWidget, MenuWidget, etc) that the user can > place on the page. > [...] > > class Widget a where > render :: a -> Html > > -- A page has a title and a Widget. > -- I k

Re: [Haskell-cafe] Re: Bathroom reading

2007-08-16 Thread Dan Weston
I hate to be a party pooper, but isn't this just: > f = foldr (\a z -> (a:snd z,fst z)) ([],[]) This takes less time to grok and takes no longer to run. But why stop there? > import Control.Arrow > swap = snd &&& fst > f = foldr (\a -> swap >>> first (a:)) ([],[]) Just read this aloud to see

[Haskell-cafe] Re: trouble building 6.7 on ubuntu

2007-08-16 Thread Ian Lynagh
On Thu, Aug 16, 2007 at 09:39:54AM -0400, Thomas Hartman wrote: > > The programs included with the Ubuntu system are free software; > checking host system type... i686-pc-linux-gnu > checking target system type... i686-pc-linux-gnu > Which we'll further canonicalise into: i386-unknown-linux > chec

Re: [Haskell-cafe] Diagnosing stack overflow

2007-08-16 Thread Bryan O'Sullivan
Justin Bailey wrote: I am trying to determine why my stack overflows in my medium sized program (it has several modules but maybe only 1000 LOC total). On Windows, at least, the ghcprof visualization tool doesn't work. Any suggestions besides an output trace? You shouldn't need ghcprof. Just c