Re: ConstraintKinds feature suggestion and question about type family peculiarity

2013-06-16 Thread Roman Cheplyaka
* Merijn Verstraaten mer...@inconsistent.nl [2013-06-15 22:05:52+0100] 2) for some reason the type families syntax always requires a full argument list, which I find rather ugly. I would much prefer to use KindSignatures and write type family Restrict :: * - [*] - Constraint, but GHC

ConstraintKinds feature suggestion and question about type family peculiarity

2013-06-15 Thread Merijn Verstraaten
Hello fellow haskellers! I was experimenting with restricting functions operating on GADTs with phantom types to only work on a subset of the possible phantom types. I ended up with the following code: {-# LANGUAGE ConstraintKinds, DataKinds, GADTs, TypeFamilies, TypeOperators #-} import

[Haskell-cafe] Efficiency/Evaluation Question

2013-06-15 Thread Christopher Howard
s (tail l)) n (i + 1) My question: With the way Haskell works (thunks, lazy evaluation, and all that mystery), is it actually worth the trouble of /precalculating/ the maximum row values and minimum column values, to compare cell values against? Or will, for example, something like

Re: [Haskell-cafe] Efficiency/Evaluation Question

2013-06-15 Thread Tommy Thorn
, the row maximum and the column minimum. From there its a trivial filter to find your results. (I'm sure there's a more elegant solution). My question: With the way Haskell works (thunks, lazy evaluation, and all that mystery), is it actually worth the trouble of /precalculating/ the maximum row

Re: [Haskell-cafe] Efficiency/Evaluation Question

2013-06-15 Thread Christopher Howard
On 06/15/2013 04:39 PM, Tommy Thorn wrote: There's not enough context to answer the specific question, but lazy evaluation isn't magic and the answer is probably no. Tommy Perhaps to simplify the question somewhat with a simpler example. Suppose you have code: let f x = if (x

Re: [Haskell-cafe] Efficiency/Evaluation Question

2013-06-15 Thread Christopher Howard
On 06/15/2013 05:02 PM, Christopher Howard wrote: On 06/15/2013 04:39 PM, Tommy Thorn wrote: Perhaps to simplify the question somewhat with a simpler example. Suppose you have code: let f x = if (x 4) then f 0 else (sin x + 2 * cos x) : f (x + 1) After calculating

Re: [Haskell-cafe] Efficiency/Evaluation Question

2013-06-15 Thread Clark Gaebel
Yes. In general, GHC won't CSE for you. - Clark On Saturday, June 15, 2013, Christopher Howard wrote: On 06/15/2013 04:39 PM, Tommy Thorn wrote: There's not enough context to answer the specific question, but lazy evaluation isn't magic and the answer is probably no. Tommy

Re: [Haskell-cafe] Efficiency/Evaluation Question

2013-06-15 Thread Tikhon Jelvis
There's a very good StackOverflow question which covers this: When is memoization automatic in GHC?[1]. I found it really cleared up the issue for me. [1]: http://stackoverflow.com/questions/3951012/when-is-memoization-automatic-in-ghc-haskell On Sat, Jun 15, 2013 at 9:13 PM, Clark Gaebel cgae

Re: [Haskell-cafe] Question about Newtype op() function arguments.

2013-06-12 Thread David Banas
Ah, so is the idea, then, to use *op()* when `n` wasn't actually constructed formally, but rather assembled by the user, so as to match the type of the accessor function normally supplied as the argument to the constructor? On 6/7/2013 4:51 PM, Tom Ellis wrote: On Fri, Jun 07, 2013 at

[Haskell-cafe] Question about Newtype op() function arguments.

2013-06-07 Thread David Banas
Hi All, Referring to the following, which is taken from the *Control.Newtype *documentation page: op :: Newtypehttp://hackage.haskell.org/packages/archive/newtype/0.2/doc/html/Control-Newtype.html#t:Newtype n o = (o - n) - n -

Re: [Haskell-cafe] Question about Newtype op() function arguments.

2013-06-07 Thread Roman Cheplyaka
* David Banas capn.fre...@gmail.com [2013-06-07 07:08:19-0700] Hi All, Referring to the following, which is taken from the *Control.Newtype *documentation page: op :: Newtypehttp://hackage.haskell.org/packages/archive/newtype/0.2/doc/html/Control-Newtype.html#t:Newtype n o = (o - n) -

Re: [Haskell-cafe] Question about Newtype op() function arguments.

2013-06-07 Thread Tom Ellis
On Fri, Jun 07, 2013 at 07:08:19AM -0700, David Banas wrote: op :: Newtypehttp://hackage.haskell.org/packages/archive/newtype/0.2/doc/html/Control-Newtype.html#t:Newtype n o = (o - n) - n - oSourcehttp://hackage.haskell.org/packages/archive/newtype/0.2/doc/html/src/Control-Newtype.html#op

Re: [Haskell-cafe] Question about Newtype op() function arguments.

2013-06-07 Thread Joe Q
The phantom parameter solves the same problem as scoped type variables. Granted, if you find yourself in that kind of polymorphic soup you have deeper problems... On Jun 7, 2013 2:53 PM, Tom Ellis tom-lists-haskell-cafe-2...@jaguarpaw.co.uk wrote: On Fri, Jun 07, 2013 at 07:08:19AM -0700, David

Re: [Haskell-cafe] Question about Newtype op() function arguments.

2013-06-07 Thread Tom Ellis
On Fri, Jun 07, 2013 at 04:05:09PM -0400, Joe Q wrote: The phantom parameter solves the same problem as scoped type variables. Granted, if you find yourself in that kind of polymorphic soup you have deeper problems... I don't understand this. Scoped type variables are used when you want to

Re: [Haskell-cafe] Question about Newtype op() function arguments.

2013-06-07 Thread Joe Quinn
On 6/7/2013 4:51 PM, Tom Ellis wrote: On Fri, Jun 07, 2013 at 04:05:09PM -0400, Joe Q wrote: The phantom parameter solves the same problem as scoped type variables. Granted, if you find yourself in that kind of polymorphic soup you have deeper problems... I don't understand this. Scoped type

Re: [Haskell-cafe] question about singletons

2013-06-02 Thread TP
Thanks Richard, now I have my answers. Richard Eisenberg wrote: - The type system of Haskell is based on theoretical work that resolutely assumes that types of non-* kind are uninhabited. While it is possible to stretch imagination to allow types like 'Zero to be inhabited, the designers of

Re: [Haskell-cafe] question about singletons

2013-06-01 Thread TP
Thanks Richard for your detailed answer. Please find my reply below (note I have rearranged some of your paragraphs). Richard Eisenberg wrote: * Types at kind other than * do not have any inhabitants -- in fact, some people would hesitate to call type-like things at kind other than * types!

Re: [Haskell-cafe] question about singletons

2013-06-01 Thread Richard Eisenberg
On Jun 1, 2013, at 8:18 PM, TP wrote: In other words, bottom can be an inhabitant of a concrete type, not a type constructor, which I can understand. But a type of kind Nat is a concrete type, so why bottom cannot be an inhabitant of this type? We also have the nice maxim that every

Re: [Haskell-cafe] question about singletons

2013-06-01 Thread wren ng thornton
On 6/1/13 3:18 PM, TP wrote: In other words, bottom can be an inhabitant of a concrete type, not a type constructor, which I can understand. But a type of kind Nat is a concrete type, so why bottom cannot be an inhabitant of this type? The technical term is proper type. That is, types are used

[Haskell-cafe] question about singletons

2013-05-31 Thread TP
Hi all, Following a discussion on Haskell Cafe some time ago (1), Roman C. wrote: On the other hand, the type 'Succ 'Zero has kind 'Nat and doesn't have any inhabitants — only types of kind * do. Indeed, this is what seems to occur in the following example: --- {-#

Re: [Haskell-cafe] question about singletons

2013-05-31 Thread Richard Eisenberg
...@haskell.org] On Behalf Of TP Sent: 31 May 2013 13:58 To: haskell-cafe@haskell.org Subject: [Haskell-cafe] question about singletons Hi all, Following a discussion on Haskell Cafe some time ago (1), Roman C. wrote: On the other hand, the type 'Succ 'Zero has kind 'Nat and doesn't have any

Re: [Haskell-cafe] question about type constructors

2013-05-23 Thread Roman Cheplyaka
* TP paratribulati...@free.fr [2013-05-23 00:34:57+0200] Hi, In the program I am trying to write, I have a problem that can be reduced to the following dummy example: -- {-# LANGUAGE GADTs #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE KindSignatures #-} {-#

Re: [Haskell-cafe] question about type constructors

2013-05-23 Thread TP
- Person c Thanks a lot. Now I am using FlexibleContexts, and it works correctly (see code below). I think I have understood the problem. However, I have still one question. In the code below, I have added data constructors Child2, Child3 (imagining a world where every people has three children

Re: [Haskell-cafe] question about type constructors

2013-05-23 Thread Roman Cheplyaka
:: (PrettyPrint a, PrettyPrint b) = String - Person a - Person b - Person c Thanks a lot. Now I am using FlexibleContexts, and it works correctly (see code below). I think I have understood the problem. However, I have still one question. In the code below, I have added data constructors Child2

[Haskell-cafe] question about type constructors

2013-05-22 Thread TP
Hi, In the program I am trying to write, I have a problem that can be reduced to the following dummy example: -- {-# LANGUAGE GADTs #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE IncoherentInstances #-}

Re: [Haskell-cafe] question about GADT and deriving automatically a Show instance

2013-05-18 Thread TP
Chris Wong wrote: data Person :: Gender - * where Dead :: Person Gender -- WHAT DO I PUT HERE Alive :: { name :: String , weight :: Float , father :: Person Gender } - Person Gender Here's the problem. In the line: Dead :: Person Gender you

Re: [Haskell-cafe] question about GADT and deriving automatically a Show instance

2013-05-18 Thread Denis Kasak
On 18 May 2013 11:16, TP paratribulati...@free.fr wrote: snip However, I have not managed to make the version with forall work. Below, the first occurrence of forall is ok, but the three following yield error. {-# LANGUAGE GADTs #-} {-# LANGUAGE

Re: [Haskell-cafe] question about GADT and deriving automatically a Show instance

2013-05-18 Thread TP
Denis Kasak wrote: Note that all of this would work even without explicit quantification since you have already specified that Person accepts an argument of kind Gender. In other words, this works as expected: data Person :: Gender - * where Dead :: Person a Alive :: { name ::

[Haskell-cafe] question about GADT and deriving automatically a Show instance

2013-05-17 Thread TP
Hi everybody, I have a question about deriving automatically a Show instance when using GADT. It works in this situation: {-# LANGUAGE GADTs #-} data Male data Female data Person gender where Dead :: Person gender Alive :: { name :: String

Re: [Haskell-cafe] question about GADT and deriving automatically a Show instance

2013-05-17 Thread Adam Gundry
Hi TP, On 17/05/13 15:32, TP wrote: | [...] | | So I modify my code by removing deriving Show, and adding the line: | | instance Show (Person gender) | | | But now, I obtain: | | $ runghc test_show.hs | GHC stack-space overflow: current

Re: [Haskell-cafe] question about GADT and deriving automatically a Show instance

2013-05-17 Thread TP
Adam Gundry wrote: [...] To use standalone deriving, you need to write deriving instance Show (Person gender) and everything will work fine. By writing instance Show (Person gender) you are instead giving an instance with no methods, and the default methods in the Show class contain

Re: [Haskell-cafe] question about GADT and deriving automatically a Show instance

2013-05-17 Thread Chris Wong
On Sat, May 18, 2013 at 9:11 AM, TP paratribulati...@free.fr wrote: So the following version does not work: [..] data Person :: Gender - * where Dead :: Person Gender -- WHAT DO I PUT HERE Alive :: { name :: String , weight ::

Re: [Haskell-cafe] Lambda Calculus question on equivalence

2013-05-04 Thread Jon Fairbairn
Francesco Mazzoli f...@mazzo.li writes: At Fri, 03 May 2013 16:34:28 +0200, Andreas Abel wrote: The answer to your question is given in Boehm's theorem, and the answer is no, as you suspect. For the untyped lambda-calculus, alpha-equivalence of beta-eta normal forms is the same

Re: [Haskell-cafe] Lambda Calculus question on equivalence

2013-05-04 Thread Francesco Mazzoli
At Sat, 04 May 2013 09:34:01 +0100, Jon Fairbairn wrote: α-equivalence on the Böhm trees — normal forms extended to infinity. I suppose that counts as “some semantics” but its very direct. Ah yes, that makes sense. Thanks! Francesco ___

Re: [Haskell-cafe] Lambda Calculus question on equivalence

2013-05-03 Thread Andreas Abel
The answer to your question is given in Boehm's theorem, and the answer is no, as you suspect. For the untyped lambda-calculus, alpha-equivalence of beta-eta normal forms is the same as observational equivalence. Or put the other way round, two normal forms which are not alpha-equivalent can

Re: [Haskell-cafe] Lambda Calculus question on equivalence

2013-05-03 Thread Francesco Mazzoli
At Fri, 03 May 2013 16:34:28 +0200, Andreas Abel wrote: The answer to your question is given in Boehm's theorem, and the answer is no, as you suspect. For the untyped lambda-calculus, alpha-equivalence of beta-eta normal forms is the same as observational equivalence. Or put the other way

[Haskell-cafe] Lambda Calculus question on equivalence

2013-05-02 Thread Ian Price
if it was possible to find a useful notion of function equality, such that it would be equivalent to structural equality (aside from just defining it this way), though obviously we cannot do this in general. So the question I came up with was: Can two normalised (i.e. no subterm can be beta or eta reduced) lambda

Re: [Haskell-cafe] Lambda Calculus question on equivalence

2013-05-02 Thread Edward Z. Yang
be equivalent to structural equality (aside from just defining it this way), though obviously we cannot do this in general. So the question I came up with was: Can two normalised (i.e. no subterm can be beta or eta reduced) lambda terms be observationally equivalent, but not alpha equivalent

Re: [Haskell-cafe] Lambda Calculus question on equivalence

2013-05-02 Thread Francesco Mazzoli
in the same way, and I got to wondering if it was possible to find a useful notion of function equality, such that it would be equivalent to structural equality (aside from just defining it this way), though obviously we cannot do this in general. So the question I came up with was: Can two

Re: [Haskell-cafe] Lambda Calculus question on equivalence

2013-05-02 Thread Timon Gehr
the question I came up with was: Can two normalised (i.e. no subterm can be beta or eta reduced) lambda terms be observationally equivalent, but not alpha equivalent? By observationally equivalent, I mean A and B are observationally equivalent if for all lambda terms L: (L A) is equivalent to (L B

Re: [Haskell-cafe] Lambda Calculus question on equivalence

2013-05-02 Thread Francesco Mazzoli
. ... (I guess the question is about untyped lambda calculus.) I don’t think so, since Ian talked about ‘terminating’ λ-calculus, while the untyped λ-calculus isn’t... otherwise you can’t normalise and compare. Besides that, the typed calculi I cited are interesting because they internalise some notion

Re: [Haskell-cafe] Lambda Calculus question on equivalence

2013-05-02 Thread Edward Z. Yang
Excerpts from Timon Gehr's message of Thu May 02 14:16:45 -0700 2013: Those are not lambda terms. Furthermore, if those terms are rewritten to operate on church numerals, they have the same unique normal form, namely λλλ 3 2 (3 2 1). The trick is to define the second one as x * 2 (and assume

Re: [Haskell-cafe] Lambda Calculus question on equivalence

2013-05-02 Thread Roman Cheplyaka
IIRC, Barendregt'84 monography (The Lambda Calculus: Its Syntax and Semantics) has a significant part of it devoted to this question. * Ian Price ianpric...@googlemail.com [2013-05-02 20:47:07+0100] Hi, I know this isn't perhaps the best forum for this, but maybe you can give me some

Re: [Haskell-cafe] Lambda Calculus question on equivalence

2013-05-02 Thread Timon Gehr
)...) holds: the same function will always produce the same output given definitionally equal arguments. ... (I guess the question is about untyped lambda calculus.) I don’t think so, since Ian talked about ‘terminating’ λ-calculus, while the untyped λ-calculus isn’t... 'terminating' does not occur

Re: [Haskell-cafe] Lambda Calculus question on equivalence

2013-05-02 Thread Timon Gehr
On 05/02/2013 11:37 PM, Edward Z. Yang wrote: Excerpts from Timon Gehr's message of Thu May 02 14:16:45 -0700 2013: Those are not lambda terms. Furthermore, if those terms are rewritten to operate on church numerals, they have the same unique normal form, namely λλλ 3 2 (3 2 1). The trick is

Re: [Haskell-cafe] Lambda Calculus question on equivalence

2013-05-02 Thread Francesco Mazzoli
‘terminating’ λ-calculus, while the untyped λ-calculus isn’t... 'terminating' does not occur in the original post. ‘normal form’ does, which is what I was referring to. otherwise you can’t normalise and compare. ... The terms in question are already normalised. ‘(L A)’ and ‘(L B

[Haskell-cafe] Automated Differentiation Type Question

2013-04-23 Thread Dominic Steinitz
Can anyone tell me why I get a type error with testGrad2? What are my options? Clearly I would like to be able find the gradient of my cost function for different sets of observations. Thanks, Dominic. {-# LANGUAGE NoMonomorphismRestriction #-} import Numeric.AD default() costFn ::

Re: [Haskell-cafe] Automated Differentiation Type Question

2013-04-23 Thread Dominic Steinitz
Answering my own question, what I needed was: testGrad2 :: (Fractional a, Num a) = (forall s . Mode s = [AD s a]) - (forall s . Mode s = [[AD s a]]) - [a] - [a] testGrad2 ys xss = grad (costFn ys xss) On 23 Apr 2013, at 10:44, Dominic Steinitz domi

Re: [Haskell-cafe] Specialized Computer Architecture - A Question

2013-03-31 Thread Tommy Thorn
And if you are, you may be interested in https://github.com/tommythorn/Reduceron The underlying topic is a fascinating one. The fact that people ignore is that silicon cycle time improvements have been fairly modest - perhaps 2-3 orders of magnitude and we have long been at the point where wire

Re: [Haskell-cafe] A question about data declaration

2013-03-23 Thread Doug Burke
On Mar 22, 2013 2:58 AM, C K Kashyap ckkash...@gmail.com wrote: Thanks Eric and Brent, Even with GADT, it appears that I'd need extra data definitions. I'll go without GADT then ... Brent, my use case is not particularly complicated. I am trying to model the pdf spec - which says that pdf

Re: [Haskell-cafe] A question about data declaration

2013-03-23 Thread Evan Laforge
Brent, my use case is not particularly complicated. I am trying to model the pdf spec - which says that pdf contains Objects that could of of types Number, String, Name, Array and Dictionary - while array is list of objects, the Disctionary is a list of tuples (Name, Object) not (Object,

Re: [Haskell-cafe] A question about data declaration

2013-03-22 Thread C K Kashyap
Thanks Eric and Brent, Even with GADT, it appears that I'd need extra data definitions. I'll go without GADT then ... Brent, my use case is not particularly complicated. I am trying to model the pdf spec - which says that pdf contains Objects that could of of types Number, String, Name, Array

Re: [Haskell-cafe] To seq or not to seq, that is the question

2013-03-22 Thread Tom Ellis
On Fri, Mar 08, 2013 at 08:53:15PM -0800, Edward Z. Yang wrote: Are these equivalent? If not, under what circumstances are they not equivalent? When should you use each? evaluate a return b a `seq` return b return (a `seq` b) Furthermore, consider: [...] - Does the

[Haskell-cafe] question about PutM patterns

2013-03-22 Thread Alexander V Vershilov
Hello, cafe. I have a big problem using builders, so currently I'm using own builder based on Nettle one [1]. It uses Strict bytestring to build into and unchecked writes, thus it's very unsafe, plus other builders/PutM, developed rapidly so I like to switch to another one. However I use some

[Haskell-cafe] A question about data declaration

2013-03-21 Thread C K Kashyap
Hi, I have a situation where I need to define a data type T such that data T = C1 Int | C2 Char | C3 T However, I want to enforce a constraint that C3 only allows (C2 Char) and not (C1 Int). That is x = C3 (C1 10) -- should not compile - but my above definition will let it compile I was

Re: [Haskell-cafe] A question about data declaration

2013-03-21 Thread Erik Hesselink
You could use a GADT: {-# LANGUAGE GADTs #-} data T a where C1 :: Int - T Int C2 :: Char - T Char C3 :: T Char - T Char This will allow you to put a C3 in a C3. If you want to prevent that, just invent some other index, something like: {-# LANGUAGE GADTs, EmptyDataDecls #-} data Yes

Re: [Haskell-cafe] A question about data declaration

2013-03-21 Thread Brent Yorgey
On Thu, Mar 21, 2013 at 06:18:46PM +0530, C K Kashyap wrote: Hi, I have a situation where I need to define a data type T such that data T = C1 Int | C2 Char | C3 T However, I want to enforce a constraint that C3 only allows (C2 Char) and not (C1 Int). That is If C3 should only be able

Re: [Haskell-cafe] Specialized Computer Architecture - A Question

2013-03-19 Thread Simon Farnsworth
OWP wrote: Ironically, you made an interesting point on how Moore's Law created the on chip real estate that made specialized machines possible. As transistor sizing shrinks and die sizes increase, more and more real estate should now be available for usage. Oddly, what destroyed

Re: [Haskell-cafe] Specialized Computer Architecture - A Question

2013-03-18 Thread OWP
If I may ask, I'm not quite sure what O(2^n) and O(1) are? Besides Moore's Law, digital computing also benefits from mature tools and expertise for optimizing performance at all levels of the system: process technology, fundamental circuits, layout and algorithms. Many engineers are

Re: [Haskell-cafe] Specialized Computer Architecture - A Question

2013-03-18 Thread Gwern Branwen
On Mon, Mar 18, 2013 at 4:31 PM, OWP owpmail...@gmail.com wrote: If I may ask, I'm not quite sure what O(2^n) and O(1) are? Just a metaphor using algorithmic complexity, is all. I'm curious, were not all these built on the foundation of Moore's Law? Everything Vigoda lists has Moore's Law in

Re: [Haskell-cafe] Specialized Computer Architecture - A Question

2013-03-18 Thread Brandon Allbery
On Mon, Mar 18, 2013 at 4:31 PM, OWP owpmail...@gmail.com wrote: Let me rephrase that, of course they will survive politically. People built these tools and if built, they will be use but will they survive efficiently? In the future, if a particular specialized architecture is somewhat

Re: [Haskell-cafe] Specialized Computer Architecture - A Question

2013-03-18 Thread Richard A. O'Keefe
On 19/03/2013, at 9:31 AM, OWP wrote: If I may ask, I'm not quite sure what O(2^n) and O(1) are? Check any data structures and algorithms textbook. Reverting to the original topic, THIS is the age of specialised machines. A lot of the chips out there are not just a CPU but a SoC (System on a

Re: [Haskell-cafe] Specialized Computer Architecture - A Question

2013-03-18 Thread OWP
Ironically, you made an interesting point on how Moore's Law created the on chip real estate that made specialized machines possible. As transistor sizing shrinks and die sizes increase, more and more real estate should now be available for usage. Oddly, what destroyed specialized machines in

[Haskell-cafe] Specialized Computer Architecture - A Question

2013-03-17 Thread OWP
Hi, I was reading the paper A History of Haskell: being lazy with class ( http://www.haskell.org/haskellwiki/History_of_Haskel) and came on a section (I 2.1) which briefly explained the work people did on making non-von Neumann architectures. It concluded by saying Much (but not all) of this

Re: [Haskell-cafe] Specialized Computer Architecture - A Question

2013-03-17 Thread Gwern Branwen
On Sun, Mar 17, 2013 at 5:56 PM, OWP owpmail...@gmail.com wrote: These stock architectures, were they really so good that they out performed the specialized ones on it's own merits or was this mainly due to Moore's Law on transistors? In other words, suppose we separate Moore's Law from the

Re: [Haskell-cafe] Question about updating GHC on MacOS

2013-03-14 Thread Alfredo Di Napoli
From my $0.2 experience, if you are planning of having multiple GHC installation, it would be better to do a fresh install using the bootstrapped GHC you can find on the website. Roughly I have done this way (on my Mac and on My EC2 instance): (inside a ghc bootstrapped folder) ./configure

Re: [Haskell-cafe] Question about updating GHC on MacOS

2013-03-11 Thread Alp Mestanogullari
I don't think so. However, you can install the OS X binaries for ghc 7.6.2 and make that sit just next to your Haskell Platform install. You can even use your existing cabal-install to install packages for the freshly installed ghc by doing 'cabal install foo --with-ghc=/path/to/ghc'. Just watch

Re: [Haskell-cafe] To seq or not to seq, that is the question

2013-03-10 Thread Albert Y. C. Lai
On 13-03-08 11:53 PM, Edward Z. Yang wrote: Are these equivalent? If not, under what circumstances are they not equivalent? When should you use each? evaluate a return b a `seq` return b return (a `seq` b) Let a = div 0 0 (or whatever pure but problematic expression you like)

Re: [Haskell-cafe] To seq or not to seq, that is the question

2013-03-09 Thread Tom Ellis
On Fri, Mar 08, 2013 at 08:53:15PM -0800, Edward Z. Yang wrote: Are these equivalent? If not, under what circumstances are they not equivalent? When should you use each? evaluate a return b [...] - Use 'evaluate' when you mean to say, Evaluate this thunk to HNF before doing

Re: [Haskell-cafe] To seq or not to seq, that is the question

2013-03-09 Thread Edward Z. Yang
Excerpts from Tom Ellis's message of Sat Mar 09 00:34:41 -0800 2013: I've never looked at evaluate before but I've just found it's haddock and given it some thought. http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Exception-Base.html#v:evaluate Since it is

[Haskell-cafe] To seq or not to seq, that is the question

2013-03-08 Thread Edward Z. Yang
Are these equivalent? If not, under what circumstances are they not equivalent? When should you use each? evaluate a return b a `seq` return b return (a `seq` b) Furthermore, consider: - Does the answer change when a = b? In such a case, is 'return $! b' permissible? -

[Haskell-cafe] Question about updating GHC on MacOS

2013-03-07 Thread Graham Klyne
Hi, I have Haskell Platform with GHC[i] 7.4.2 installed on a MacOS system. There's a problem with the handling of certain Markdown constructs in literate Haskell (lines starting with '#') that I understand is fixed in 7.6.2. Therefore, I'd like to be able to update my GHC installation to

Re: [Haskell-cafe] simple parsec question

2013-03-05 Thread Immanuel Normann
Carlo, Thanks a lot! This looks very promising (though I have to test it for my purpose more in depth). As you mention, the key seems to be the optionMaybe combinator. Thanks for pointing to it. Immanuel 2013/3/5 Carlo Hamalainen carlo.hamalai...@gmail.com On Mon, Mar 4, 2013 at 1:44 AM,

Re: [Haskell-cafe] simple parsec question

2013-03-05 Thread S. Doaitse Swierstra
Maybe this is something you do not even want to use a parser combinator library for. The package http://hackage.haskell.org/packages/archive/list-grouping/0.1.1/doc/html/Data-List-Grouping.html contains a function breakBefore, so you can write main = do inp - readFile ... let

Re: [Haskell-cafe] simple parsec question

2013-03-04 Thread Immanuel Normann
Andrey, Thanks a lot for your effort! I have the same suspect that the lookahead in the content parser is the problem, but I don't know how to solve it either. At least the I learned from your code that noneOf is also a quite useful parser in this context which I have overlooked. Anyway, if you

Re: [Haskell-cafe] simple parsec question

2013-03-04 Thread Carlo Hamalainen
On Mon, Mar 4, 2013 at 1:44 AM, Immanuel Normann immanuel.norm...@googlemail.com wrote: I am trying to parse a semi structured text with parsec that basically should identify sections. Each section starts with a headline and has an unstructured content - that's all. Here's my attempt:

[Haskell-cafe] simple parsec question

2013-03-03 Thread Immanuel Normann
Hi, I am trying to parse a semi structured text with parsec that basically should identify sections. Each section starts with a headline and has an unstructured content - that's all. For instance, consider the following example text (inside the dashed lines): --- top 1:

Re: [Haskell-cafe] simple parsec question

2013-03-03 Thread Andrey Chudnov
Immanuel, Since a heading always starts with a new line (and ends with a colon followed by a carriage return or just a colon?), I think it might be useful to first separate the input into lines and then classify them depending on whether it's a heading or not and reassemble them into the

Re: [Haskell-cafe] simple parsec question

2013-03-03 Thread Immanuel Normann
Andrey, Thanks for your attempt, but it doesn't seem to work. The easy part is the headline, but the content makes trouble. Let me write the code a bit more explicit, so you can copy and paste it: -- {-# LANGUAGE FlexibleContexts #-} module Main where

Re: [Haskell-cafe] simple parsec question

2013-03-03 Thread Andrey Chudnov
Immanuel, I tried but I couldn't figure it out. Here's a gist with my attempts and results so far: https://gist.github.com/achudnov/f3af65f11d5162c73064 There, 'test' uses my attempt at specifying the parser, 'test2' uses yours. Note that your attempt wouldn't parse multiple sections -- for that

[Haskell-cafe] Question about forkIO

2013-02-28 Thread C K Kashyap
Hi All, Say I have a haskell function 'f' that does a forkIO and starts an action a. I create a DLL of this haskell code and inovke f from C. Can I expect the a to continue to run once f has returned to C? Regards, Kashyap ___ Haskell-Cafe mailing

Re: [Haskell-cafe] Question about forkIO

2013-02-28 Thread C K Kashyap
Just to clarify, here is the sample haskell code that I am using - {-# LANGUAGE ForeignFunctionInterface #-} module Glue where import Foreign.C.String import qualified Control.Concurrent as CC funHaskell :: CString - IO Int funHaskell cstr = do putStrLn Haskell function called str -

Re: [Haskell-cafe] Question about forkIO

2013-02-28 Thread Brandon Allbery
On Thu, Feb 28, 2013 at 6:09 AM, C K Kashyap ckkash...@gmail.com wrote: Say I have a haskell function 'f' that does a forkIO and starts an action a. I create a DLL of this haskell code and inovke f from C. Can I expect the a to continue to run once f has returned to C? While you're off in C

Re: [Haskell-cafe] Question about forkIO

2013-02-28 Thread Donn Cave
Quoth C K Kashyap ckkash...@gmail.com, ... Say I have a haskell function 'f' that does a forkIO and starts an action a. I create a DLL of this haskell code and inovke f from C. Can I expect the a to continue to run once f has returned to C? Once control returns to f's caller, outside of the

Re: [Haskell-cafe] Question about forkIO

2013-02-28 Thread C K Kashyap
Hey Donn .. thanks, it turns out that threads do resume!!! This is how I got my gmail stuff working. I only have a doubt if the TCP keep/alive stuff continues to happen or not Regards, Kashyap On Thu, Feb 28, 2013 at 9:07 PM, Donn Cave d...@avvanta.com wrote: Quoth C K Kashyap

Re: [Haskell-cafe] question about: --hyperlink-source

2013-02-22 Thread Albert Y. C. Lai
On 13-02-21 05:18 AM, Doaitse Swierstra wrote: I ran into the problem that for the packages which I install using cabal install The generated html does not contain links to the sources. This issue was raised before in:

[Haskell-cafe] question about: --hyperlink-source

2013-02-21 Thread Doaitse Swierstra
I ran into the problem that for the packages which I install using cabal install The generated html does not contain links to the sources. This issue was raised before in: http://stackoverflow.com/questions/1587635/haddock-for-cabal-installed-modules I have been looking into the documentation

Re: [Haskell-cafe] question about: --hyperlink-source

2013-02-21 Thread Ivan Lazar Miljenovic
On 21 February 2013 21:18, Doaitse Swierstra doai...@swierstra.net wrote: I ran into the problem that for the packages which I install using cabal install The generated html does not contain links to the sources. This issue was raised before in:

Re: [Haskell-cafe] performance question

2013-02-14 Thread Nicolas Bock
I have to agree that reading and maintaining regular expressions can be challenging :) On Wed, Feb 13, 2013 at 9:50 PM, Erik de Castro Lopo mle...@mega-nerd.comwrote: wren ng thornton wrote: Regexes are powerful and concise for recognizing regular languages. They are not, however, very

Re: [Haskell-cafe] performance question

2013-02-14 Thread Richard A. O'Keefe
Just to play devil's advocate: 100% agreed that there are better things to do in Haskell _source code_ than regexps. The thing about regexps is that they can be accepted at run time as _data_. This means, for example, that they can be put in whatever you use for localisation. See for

Re: [Haskell-cafe] performance question

2013-02-14 Thread wren ng thornton
and still love it.) And at some point we have to call into question the idea of regexes as an embedded DSL when we then turn around and try to have Perl be a DSL embedded into the regex language. One of the big things that makes regexes so nice is that they identify crucial combinators like

Re: [Haskell-cafe] performance question

2013-02-14 Thread David Thomas
this, but it's extremely baroque, hard to get right, and impossible to maintain. (N.B., I was raised on Perl and still love it.) And at some point we have to call into question the idea of regexes as an embedded DSL when we then turn around and try to have Perl be a DSL embedded into the regex language

Re: [Haskell-cafe] performance question

2013-02-14 Thread brandon s allbery kf8nh
was raised on Perl and still love it.) And at some point we have to call into question the idea of regexes as an embedded DSL when we then turn around and try to have Perl be a DSL embedded into the regex language. One of the big things that makes regexes so nice is that they identify

Re: [Haskell-cafe] performance question

2013-02-13 Thread Branimir Maksimovic
replacing it. Date: Tue, 12 Feb 2013 20:32:01 -0800 From: bri...@aracnet.com To: nicolasb...@gmail.com CC: bm...@hotmail.com; b...@redivi.com; haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] performance question On Tue, 12 Feb 2013 15:57:37 -0700 Nicolas Bock nicolasb...@gmail.com wrote

Re: [Haskell-cafe] performance question

2013-02-13 Thread Brandon Allbery
On Tue, Feb 12, 2013 at 11:32 PM, bri...@aracnet.com wrote: actualy native code compiler. Can't regex be done effectively in haskell ? Is it something that can't be done, or is it just such minimal effort to link to pcre that it's not worth the trouble ? PCRE is pretty heavily optimized.

Re: [Haskell-cafe] performance question

2013-02-13 Thread Nicolas Bock
Since I have very little experience with Haskell and am not used to Haskell-think yet, I don't quite understand your statement that regexes are seen as foreign to Haskell-think. Could you elaborate? What would a more native solution look like? From what I have learned so far, it seems to me that

Re: [Haskell-cafe] performance question

2013-02-13 Thread David Thomas
One way in which regexps are foreign to Haskell-think is that, if they break, they generally break at run-time. This could be ameliorated with template haskell, but a substantial portion of Haskell coders find that a smell itself. On Wed, Feb 13, 2013 at 8:32 AM, Nicolas Bock

Re: [Haskell-cafe] performance question

2013-02-13 Thread Nicolas Trangez
On Wed, 2013-02-13 at 08:39 -0800, David Thomas wrote: One way in which regexps are foreign to Haskell-think is that, if they break, they generally break at run-time. This could be ameliorated with template haskell Care to elaborate on the ameliorate using TH part? I figure regexes would be

Re: [Haskell-cafe] performance question

2013-02-13 Thread MigMit
Well, this runtime errors are actually type errors. Regexps are actually a DSL, which is not embedded in Haskell. But it could be. Strings won't work for that, but something like that would: filter (match $ a many anyChar .txt) filenames and this certainly can be produced by TH like that:

Re: [Haskell-cafe] performance question

2013-02-13 Thread Brandon Allbery
On Wed, Feb 13, 2013 at 11:32 AM, Nicolas Bock nicolasb...@gmail.comwrote: Since I have very little experience with Haskell and am not used to Haskell-think yet, I don't quite understand your statement that regexes are seen as foreign to Haskell-think. Could you elaborate? What would a more

<    1   2   3   4   5   6   7   8   9   10   >