Re: [Haskell-cafe] Rigid skolem type variable escaping scope

2012-08-24 Thread Matthew Steele
On Aug 23, 2012, at 10:32 PM, wren ng thornton wrote: Now, be careful of something here. The reason this fails is because we're compiling Haskell to System Fc, which is a Church-style lambda calculus (i.e., it explicitly incorporates types into the term language). It is this fact of being

[Haskell-cafe] Rigid skolem type variable escaping scope

2012-08-22 Thread Matthew Steele
While working on a project I have come across a new-to-me corner case of the type system that I don't think I understand, and I am hoping that someone here can enlighten me. Here's a minimal setup. Let's say I have some existing code like this: {-# LANGUAGE Rank2Types #-} class

Re: [Haskell-cafe] Rigid skolem type variable escaping scope

2012-08-22 Thread Matthew Steele
On Aug 22, 2012, at 3:02 PM, Lauri Alanko wrote: Quoting Matthew Steele mdste...@alum.mit.edu: {-# LANGUAGE Rank2Types #-} class FooClass a where ... foo :: (forall a. (FooClass a) = a - Int) - Bool foo fn = ... newtype IntFn a = IntFn (a - Int) bar :: (forall

Re: [Haskell-cafe] Rigid skolem type variable escaping scope

2012-08-22 Thread Matthew Steele
On Aug 22, 2012, at 4:32 PM, Erik Hesselink wrote: On Wed, Aug 22, 2012 at 10:13 PM, Matthew Steele mdste...@alum.mit.edu wrote: On Aug 22, 2012, at 3:02 PM, Lauri Alanko wrote: Quoting Matthew Steele mdste...@alum.mit.edu: {-# LANGUAGE Rank2Types #-} class FooClass a where

Re: [Haskell-cafe] for = flip map

2012-03-28 Thread Matthew Steele
Doesn't for already exist, in Data.Traversable? Except that for = flip traverse. http://www.haskell.org/hoogle/?hoogle=for Cheers, -Matthew On Wed, Mar 28, 2012 at 3:58 PM, Johannes Waldmann waldm...@imn.htwk-leipzig.de wrote: Good: we have  mapM, and we have forM ( = flip mapM )  . Sure

Re: [Haskell-cafe] for = flip map

2012-03-28 Thread Matthew Steele
On Mar 28, 2012, at 4:19 PM, Christopher Done wrote: On 28 March 2012 22:05, Matthew Steele mdste...@alum.mit.edu wrote: Doesn't for already exist, in Data.Traversable? Except that for = flip traverse. Traverse doesn't fit the type of fmap, it demands an extra type constructor

Re: [Haskell-cafe] Why aren't there anonymous sum types in Haskell?

2011-06-21 Thread Matthew Steele
On Jun 21, 2011, at 4:02 PM, Malcolm Wallace wrote: On 21 Jun 2011, at 20:53, Elliot Stern wrote: A tuple is basically an anonymous product type. It's convenient to not have to spend the time making a named product type, because product types are so obviously useful. Is there any reason

Re: [Haskell-cafe] Can it be proven there are no intermediate useful type classes between Applicative Functors Monads?

2011-06-06 Thread Matthew Steele
On Mon, Jun 6, 2011 at 3:39 PM, Casey McCann syntaxgli...@gmail.com wrote: On Mon, Jun 6, 2011 at 12:19 PM, Brent Yorgey byor...@seas.upenn.edu wrote: The idea is that Applicative computations have a fixed structure which is independent of intermediate results; Monad computations correspond to

[Haskell-cafe] Calling a C function that returns a struct by value

2011-05-25 Thread Matthew Steele
From Haskell, I want to call a C function that returns a struct by value (rather than, say, returning a pointer). For example: typedef struct { double x; double y; } point_t; point_t polar(double theta); I can create a Haskell type Point and make it an instance of Storable easily

Re: [Haskell-cafe] naming convention for maybes?

2011-04-22 Thread Matthew Steele
In my own code, I usually use a 'mb' prefix with camelCase, like so: case mbStr of Just str - ... Nothing - ... But I agree that it doesn't always look very nice. I'm curious what others do. On Apr 22, 2011, at 1:14 PM, Evan Laforge wrote: Here's a simple issue that's been with

Re: [Haskell-cafe] ArrowLoop and streamprocessors

2011-03-31 Thread Matthew Steele
On Mar 30, 2011, at 5:29 PM, Mathijs Kwik wrote: So loop really doesn't seem to help here, but I couldn't find another way either to feed outputs back into the system. What I need is: Either A B ~ Either C B - A ~ C Does such a thing exist? Based on your description, it sounds to me like you

Re: [Haskell-cafe] getting last char of String

2010-12-31 Thread Matthew Steele
Sounds like you're looking for `last', which is in the Prelude. http://www.haskell.org/ghc/docs/6.12.2/html/libraries/base-4.2.0.1/Prelude.html#v%3Alast Cheers, -Matt On Dec 31, 2010, at 3:39 PM, Aaron Gray wrote: Is there an easy Haskell function that gets the last Char of a [Char] or

Re: [Haskell-cafe] Musings on type systems

2010-11-19 Thread Matthew Steele
TAPL is also a great book for getting up to speed on type theory: http://www.cis.upenn.edu/~bcpierce/tapl/ I am no type theorist, and I nonetheless found it very approachable. I've never read TTFP; I will have to check that out. (-: On Nov 19, 2010, at 4:31 PM, Daniel Peebles wrote:

[Haskell-cafe] Equivalent of withForeignPtr for System.Mem.Weak?

2010-10-31 Thread Matthew Steele
I have an object to which I have added one or more finalizers via addFinalizer from System.Mem.Weak. I would like to have a function that allows me to make use of the object within a block of IO code, and guarantee that the finalizer(s) will not be called during the code block -- sort of