Re: [Haskell-cafe] Re: let and fixed point operator

2007-09-03 Thread Jules Bean
Peter Hercek wrote: f = g . transform displacement . scale factor or pointfully f x = g (transform displacement (scale factor x)) with the appropriate combinators. Essentially the same idea as the one from Brent Yorgey. Works fine till the operations can fill easily on one line. Then it does

Re: [Haskell-cafe] Re: let and fixed point operator

2007-09-03 Thread Jules Bean
Peter Hercek wrote: Jules Bean wrote: I have no idea what you're talking about. It works fine on multiple lines: f x = g . transform displacement . scale factor $ x is perfectly valid. Yes, it is. It is not an issue if you prefer to indent based on previous line

Re: [Haskell-cafe] About mplus

2007-09-05 Thread Jules Bean
David Benbennick wrote: You mean (++) = mplus. I've wondered that too. Similarly, one should define map = fmap. And a lot of standard list functions can be generalized to MonadPlus, for example you can define filter :: (MonadPlus m) = (a - Bool) - m a - m a Somehow this filter fails my

Re: [Haskell-cafe] About mplus

2007-09-05 Thread Jules Bean
ok wrote: On 5 Sep 2007, at 6:16 pm, Henning Thielemann wrote: I think it is very sensible to define the generalized function in terms of the specific one, not vice versa. The specific point at issue is that I would rather use ++ than `mplus`. In every case where both are defined, they

Re: [Haskell-cafe] Extending the idea of a general Num to other types?

2007-09-05 Thread Jules Bean
Ketil Malde wrote: String is not an instance of class Foo -- single param No instance for (Bar String Int)-- multi-param If you quote things, you can also consider: 'String Int' is not an instance of class 'Bar'. Downside is that 'String Int' by

Re: [Haskell-cafe] turning an imperative loop to Haskell

2007-09-06 Thread Jules Bean
Axel Gerstenberger wrote: Thanks to all of you. The suggestions work like a charm. Very nice. I still need to digest the advices, but have already one further question: How would I compute the new value based on the 2 (or even more) last values instead of only the last one? [ 2, 3 , f 3 2,

Re: [Haskell-cafe] Data.Binary Endianness

2007-09-10 Thread Jules Bean
Adrian Neumann wrote: For example, the internet states, that the magic number, that puts 'BM' in the first two bytes of the file is 19778. But when I put (19778::Word16) I get 'MB' instead. I read on the german Wikipedia, that bmp uses little endian encoding, but Data.Binary uses big endian.

Re: [Haskell-cafe] Data.Binary Endianness

2007-09-10 Thread Jules Bean
Thomas Schilling wrote: On Mon, 2007-09-10 at 11:10 +0100, Jules Bean wrote: The docs are not as well interlinked as you might hope. In fact, the docs on hackage are interlinked nicely. That is, for packages for which the documentation builds. On the documentation page: http

Re: [Haskell-cafe] Data.Binary Endianness

2007-09-11 Thread Jules Bean
Ketil Malde wrote: On Tue, 2007-09-11 at 09:10 +0200, Sven Panne wrote: foo :: Binary a = ... - a - ...? This should probably mean foo is using some portable (de-)serialization, but doesn't care about the actual representation, I'm probably missing something, but: How can the format be

Re: [Haskell-cafe] Data.Binary Endianness

2007-09-11 Thread Jules Bean
Ketil Malde wrote: On Tue, 2007-09-11 at 12:01 +0100, Jules Bean wrote: How can the format be portable if the representation isn't unambigously defined? And if it is unabmigously defined, what's wrong with using it for externally defined data formats? It's portable because it works on other

Re: [Haskell-cafe] Tiny documentation request

2007-09-11 Thread Jules Bean
Andrew Coppin wrote: OTOH, I recently discovered that GHCi has the ability to show you what's defined in a given module without me having to wait 40 seconds for Firefox to start... Shame you can't scroll its output. (And still no help if you're not sure of the module name.) !!! Run ghci in

Re: [Haskell-cafe] haskell and reflection

2007-09-11 Thread Jules Bean
Greg Meredith wrote: Haskellians, Am i wrong in my assessment that the vast majority of reflective machinery is missing from Haskell? Specifically, * there is no runtime representation of type available for programmatic representation * there is no runtime representation of the

Re: [Haskell-cafe] Data.Binary Endianness

2007-09-11 Thread Jules Bean
Bryan O'Sullivan wrote: (All of the above speaks of the 'high-level' Data.Binary not the 'low-level'.) Data.Binary *is* the low-level Data.Binary :-) I was distinguishing between these two levels: (1) High-level = Binary typeclass. Contains instances for many, many useful common types, the

Re: [Haskell-cafe] Haskell and State Monad.

2007-09-12 Thread Jules Bean
VinyleEm wrote: Hello all, I am Vinay Emani, new to this forum. I am doing an academic project of writing an assembler cum linker in Haskell as part of building a compiler set written entirely in Haskell. Since i am new to the language, i thought it would do me good to look at some of the

Re: [Haskell-cafe] getting crazy with character encoding

2007-09-12 Thread Jules Bean
David Benbennick wrote: On 9/12/07, Andrea Rossato [EMAIL PROTECTED] wrote: If I run it in a console I get abAAA (sort of) no matter what my LANG is - 8 single 8 -bit characters. It's possible to set your Linux console to grok UTF8. I don't remember the details, but I'm sure you can Google

Re: [Haskell-cafe] Re: Is take behaving correctly?

2007-09-13 Thread Jules Bean
Neil Mitchell wrote: Hi A more serious point is that in some cases we might want take to underapproximate, or zip to truncate (or tail [] = [] ?). I don't think there's always a clear library choice here. I have a zipWithEq function I often use, which crashes if the zip'd lists aren't equal.

Re: [Haskell-cafe] Re: Is take behaving correctly?

2007-09-13 Thread Jules Bean
Neil Mitchell wrote: Hi Although I appluad the semantics of the safe package, I'm not delighted with the idea of replacing our concise elegant standard library names with uglyAndRatherLongCamelCaseNamesThatCouldBePerlOrEvenJava though. Conciseness of expression is a virtue. They aren't that

Re: [Haskell-cafe] Re: Is take behaving correctly?

2007-09-13 Thread Jules Bean
Jeff Polakow wrote: Hello, There are 4 variants of tail: tail :: [a] - [a] -- normal tailDef :: [a] - [a] - [a] -- returns the first argument on [] tailMay :: [a] - Maybe [a] -- returns a Nothing tailNote :: String - [a] - [a] -- crashes, but with a helpful message tailSafe ::

[Haskell-cafe] MonadGL - Partitioning effects without giving up type inference

2007-09-13 Thread Jules Bean
The OpenGL bindings which come bundled with ghc are a really great example of how even an almost-literal port of a C API can still be easier to work with in haskell than it is in C, because of the benefits of type inference and powerful abstractions. Even the ability to mapM_ is a tool to make C

Re: [Haskell-cafe] C's fmod in Haskell

2007-09-17 Thread Jules Bean
Peter Verswyvelen wrote: Maybe this is a stupid question, but I don't find something similar in Haskell. I find mod and rem, which work on integers. But I'm looking for a function similar to C's fmod. Of course I can write it myself, but I guess it must already exist under a different

[Haskell-cafe] Re: [Haskell] Blocked STM GC question

2007-09-18 Thread Jules Bean
Simon Marlow wrote: Ashley Yakeley wrote: If I have a thread that's blocked on an STM retry or TChan read, and none of its TVars are referenced elsewhere, will it get stopped and garbage-collected? I have in mind a pump thread that eternally reads off a TChan and pushes the result to some

Re: [Haskell-cafe] bindings to the xmms_remote API, GList and something more

2007-09-24 Thread Jules Bean
Andrea Rossato wrote: I'm not even sure if this message will get through. Actually this is the only mailing list I have some problem with... perhaps some filter may be considering my messages as spam. I'd like to have a copy of that filter installed on my system! I saw it. In total, four

Re: [Haskell-cafe] Shouldnt this be lazy too?

2007-09-25 Thread Jules Bean
Vimal wrote: From the wiki: If you write it, you force Haskell to create all list nodes. ... Alright. Now, lets look at the definition again: length [] = 0 length (x:xs) = 1 + length xs We see that the value of *x* isnt needed at all. So, why does GHC allocate so much memory creating all

Re: [Haskell-cafe] Newb question about map and a list of lists

2007-09-28 Thread Jules Bean
Chuk Goodin wrote: I have a list of lists of pairs of numeric Strings (like this: [[2,3],[1,2],[13,14]] etc.) I'd like to change it into a list of a list of numbers, but I'm not sure how to go about it. If it was just one list, I could use map, but map.map doesn't seem to work. Any

Re: [Haskell-cafe] Opengl and Haskell GLdouble/GLfloat vs. Double/Float

2007-09-28 Thread Jules Bean
bbrown wrote: I am going to be doing a lot of opengl stuff in haskell and so far one thing has irked me. Why does haskell keep the GLFloat and GL types and not just the Haskell types. It mirrors the C API in doing so. I assume that this is because, in principle a system might exist where

Re: [Haskell-cafe] Assignment, Substitution or what?

2007-10-03 Thread Jules Bean
PR Stanley wrote: Yes and thanks for the reply. When a function is declared in C the argument variable has an address somewhere in the memory: int f ( int x ) { return x * x; } any value passed to f() is assigned to x. x is the identifier for a real slot in the memory (the stack most likely)

[Haskell-cafe] with and preserving for local state

2007-10-03 Thread Jules Bean
Lots of external libraries contain state, but one that really contains a *lot* of state is the OpenGL libraries, since OpenGL is specified as a statemachine. This means that when you're writing structured code you quite often want to save and restore chunks of state 'automatically'. For the

Re: [Haskell-cafe] Re: bizarre memory usage with data.binary

2007-10-03 Thread Jules Bean
Spencer Janssen wrote: On Tuesday 02 October 2007 19:51:47 Anatoly Yakovenko wrote: If its specifically the list instance, where we currently trade laziness for efficiency of encoding (which may or may not be the right thing), I'd suggest a fully lazy encoding instance? Its not really a list,

Re: [Haskell-cafe] Re: bizarre memory usage with data.binary

2007-10-04 Thread Jules Bean
Thomas Conway wrote: On 10/4/07, Jules Bean [EMAIL PROTECTED] wrote: ...and indeed it can't be done, except by the naive brute-force method of comparing every subtree, possibly optimised by cryptographically hashing a representation of every subtree, since sharing isn't an observable property

Re: [Haskell-cafe] Haskell FFI and finalizers

2007-10-04 Thread Jules Bean
Stefan O'Rear wrote: Calling Haskell code from the garbage collector is essentially impossible to do efficiently and correctly. Don't even try it, your sanity is not worth saving 3 lines of C coding. It is a sad thing indeed if that is correct advice. Jules

Re: [Haskell-cafe] pi

2007-10-10 Thread Jules Bean
[EMAIL PROTECTED] wrote: Somehow I do not only think that the default implementation would be good for nothing, but that putting PI into Floating as a class member, serves nobody. Are you aware that it already is in the Floating class? This discussion is not about adding it, but about whether

Re: [Haskell-cafe] pi

2007-10-10 Thread Jules Bean
[EMAIL PROTECTED] wrote: This discussion is not about adding it, but about whether or not it should have a default. Are you suggesting pi should be removed from the Floating class? Then, what type would you give pi? First, I don't care whether it is there or not. When I use it, I define a

Re: [Haskell-cafe] Filesystem questions

2007-10-14 Thread Jules Bean
Yitzchak Gale wrote: How about a built-in function that represents a directory tree as a lazy Data.Tree? Please no. The last thing haskell needs is more dangerous semantically broken non-referentially-transparent lazy IO structures. Jules ___

Re: [Haskell-cafe] Java - Haskell adjustment

2007-10-15 Thread Jules Bean
Ryan Bloor wrote: Hi, its Ryan here... I've just come from an intensive course in java and have been thrown into the imperative world of haskell. The problem that I have is extremely simple in java but I am having trouble adjusting my old mindset. A multiset is a collection of items. Each

Re: [Haskell-cafe] Bug in runInteractiveProcess?

2007-10-16 Thread Jules Bean
John Goerzen wrote: Many systems will just try to close *all* FDs except the ones they need after a fork(). Another approach would be to maintain a global list of FDs that the Haskell thread is using, and close all of them except the pipe ends in the child. Does this make sense to everyone?

Re: [Haskell-cafe] Automatic file closing after readFile

2007-10-18 Thread Jules Bean
Is there some (easy) way to avoid this while still using readFile? readFile' f = do s - readFile f return (length s `seq` s) (and curse the fact that the default readFile is unsafelazy). Jules ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] Automatic file closing after readFile

2007-10-18 Thread Jules Bean
Magnus Therning wrote: On Thu, Oct 18, 2007 at 12:05:40 +0100, Jules Bean wrote: Is there some (easy) way to avoid this while still using readFile? readFile' f = do s - readFile f return (length s `seq` s) (and curse the fact that the default readFile is unsafelazy

Re: [Haskell-cafe] Hiding side effects in a data structure

2007-10-19 Thread Jules Bean
Simon Peyton-Jones wrote: Good idea. GHC uses it http://darcs.haskell.org/ghc/compiler/basicTypes/UniqSupply.lhs Lennart Augustsson and friends invented it @techreport{Augustsson92a, ... You know what would be really nice? A summary of here are all the really cool tricks we use in

Re: [Haskell-cafe] Do you trust Wikipedia?

2007-10-19 Thread Jules Bean
[EMAIL PROTECTED] wrote: *PLEASE*, show me untrustworthy Wikipedia pages. Any article on a disputed territory or open political dispute. Most articles on a controversial philosophy. Many articles on living people. I hope I don't have to give examples. Certainly I don't wish to discuss any

Re: [Haskell-cafe] Polymorphic (typeclass) values in a list?

2007-10-19 Thread Jules Bean
Sebastian Sylvan wrote: On 19/10/2007, Kalman Noel [EMAIL PROTECTED] wrote: data ExistsNumber = forall a. Num a = Number a I'm without a Haskell compiler, but shouldn't that be exists a.? IIRC forall will work too, but the right way to do it is exists, right? No. It's been suggested but

Re: [Haskell-cafe] Automatic file closing after readFile

2007-10-19 Thread Jules Bean
I agree with Matthew's comments in the post immediately before this. It takes him two decent paragraphs to explain what is going on, including a description of WHNF, a suggestion to use pen paper, a suggestion to read up on the semantics of unsafeInterleaveIO and more. What I find

Re: [Haskell-cafe] wordsBy in the base libraries?

2007-10-22 Thread Jules Bean
Maxime Henrion wrote: Hello all, What do you think about having a wordsBy function in the standard libraries? It often comes in handy. I speculate (but don't know) that the reason we don't have one is that there are quite a few choices to make: * delimiter as function (Char -

Re: [Haskell-cafe] Type vs TypeClass duality

2007-10-23 Thread Jules Bean
Short answer: You are worrying about syntax. The things you want are possible. TJ wrote: Following up on my previous thread, I have figured out why it bothered me that we cannot have a list such as the following: [abc, 123, (1, 2)] :: Show a = [a] That type doesn't mean what you want it to

Uniqueness of principle type? (was Re: [Haskell-cafe] Type vs TypeClass duality)

2007-10-23 Thread Jules Bean
TJ wrote: No. I am saying that Haskell's type system forces me to write boilerplate. Fair enough. Why can't it automatically construct them then? Assuming we do have a syntax for A list of objects, each of which is of some possibly different type 'a', subject only to the restriction that a

Re: [Haskell-cafe] newbie question about list performance

2007-10-29 Thread Jules Bean
John Lato wrote: I'm working with moderate-sized files (tens to hundreds of MBs) that have some ascii header data followed by a bunch of 32-bit ints. but I don't know if [Int32] is actually the best choice. It seems to me that something like a lazy list of strict arrays (analogous to a lazy

Re: [Haskell-cafe] viewing HS files in Firefox

2007-10-30 Thread Jules Bean
Isaac Dupree wrote: When I try to go to one of the Module.hs files, e.g. on darcs.haskell.org, it now has type HS and Firefox refuses to display it (and only lets me download it). Does anyone know how to make Firefox treat certain file types as others (HS as plain text, in particular)? so

Re: [Haskell-cafe] Re: Why can't Haskell be faster?

2007-10-31 Thread Jules Bean
Paulo J. Matos wrote: type system? Why is that? Shouldn't type system in fact speed up the generated code, since it will know all types at compile time? The *existence* of a type system is helpful to the compiler. Peter was referring to the differences between haskell and clean.

Re: [Haskell-cafe] Re: Why can't Haskell be faster?

2007-10-31 Thread Jules Bean
Robin Green wrote: On Wed, 31 Oct 2007 14:17:13 + Jules Bean [EMAIL PROTECTED] wrote: Specifically, clean's uniqueness types allow for a certain kind of zero-copy mutation optimisation which is much harder for a haskell compiler to automatically infer. It's not clear to me that it's

Re: [Haskell-cafe] do/if/then/else confusion

2007-11-01 Thread Jules Bean
David Carter wrote: readdirAll :: PD.DirStream - IO [String] readdirAll d = do dir - PD.readDirStream d if dir == then return [] else rest - readdirAll d return (dir:rest) Compiling with GHC 6.6.1 gives me the not-very-useful message Parse error in pattern,

Re: [Haskell-cafe] Disjunctive Normal Form

2007-11-01 Thread Jules Bean
It's much much easier to work with n-ary than binary. It's also easier to define disjunctive normal form by mutual recursion with conjunctive normal form. Jules ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] using an external application

2007-11-02 Thread Jules Bean
Can you please give me some hint to solve this problem? I'm a beginning haskell developer and I'm still a bit confused by the IO monad. Other people have explained to the OP why unsafe lazy IO is breaking his code. Yet another piece of evidence, in my opinion, that unsafe-lazy-by-default is

Re: [Haskell-cafe] The question of ByteString

2007-11-05 Thread Jules Bean
Brandon S. Allbery KF8NH wrote: On Nov 3, 2007, at 5:34 , Andrew Coppin wrote: (BTW, anybody have any clue what's happening with stream fusion? I remember reading the paper saying hey, this is how it works and it's cool and we're going to try to replace the whole list library with new

Re: [Haskell-cafe] FP design

2007-11-06 Thread Jules Bean
Levi Stephen wrote: Hi, I'm was wondering how most people work during when designing a functional program. Do you create data structures/types first? Do you work from some type signatures? For example, take a blog. Is the first step likely to be something like: data BlogEntry = BlogEntry {

Re: [Haskell-cafe] Memory-mapped arrays? (IArray interfaces, slices, and so on)

2007-11-07 Thread Jules Bean
Joel Reymont wrote: Is there such a thing as memory-mapped arrays in GHC? In principle, there could be an IArray instance to memory-mapped files. (There could also be a mutable version, but just the IArray version would be useful). I noticed just the other day that there are some 'obvious'

Re: [Haskell-cafe] Re: Memory-mapped arrays? (IArray interfaces, slices, and so on)

2007-11-08 Thread Jules Bean
Aaron Denney wrote: It may be that by opening it in write mode you could ensure that noone else modifies it (although I don't think this would work e.g. on nfs), It doesn't even work locally. Right. But mmap is only sensible to use (even in C) when you know about all the other processes

Re: [Haskell-cafe] Sinus in Haskell

2007-11-10 Thread Jules Bean
Brent Yorgey wrote: More generally, this is due to the fact that floating-point numbers can only have finite precision, so a little bit of rounding error is inevitable when dealing with irrational numbers like pi. This problem is in no way specific to Haskell. But some systems always

Re: [Haskell-cafe] Why are OCaml and Haskell being used at these companies?

2007-11-13 Thread Jules Bean
Laurent Deniau wrote: Henning Thielemann wrote: On Tue, 13 Nov 2007, Jon Harrop wrote: On Tuesday 13 November 2007 08:41, Henning Thielemann wrote: On Tue, 13 Nov 2007, Jon Harrop wrote: Penetration is highest in parts of industry where small groups of talented programmers get together,

Re: [Haskell-cafe] Re: Weird ghci behaviour?

2007-11-13 Thread Jules Bean
Simon Peyton-Jones wrote: | For technical reasons, GHCi can only support the *-form for modules | which are interpreted, so compiled modules and package modules can | only contribute their exports to the current scope. But it does mean | the interpreter isn't referentially transparent, which is

Re: [Haskell-cafe] Re: Weird ghci behaviour?

2007-11-13 Thread Jules Bean
Aaron Denney wrote: On 2007-11-13, Jules Bean [EMAIL PROTECTED] wrote: Simon Peyton-Jones wrote: | For technical reasons, GHCi can only support the *-form for modules | which are interpreted, so compiled modules and package modules can | only contribute their exports to the current scope

Re: [Haskell-cafe] Renaming constructors for readability

2007-11-14 Thread Jules Bean
Henning Thielemann wrote: On Tue, 13 Nov 2007, Dougal Stanton wrote: On 13/11/2007, Henning Thielemann [EMAIL PROTECTED] wrote: On Tue, 13 Nov 2007, Dougal Stanton wrote: -- int a = 3; -- int *pa = a; ampersand :: t - Pointer t ampersand a = Just a What's bad about using 'ampersand'

Re: [Haskell-cafe] Re: Weird ghci behaviour?

2007-11-15 Thread Jules Bean
Simon Marlow wrote: The only problem with this is that someone who isn't aware of this convention might accidentally be ignoring compiled code, or might wonder why their compiled code isn't being used. Well, perhaps this is less confusing than the current behaviour; personally I find the

Re: [Haskell-cafe] Re: let vs. where

2007-11-16 Thread Jules Bean
John Lato wrote: This actually clears up something that's been bothering me for some time. I've never really like syntax of types for functions with multiple arguments. Using the same token, -, to separate both arguments and the result seems very poor, because when reading a type you don't

Re: [Haskell-cafe] Tetris

2007-11-20 Thread Jules Bean
Andrew Coppin wrote: GLUT and GLX will also work, and at least the former has a Haskell binding. As far as I'm aware, GLUT isn't available for Windows. (Or rather, I tried it once, and it wasn't happy at all. And after some Google searching, I found it's not around any more.) As far as

Re: [Haskell-cafe] Tetris

2007-11-21 Thread Jules Bean
Peter Verswyvelen wrote: Yes indeed, and various implementations of GLUT on Windows have different quirks. The biggest lack of GLUT is its inability to load images... IMHO if you want to do OpenGL with Haskell, it's best to start with Gtk2HS anyway, which has all the support needed. ..at

Re: [Haskell-cafe] More problems [Tetris]

2007-11-22 Thread Jules Bean
Peter Verswyvelen wrote: No GLUT is not bundled with GHC 6.8.1 anymore. Yes, that is weird. I think it's weird too, so I bug reported it: http://hackage.haskell.org/trac/ghc/ticket/1917 Jules ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Call external program and get stdout

2007-11-22 Thread Jules Bean
Maurí­cio wrote: Hi, How can I call a program (like, for instance, 'grep text *') and get the standard output? All actions I found (executeFile, system) do not give me the output of the program. http://haskell.org/ghc/docs/latest/html/libraries/process-1.0.0.0/System-Process.html

Re: [Haskell-cafe] Re: Composing monads

2007-11-23 Thread Jules Bean
module Main (Main.main) where import Control.Monad import System.IO (*) :: Monad m = m () - (a - m ()) - (a - m ()) (*) f f' = \a - do{ f; f' a; } main :: IO () main = mapM_ ((putStrLn ) * putStrLn) $ map show [1,2,3] There is nothing wrong with that, but I would normally write:

Re: [Haskell-cafe] Composing monads

2007-11-23 Thread Jules Bean
Maurí­cio wrote: Hi, If I have two computations a-IO b and b-IO c, can I join them to get an a-IO c computation? I imagine something like a liftM dot operator. You've already been shown the = operator and how to define it from = by other answers. Just for variety, here is how you would

Re: [Haskell-cafe] Why aren't Float and Double Bounded?

2007-11-28 Thread Jules Bean
Josh Lee wrote: On Tue, 27 Nov 2007 14:41:59 -0500 Isaac Dupree [EMAIL PROTECTED] wrote: Henning Thielemann wrote: On Mon, 26 Nov 2007, Jason Dusek wrote: Among numeric types, it seems that only integer types are Bounded. Maybe because IEEE format supports Infinity? therefore, maxBound is

Re: [Haskell-cafe] Question about takeMVar

2007-11-28 Thread Jules Bean
Maurí­cio wrote: Hi, 'takeMVar' documentation says if there are multiple threads blocked in takeMVar, and the MVar becomes full, only one thread will be woken up. Since 'takeMVar' is a reading function, i.e., it doesn't change the value of the variable, why waking up only one thread? If we

Re: [Haskell-cafe] fast Array operations: foldl, drop

2007-11-29 Thread Jules Bean
Henning Thielemann wrote: I thought operations like foldl' and drop must be very fast on arrays (especially UArray) with appropriate pointer tricks, I mean pointer incrementing instead of indexing for foldl' and a pointer into the array for drop. Is it planned to add such functions? Ok, if foldl

Re: [Haskell-cafe] Re: Strings and utf-8

2007-11-29 Thread Jules Bean
Duncan Coutts wrote: On Wed, 2007-11-28 at 17:38 -0200, Maurí­cio wrote: (...) When it's phrased as truncates to 8 bits it sounds so simple, surely all we need to do is not truncate to 8 bits right? The problem is, what encoding should it pick? UTF8, 16, 32, EBDIC? (...) One

Re: [Haskell-cafe] Re: do

2007-12-04 Thread Jules Bean
Ben Franksen wrote: I don't buy this. As has been noted by others before, IO is a very special case, in that it can't be defined in Haskell itself, and there is no evaluation function runIO :: IO a - a. This is a straw man. Most monads will not have such a function: There is no function

Re: [Haskell-cafe] Advice for clean code.

2007-12-04 Thread Jules Bean
Felipe Lessa wrote: On Dec 4, 2007 1:28 AM, Don Stewart [EMAIL PROTECTED] wrote: -- How to display results instance Show Action where show MoveOutOfBounds= Sorry you can't move in that direction. show (MoveBadTerrain a) = case a of

Re: [Haskell-cafe] Array copying

2007-12-04 Thread Jules Bean
Andrew Coppin wrote: Andrew Coppin wrote: copy :: Word32 - IOUArray Word32 Bool - Word32 - IO (IOUArray Word32 Bool) copy p grid size = do let size' = size * p grid' - newArray (1,size') False mapM_ (\n - do b - readArray grid n if b then mapM_ (\x - writeArray grid' (n

Re: [Haskell-cafe] Why is this strict in its arguments?

2007-12-05 Thread Jules Bean
Paulo J. Matos wrote: Hello all, Hi. findAllPath :: (a - Bool) - (BTree a) - Maybe [[a]] findAllPath pred (Leaf l) | pred l = Just [[l]] | otherwise = Nothing findAllPath pred (Branch lf r rt) | pred r = let lfpaths = findAllPath pred lf

Re: [Haskell-cafe] Why is this strict in its arguments?

2007-12-06 Thread Jules Bean
Alistair Bayley wrote: Nested Maybe cases put me in mind of the Maybe monad. Although in this case it''s not trivial; we also need to involve the Maybe [a] instance of Data.Monoid too (for the mappend function). I do wonder if I'm abusing the monadic instances of Maybe though; is this really any

Re: [Haskell-cafe] type class question

2007-12-06 Thread Jules Bean
Peter Padawitz wrote: Yes, the recursive calls of compCommand are supposed to be calls of compBlock. The intention of the program is a generic evaluator comp... of Sigma-terms in arbitrary Sigma-algebras. The signature Sigma is given by the first 4 types (and the corresponding functions in

Re: [Haskell-cafe] Re: Waiting for thread to finish

2007-12-06 Thread Jules Bean
ChrisK wrote: A safer gimmick... Ben Franksen wrote: tickWhileDoing :: String - IO a - IO a tickWhileDoing msg act = do hPutStr stderr msg hPutChar stderr ' ' hFlush stderr start_time - getCPUTime tickerId - forkIO ticker ... an async exception here will leave the ticker runnning

Re: [Haskell-cafe] Re: Waiting for thread to finish

2007-12-06 Thread Jules Bean
david48 wrote: Threads won't give you a speedup unless you run the program on a multi-core/multi-proc machine. That's actually not true. Threads allow you managing your IO blocking better, and not making IO block your whole program can certainly speed it up by a couple of orders of

Re: [Haskell-cafe] Re: Re: type class question

2007-12-06 Thread Jules Bean
Ben Franksen wrote: Ryan Ingram wrote: On 12/5/07, Ben Franksen [EMAIL PROTECTED] wrote: You would have to use functional dependencies or associated types to eliminate this error. Alternatively, you can add a dummy argument of type block and pass undefined :: BlockType in to help choose the

Re: [Haskell-cafe] Re: Re: type class question

2007-12-07 Thread Jules Bean
Peter Padawitz wrote: Functional dependencies don't work in my case. Actually, I don't see why they should. Ah well, it's cruel to say that without explaining to us why! I'm not sure why a complete cyclic dep a - b - c - d - a isn't what you want. What seems to be needed here is a type

Re: [Haskell-cafe] Re: Re: type class question

2007-12-07 Thread Jules Bean
Peter Padawitz wrote: Jules Bean wrote: Peter Padawitz wrote: Functional dependencies don't work in my case. Actually, I don't see why they should. Ah well, it's cruel to say that without explaining to us why! Cause I don't see why the instantiation conflicts pointed out by others

Re: [Haskell-cafe] Re: Re: type class question

2007-12-07 Thread Jules Bean
Peter Padawitz wrote: So the fundep would solve the problem. But, actually, it doesn't :-( But actually, it does! Ben Franksen's answer from yesterday compiles fine for me if I add the missing fundep, block - command. Your original code compiles without error, given the fundep. Exact

Re: [Haskell-cafe] Point and link

2007-12-08 Thread Jules Bean
Bit Connor wrote: On Dec 8, 2007 10:15 PM, Andrew Coppin [EMAIL PROTECTED] wrote: Bit Connor wrote: On Dec 8, 2007 8:19 PM, Andrew Coppin [EMAIL PROTECTED] wrote: http://alts.homelinux.net/shots/195-0.jpg This is the kind of thing I'd like to end up with. Such a GUI would also be cool for

Re: [Haskell-cafe] Re: type class question

2007-12-10 Thread Jules Bean
Try again without missing out the list... Peter Padawitz wrote: Jules Bean wrote: Incidentally, I question why the compFoo are methods. Why not just make them polymorphic functions? They don't look like you expect instances to change them. The code continues to compile if I make them

Re: [Haskell-cafe] What is the role of $!?

2007-12-10 Thread Jules Bean
David Fox wrote: Here is a practical example I ran into a few days ago. With this expression: writeFile path (compute text) the file at path would be overwritten with an empty file if an error occurs while evaluating (compute text). With this one: writeFile path $! (compute text)

Re: [Haskell-cafe] Re: type class question

2007-12-10 Thread Jules Bean
Peter Padawitz wrote: What is so bad about making compFoo part of the class? It reduces the code (constraints can be avoided) and reflects the close connection between a signature Sig (implemented by the class) and the evaluation (compFoo) of Sig-terms in Sig-algebras. making it part of the

Re: [Haskell-cafe] Re: type class question

2007-12-10 Thread Jules Bean
Peter Padawitz wrote: Jules Bean wrote: Peter Padawitz wrote: What is so bad about making compFoo part of the class? It reduces the code (constraints can be avoided) and reflects the close connection between a signature Sig (implemented by the class) and the evaluation (compFoo) of Sig

Re: [Haskell-cafe] class default method proposal

2007-12-11 Thread Jules Bean
David Menendez wrote: On Dec 11, 2007 9:20 AM, Duncan Coutts [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: So my suggestion is that we let classes declare default implementations of methods from super-classes. snip. Does this proposal have any unintended consequences? I'm not

Re: [Haskell-cafe] Execution of external command

2007-12-14 Thread Jules Bean
Evan Laforge wrote: it seems that script may be not terminated if its output isn't read, so better code should be (_, h, g, _) - runInteractiveCommand script params result - hGetLine h hGetContents h = evaluate.length hGetContents g = evaluate.length Tangent here, but does anyone else think

Re: [Haskell-cafe] Monads that are Comonads and the role of Adjunction

2007-12-14 Thread Jules Bean
Dan Weston wrote: apfelmus wrote: Luke Palmer wrote: Isn't a type which is both a Monad and a Comonad just Identity? (I'm actually not sure, I'm just conjecting) Good idea, but it's not the case. data L a = One a | Cons a (L a) -- non-empty list Maybe I can entice you to elaborate

Re: [Haskell-cafe] type classes

2007-12-14 Thread Jules Bean
Peter Padawitz wrote: I'd like to define several instances of the same type class with the same type variable instance. Only method instances differ. How can I do this without writing copies of the type class? newtypes and modules have both been suggested. I have another suggestion: Don't!

Re: [Haskell-cafe] #haskell works

2007-12-15 Thread Jules Bean
Tim Chevalier wrote: It sounds like Team GHC is thinking about the exact same things you are here: http://hackage.haskell.org/trac/ghc/wiki/Status/Nov07 Thanks for posting that. I was unaware of that link, and it was very interesting reading. Jules

Re: [Haskell-cafe] Implementing a MUD server in haskell

2007-12-16 Thread Jules Bean
Jack Kelly wrote: struct room{ ... struct player * players; ... }; struct player{ ... struct room * room; ... }; From what I can see, I'd use a record type for players and rooms, but I'm not sure how to replicate the pointer effects: Essentially you have to choose some form of

Re: [Haskell-cafe] Questions about the Fu nctor class and it's use in Data types à la c arte

2007-12-16 Thread Jules Bean
[EMAIL PROTECTED] wrote: Roberto Zunino writes: without seq, there is no way to distinguish between undefined and (const undefined), no way to distinguish is perhaps too strong. They have slightly different types. At a particular type which they both inhabit, such as (a-b) or, to be

Re: [Haskell-cafe] OOP'er with (hopefully) trivial questions.....

2007-12-17 Thread Jules Bean
Peter Verswyvelen wrote: Very interesting, I did not know that! I thought newtype was an optimization of data, and that newtype was bad terminology. But if newtype is just a wrapper around a type, then the name is choosen well. I'm a bit confused why then one needs a data-constructor-like

Re: [Haskell-cafe] OOP'er with (hopefully) trivial questions.....

2007-12-18 Thread Jules Bean
Miguel Mitrofanov wrote: There's a third way, too, and I haven't seen anybody mention it yet I've noticed it, but there are some problems with this representation, so I decided not to mention it. It's OK as far as we don't want functions working on two areas - I don't see, how we can

Re: [Haskell-cafe] list utilities -- shouldn't these be in the hierarchical libs somewhere?

2007-12-18 Thread Jules Bean
Thomas Hartman wrote: I found http://haskell.cs.yale.edu/haskell-report/List.html had many useful one off type list functions such as subsequences and permutations which are nowhere to be found in hoogle, Data.List, or the haskell hierarchical libs Weird. It's not very many. Other

Re: [Haskell-cafe] OOP'er with (hopefully) trivial questions.....

2007-12-18 Thread Jules Bean
Miguel Mitrofanov wrote: class Shape a where { intersect :: Shape b = a - b - Bool } data Shape a = { intersect :: Shape b = a - b - Bool } in fact, the syntax is rather similar, too! :) Um, well, and how are you going to implement it? Yes, exactly. My only point is There

  1   2   3   4   5   >