Re: [Haskell-cafe] Re: [Coq-Club] An encoding of parametricity in Agda

2009-09-24 Thread Benja Fallenstein
Hi Taral, Eugene, [Taral] Perhaps I don't understand Agda very well, but I don't see parametricity here. For one, there's no attempt to prove that: forall (P Q : forall a, a - a), P = Q. [Eugene] Under parametricity, I mean the Reynolds Abstraction Theorem, from which free theorems follow.

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-25 Thread Benja Fallenstein
Hi Duncan and all, On Wed, Mar 25, 2009 at 3:52 AM, Duncan Coutts duncan.cou...@worc.ox.ac.uk wrote: On Mon, 2009-03-23 at 08:11 -0400, Xiao-Yong Jin wrote: tryArith :: a - Either ArithException a tryArith = unsafePerformIO . try . evaluate You must not do this. It breaks the semantics of

Re: [Haskell-cafe] Use unsafePerformIO to catch Exception?

2009-03-25 Thread Benja Fallenstein
On Thu, Mar 26, 2009 at 2:40 AM, Duncan Coutts duncan.cou...@worc.ox.ac.uk wrote: I was not being precise when I said tests for _|_. As you point out, the semantics of imprecise exceptions distinguishes exceptions from bottom, however pure code cannot make that distinction and so that's why I

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-24 Thread Benja Fallenstein
2009/3/24 Peter Verswyvelen bugf...@gmail.com: This strategy is doomed to failure, unfortunately. So it is the good strategy, because Haskell's slogan is avoid success at all cost :-) IN THE YEAR 1987, WAR WAS BEGINNING BIG, IMPERATIVE SOFTWARE BEHEMOTHS CLASHED IN A STATE OF IMPURITY

[Haskell-cafe] Re: [Haskell] Google Summer of Code 2009

2009-02-11 Thread Benja Fallenstein
Hi all, On Tue, Feb 10, 2009 at 3:26 PM, Malcolm Wallace malcolm.wall...@cs.york.ac.uk wrote: If you have ideas for student projects that you think would benefit the Haskell community, now is the time to start discussing them on mailing lists of your choice. We especially encourage students

Re: [Haskell-cafe] Re: Laws and partial values

2009-01-24 Thread Benja Fallenstein
Hi Lennart, On Sat, Jan 24, 2009 at 10:47 PM, Lennart Augustsson lenn...@augustsson.net wrote: You can dream up any semantics you like about bottom, like it has to be () for the unit type. But it's simply not true. I suggest you do some cursory study of denotational semantics and domain

Re: Improved documentation for Bool (Was: [Haskell-cafe] Comments from OCaml Hacker Brian Hurt)

2009-01-18 Thread Benja Fallenstein
On Sun, Jan 18, 2009 at 5:48 PM, rocon...@theorem.ca wrote: I noticed the Bool datatype isn't well documented. Since Bool is not a common English word, I figured it could use some haddock to help clarify it for newcomers. -- |The Bool datatype is named after George Boole (1815-1864). --

Re: [Haskell-cafe] Stupid question #374: why is MaybeT not in the standard library?

2008-12-23 Thread Benja Fallenstein
On Tue, Dec 23, 2008 at 2:52 AM, Antoine Latter aslat...@gmail.com wrote: Although I still had to use my own because I wanted a MonadPlus instance. I would offer a patch, but since there's more than one useful MonadPlus instance for MaybeT it probably still wouldn't be right for everyone.

Re: [Haskell-cafe] Stupid question #374: why is MaybeT not in the standard library?

2008-12-23 Thread Benja Fallenstein
On Tue, Dec 23, 2008 at 8:05 PM, Benja Fallenstein benja.fallenst...@gmail.com wrote: Umh, there is a MonadPlus instance in the package? Ah: ...in the version Cale uploaded two days ago, not in the previous version. Sorrynevermindisee :) - Benja

Re: [Haskell-cafe] Proof that Haskell is RT

2008-11-12 Thread Benja Fallenstein
Hi all, On Wed, Nov 12, 2008 at 2:09 PM, Lennart Augustsson [EMAIL PROTECTED]wrote: You can't write a straightforward dynamic semantics (in, say, denotational style) for Haskell. The problem is that with type classes you need to know the types compute the values. ... It's possible that

Re: [Haskell-cafe] Haskell symbol ~

2008-08-27 Thread Benja Fallenstein
Hi Maurí­cio, I've got one thing to add to the replies so far: On Wed, Aug 27, 2008 at 8:23 PM, Maurí­cio [EMAIL PROTECTED] wrote: What does '~' mean in Haskell? I read in haskell.org/haskellwiki/Keywords that (...) Matching the pattern ~pat against a value always suceeds, and matching will

Re: [Haskell-cafe] Thinking about an unlistN

2008-08-10 Thread Benja Fallenstein
Hi, On Sun, Aug 10, 2008 at 8:57 PM, Michael Feathers [EMAIL PROTECTED] wrote: If I have, say, a function f :: a - a - a - a - b it would be nice to be able to just: unlistN 4 f [1..4] It indeed doesn't work like this; there's more than one way to do something *like* this, if you really want

Re: [Haskell-cafe] Stripping text of xml tags and special symbols

2008-08-05 Thread Benja Fallenstein
Hi Pieter, 2008/8/5 Pieter Laeremans [EMAIL PROTECTED]: But the sphinx indexer complains that the xml isn't valid. When I look at the errors this seems due to some documents containing not well formed html. If you need to cope with non-well-formed HTML, try HTML Tidy:

Re: [Haskell-cafe] Precedence and associativity in a pretty-printer

2008-01-22 Thread Benja Fallenstein
Hi Edsko, On Jan 22, 2008 7:34 PM, Edsko de Vries [EMAIL PROTECTED] wrote: Is there a nice way to pretty-print such an expression with the minimal number of brackets? I can come up with something, but I'm sure somebody thought hard about this problem before and came up with a really nice

Re: [Haskell-cafe] functional graphs

2008-01-21 Thread Benja Fallenstein
Hi Christian, On Jan 21, 2008 10:57 AM, Christian Maeder [EMAIL PROTECTED] wrote: Thanks for pointing out this proposal. The actual problem is mkGraph that needs all the many edges created beforehand (that's what I wanted to avoid). Well, uh, at the risk of being obvious, if you can avoid

Re: [Haskell-cafe] functional graphs

2008-01-19 Thread Benja Fallenstein
Hi Christian, On Jan 18, 2008 1:55 PM, Christian Maeder [EMAIL PROTECTED] wrote: data CGraph a b = CGraph [a] (a - a - b) Can I define an instance for the fgl Graph class? I had no idea how to define empty (except using undefined). Well, presumably the function does not need to be defined

Re: [Haskell-cafe] functional graphs

2008-01-19 Thread Benja Fallenstein
Hi, On Jan 19, 2008 6:05 PM, Thomas Hartman [EMAIL PROTECTED] wrote: Do you just assume that every two nodes have an edge between them [...]? Since that's what complete graph means, I assume so =-) - Benja ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] 0/0 1 == False

2008-01-10 Thread Benja Fallenstein
Hi Mitar, On Jan 10, 2008 9:22 AM, Mitar [EMAIL PROTECTED] wrote: I understand that proper mathematical behavior would be that as 0/0 is mathematically undefined that 0/0 cannot be even compared to 1. My understanding is that common mathematical practice is that comparing an undefined value to

Re: [Haskell-cafe] \_ - not equivalent to const $

2008-01-10 Thread Benja Fallenstein
On Jan 10, 2008 11:54 PM, Luke Palmer [EMAIL PROTECTED] wrote: Can someone explain what the heck is going on here? Evaluating (const EXPR) creates a closure object with a pointer to 'const' and a pointer to the EXPR thunk. Call this closure object C. Evaluating (C undefined) calls 'const' with

Re: [Haskell-cafe] Basic question concerning data constructors

2008-01-02 Thread Benja Fallenstein
Hi Yitz, On Jan 2, 2008 10:34 AM, Yitzchak Gale [EMAIL PROTECTED] wrote: No, only countably many. By the type expression Integer - Integer we mean all Haskell functions mapping Integers to Integers. There are only countably many of those. ... But that was not the context in this thread. The

Re: [Haskell-cafe] Basic question concerning data constructors

2008-01-01 Thread Benja Fallenstein
On Dec 31, 2007 7:17 AM, [EMAIL PROTECTED] wrote: This declaration states that there's a bijection between the elements of Foo and the elements of 2^Foo, which by Cantor's diagonal theorem cannot be true for any set. That's because we only allow computable functions, Nit the nit: Or (more

Re: [Haskell-cafe] The semantics of constructor patterns

2007-12-30 Thread Benja Fallenstein
Hi Cristian, On Dec 30, 2007 6:10 PM, Cristian Baboi [EMAIL PROTECTED] wrote: What I don't get it : (s a1 a2 ... at) must be the value of A in the semantic domain. Let call that value a. Then how can one know if a was built with (s a1 a2 ... at) and not with (egg b1 b2) ? Because the

Re: [Haskell] Empty instance declaration

2007-12-28 Thread Benja Fallenstein
On Dec 28, 2007 5:14 PM, Mike Haskel [EMAIL PROTECTED] wrote: You can define Show as a data type, rather than a type class: type Show a = Either (a - String) (Int - a - String - String) ... The constructors for Show make explicit the two ways to define an instance. This technique also has

Re: [Haskell-cafe] Missing join and split

2007-12-28 Thread Benja Fallenstein
Hi all, On Dec 28, 2007 12:38 PM, Andrew Coppin [EMAIL PROTECTED] wrote: For joining you probably want some combination of intersperse and concat, e.g. unlines = concat . intersperse \n And that's what we have :-) Data.List.intercalate :: [a] - [[a]] - [a] Data.List.intercalate x = concat

Re: [Haskell-cafe] Missing join and split

2007-12-28 Thread Benja Fallenstein
On Dec 28, 2007 3:55 PM, David Roundy [EMAIL PROTECTED] wrote: On Dec 28, 2007 9:51 AM, Benja Fallenstein [EMAIL PROTECTED] wrote: If you use intercalate to join, I would presume that you would want to use an inverse of it to split. I'd write it like this: Of course, there is no inverse

Re: [Haskell-cafe] Missing join and split

2007-12-28 Thread Benja Fallenstein
On Dec 28, 2007 4:24 PM, Benja Fallenstein [EMAIL PROTECTED] wrote: Right; I misspoke. What I meant was that you would want a split such that intercalate a (split a xs) = a for finite, total (a,xs) (and, since it's achievable, even for infinite xs). Of course, (split a xs = [xs

Re: [Haskell-cafe] Re: Comments on reading two ints off Bytestring

2007-12-26 Thread Benja Fallenstein
On Dec 23, 2007 1:44 PM, Isaac Dupree [EMAIL PROTECTED] wrote: parseHeader3 :: BS.ByteString - Maybe (Int, Int) parseHeader3 bs = do (x, rest) - BS.readInt $ BS.dropWhile (not . isDigit) bs (y, _) - BS.readInt $ BS.dropWhile (not . isDigit) rest return (x, y) But that version still

Re: [Haskell-cafe] Re: CAF's in Haskell

2007-12-26 Thread Benja Fallenstein
Hi Neil, On Dec 26, 2007 7:16 PM, Neil Mitchell [EMAIL PROTECTED] wrote: Given the code: fred = 2 + 2 bob = fred + fred In a Haskell implementation fred would be evaluated once to 4, then used twice. The 2+2 would only happen once (ignore defaulting and overloaded numerics for now). Is

Re: [Haskell-cafe] New to Haskell

2007-12-18 Thread Benja Fallenstein
Hi Cristian, On Dec 18, 2007 10:53 AM, Cristian Baboi [EMAIL PROTECTED] wrote: - the lambda expressions can be written (input) but cannot be printed (output) Yes, since two different lambda expressions can denote the same function. I just want the sistem to be able to print one of these

Re: [Haskell-cafe] New to Haskell

2007-12-18 Thread Benja Fallenstein
Hi Henning, On Dec 18, 2007 3:53 PM, Henning Thielemann [EMAIL PROTECTED] wrote: Since this was discussed already here, I summed it up in: http://www.haskell.org/haskellwiki/Show_instance_for_functions I find the discussion under theoretical answer unsatisfying. The property that a Show

Re: [Haskell-cafe] New to Haskell

2007-12-18 Thread Benja Fallenstein
On Dec 18, 2007 4:50 PM, Benja Fallenstein [EMAIL PROTECTED] wrote: Further, even with extensionality, we can (with compiler support) in principle have Show instances other than enumerating the graph. Now that I said it, I'm starting to doubt we even need compiler support beyond what we have

Re: [Haskell-cafe] New to Haskell

2007-12-18 Thread Benja Fallenstein
Hi Henning, On Dec 18, 2007 5:17 PM, Henning Thielemann [EMAIL PROTECTED] wrote: The mathematical definition of function I know of, says that functions are special relations, and relations are sets of pairs. Their is nothing about intension. That's the standard definition in set theory, but

Re: [Haskell-cafe] New to Haskell

2007-12-18 Thread Benja Fallenstein
Hi Paul, On Dec 18, 2007 5:18 PM, Paul Hudak [EMAIL PROTECTED] wrote: If the semantics of a language says that a function f is equivalent to a function g, but there is a function h such that h(f) is not equivalent to h(g), then h cannot be a function. Sure. Therefore that language cannot

Re: [Haskell-cafe] New to Haskell

2007-12-18 Thread Benja Fallenstein
On Dec 18, 2007 6:01 PM, Paul Hudak [EMAIL PROTECTED] wrote: Well, my caveat was that the Haskell designers wanted it this way. So you are essentially rejecting my caveat, rather than creating a new one. :-) I mean, I reject the answer They wanted it this way because I think the answer should

[Haskell-cafe] A Show instance for simple functions

2007-12-18 Thread Benja Fallenstein
Hi all, Below is a program that implements Show for functions whose type is composed of only (-) and type variables (or, more precisely, of (-) and (State Int Term), but any type composed of (-) and type variables can obviously be specialized to that). (-fglasgow-exts is needed only for the

Re: [Haskell-cafe] New to Haskell

2007-12-18 Thread Benja Fallenstein
Hi Paul, On Dec 19, 2007 6:54 AM, Paul Hudak [EMAIL PROTECTED] wrote: Your version of the answer is in fact correct, but is just an elaboration of the original one. So, I don't see what your point is... Ok, sorry, I'll try again... I'm trying to say that in my opinion, it's important to

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-14 Thread Benja Fallenstein
Hi Corey, On Dec 14, 2007 8:44 PM, Corey O'Connor [EMAIL PROTECTED] wrote: The reason I find all this odd is because I'm not sure how the type class Functor relates to the category theory concept of a functor. How does declaring a type constructor to be an instance of the Functor class relate

Re: [Haskell-cafe] Questions about the Functor class and it's use in Data types à la carte

2007-12-14 Thread Benja Fallenstein
On Dec 15, 2007 3:44 AM, Benja Fallenstein [EMAIL PROTECTED] wrote: Hmmm. Something about that ticks off my don't play fast and loose with bottom detector. I should add that I do think you're correct if you ignore the existence of bottom, and I'm pretty sure that you're correct if you allow

Re: Re[2]: [Haskell-cafe] Execution of external command

2007-12-14 Thread Benja Fallenstein
On Dec 14, 2007 10:38 AM, Bulat Ziganshin [EMAIL PROTECTED] wrote: hUnsafeGetContentsDontUseThisUnlessYouHaveSpentThreeMonthsLearningGHCsExecutionSemanticsOrYouWillRegretIt i have more advanced proposal - we should include in its name whole paper on its semantics so anyone using it will be

Re: [Haskell-cafe] Software Tools in Haskell

2007-12-14 Thread Benja Fallenstein
On Dec 14, 2007 9:29 AM, Henning Thielemann [EMAIL PROTECTED] wrote: I remember there was a discussion about how to implement full 'wc' in an elegant but maximally lazy form, that is counting bytes, words and lines in one go. Did someone have a nice idea of how to compose the three counters

Re: [Haskell-cafe] eager/strict eval katas

2007-12-12 Thread Benja Fallenstein
Hi Thomas, On Dec 12, 2007 5:31 PM, Thomas Hartman [EMAIL PROTECTED] wrote: (solution involves building an accum list of (average,listLength) tuples. again you can't do a naive fold due to stack overflow, but in this case even strict foldl' from data.list isn't strict enough, I had to define

Re: [Haskell-cafe] eager/strict eval katas

2007-12-12 Thread Benja Fallenstein
On Dec 12, 2007 9:58 PM, Don Stewart [EMAIL PROTECTED] wrote: And no need to even use custom ones, just use the library strict pairs, http://hackage.haskell.org/packages/archive/strict/0.2/doc/html/Data-Strict-Tuple.html Oh, good! :) 'nother Haskell lesson learned. Thanks, - Benja

Re: [Haskell-cafe] Software Tools in Haskell

2007-12-12 Thread Benja Fallenstein
Another version of detab: main = interact $ perLine $ concat . snd. mapAccumL f 0 where f tab '\t' = (0, replicate (4-tab) ' ') f tab char = ((tab+1) `mod` 4, [char]) - Benja ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Software Tools in Haskell

2007-12-12 Thread Benja Fallenstein
On Dec 13, 2007 2:20 AM, Benja Fallenstein [EMAIL PROTECTED] wrote: Another version of detab: main = interact $ perLine $ concat . snd. mapAccumL f 0 where f tab '\t' = (0, replicate (4-tab) ' ') f tab char = ((tab+1) `mod` 4, [char]) Although on reflection, I think I might like

Re: [Haskell-cafe] Software Tools in Haskell

2007-12-12 Thread Benja Fallenstein
On Dec 13, 2007 2:28 AM, Benja Fallenstein [EMAIL PROTECTED] wrote: Although on reflection, I think I might like the following compromise with Tillmann's version best: main = interact $ perLine $ detab 0 where detab tab ('\t':cs) = replicate (4-tab) ' ' ++ detab 0 cs

Re: [Haskell-cafe] Re: [Haskell] IVars

2007-12-09 Thread Benja Fallenstein
Hi Conal, On Dec 9, 2007 6:09 PM, Conal Elliott [EMAIL PROTECTED] wrote: readIVar' :: IVar a - a readIVar' = unsafePerformIO . readIVar so, we do not need readIVar'. it could be a nice addition to the libraries, maybe as unsafeReadIVar or unsafeReadMVar. The same argument applies any to

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

2007-12-07 Thread Benja Fallenstein
On Dec 7, 2007 6:57 PM, Peter Padawitz [EMAIL PROTECTED] wrote: Jules Bean wrote: Peter Padawitz wrote: Cause I don't see why the instantiation conflicts pointed out by others would vanish then. They would. If it's really true that there is only one possible choice of b,c,d for

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

2007-12-05 Thread Benja Fallenstein
Hi Paolo, On Dec 5, 2007 2:09 PM, Paulo J. Matos [EMAIL PROTECTED] wrote: I'm glad that my initial post generated such an interesting discussion but I'm still not understanding why the first version of findAllPath seems to be computing the whole list even when I just request the head, while

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

2007-12-05 Thread Benja Fallenstein
On Dec 5, 2007 5:40 PM, Paulo J. Matos [EMAIL PROTECTED] wrote: Oh, but lfpaths is not nothing so that means that isNothing rtpaths shouldn't be evaluated, right? You're right, and I was stupid not to think about that case. Since Luke already gave an in-depth analysis I'll be quiet now :-) -

Re: [Haskell-cafe] Properties of monads

2007-11-18 Thread Benja Fallenstein
Hi Radosław, You should be able to write this with MaybeT as follows: getStrip :: IO ( Maybe String ) getStrip = runMaybeT $ do pageContent - liftIO $ downloadFile mainPageAddress let x = patternForStrip pageContent print x z - x liftIO $ downloadFile $ mainPageAddress ++ z

Re: [Haskell-cafe] Properties of monads

2007-11-18 Thread Benja Fallenstein
On 11/18/07, Benja Fallenstein [EMAIL PROTECTED] wrote: Hi Radosław, You should be able to write this with MaybeT as follows: Correction, sorry. The code in my original mail doesn't take care of converting the 'Maybe's returned by the functions you're calling into 'MaybeT's. The following

Re: [Haskell-cafe] Producing MinimumValue

2007-07-20 Thread Benja Fallenstein
2007/7/19, Jason Dagit [EMAIL PROTECTED]: I prefer, allEqual [] = True allEqual xs = foldl1 (==) xs But, unfortunately, it's not a one liner like yours (unless you allow allEqual [] = undefined). Oh and silly me, that only works for [Bool]. My natural instinct is, allEqual [] = True

Re: Re[2]: [Haskell-cafe] Producing MinimumValue

2007-07-20 Thread Benja Fallenstein
2007/7/20, Bulat Ziganshin [EMAIL PROTECTED]: allEqual [] = True allEqual (x:xs) = all (== x) xs with the same caveat about allEqual [] as in your case. allEqual xs = all (== head xs) xs Rght. Not evaluated in the edge case, because xs is empty. Didn't think of that, nice :-) -

Re: [Haskell-cafe] Newbie question about tuples

2007-07-12 Thread Benja Fallenstein
Hi Peter, 2007/7/12, peterv [EMAIL PROTECTED]: Q1) Is it possible to treat a tuple of N elements in a generic way? So instead of writing functions like lift1 e1, lift2 (e1,e2), lift3 (e1,e2,e3) just one function liftN that works on tuples of any length? Q2) (Maybe related to Q1) Can I convert

Re: [Haskell-cafe] Functional dependencies *not* part of the next Haskell standard?

2007-07-12 Thread Benja Fallenstein
2007/7/12, peterv [EMAIL PROTECTED]: Amazing, so simple it is, Yoda would say ;) I did not realize one could perform partial application on types when declaring instances (I mean not specifying the type of Vector2 in instance Vector Vector2). You ought to meditate on the type class 'Monad,'

Re: [Haskell-cafe] Trying to make a Typeable instance

2007-07-08 Thread Benja Fallenstein
Hi Adrian, 2007/7/8, Adrian Hey [EMAIL PROTECTED]: So it seems ghc doesn't like kinds (* - *) either :-( Actually, AFAICT the problem seems to be with Data.Typeable itself rather than ghc. There is no proper TypeRep for (ListGT map k a) because map is not a type. Have you tried using

Re: [Haskell-cafe] sha1 implementation thats only 12 times slower then C

2007-07-01 Thread Benja Fallenstein
Hi, 2007/7/1, Bulat Ziganshin [EMAIL PROTECTED]: aa - unsafeRead a5 0 return $! aa bb - unsafeRead a5 1 return $! bb If this is a useful pattern, would it make sense to have a function to encapsulate it? mseq :: Monad m = m a - m a mseq m = m = (return $!) - Benja

Re: [Haskell-cafe] Read-only functions in State Monad

2007-06-30 Thread Benja Fallenstein
Hi Ken, 2007/7/1, Ken Takusagawa [EMAIL PROTECTED]: I'd like to have a state monad with the feature that I can somehow annotate using the type system that some functions are only going to read the state and not modify it. I would suggest declaring a MonadReader instance for State, and writing

Re: [Haskell-cafe] Constructing a datatype given just its constructor as a string?

2007-06-25 Thread Benja Fallenstein
Hi Hugh, 2007/6/25, Donald Bruce Stewart [EMAIL PROTECTED]: hughperkins: Just noticed that all my responses have been going only to Neil, not to the group. Anyway, the jist of our conversation was that it's not possible to create arbitrary datatypes/constructors from

Re: [Haskell-cafe] Practical Haskell question.

2007-06-25 Thread Benja Fallenstein
Hi Peter, 2007/6/25, peterv [EMAIL PROTECTED]: I'm baffled. So using the Arrow abstraction (which I don't know yet) would solve this problem? How can (perfectActionB x) be checked with without ever executing performActionA which evaluates to x? This can only be done when x is a constant

[Haskell-cafe] SYB with class, simplified

2007-06-25 Thread Benja Fallenstein
Hi all, The scrap your boilerplate with class sytstem [1] has two big advantages over the plain SYB system from Data.Generics, IMHO: One, it lets you declare an 'open' generic function as a type class, to which new cases can be added by adding new instances (emphasized in the paper); and two, it

Re: [Haskell-cafe] Practical Haskell question.

2007-06-25 Thread Benja Fallenstein
2007/6/25, Michael T. Richter [EMAIL PROTECTED]: OK, just to prevent this getting side-tracked: I'm absolutely uninterested in the results of performActionA before determining if performActionB is permitted/possible/whatever. Think more in terms of security permissions or resource

Re: [Haskell] Class type constraining?

2007-06-22 Thread Benja Fallenstein
2007/6/22, Hugo Pacheco [EMAIL PROTECTED]: class Functor f = C f a b | f a - b where ftest :: f a - b I want to write some function test :: (C f a b) = (a - b) test = ftest . undefined I'm not sure whether this is what you want, but the obvious way to make this type-check would seem to be

[Haskell-cafe] Recursive instance dictionaries in GHC

2007-06-19 Thread Benja Fallenstein
Hi, I can't figure out why the following program compiles with this instance declaration instance Size (Maybe [a]) = Size [a] where size x = size (foo x) but has GHC loop forever with this one: instance (Foo a b, Size b) = Size a where size x = size (foo x) Anybody here know? Thanks, -

Re: [Haskell-cafe] Memo + IORef

2007-06-16 Thread Benja Fallenstein
Hi Tony, 2007/6/16, Tony Morris [EMAIL PROTECTED]: I was told on #haskell (IRC) the other day that it is possible to write a general memoisation table using IORef and unsafePerformIO. I can't think of how this can be achieved without writing to a file, since a function cannot hold state between

[Haskell-cafe] Reading open data types

2007-06-13 Thread Benja Fallenstein
Hi all, We've had a discussion on #haskell about how we can make a function that reads in serialized values of an open data type, such as class (Show a, Read a) = MyClass a where typeTag :: a - String ... operations on the open data type... data Obj = forall a. MyClass a = Obj { unObj ::

Re: [Haskell-cafe] Reading open data types

2007-06-13 Thread Benja Fallenstein
Hi Isaac, 2007/6/13, Isaac Dupree [EMAIL PROTECTED]: Since Show instances can overlap (e.g. (show (1::Int)) == (show (1::Integer))), we need to tag with the type. Indeed. But that's the easy part :-) Reminds me of Typeable. Since GHC lets us derive Typeable with a guarantee of different

Re: [Haskell-cafe] Reading open data types

2007-06-13 Thread Benja Fallenstein
Hi Bulat, 2007/6/13, Bulat Ziganshin [EMAIL PROTECTED]: We've had a discussion on #haskell about how we can make a function that reads in serialized values of an open data type, such as look at Data.Generics.Text which may be implements exactly what you need Unfortunately not.

Re: [Haskell-cafe] Reading open data types

2007-06-13 Thread Benja Fallenstein
2007/6/14, Stefan O'Rear [EMAIL PROTECTED]: On Wed, Jun 13, 2007 at 05:12:25PM +0300, Benja Fallenstein wrote: However, this is still kind of boring. Is there a better way? If not, would it be a good idea to have compiler support for building this kind of type table? The compiler does build

Re: [Haskell-cafe] Higher order types via the Curry-Howard correspondence

2007-05-13 Thread Benja Fallenstein
2007/5/12, Derek Elkins [EMAIL PROTECTED]: In Haskell codata and data coincide, but if you want consistency, that cannot be the case. For fun and to see what you have to avoid, here's the proof of Curry's paradox, using weird infinite data types. We'll construct an expression that inhabits any

Re: [Haskell-cafe] Higher order types via the Curry-Howard correspondence

2007-05-13 Thread Benja Fallenstein
2007/5/13, Benja Fallenstein [EMAIL PROTECTED]: Modulo the constructor and destructor invocation, this is just the familiar non-terminating ((\x - x x) (\x - x x)), of course. The same technique also gives us data Y a = Y (Y a - a) y :: (a - a) - a y f = (\(Y x) - f $ x $ Y x) $ Y $ (\(Y x

Re: [Haskell-cafe] Higher order types via the Curry-Howard correspondence

2007-05-11 Thread Benja Fallenstein
Adding some thoughts to what David said (although I don't understand the issues deeply enough to be sure that these ideas don't lead to ugly things like paradoxes)-- 2007/5/10, Gaal Yahas [EMAIL PROTECTED]: Since the empty list inhabits the type [b], this theorem is trivially a tautology, so

[Haskell-cafe] Soft references

2007-04-18 Thread Benja Fallenstein
Hi all, Is there a way to achieve the effect of soft references in GHC? Or if not, is there any hope that they will be implemented in the future? (Soft references are like weak references, except that they are only reclaimed by the garbage collector if memory is short.) I'm building a

Re: [Haskell-cafe] Why the Prelude must die

2007-03-25 Thread Benja Fallenstein
Hi, (new here) 2007/3/25, Jacques Carette [EMAIL PROTECTED]: Some classes would become even more important: monoid, groupoid, semi-group, loop (semi-group with identity), etc. But all of those are, to the average programmer (and many a mathematician), just as scary as Monad. Of course, when