[Haskell-cafe] Hackage and version control
Hello, It seems to me that Hackage doesn't provide version control, e.g. check out and check in. Am I incorrect? Kind regards, Vasili ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] FFI problem - possibility of CStringLen overflow?
While rewriting cautious-file to use ByteStrings and FFI just now, I came across this potential problem: Why does the FFI specification define CStringLen as (Ptr CChar, Int)? As the FFI specification itself notes, Haskell 98 implementors are allowed to have a quite small range for Int (only up to 2^29-1) - so you could in principle have a very large String which cannot be represented as a CStringLen, or a very large CString which cannot be represented as a CStringLen. They would take up wads of memory, so this has probably never happened yet, but it's in principle possible, no? If so, what are the implications of this for code correctness? -- Robin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] FFI problem - possibility of CStringLen overflow?
Hello Robin, Monday, July 20, 2009, 6:24:49 AM, you wrote: Why does the FFI specification define CStringLen as (Ptr CChar, Int)? 1. i think it was done to simplify using the api 2. hugs usually don't used for data-massive apps, it's niche is learning and quick development -- Best regards, Bulatmailto:bulat.zigans...@gmail.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hackage and version control
On Mon, Jul 20, 2009 at 9:26 AM, Vasili I. Galchinvigalc...@gmail.com wrote: Hello, It seems to me that Hackage doesn't provide version control, e.g. check out and check in. Am I incorrect? Hackage is, AFAIU, a repository where _released_ versions of libraries/tools/etc related to Haskell can be kept. It is not fully comparable to SourceForge, Github, or any other _source hosting_ service. If you are looking for source hosting then take a look at SF, Github, Google Code, or something like that. Then upload _released_ versions to Hackage. IIRC there is also the possibility of having a Darcs repo on community.haskell.org. /M -- Magnus Therning(OpenPGP: 0xAB4DFBA4) magnus@therning.org Jabber: magnus@therning.org http://therning.org/magnus identi.ca|twitter: magthe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: was: Debugging methods for haskell structured data types the right way in haskell
Fernan Bolando fernanbola...@mailc.net writes: On Sun, Jul 19, 2009 at 7:40 AM, wren ng thorntonw...@freegeek.org wrote: Fernan Bolando wrote: The intention is z0 is a system parameter and database, it contains a set of info needed to define a particular simulation A single-constructor ADT, especially with the labeled-fields syntax, is pretty close to C structs; no need to reinvent them and give yourself headaches. Really, the only thing you should be using lists for is a variable-length sequence of elements drawn from the same type and distinguished only by their position in the sequence. This is the kind of code recommendations I was looking. I'd worked out a longer reply over the weekend, but wren got there first (It hadn't occured to me that anyone would write that much code without knowing about algebraic types, so thought something else was going on). I'd like to add that thinking about the C code for a programme like this is counterproductive. If you are doing various mathematical operations, it's better to go straight from the mathematics to Haskell, and work out the appropriate abstractions (in Haskell) for the operations you are using. You'll generally end up with much shorter code that is easier to maintain. It might be worth pointing out that you can do things with Haskell data structures that you can't do conveniently in C. For example, if you were doing something that involved calculating the determinants of matrices fairly often, but you didn't know in advance which matrices, you could define your own matrix type like this (roughly): data MyMatrix t = MM {theNumbers:: Matrix t, my_determinant:: t} make_matrix m = MM {theNumbers = m, my_determinant = determinant m } and then use make_matrix whenever you make a new matrix and my_determinant whenever you want a determinant. Now, although to a C programmer this looks like you calculate the determinant of every matrix, laziness means that you only calculate the ones you use, and calculate them at most once for each matrix. -- Jón Fairbairn jon.fairba...@cl.cam.ac.uk ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hackage and version control
Hello Vasili, Monday, July 20, 2009, 12:26:52 PM, you wrote: It seems to me that Hackage doesn't provide version control, e.g. check out and check in. Am I incorrect? i recommend you to use either codeplex or code.google -- Best regards, Bulatmailto:bulat.zigans...@gmail.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hackage and version control
On Mon, 20 Jul 2009 10:03:56 +0100 Magnus Therning mag...@therning.org wrote: On Mon, Jul 20, 2009 at 9:26 AM, Vasili I. Galchinvigalc...@gmail.com wrote: Hello, It seems to me that Hackage doesn't provide version control, e.g. check out and check in. Am I incorrect? Hackage is, AFAIU, a repository where _released_ versions of libraries/tools/etc related to Haskell can be kept. It is not fully comparable to SourceForge, Github, or any other _source hosting_ service. If you are looking for source hosting then take a look at SF, Github, Google Code, or something like that. Then upload _released_ versions to Hackage. IIRC there is also the possibility of having a Darcs repo on community.haskell.org. Yes, and darcs repos can also be hosted on patch-tag.com. community.haskell.org requires you to wait for a volunteer to review every new project request. Although, you don't need to make a project request if you only want a 1-developer repository. And by the way, it only hosts Haskell-related projects, not arbitrary darcs repositories. patch-tag.com doesn't have those constraints. -- Robin ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hackage and version control
Or patch-tag.com On 20 Jul 2009, at 13:27, Bulat Ziganshin wrote: Hello Vasili, Monday, July 20, 2009, 12:26:52 PM, you wrote: It seems to me that Hackage doesn't provide version control, e.g. check out and check in. Am I incorrect? i recommend you to use either codeplex or code.google -- Best regards, Bulatmailto:bulat.zigans...@gmail.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hackage and version control
Don't forget about Patch-tag! Bulat Ziganshin wrote: Hello Vasili, Monday, July 20, 2009, 12:26:52 PM, you wrote: It seems to me that Hackage doesn't provide version control, e.g. check out and check in. Am I incorrect? i recommend you to use either codeplex or code.google begin:vcard fn:Joseph Fredette n:Fredette;Joseph adr:Apartment #3;;6 Dean Street;Worcester;Massachusetts;01609;United States of America email;internet:jfred...@gmail.com tel;home:1-508-966-9889 tel;cell:1-508-254-9901 x-mozilla-html:FALSE url:lowlymath.net, humbuggery.net version:2.1 end:vcard ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hackage and version control
Am Montag, 20. Juli 2009 05:25 schrieb Robin Green: community.haskell.org requires you to wait for a volunteer to review every new project request. However, response times are usually low. Best wishes, Wolfgang ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re[2]: [Haskell-cafe] Hackage and version control
Hello Joe, Monday, July 20, 2009, 2:36:28 PM, you wrote: afaik it provides minimal features, only VCS, while sitea i mentioned provides full service for OSS developer Don't forget about Patch-tag! Bulat Ziganshin wrote: Hello Vasili, Monday, July 20, 2009, 12:26:52 PM, you wrote: It seems to me that Hackage doesn't provide version control, e.g. check out and check in. Am I incorrect? i recommend you to use either codeplex or code.google -- Best regards, Bulatmailto:bulat.zigans...@gmail.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: cautious-file 0.1.1: Ways to write a file cautiously, to avoid data loss
I've since uploaded two new versions with the following changes: 0.1.2: Fixed an issue where it would clobber symbolic links to files, which is usually not what you want. Test case added for this. 0.1.3: ByteString support! FFI is also now used under the hood to do things in a slightly less hacky way. -- Robin On Sun, 19 Jul 2009 23:35:34 +0100 Robin Green gree...@greenrd.org wrote: I'm pleased to announce the first public release of cautious-file: http://hackage.haskell.org/package/cautious-file snip ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Implicit concatenation in list comprehensions
I think the tuple sections are a great idea! It also makes tuple types and constructors more alike: x :: (,) String Double x = (,) Pi 3.14159 I can also see some uses in writing pointfree code. I would definitely want this in a future GHC (or any other Haskell compiler/interpreter) release. I'm not so sure about the list comprehension concatenation. Like Thomas Schilling wrote, it is only a bit shorter then writing it with the current syntax. So I'm not sure if it is worth the cost. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: cautious-file 0.1.1: Ways to write a file cautiously, to avoid data loss
Nice library! On Sun, Jul 19, 2009 at 11:35:34PM +0100, Robin Green wrote: A variant, writeFileWithBackup, also allows you to supply a custom backup computation to backup old copy(ies) of the destination file It would be nice to have the backup action receive the file name as a parameter, so it would be possible to have a library of possible backup strategies. :) -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Typeclass default implementation in subclasses
Hi all, This email is literate Haskell. I have a question about default implementations of typeclasses. {-# LANGUAGE TypeSynonymInstances #-} module Thing where import Text.PrettyPrint.HughesPJ Let say I want to pretty-print some values, enclosed in double quotes. The natural thing to do (within the HughesPJ pretty-printing framework, anyway - and that's where I am in this problem's wider context) is: ppQuote :: Show a = a - Doc ppQuote = doubleQuotes . text . show Now, this works nicely for (say) Int: x :: Int x = 1 *Thing ppQuote x 1 But less nicely for String and Char, because their Show instances already insert double/single quotes respectively: y :: String y = hello z :: Char z = 'a' *Thing ppQuote y hello *Thing ppQuote z 'a' I don't want this. I'd like them to be hello and a respectively. So I thought I'd create a typeclass, whose default implementation is as above... class (Show a) = Quotable a where quote :: a - Doc quote = ppQuote ... but with specialised instances for String and Char (the former seems to need the TypeSynonymInstances extension?): instance Quotable String where quote = text . show -- don't need the doubleQuotes call for String instance Quotable Char where quote c = quote [c] -- just lift it to String Unfortunately, while this works great for String and Char... *Thing quote y hello *Thing quote z a ... the default implementation mechanism doesn't work as I'd expect/hope: *Thing quote x interactive:1:0: No instance for (Quotable Int) arising from a use of `quote' at interactive:1:0-6 Possible fix: add an instance declaration for (Quotable Int) In the expression: quote x In the definition of `it': it = quote x What I would _like_ would be for the compiler to say OK, the Quotable class depends on the Show class, and Int is an instance of Show so Int is also an instance of Quotable, having the default implementation (since there isn't a specialised one for it) - but clearly it doesn't. Please can someone tell me why this doesn't happen, and if there is a way of making it happen? Also, if there's a more sensible way of attacking this whole problem, I'd be curious to hear it. I should perhaps add that this isn't a huge problem for me, because my instances will in practice tend to be String and Char anyway, and one can of course add Quotable instances for anything else easily enough - but I'm curious now I've come this far. :-) Many thanks! -Andy ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ICFP contest write-up
For all Portuguese reading haskellers, I am describing my ICFP 2009 contest write-up on my blog. Feel free to comment. http://rafaelgcpp.blogspot.com/search/label/ICFP2009 For the non-Portuguese readers, Google translation tools do a lousy job, but it is still readable. Regards Rafael Gustavo da Cunha Pereira Pinto ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] SpecConstr difficulties
Hi everyone, I've been having some trouble getting SpecConstr to work as I want it to. The following example (see end of email) came up in some code I was playing around with. The loops g1 and g2 both compute the same thing: the maximum element of the list (which has been fused away) of numbers from 1 to 10. Since 'maximum' is a foldl1 not a foldl, I use a strict Maybe type as an accumulator. The Maybe gets filled after the first element is seen, so the Maybe is a Just for almost the entire running of the loop. It would be good to have this recognised by SpecConstr, to create an optimised loop for the Just case. This does indeed happen for g1, but not for g2. My difficulty is that I am only able to produce code similar to g2, i.e. where the pattern matching is in a separate function, 'expose', because the 'expose' function is implemented in a type-class, like in stream-fusion. Is there some way to keep the SpecConstr while leaving the 'expose' as a separate function? Here is the code: {-# LANGUAGE BangPatterns #-} module Test(ans1,ans2) where import Prelude hiding(Maybe(..)) data Maybe a = Just !a | Nothing Nothing `mapp` Just b = Just b Just a `mapp` Just b = Just (max a b) ans1 = g1 Nothing (0::Int) g1 m !n = case m of Nothing - if n 10 then m else g1 (m `mapp` Just n) (n+1) Just x - if n 10 then m else g1 (m `mapp` Just n) (n+1) ans2 = g2 Nothing (0::Int) g2 m !n = expose m (if n 10 then m else g2 (m `mapp` Just n) (n+1)) expose Nothing b = b expose (Just a) b = a `seq` b On a similar note, when I was having difficulties with this problem, I started to wonder if it would be possible to come up with a more direct way to tell GHC, do SpecConstr on this variable. From reading the source code of the stream-fusion package, it seems that the current way of doing this is with 'expose' functions like I wrote below. Could we instead have a {-# SPECCONSTR #-} pragma, to be used on function arguments, like: foo {-# SPECCONSTR #-} x y {-# SPECCONSTR #-} z = ... This pragma should say to the GHC something like ignore conditions H2, H5 and H6 of the SpecConstr paper, for this function and this argument. Cheers, Reiner ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Typeclass default implementation in subclasses
This post is also literate haskell. By enabling these potentially dangerous extensions you'll get the behaviour you want. {-# LANGUAGE TypeSynonymInstances #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE OverlappingInstances #-} module Thing where import Text.PrettyPrint.HughesPJ ppQuote :: Show a = a - Doc ppQuote = doubleQuotes . text . show x :: Int x = 1 y :: String y = hello z :: Char z = 'a' class (Show a) = Quotable a where quote :: a - Doc quote = ppQuote instance (Show a) = Quotable a instance Quotable String where quote = text . show -- don't need the doubleQuotes call for String instance Quotable Char where quote c = quote [c] -- just lift it to String Example: *Thing quote pi pi *Thing quote 3.14159 3.14159 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANNOUNCE: graphviz-2999.1.0.1
This is a bug-fix release to fix the various Attribute-related problems in the previous release (2999.0.0.0) spotted mainly by Zsolt Dollenstein. Please disregard version 2999.1.0.0; it had a small bug. Similarly, people should avoid using 2999.0.0.0 unless they don't use any Either-based Attributes. The problem (which took me a while to realise) was that whilst I was using Either to denote that an attribute could take one of two different types of values (e.g. Bool and String) and the parsing for that worked. However, since I was using Show (I know it's bad, it was on my TODO, remember?) to generate the Dot code, then whenever one of these values was converted then either Left or Right would appear, and GraphViz doesn't seem to like that for some reason... I also took the opportunity to define custom types for more Attributes (as they only accept certain String values). Furthermore, GraphViz states that attributes that can accept a boolean value are set to True when the attribute is listed on its own; the library now does this even for those Attributes that use a custom type that combines Bool with something else. One other small change is that the Color Attribute now takes in a list of Colors; if you only want one, use a singleton list (it was either that or a custom datatype that takes either a single Color or a list of Colors...). Note that 2999.1.0.0 accidentally only had singleton Color values for the Color Attribute rather than a list, hence the quick version bump. Nothing else has changed in the library apart from the Attributes. Regarding my request in the previous email about the possible new layout of the DotGraph datatype: How many people actually build DotGraphs by hand or pull them apart by hand? If there were getNodes :: DotGraph - [Node] and getEdges :: DotGraph - [Edge] functions available, would you accept an all-in-one data type that just contains a generic list of statements and thus follows upstream more closely? Even leaving aside parsing, this would allow for greater flexibility for creating wild and wacky graphs or for a monadic interface or something for building DotGraphs (which someone has asked me for, but which at the moment I have no idea how to do...). -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Implicit concatenation in list comprehensions
On Mon, Jul 20, 2009 at 1:27 PM, Roel van Dijkvandijk.r...@gmail.com wrote: I think the tuple sections are a great idea! It also makes tuple types and constructors more alike: x :: (,) String Double x = (,) Pi 3.14159 I just realised this is already in GHC :-) But does you patch also add the equivalent for tuple type annotations? x :: (String, ) Double x = (Pi, ) 3.14159 I am also wondering what the following would/should mean: (1, , ( , 2), ) 'a' 'b' 'c' Should this mean (1, 'a', ('b', 2), 'c') or (1, 'a', ('c', 2), 'b') Intuitively I would expect the first option. Just reading from left to right. But it doesn't look entirely trivial. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Implicit concatenation in list comprehensions
Roel van Dijk wrote: On Mon, Jul 20, 2009 at 1:27 PM, Roel van Dijkvandijk.r...@gmail.com wrote: I think the tuple sections are a great idea! It also makes tuple types and constructors more alike: x :: (,) String Double x = (,) Pi 3.14159 I just realised this is already in GHC :-) But does you patch also add the equivalent for tuple type annotations? x :: (String, ) Double x = (Pi, ) 3.14159 I am also wondering what the following would/should mean: (1, , ( , 2), ) 'a' 'b' 'c' I would expect it to be a type error, since I think the following is the only sane type the tuple can have (assuming numeric literals :: Int): (1, , ( , 2), ) :: a - b - (Int, a, c - (c, Int), b) Ganesh === Please access the attached hyperlink for an important electronic communications disclaimer: http://www.credit-suisse.com/legal/en/disclaimer_email_ib.html === ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Implicit concatenation in list comprehensions
I am also wondering what the following would/should mean: (1, , ( , 2), ) 'a' 'b' 'c' I would expect it to be a type error, since I think the following is the only sane type the tuple can have (assuming numeric literals :: Int): (1, , ( , 2), ) :: a - b - (Int, a, c - (c, Int), b) Ganesh Ah you're completely right! I would be applying a tuple to a Char which is nonsense. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] FFI problem - possibility of CStringLen overflow?
On Sun, Jul 19, 2009 at 7:24 PM, Robin Green gree...@greenrd.org wrote: While rewriting cautious-file to use ByteStrings and FFI just now, I came across this potential problem: Why does the FFI specification define CStringLen as (Ptr CChar, Int)? Do you think it was a typo and the author(s) meant (Ptr CChar, CInt) ? Jason ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Anglohaskell - wifi signups
Wifi signups are Anglohaskell are now on the wiki - please add your details by the 31st of July if you want a wifi account at MS Research for the Friday. Alternatively, reply to this email with your full name, institution, country of residence and email address. The Anglohaskell wiki page can be found at http://www.haskell.org/haskellwiki/AngloHaskell/2009 There's still room for more talks if anyone's got something they fancy giving a go - everything from cutting edge research to what I did with Haskell on my holiday is welcome, as is everyone from GHC implentors to newbies frantically writing Hello World on their laptop in the back row. -- fli...@flippac.org ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Pruning the Front Page
All, I think we should remove unmaintained or refocused implementations from the haskell.org front page. This would mean removing: YHC - unmaintained, hasn't built for me in a while LHC - Not a standalone compiler these days - perhaps should be linked as a GHC subproject? Other than those I'd propose NHC but I'm guessing that would get some pushback (even though it currently doesn't build for me). Before anyone brings up HUGS I'll just say that 1) it is used 2) it builds 3) at least it's been updated more recently than the Haskell langauge. Thomas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Pruning the Front Page
thomas.dubuisson: All, I think we should remove unmaintained or refocused implementations from the haskell.org front page. This would mean removing: YHC - unmaintained, hasn't built for me in a while LHC - Not a standalone compiler these days - perhaps should be linked as a GHC subproject? Other than those I'd propose NHC but I'm guessing that would get some pushback (even though it currently doesn't build for me). Before anyone brings up HUGS I'll just say that 1) it is used 2) it builds 3) at least it's been updated more recently than the Haskell langauge. I guess we just acknowledge that all implementations are not equal, and for newbies we strongly recommend GHC + Haskell Platform. For reference, we point to a page listing all implementations. This follows convention (i.e. Python, Ruby only point to the canonical impls, not the various forks). -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Implicit concatenation in list comprehensions
2009/7/20 Roel van Dijk vandijk.r...@gmail.com: I just realised this is already in GHC :-) But does you patch also add the equivalent for tuple type annotations? x :: (String, ) Double x = (Pi, ) 3.14159 It doesn't, and indeed it would only work in the special case where your only missing type arguments are on the right (since we lack type-level lambda, we can only accept eta-reduced forms). So it probably wouldn't be worth it - it wouldn't allow you to write anything significantly shorter than the existing form (,) String. Cheers, Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Ambiguous type variable - help!
On 19 Jul 2009, at 21:18, Yitzchak Gale wrote: Hi Phil, I've concocted a very simple example to illustrate this (below) - but it doesn't compile because ghc complains that my type is ambiguous arising from my use of 'fromSeq'. Notice that you have given two completely separate sets of instructions of what to do depending on whether Int or Double is selected. You have not given any indication of how to choose between them, even at runtime. Of course, the compiler doesn't care that your string constants Int and Double happen also to be the names of types if unquoted. I see now. I'm passing fromSeq a SeqType, but it has no way of knowing if I want to process it as an Int or a Double. The only thing which is polymorphic is nextSeq as it must handle the underlying state of Int and Double. Your result function handles the general case and the typeclass instances deal with the specialization depending on the state's type. The printResult function takes in a SeqType and then parses (for want of a better word) out the underlying type of Int or Double. It then calls results against the Int or Double which in turn will invoke the correct version of nextSeq. Thank you very much for explaining this! Phil. import Control.Monad.State -- Why Strict? Haskell is lazy by default. Ahh, no reason for the Strict - in the large program I'm righting it is required because otherwise I end up with almighty thunks. But here it serves no purpose. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Implicit concatenation in list comprehensions
Excerpts from Max Bolingbroke's message of Sun Jul 19 16:58:08 +0200 2009: Dear Cafe, For fun, I spent a few hours yesterday implement support for this syntax in GHC, originally propsed by Koen Claessen: [...] P.S. I also implemented tuple sections (http://hackage.haskell.org/trac/ghc/ticket/3377#comment:3) which are a lot more useful: I vote for both extensions. -- Nicolas Pouillard http://nicolaspouillard.fr ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Implicit concatenation in list comprehensions
2009/7/21 Roel van Dijk vandijk.r...@gmail.com: I am also wondering what the following would/should mean: (1, , ( , 2), ) 'a' 'b' 'c' I would expect it to be a type error, since I think the following is the only sane type the tuple can have (assuming numeric literals :: Int): (1, , ( , 2), ) :: a - b - (Int, a, c - (c, Int), b) Ganesh Ah you're completely right! I would be applying a tuple to a Char which is nonsense. You can kind of do it if you indicate which 'field' is to be applied: import Control.Applicative newtype Fst b a = Fst (a,b) deriving (Show) newtype Snd a b = Snd (a,b) deriving (Show) instance Functor (Fst b) where fmap f (Fst (a,b)) = Fst (f a,b) instance Functor (Snd a) where fmap f (Snd (a,b)) = Snd (a,f b) f $$ x = ($x) $ f ... Fst ((,)1,3) $$ 2 -- no section, don't have the patch ;) Fst ((1,2),3) signature.asc Description: OpenPGP digital signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Pruning the Front Page
On Mon, Jul 20, 2009 at 2:09 PM, Thomas DuBuissonthomas.dubuis...@gmail.com wrote: All, I think we should remove unmaintained or refocused implementations from the haskell.org front page. This would mean removing: YHC - unmaintained, hasn't built for me in a while LHC - Not a standalone compiler these days - perhaps should be linked as a GHC subproject? Other than those I'd propose NHC but I'm guessing that would get some pushback (even though it currently doesn't build for me). Before anyone brings up HUGS I'll just say that 1) it is used 2) it builds 3) at least it's been updated more recently than the Haskell langauge. Thomas What about UHC and JHC? They're both maintained (in their varying degrees), but I don't think they can do anything but pure Haskell '98*, and I dunno whether they could even compile the Cabal packages which are/depend only on Haskell '98. What should our criterion be? Just maintained? Maintained and at least able to compile Haskell '98 source? Maintained, able to compile Haskell '98, and also the pure Haskell '98 subset of Hackage? I prefer the last triplet since it's the best for newbies and the minimum necessary for practicality beyond rolling everything oneself, but perhaps that's too strict for everyone else. * by which I mean Haskell '98, the FFI, and hierarchical modules -- gwern ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] understanding HXT's insertChildrenAfter
Playing on HXT 8.3.0 via cabal on GHC 6.10.2. While there are plenty of useful examples of extract data from XML, applying the appropriate API to transform and/or merging still baffle me. In this case, it is the insertChildrenAfter, let's try it with the following example: given 2 files --- update.xml ?xml version=1.0 encoding=UTF-8? update hotsky is now orange/hot hotfish is fresh/hot hotviolets are blue/hot /update --- master.xml ?xml version=1.0 encoding=UTF-8? news page1 hotsky is blue/hot hotroses are red/hot /page1 page2 storygame shipped on sunday/story /page2 /news with the intention of augment the master list with the new items: import Text.XML.HXT.Arrow import qualified Text.XML.HXT.DOM as DOM getMaster = readDocument [(a_validate,v_0)] master.xml removeDocWhiteSpace getUpdate = readDocument [(a_validate,v_0)] update.xml removeDocWhiteSpace selectUpdateArea = getChildren hasName news getChildren hasName page1 updateContent = insertChildrenAfter (selectUpdateArea) (getUpdate getChildren getChildren) main = do runX ( getMaster updateContent putXmlTree - ) instead the following tree is produced: ---XTag / | +---XTag hot | | | +---XText sky is red | +---XTag hot | | | +---XText fish is fresh | +---XTag hot | | | +---XText violets are blue | +---XTag news | +---XTag page1 | | | +---XTag hot | | | | | +---XText sky is blue | | | +---XTag hot | | | +---XText roses are red | +---XTag page2 | +---XTag story | +---XText game shipped Can someone give some examples of how insertChildrenAfter works? How about also some general guidelines when comes to merging/grafting XML documents. Jake ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe