[Haskell-cafe] Re: Existentials and type var escaping

2007-06-11 Thread Ben Rudiak-Gould
Roberto Zunino wrote: foo, as defined above does not work (lazy patterns not allowed), and in foo y = E (case y of E x - x) a variable escapes. I also tried with CPS with no success. Is foo definable at all? I'm starting to think that it is not, and that there must be a very good reason for

Visual Haskell 0.2 installer bug

2007-03-07 Thread Ben Rudiak-Gould
The Visual Haskell 0.2 VS'03 installer, downloaded today from http://www.haskell.org/visualhaskell/release-0.2/VSHaskell71.msi doesn't work correctly when a nonstandard install root is specified. All of the root-folder files go into the correct place, but files in subfolders (like bin) go

Re: Fractional/negative fixity?

2006-11-10 Thread Ben Rudiak-Gould
[EMAIL PROTECTED] wrote: I think that computable real fixity levels are useful, too. Only finitely many operators can be declared in a given Haskell program. Thus the strongest property you need in your set of precedence levels is that given arbitrary finite sets of precedences A and B, with

Re: Fractional/negative fixity?

2006-11-10 Thread Ben Rudiak-Gould
I'm surprised that no one has mentioned showsPrec and readsPrec. Anything more complicated than negative fixities would require their interfaces to be changed. -- Ben ___ Haskell-prime mailing list Haskell-prime@haskell.org

[Haskell-cafe] Re: Fractional/negative fixity?

2006-11-10 Thread Ben Rudiak-Gould
I'm surprised that no one has mentioned showsPrec and readsPrec. Anything more complicated than negative fixities would require their interfaces to be changed. -- Ben ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Rank N type tutorial?

2006-10-27 Thread Ben Rudiak-Gould
Greg Buchholz wrote: I'm not quite sure why this is illegal... foo :: Integer - (forall a. Show a = a) foo 2 = [foo] foo x = x ...while this is just fine... bar :: Integer - (forall a. Show a = a-b) - b bar 2 k = k [bar] bar x k = k x The way to think about it is that foralls are extra

[Haskell] Lexically scoped type variables: new proposal

2006-10-26 Thread Ben Rudiak-Gould
Hi, everyone. Long time no see. I have a specific proposal for scoped type variables, which is totally different from plans A and B, and which I'd like people to pick to pieces for me. (Especially you, Simon.) Type variable scoping in System F is simple: the type bindings are explicit and follow

Re: [Haskell-cafe] Re: Existentially-quantified constructors: Hugs is fine, GHC is not?

2006-05-19 Thread Ben Rudiak-Gould
Ross Paterson wrote: Why would a type variable be present at runtime, let alone bound to _|_? Well, it'd be present in jhc. And you want your intermediate language to typecheck even if the types disappear before you get to assembly language. And the same issue shows up with dictionaries,

Re: Class System current status

2006-05-12 Thread Ben Rudiak-Gould
Johannes Waldmann wrote: class ( Show p, ToDoc i, Reader b, ToDoc b, Measure p i b ) = Partial p i b | p i - b where ... -- (*) (*) A funny visual aspect of FDs is the absurd syntax. On the left of |, the whitespace is (type arg) application, but on the right, it suddenly denotes

[Haskell-cafe] Re: develop new Haskell shell?

2006-05-12 Thread Ben Rudiak-Gould
Brian Hulley wrote: Donn Cave wrote: (cd /etc/stuff; cat * result) Well the problem here is that the command leaves you in /etc/stuff so you have to remember this when you subsequently execute another command. No it doesn't. The parentheses around the command sequence cause it to run in

Re: WordPtr,IntPtr,IntMax,WordMax

2006-05-11 Thread Ben Rudiak-Gould
John Meacham wrote: also, incidentally, for anyone on x86 that cares about math performance, use -optc-fsse2 to make it use the much nicer math coprocessor available on modern x86 cpus. I object to its characterization as nicer. It's faster, but *lower precision*. It worries me that people

Re: WordPtr,IntPtr,IntMax,WordMax

2006-05-11 Thread Ben Rudiak-Gould
Simon Marlow wrote: I suppose you might argue that extra precision is always good. Well... I'm having a hard time thinking of a situation where it isn't. I realize that people want reproducibility, I'm just not convinced that they should. The situations where optimization flags make a

Re: WordPtr,IntPtr,IntMax,WordMax

2006-05-11 Thread Ben Rudiak-Gould
skaller wrote: On Fri, 2006-05-12 at 00:34 +0100, Ben Rudiak-Gould wrote: Simon Marlow wrote: I suppose you might argue that extra precision is always good. Well... I'm having a hard time thinking of a situation where it isn't. Wastes space in the cache tree, slowing down the program

[Haskell-cafe] Re: Existentially-quantified constructors: Hugs is fine, GHC is not?

2006-05-11 Thread Ben Rudiak-Gould
Otakar Smrz wrote: data ... = ... | forall b . FMap (b - a) (Mapper s b) ... where FMap qf qc = stripFMap f q the GHC compiler as well as GHCi (6.4.2 and earlier) issue an error My brain just exploded. I can't handle pattern bindings for existentially-quantified

Re: deeqSeq proposal

2006-04-05 Thread Ben Rudiak-Gould
Andy Gill wrote: - [various reasons for deepSeq] You left out the one that most interests me: ensuring that there are no exceptions hiding inside a data structure. deepSeq :: a - b - b This ties demand for the (fully evaluated) normal form of an expression to demand for the WHNF of a

[Haskell-cafe] Re: how would this be done? type classes?existential types?

2006-03-23 Thread Ben Rudiak-Gould
Brian Hulley wrote: Is there a reason for using instead of [exists a. Resource a=a] ? Only that = looks like a function arrow, looks like a tuple. I stole this notation from an unpublished paper by SimonPJ et al on adding existential quantification to Haskell. I'm not especially

[Haskell-cafe] Re: Positive integers

2006-03-23 Thread Ben Rudiak-Gould
Daniel McAllansmith wrote: I can see the domain bounds check would be a problem in theory, but in practice doesn't the type enforce that? Keeping Word positive costs nothing because it just overflows. Wouldn't it be much the same? If you're planning wraparound semantics then you're better

Re: Strict tuples

2006-03-22 Thread Ben Rudiak-Gould
John Meacham wrote: ghc's strictness analyzer is pretty darn good, If something is subtle enough for the compiler not to catch it, then the programmer probably won't right off the bat either. Even the best strictness analyzer can't determine that a function is strict when it really isn't. The

Re: Strict tuples

2006-03-22 Thread Ben Rudiak-Gould
Bulat Ziganshin wrote: Taral wrote: T I don't see that more optimization follows from the availability T of information regarding the strictness of a function result's T subcomponents. ghc uses unboxed tuples just for such sort of optimizations. instead of returning possibly-unevaluated pair

[Haskell-cafe] Re: different code in different platforms

2006-03-17 Thread Ben Rudiak-Gould
Neil Mitchell wrote: #ifdef __WIN32__ (Windows code) #else (Linux code) #endif In Yhc, we use a runtime test to check between Windows and Linux. I think the cleanest solution is to factor the OS-specific code into separate modules with OS-independent interfaces and names, and pull

[Haskell-cafe] Re: how would this be done? type classes? existential types?

2006-03-17 Thread Ben Rudiak-Gould
Matthias Fischmann wrote: now i want to create a list of a type similar to [r1, r2, r3] :: (Resource a) = [a] but with r1 being pizza, r2 being crude oil, and so on. The type you actually want here is [exists a. (Resource a) a], but no Haskell implementation supports that. data Rs =

[Haskell-cafe] Re: how would this be done? type classes? existentialtypes?

2006-03-17 Thread Ben Rudiak-Gould
Matthias Fischmann wrote: is there any difference between these two? if they are equivalent, why the two different ways to say it? data X where X :: (Resource a) = a - X data Y = forall a . (Resource a) = Y a There's no difference. There are two ways to say it for historical reasons.

[Haskell-cafe] Re: how would this be done? type classes? existential types?

2006-03-17 Thread Ben Rudiak-Gould
Matthias Fischmann wrote: On Thu, Mar 16, 2006 at 12:40:00PM +, Chris Kuklewicz wrote: (Why isn't it resourceName :: String ?) when i am trying this, ghc complains that the type of resourceName doesn't have any occurrance of 'a', and i feel that it must be harder for the type engine to

Re: small extension to `...` notation

2006-03-08 Thread Ben Rudiak-Gould
Philippa Cowderoy wrote: On Wed, 8 Mar 2006, Doaitse Swierstra wrote: xs `zipWith (+)` ys There is one problem with this: it doesn't nest [...] Another problem is that it's not clear how to declare the fixity of these things. Should they always have the default fixity? Should they be

Re: relaxed instance rules spec (was: the MPTC Dilemma (please solve))

2006-03-07 Thread Ben Rudiak-Gould
John Meacham wrote: On Thu, Mar 02, 2006 at 03:53:45AM -, Claus Reinke wrote: the problem is that we have somehow conjured up an infinite type for Mul to recurse on without end! Normally, such infinite types are ruled out by occurs-checks (unless you are working with Prolog III;-), so

[Haskell-cafe] Re: Layout rule (was Re: PrefixMap: code review request)

2006-03-02 Thread Ben Rudiak-Gould
I wrote: I just installed Visual Haskell 0.1, and when I type in the editor, CPU usage rises to about 70% and there's a noticeable delay before each character appears on the screen. This is no longer happening, so I guess I ran afoul of a bug. -- Ben

[Haskell] Re: Visual Haskell: Could not find module `Control.Monad.Writer'

2006-03-01 Thread Ben Rudiak-Gould
Replying to an old thread... Bernd Holzm├╝ller wrote: Could not find module `Control.Monad.Writer': use -v to see a list of the files searched for I just installed Visual Haskell and ran into the same problem, and the solution I found was to right click on References in the project and

Re: overlapping instances and constraints

2006-03-01 Thread Ben Rudiak-Gould
Niklas Broberg wrote: Ben Rudiak-Gould wrote: Are there uses of overlapping instances for which this isn't flexible enough? Certainly! Hmm... well, what about at least permitting intra-module overlap in Haskell' (and in GHC without -foverlapping-instances)? It's good enough for many

[Haskell-cafe] Re: Layout rule (was Re: PrefixMap: code review request)

2006-03-01 Thread Ben Rudiak-Gould
Duncan Coutts wrote: hIDE and Visual Haskell use the ghc lexer and get near-instantaneous syntax highlighting. Hmm... I just installed Visual Haskell 0.1, and when I type in the editor, CPU usage rises to about 70% and there's a noticeable delay before each character appears on the screen.

[Haskell-cafe] Re: Layout rule (was Re: PrefixMap: code review request)

2006-03-01 Thread Ben Rudiak-Gould
Benjamin Franksen wrote: TAB characters in program text should be forbidden by law. Well... they are quite useful for lining things up if you're using a proportional font, and I don't think proportionally-spaced code is a bad idea. I want them to be optional. But it would be nice if parsers

[Haskell-cafe] Re: Layout rule

2006-03-01 Thread Ben Rudiak-Gould
Ketil Malde wrote: Multi line comments are nice for commenting out blocks of code. They're also nice for comments within a line. E.g. haskell-src-exts contains the declaration data HsQualConDecl = HsQualConDecl SrcLoc {- forall -} [HsName] {- . -} HsContext {- = -}

[Haskell-cafe] Re: PrefixMap: code review request

2006-02-28 Thread Ben Rudiak-Gould
Brian Hulley wrote: Whoever thought up the original Haskell layout rule assumed that people would be happy using a single fixed width font, tabs set to 8 spaces, and didn't care about the brittleness of the code (in the face of identifier renamings) it allowed one to write. Are you

[Haskell-cafe] Re: rounding errors with real numbers.

2006-02-28 Thread Ben Rudiak-Gould
Henning Thielemann wrote: Maybe you should use a kind of convex combination, that is (x-oldLower)*a + (oldUpper-x)*b Maybe lower*(1-z) + upper*z where z = (x-oldLower) / (oldUpper-oldLower). I think this will always map oldLower and oldUpper to lower and upper exactly, but I'm not sure it's

[Haskell-cafe] Layout rule (was Re: PrefixMap: code review request)

2006-02-28 Thread Ben Rudiak-Gould
Brian Hulley wrote: Here is my proposed layout rule: 1) All layout keywords (where, of, let, do) must either be followed by a single element of the corresponding block type, and explicit block introduced by '{', or a layout block whose first line starts on the *next* line I wouldn't have

[Haskell] Re: strange behavior of Implicit Parameters

2006-02-27 Thread Ben Rudiak-Gould
I'd advise against using implicit parameters, because (as you've seen) it's hard to reason about when they'll get passed to functions. Another example: http://www.haskell.org/pipermail/haskell-cafe/2005-January/008571.html -- Ben ___ Haskell

[Haskell-cafe] Re: -fno-monomorphism-restriction makes type-inference ambiguous?

2006-02-27 Thread Ben Rudiak-Gould
Eike Scholz wrote: mylength = synAttr listLength $ *Main :type synAttr $ synAttr :: (Data b) = ((?stack::[Dyn]) = b - a) - Attr a $ *Main :type listLength $ listLength :: (?stack::[Dyn]) = List - Float $ *Main :type (synAttr listLength) $ (synAttr listLength) :: Attr Float $ *Main :type

Re: inside the GHC code generator

2006-02-24 Thread Ben Rudiak-Gould
Rene de Visser wrote: Integer is about 30 times slower than it needs to be on GHC if you have over half the values between 2^-31 and 2^31. On i386 can you basically can test the low bit for free (it runs in parallel to the integer add instruction). This would allow only values outside this

Re: inside the GHC code generator

2006-02-24 Thread Ben Rudiak-Gould
Simon Peyton-Jones wrote: | [...] put a static table in the executable with | information about register and stack usage indexed by procedure return | point, and use that to unwind the stack and find roots. Every accurate garbage collector (including GHC's) uses a technique like this, but the

[Haskell] Re: Compilation of big, static tables

2006-02-24 Thread Ben Rudiak-Gould
John Meacham wrote: On Thu, Feb 23, 2006 at 10:40:31AM +, Malcolm Wallace wrote: What I would really like is a syntax to statically construct an array, without having to compute it from a list. This is exactly what my ForeignData proposal on the haskell-prime wiki is meant to address

Re: inside the GHC code generator

2006-02-23 Thread Ben Rudiak-Gould
[EMAIL PROTECTED] wrote: * multiple results can be returned via C++ paira,b template, if this is efficiently implemented in gcc There's a -freg-struct-return option in 2.x, 3.x and 4.x. I think it's off by default on many architectures. * recursive definitions translated into the for/while

Implicit Prelude (was Re: Export lists in modules)

2006-02-23 Thread Ben Rudiak-Gould
Malcolm Wallace wrote: Yes, many trivial programs would acquire one extra import decl - is that such a big deal? No, but overall it feels like a slight loss, because I'd expect the modules that gained a line to be shorter on average, and adding a line to a shorter module seems like a bigger

Re: Export lists in modules

2006-02-23 Thread Ben Rudiak-Gould
Malcolm Wallace wrote: An explicit interface would be useful for many purposes besides machine-checked documentation. For instance, it could be used to eliminate the hs-boot or hi-boot files used by some compilers when dealing with recursive modules. Why *does* ghc require hs-boot files? What

Capitalized type variables (was Re: Scoped type variables)

2006-02-23 Thread Ben Rudiak-Gould
I wrote: What I don't like is that given a signature like x :: a - a there's no way to tell, looking at it in isolation, whether a is free or bound in the type. [...] Here's a completely different idea for solving this. It occurs to me that there isn't all that much difference between

Re: Module System

2006-02-22 Thread Ben Rudiak-Gould
Simon Marlow wrote: there's a lack of modularity in the current design, such that renaming the root of a module hierarchy requires editing every single source file in the hierarchy. The only good reason for this is the separation between language and implementation. I don't see how this is

Re: The worst piece of syntax in Haskell

2006-02-22 Thread Ben Rudiak-Gould
Ashley Yakeley wrote: foo :: (Monad m) = [m a] - m [a] instance Integral a = Eq (Ratio a) class Monad m = MonadPlus m I think the most consistent (not most convenient!) syntax would be foo :: forall m a. (Monad m) = [m a] - m [a] instance forall a. (Integral a) = Eq (Ratio a)

[Haskell] Re: IO == ST RealWorld

2006-02-20 Thread Ben Rudiak-Gould
John Meacham wrote: ST doesn't have exceptions which IO does. It would be no good to make ST pay for the cost of exception handling. GHC handles them behind the scenes (I think?) but in jhc they are explicit and IO is defined as follows: data World__ data IOResult a = FailIO World__ IOError |

[Haskell] Re: Question for the haskell implementors: Arrays, unsafePerformIO, runST

2006-02-16 Thread Ben Rudiak-Gould
Data.Array.ST has runSTArray :: Ix i = (forall s . ST s (STArray s i e)) - Array i e I think if you can implement that, then all your problems will be solved. -- Ben ___ Haskell mailing list Haskell@haskell.org

Re: ExistentialQuantifier

2006-02-16 Thread Ben Rudiak-Gould
Ross Paterson wrote: I don't think the original name is inappropriate: the feature described is certainly existential quantification, albeit restricted to alternatives of data definitions. I think that existential quantification should mean, well, existential quantification, in the sense that

[Haskell] compares :: Ord a = a - a - Ordering - Ordering

2006-02-14 Thread Ben Rudiak-Gould
I just realized that the class Ord should have an additional method: class Eq a = Ord a where compares :: a - a - Ordering - Ordering compares x y d = case compare x y of { EQ - d ; o - o } ... This would make writing Ord instances much easier: instance (Ord a, Ord b, Ord c,

Re: forall a (Ord a = a- a) - Int is an illegal type???

2006-02-11 Thread Ben Rudiak-Gould
David Menendez wrote: Ben Rudiak-Gould writes: | forall a. (forall b. Foo a b = a - b) - Int | | is a legal type, for example. Is it? GHCi gives me an error if I try typing a function like that. This works: f :: forall a. (forall b. Foo a b = a - b) - Int f _ = 3 I interpret

[Haskell-cafe] Re: Matching constructors

2006-02-11 Thread Ben Rudiak-Gould
Mark T.B. Carroll wrote: Creighton Hogg [EMAIL PROTECTED] writes: data Patootie = Pa Int | Tootie Int and I want to pull out the indices of all elements of a list that have type constructor Tootie, how would I do that? x = [Pa 3, Tootie 5, Pa 7, Tootie 9, Pa 11] y = [ i |Tootie i - x ]

Re: forall a (Ord a = a- a) - Int is an illegal type???

2006-02-09 Thread Ben Rudiak-Gould
Brian Hulley wrote: I'm puzzled why GHC chooses to create illegal types instead of finding the innermost quantification point ie I would think that (Ord a= a-a) - Int should then obviously be shorthand for (forall a. Ord a= a-a) - Int and surely this could easily be

Re: exported pattern matching

2006-02-09 Thread Ben Rudiak-Gould
Philippa Cowderoy wrote: Myself I'm of the view transformational patterns (as described in http://citeseer.ist.psu.edu/299277.html) are more interesting - I can't help wondering why they were never implemented? Maybe because of tricky semantics. I'm not quite sure what case x of

Re: Passing a matrix from C to Haskell

2006-02-08 Thread Ben Rudiak-Gould
Cyril Schmidt wrote: I was thinking of something like passing the array as Ptr Int#, but how do I fetch the elements that I am interested in? I think you want Ptr CInt and peekElemOff. If the array is declared in C as int a[100][20] and p :: Ptr CInt is a Haskell pointer to it, then

Re: Restricted Data Types

2006-02-07 Thread Ben Rudiak-Gould
John Hughes wrote: That means that the Monad class is not allowed to declare return :: a - m a because there's no guarantee that the type m a would be well-formed. The type declared for return has to become return :: wft (m a) = a - m a I'm confused. It seems like the type (a - m a)

Scoped type variables

2006-02-07 Thread Ben Rudiak-Gould
Simon PJ thinks that Haskell' should include scoped type variables, and I tend to agree. But I'm unhappy with one aspect of the way they're implemented in GHC. What I don't like is that given a signature like x :: a - a there's no way to tell, looking at it in isolation, whether a is free

Re: Java-like

2006-02-07 Thread Ben Rudiak-Gould
Bulat Ziganshin wrote: {-# OPTIONS_GHC -fglasgow-exts #-} main = do return xx = ((\x - print x) :: Show a = a - IO ()) main2 = do return xx = (\(x:: (forall a . (Show a) = a)) - print x) main3 = do (x :: forall a . Show a = a) - return xx print x in this module, only main compiles ok

Re: Restricted Data Types

2006-02-07 Thread Ben Rudiak-Gould
Simon Peyton-Jones wrote: Another reasonable alternative is data Set a = Eq a = Set (List a) The type of member would become member :: a - Set a - Bool (with no Eq constraint). John Hughes mentions this in section 5.2 of the paper, and points out a problem: a function like

[Haskell-cafe] Re: extending bang proposal Re: strict Haskell dialect

2006-02-07 Thread Ben Rudiak-Gould
Brian Hulley wrote: One motivation seems to be that in the absence of whole program optimization, the strictness annotations on a function's type can allow the compiler to avoid creating thunks at the call site for cross-module calls whereas using seq in the function body itself means that the

Re: Bang patterns

2006-02-06 Thread Ben Rudiak-Gould
Pursuant to a recent conversation with Simon, my previous post to this thread is now obsolete. So please ignore it, and see the updated wiki page instead. -- Ben ___ Haskell-prime mailing list Haskell-prime@haskell.org

Re: Restricted Data Types

2006-02-06 Thread Ben Rudiak-Gould
Jim Apple wrote: Have we considered Restricted Data Types? http://www.cs.chalmers.se/~rjmh/Papers/restricted-datatypes.ps I'd never seen this paper before. This would be a really nice extension to have. The dictionary wrangling looks nasty, but I think it would be easy to implement it in

[Haskell-cafe] Re: extending bang proposal Re: strict Haskell dialect

2006-02-06 Thread Ben Rudiak-Gould
Bulat Ziganshin wrote: Hello Ketil, KM (Is the second ! actually meaningful?) yes! it means that the function is strict in its result - i.e. can't return undefined value when strict arguments are given. Unfortunately this interpretation runs pretty quickly into theoretical difficulties. A !

Re: FilePath as ADT

2006-02-05 Thread Ben Rudiak-Gould
Marcin 'Qrczak' Kowalczyk wrote: Encouraged by Mono, for my language Kogut I adopted a hack that Unicode people hate: the possibility to use a modified UTF-8 variant where byte sequences which are illegal in UTF-8 are decoded into U+ followed by another character. I don't like the idea of

[Haskell-cafe] Re: Why is $ right associative instead ofleftassociative?

2006-02-05 Thread Ben Rudiak-Gould
Paul Hudak wrote: Minor point, perhaps, but I should mention that : is not special syntax -- it is a perfectly valid infix constructor. But Haskell 98 does treat it specially: you can't import Prelude hiding ((:)), or rebind it locally, or refer to it as Prelude.:. In fact I've always

[Haskell-cafe] Re: Why is $ right associative instead of leftassociative?

2006-02-05 Thread Ben Rudiak-Gould
Tomasz Zielonka wrote: On Sun, Feb 05, 2006 at 01:14:42PM -, Brian Hulley wrote: How about: f x y . g x $ z But then you have a problem when you when you want to add something at the beginning ;-) How about: id . f x y . g x $ z -- Ben

Re: strict Haskell dialect

2006-02-04 Thread Ben Rudiak-Gould
Chris Kuklewicz wrote: Weak uses seq to achieve WHNF for it's argument newtype Weak a = WeakCon {runWeak :: a} mkWeak x = seq x (WeakCon x) unsafeMkWeak x = WeakCon x This doesn't actually do what you think it does. mkWeak and unsafeMkWeak are the same function. mkWeak 123 = seq 123

[Haskell-cafe] Re: strict Haskell dialect

2006-02-04 Thread Ben Rudiak-Gould
Chris Kuklewicz wrote: Weak uses seq to achieve WHNF for it's argument newtype Weak a = WeakCon {runWeak :: a} mkWeak x = seq x (WeakCon x) unsafeMkWeak x = WeakCon x This doesn't actually do what you think it does. mkWeak and unsafeMkWeak are the same function. mkWeak 123 = seq 123

[Haskell-cafe] Re: Why is $ right associative instead of left associative?

2006-02-04 Thread Ben Rudiak-Gould
No one has mentioned yet that it's easy to change the associativity of $ within a module in Haskell 98: import Prelude hiding (($)) infixl 0 $ f$x = f x or, for the purists, import Prelude hiding (($)) import qualified Prelude (($)) infixl 0 $ ($) = (Prelude.$)

Re: The dreaded M-R

2006-01-31 Thread Ben Rudiak-Gould
John Meacham wrote: interestingly enough, the monomorphism restriction in jhc actually should apply to all polymorphic values, independently of the type class system. x :: a x = x will transform into something that takes a type parameter and is hence not shared. Interesting. I'd been

Re: [Haskell] IO == ST RealWorld

2006-01-24 Thread Ben Rudiak-Gould
Ross Paterson wrote: But IO isn't a state monad: others are concurrently changing the world without waiting for my Haskell program to terminate. I think that closed-world behavior should be treated as a property of runST, not of the ST monad operations. Otherwise your IORef = STRef IORegion

Re: [Haskell-cafe] Guess what ... Tutorial uploaded! :)

2006-01-23 Thread Ben Rudiak-Gould
Dmitry Astapov wrote: http://www.haskell.org/hawiki/HitchhickersGuideToTheHaskell I like the approach too, but the section on IO actions, which I'm reading now, is not correct. It's not true that a - someAction has the effect of associating a with someAction, with the actual work deferred

Re: [Haskell-cafe] Shootout favouring C

2006-01-16 Thread Ben Rudiak-Gould
Isaac Gouy wrote: Please keep to the true spirit of fictional crime writing and provide a motive for these evil characters who will stop at nothing to make Haskell seem some worse than C. Erm, fictional? It strikes me that this particular brand of evil is more the norm than the exception. I

Re: [Haskell-cafe] Existentially-quantified constructors, Eq and Show

2005-12-11 Thread Ben Rudiak-Gould
John Meacham wrote: PS. many, including me, feel 'forall' is a misnomer there and should be the keyword 'exists' instead. so just read 'foralls' that come _before_ the type name as 'exists' in your head and it will make more sense. I disagree. When you write forall a. D (P a) (Q a) it

Re: [Haskell-cafe] Two questions: lazy evaluation and Church-Rosser

2005-11-19 Thread Ben Rudiak-Gould
Gregory Woodhouse wrote: I've been trying to do some background reading on lambda calculus, and have found discussions of strict evaluation strategies (call-by-value and call-by-name) but have yet to find an appropriate framework for modeling lazy evaluation Just wanted to point out that

Re: [Haskell] Monads vs. continuations

2005-10-31 Thread Ben Rudiak-Gould
I don't know if this helps, but there's a straightforward way to understand the IO monad in terms of continuation passing. You can think of a value of type IO a as being a CPS expression with a hole in it; the hole is to be filled with a continuation which expects a value of type a. The only

Re: [Haskell-cafe] newtype is superfluous

2005-10-15 Thread Ben Rudiak-Gould
Wolfgang Jeltsch wrote: This is not true. With newtype, A _|_ is _|_, with data, A _|_ is not _|_. It's probably more helpful to explain this in terms of a program that exhibits different behavior in the two cases: case error data of A x - newtype But as far as I know, the above

Re: [Haskell-cafe] Newbie question on Haskell type

2005-10-14 Thread Ben Rudiak-Gould
Cale Gibbard wrote: As an example of this sort of thing, I know that there are only 4 values of type a - Bool (without the class context). They are the constant functions (\x - True), (\x - False), and two kinds of failure (\x - _|_), and _|_, where _|_ is pronounced bottom and represents

Re: [Haskell-cafe] Growing Trees

2005-09-22 Thread Ben Rudiak-Gould
[Previously sent only to the OP -- oops] Tom Hawkins wrote: data Tree a = TreeRoot { stuff:: a , children :: [Tree] } | TreeNode { stuff:: a , parent :: Tree , children :: [Tree] } But because of these bidirectional

Re: [Haskell] Mixing monadic and non-monadic functions

2005-09-17 Thread Ben Rudiak-Gould
Bjorn Lisper wrote: However, there is a way to resolve the ambiguity that can be claimed to be the most natural one, and that is to always choose the least possible lifting. In the example above, this would mean to interpret [[1]]++[[2]] precisely as [[1]]++[[2]] (lift 0 levels) rather than

Re: [Haskell] Mixing monadic and non-monadic functions

2005-09-17 Thread Ben Rudiak-Gould
Frederik Eaton wrote: I think this is a good idea. I like the inline -, or maybe something like @. The operator-section notation (- expr) has the big advantage of being unlikely to collide with any other syntax proposals. I'm not sure what you intend to do about nested do statements,

Re: [Haskell] Mixing monadic and non-monadic functions

2005-09-14 Thread Ben Rudiak-Gould
Frederik Eaton wrote: I want the type system to be able to do automatic lifting of monads, i.e., since [] is a monad, I should be able to write the following: [1,2]+[3,4] and have it interpreted as do {a-[1,2]; b-[3,4]; return (a+b)}. The main problem is ambiguity: [[1]]++[[2]] could be

Re: [Haskell-cafe] Parity of the number of inversions of a permutation

2005-03-15 Thread Ben Rudiak-Gould
Henning Thielemann wrote: I' searching for a function which sorts the numbers and determines the parity of the number of inversions. I assume that there are elegant and fast algorithms for this problem (n * log n time steps), e.g. a merge sort algorithm. This is a rather nice little problem. I

Re: [Haskell] Proposal: Allow \= for field update in record update syntax

2005-03-02 Thread Ben Rudiak-Gould
Benjamin Franksen wrote: On Thursday 24 February 2005 23:27, Keean Schupke wrote: Well, not quite true, because the type of the label is used to index the value, the selection happens at compile time. So at run time there is no instance selection left... it is simply the value. At least in

Re: [Haskell] Type of y f = f . f

2005-02-28 Thread Ben Rudiak-Gould
Pedro Vasconcelos wrote: Jim Apple [EMAIL PROTECTED] wrote: Is there a type we can give to y f = f . f y id y head y fst are all typeable? Using ghci: Prelude let y f = f.f Prelude :t y y :: forall c. (c - c) - c - c So it admits principal type (a-a) - a-a. From this you can see that (y

Re: [Haskell] Typing in haskell and mathematics

2005-02-01 Thread Ben Rudiak-Gould
Jeremy Gibbons wrote: If you want a b c to mean (a b) (b c) but a + b + c to mean (a + b) + c, you're going to have to treat differently from +, which goes against the spirit of considering them both simply functions. I've wanted to chime in here for a while now. I strongly disagree with

Re: [Haskell-cafe] Re: File path programme

2005-01-31 Thread Ben Rudiak-Gould
Peter Simons wrote: The module currently knows only _relative_ paths. I am still experimenting with absolute paths because I have recently learned that on Windows something like C:foo.txt is actually relative -- not absolute. Very weird. \foo.txt is also relative on Win32. And con.txt is absolute.

Re: [Haskell] space behaviour of lazy recursive lists

2005-01-30 Thread Ben Rudiak-Gould
Axel Jantsch wrote: Consider: gibs = 1 : 1 : (zipWith f gibs (tail gibs)) where f x y = min (x + y) 10 [...] how can I force the garbage collector to reclaim the memory of the head of the list after I have processed it, since I will never ever reference it again? There's no entirely

Re: [Haskell-cafe] The Nature of Char and String

2005-01-30 Thread Ben Rudiak-Gould
John Goerzen wrote: Char in Haskell represents a Unicode character. I don't know exactly what its size is, but it must be at least 16 bits and maybe more. String would then share those properties. However, usually I'm accustomed to dealing with data in 8-bit words. So I have some questions: Char

Re: [Haskell-cafe] File path programme

2005-01-26 Thread Ben Rudiak-Gould
robert dockins wrote: After the discussion about file paths over the last several days I went home and put together a quick trial implementation for unix file paths, with the idea of adding windows, SMB and maybe VMS (why not?) paths. This is great. Comments below. data PathRoot =

Re: [Haskell-cafe] Haskell programs in C

2005-01-25 Thread Ben Rudiak-Gould
Mark Carroll wrote: Wasn't there someone mentioning here a little while ago some project where they strip most of System.* from the libraries and get something that might be suitable for embedded applications? What was that called? Anyone remember? hOp: http://www.macs.hw.ac.uk/~sebc/hOp/ --

Re: [Haskell-cafe] File path programme

2005-01-25 Thread Ben Rudiak-Gould
Jules Bean wrote: [...] it is an extension of the notion that /foo/ and /foo refer to the same directory. (Except, apparently, in the presence of symbolic links... or so I have some vague memory) Yes, /foo/ is equivalent to /foo/., which is not always the same as /foo. If /foo is a symlink,

Re: [Haskell-cafe] File path programme

2005-01-24 Thread Ben Rudiak-Gould
Isaac Jones wrote: You might be interested in the new FilePath module that's in the works. There's been a lot of work to make these functions portable. http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/libraries/base/System/FilePath.hs I didn't realize this was in CVS. IMHO this library is

Re: [Haskell-cafe] Re: Top Level etc.

2005-01-20 Thread Ben Rudiak-Gould
Jim Apple wrote: Does anyone have examples of these? This one scares the foo out of me: * It's not even safe in general to add a signature giving the same type that the compiler would infer anyway Here's an example: len :: [a] - Int len xs = let ?accum = 0 in len' xs len'

Re: [Haskell-cafe] Re: Hugsvs GHC (again)was: Re: Somerandomnewbiequestions

2005-01-20 Thread Ben Rudiak-Gould
Glynn Clements wrote: Keean Schupke wrote: Why is disk a special case? With slow streams, where there may be an indefinite delay before the data is available, you can use non-blocking I/O, asynchronous I/O, select(), poll() etc to determine if the data is available. [...] With files or block

Re: [Haskell] Re: Why is getArgs in the IO monad?

2005-01-18 Thread Ben Rudiak-Gould
Conal Elliott wrote: The meaning of length getArgs would then have to be a value whose type is the meaning of Haskell's Int, i.e. either bottom or a 32-bit integer. I'm guessing that none of those 2^32+1 values is what you'd mean by length getArgs. On the other hand, the IO monad is a much

Re: [Haskell-cafe] Re: Hugs vs GHC (again)was: Re: Somerandomnewbiequestions

2005-01-17 Thread Ben Rudiak-Gould
John Meacham wrote: Actually, If I were writing new haskell libraries, I would use mmap whenever I could for accessing files. not only does it make the file pointer problem go away, but it can be drastically more efficient. I'm not sure this is a good idea, because GHC really needs non-blocking

Re: [Haskell-cafe] I/O interface

2005-01-17 Thread Ben Rudiak-Gould
Marcin 'Qrczak' Kowalczyk wrote: Convenience. I'm worried that it uses separate types for various kinds of streams: files, pipes, arrays (private memory), and sockets. Haskell is statically typed and lacks subsumption. This means that even though streams are unified by using a class, code which

Re: [Haskell-cafe] performance question

2005-01-17 Thread Ben Rudiak-Gould
Stijn De Saeger wrote: data Bound = I Double | E Double deriving (Eq, Show, Ord) data Interval = Il Bound Bound | Nil Bound Bound deriving (Eq,Ord) isIn :: Double - Interval - Bool isIn r (Nil x y) = not (isIn r (Il x y)) isIn r (Il (I x) (I y)) = r = x r = y isIn r (Il (I x) (E y)) = r = x

Re: [Haskell-cafe] Linear shuffle

2005-01-15 Thread Ben Rudiak-Gould
Marcin 'Qrczak' Kowalczyk wrote: Henning Thielemann [EMAIL PROTECTED] writes: I did some shuffling based on mergesort [...] I think it doesn't guarantee equal probabilities of all permutations. It doesn't (proof: it has a bounded runtime, which can't be true of a perfect shuffling algorithm

Re: [Haskell-cafe] Linear shuffle

2005-01-15 Thread Ben Rudiak-Gould
Scott Turner wrote: Analogous to quicksort's bad behavior in the worst case, an invocation of 'partition' is not guaranteed to make any progress with the shuffling, because one of the output lists might receive all of the input items. It's worse than quicksort, because there's no guarantee that

  1   2   3   >