Re: [Haskell-cafe] Re: [Haskell] Type-Level Naturals Like Prolog?
Hello Donald, Thursday, July 13, 2006, 9:33:34 AM, you wrote: >> Why can't Haskell (with extensions) do type-level Peano naturals in >> the same fashion? The code would be something like: darcs get --partial --tag '0.1' http://www.eecs.tufts.edu/~rdocki01/typenats/ -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: [Haskell] Type-Level Naturals Like Prolog?
jawarren: > Haskell's type checking language is a logical programming language. > The canonical logical language is Prolog. However, Idealised Prolog > does not have data structures, and does Peano numbers like: > > natural(zero). > natural(x), succ(x,y) :- natural(y) > > And I believe (but cannot confirm): > > succ(zero,y). > succ(x,y) :- succ(y,z) > > Why can't Haskell (with extensions) do type-level Peano naturals in > the same fashion? The code would be something like: > > >data Zero > > > >class Natural x where > > toInt :: x -> Integer > >instance Natural Zero where > > toInt _ = 0 > >instance (Natural x, Succ x y) => Natural y where > > toInt y = undefined + 1 > > > >class Succ x y > >instance Succ Zero y > >instance Succ x y => Succ y z > > > >zero = toInt (undefined :: Zero) -- THIS SUCCEEDS > > > >one = toInt (undefined :: (Succ Zero x) => x) -- THIS FAILS > Perhaps these will be useful? http://www.haskell.org/haskellwiki/Peano_numbers http://www.haskell.org/haskellwiki/Type_arithmetic and a bit of stuff here http://www.haskell.org/haskellwiki/Smart_constructors Cheers, Don (P.S. moved to haskell-cafe@haskell.org, more appropriate) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?
Quoth "Jared Updike" <[EMAIL PROTECTED]>: (... quoting me) |> Hence I would much rather have the split condition be the first |> parameter -- the infix notation looks good, but it will need a |> "flip" to get the parameters in the right order. | | This also goes along with join in python, i.e. | | "\n".join(xs) | ==> | "\n" `join` xs |in Haskell (wherejoin sep = concat . intersperse sep ) Suit yourself! Since we seem to be in agreement on the basic point, I won't go into what I think about "\n".join(xs). Donn Cave, [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Comma in the front
Hi, Are cool kids supposed to put the comma in front like this? Some cool kids do, some cool kids don't. Some do both, depending on their mood. The advantage of a leading , is that now the comma's line up, and if you want to add an item on the end of a list [a ,b ,c ] It's just a one line change, whereas with the comma after, you'd have to change the previous line as well - which is more effort and gives more noise in the darcs copy. Thanks Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Comma in the front
Are cool kids supposed to put the comma in front like this? , foo , bar , baz Is this for historical or other reasons because Emacs formats Haskell code well enough regardless. Thanks, Joel -- http://wagerlabs.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Breaking cycles in a directed graph.
On Wednesday 12 July 2006 21:11, Henning Thielemann wrote: > On Wed, 12 Jul 2006, Daniel McAllansmith wrote: > > Hello. > > > > I'm currently using Data.Graph.Inductive to represent a directed graph. > > > > I want to detect all cycles within the graph and 'break' them by > > inserting a minimal number of nodes that are labelled with a special > > cycle-breaker label. > > > > Can anyone give me advice on a good algorithm for finding the cycles and > > finding the optimum edges to insert the cycle-breaking nodes on? > > There must be an algorithm for finding the minimal spanning tree or > forest. The edges that do not belong to the tree should be the labelled as > cycle-breakers. I don't think that will give me the solution I'm looking for. I'll try to rephrase my problem, I think it was a little unclear. Given a directed graph I want to find the minimal set of edges such that deletion of those edges from the graph will result in a new graph with 0 strongly connected components, ie no cycles, possibly disconnected. Perhaps the correct term is the minimal _full_ disconnecting set of edges? Once I've got that set of edges, instead of deleting them, I'll insert one of my special 'cycle-breaking' nodes, but that's nothing to do with the core graph analysis really. Examples: {(A->A)} => {(A->A)} {(A->B), (B->C)} => {} {(A->B), (B->C), (B->D), (C->A), (D->A)} => {(A->B)} because it is the least number of edges, other solutions would require deleting 2 edges. A possible solution might be to recursively break the graph into strongly connected components, delete an edge from the component then break again until there are no more sub components. That'll probably have pretty poor performance. It could be made to provide a stable solution easily though which, as Jason Dagit points out, is useful for QuickChecking a more complex algorithm. Daniel ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Breaking cycles in a directed graph.
On Wednesday 12 July 2006 19:19, Jens Fisseler wrote: > R.C. Read, R.E. Tarjan. Bounds on Backtrack Algorithms for Listing > Cycles, Paths and Spanning Trees. Networks 5: 237-252, 1975, > > section 8.3, "Cycles", of > Edward M. Reingold, Jurg Nievergelt, Narsing Deo. Combinatorial > Algorithms: Theory and Practice. Prentice-Hall, Englewood Cliffs, 1977. > > You can also find a survey in > > Prabhaker Mateti, Narsing Deo. On Algorithms for Enumerating All > Circuits of a Graph. SIAM Journal on Computing, 5(1): 90-99, 1976. Hi, Jens. You don't know if there is an overview, or implementation, of these algorithms online do you? I don't have (easy) access to these references. Another that might be applicable is: Donald B. Johnson. Finding all the elementary circuits of a directed graph. SIAM J. Comput, 5:77--84, 1975. Though I don't have access to that either. Also I gather Combinatorica, a Mathematica module, has algorithms covering this sort of thing. I understand it has a restrictive licence so I haven't looked at those either. Thanks Daniel ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?
> fields = csv `separateWith` "," > csv = fields `joinWith` "," -- equivalent to concatIntersperse Hence I would much rather have the split condition be the first parameter -- the infix notation looks good, but it will need a "flip" to get the parameters in the right order. This also goes along with join in python, i.e. "\n".join(xs) ==> "\n" `join` xs in Haskell (wherejoin sep = concat . intersperse sep ) Jared. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Breaking cycles in a directed graph.
On 7/12/06, Jens Fisseler <[EMAIL PROTECTED]> wrote: Hi Daniel, > I want to detect all cycles within the graph and 'break' them by inserting a > minimal number of nodes that are labelled with a special cycle-breaker label. > > Can anyone give me advice on a good algorithm for finding the cycles and > finding the optimum edges to insert the cycle-breaking nodes on? I've had a similar problem as I needed to find all (even-length) cycles in an undirected graph. To the best of my knowledge the algorithm, described in R.C. Read, R.E. Tarjan. Bounds on Backtrack Algorithms for Listing Cycles, Paths and Spanning Trees. Networks 5: 237-252, 1975, has the (currently) best known running time of O(V+E+EN), N being the number of cycles found. As the algorithm is not that easy to understand (at least for me), you should perhaps have a look at section 8.3, "Cycles", of Edward M. Reingold, Jurg Nievergelt, Narsing Deo. Combinatorial Algorithms: Theory and Practice. Prentice-Hall, Englewood Cliffs, 1977. The algorithm described there is easier to understand and implement. Assuming the solution is unique, this would be a good place to use QuickCheck. The simpler algorithm could be implemented and verified through some tests + code inspection until you're convinced it's correct (enough). Then you can use QuickCheck on the harder to understand algorithm using the simpler algorithm as the check. Although, this may fail to work if some graphs have multiple solutions and each algorithm picks a different solution. Just a thought, Jason ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?
On Wed, 12 Jul 2006, Evan Laforge wrote: > Also, my version of the "split but don't drop the delimiter" is > breakAll, since it's like a recursive break. > > words/unwords and lines/unlines have one argument, so a 2 argument > fielts/unfields would break that "convention". Maybe: > > fields = csv `separateWith` "," > csv = fields `joinWith` "," -- equivalent to concatIntersperse I may be confused about your point, but I think the way we get split functions down to one parameter is by partial application - commaSplit = splitBy (== ',') fields = commaSplit csv Hence I would much rather have the split condition be the first parameter -- the infix notation looks good, but it will need a "flip" to get the parameters in the right order. Donn Cave, [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?
Christian Maeder wrote: Donald Bruce Stewart schrieb: Question over whether it should be: splitBy (=='a') "aabbaca" == ["","","bb","c",""] or splitBy (=='a') "aabbaca" == ["bb","c"] I argue the second form is what people usually want. Yes, the second form is needed for "words", but the first form is needed for "lines", where one final empty element needs to be removed from your version! Prelude> lines "a\nb\n" ["a","b"] Prelude> lines "a\n\nb\n\n" ["a","","b",""] Prelude.lines and Prelude.unlines treat '\n' as a terminator instead of a separator. I'd argue that this is poor design, since information is lost ie lines . unlines === id whereas unlines . lines =/= id whereas if '\n' had been properly conceived of as a separator, the identity would hold. So I vote for the first option ie: splitBy (=='a') "aabbaca" == ["","","bb","c",""] Regards, Brian. -- Logic empowers us and Love gives us purpose. Yet still phantoms restless for eras long past, congealed in the present in unthought forms, strive mightily unseen to destroy us. http://www.metamilk.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?
2006/7/12, [EMAIL PROTECTED] <[EMAIL PROTECTED]>: Jared Updike wrote: > > "split" is... unconcatIntersperse. > > How about "separate"? ("split" or "splitBy" is better but it is used > all over the place in many libs) > > And for strings I definitely would use split :: [a] -> [a] -> [[a]] a > lot, just like Python's split function. And "words" works great for > breaking on multiple spaces, so I would avoid trying to fill that > need... FWIW my home-grown versions of these things are called fields and unfields. Also, my version of the "split but don't drop the delimiter" is breakAll, since it's like a recursive break. words/unwords and lines/unlines have one argument, so a 2 argument fielts/unfields would break that "convention". Maybe: fields = csv `separateWith` "," csv = fields `joinWith` "," -- equivalent to concatIntersperse ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Why is there no splitBy in the list module?
Jared Updike wrote: > > "split" is... unconcatIntersperse. > > How about "separate"? ("split" or "splitBy" is better but it is used > all over the place in many libs) > > And for strings I definitely would use split :: [a] -> [a] -> [[a]] a > lot, just like Python's split function. And "words" works great for > breaking on multiple spaces, so I would avoid trying to fill that > need... FWIW my home-grown versions of these things are called fields and unfields. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Hackathon hesitation
At Wed, 12 Jul 2006 10:57:54 -0700, Chad Scherrer wrote: > > [1 ] > [1.1 ] > Hi, > > I'm interested in attending the Hackathon, but I don't have any previous > experience working on compilers. Perhaps we should start a list of pre-session recommended reading on the wiki page? I would recommend at least skimming the following papers/books: Implementing functional languages: a tutorial Simon Peyton Jones and David Lester. Published by Prentice Hall, 1992. http://research.microsoft.com/~simonpj/Papers/pj-lester-book/ Typing Haskell in Haskell (1999) Mark P. Jones http://citeseer.ist.psu.edu/jones99typing.html Implementing Lazy Functional Languages on Stock Hardware: the Spineless Tagless G-machine Simon L. Peyton Jones http://research.microsoft.com/research/pubs/view.aspx?pubid=179 I like those because you can get a lot out of them, even if you have no prior compiler experience. Anyone have other suggestions? j. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Re[2]: [Haskell-cafe] Using of C constants in Haskell sources; Determining compilation environment (Unix vs Windows)
Hi I would *guess* that hsc2hs is always distributed with ghc. I know it is on Linux and BSD -- I am not sure about Windows. It is. If you want to support hugs as well, then they would need hschs-hugs installed. Debian includes that with hugs by default -- not sure about anyone else. Windows certainly does, I think its in the standard Hugs make scripts. Hugs always has cpphs available, but doesn't provide a cpp. GHC doesn't ship with cpphs, probably for license reasons. However cpphs can be used used to simulate cpp on Unix (using cpphs.compat) and hopefully soon on Windows with a --cpp flag (although not yet). Cabal should take care of cpp on all platforms by using the distributed one though. Thanks Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?
On Wed, 12 Jul 2006, Donald Bruce Stewart wrote: > I vote for this, currently implemented in Data.ByteString: > > -- | split on characters > split:: Char -> String -> [String] > > -- | split on predicate * > splitBy :: (Char -> Bool) -> String -> [String] > > and > -- | split on a string > tokens :: String -> String -> [String] OED on "token": 3b [Computing] The smallest meaningful unit of information in sequence of data for a compiler. I think that's more or less what it means to me, too. It may be possible to come up with a name that is more likely to suggest what it does and less likely to collide with identifiers used elsewhere. Maybe "splits", but anyway ideally including "split". Of course technically we seem to be talking about lists, but this last one is surely mostly about strings. > Question over whether it should be: > splitBy (=='a') "aabbaca" == ["","","bb","c",""] > or > splitBy (=='a') "aabbaca" == ["bb","c"] > > I argue the second form is what people usually want. People will want both. The second form can be computed from the first, because it discards information about the input string, but for the same reason of course the first can't be derived from the second. (I'm not the first to say that, but since mail to this list has been arriving out of order, here it is again.) The convention I know, possibly coming from the world of UNIX shell tools, the default white space split is type 2, but split on any other string is type 1. UNIX shell does that, awk, Python ... (Perl is awk gone horribly wrong, so it presumably does but if it doesn't, it's the exception that proves the rule.) It has worked for a lot of people who do a lot of splitting, for a lot of years. Donn Cave, [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Re[2]: [Haskell-cafe] Using of C constants in Haskell sources; Determining compilation environment (Unix vs Windows)
At Wed, 12 Jul 2006 16:08:02 +0400, Bulat Ziganshin wrote: > I believe that it the simplest way for programmer. But is that the > best way for users? i want to make building/installation as simple as > possible using Cabal infrastructure. is it possible that some box will > have Cabal, but not hsc2hs installed? I would *guess* that hsc2hs is always distributed with ghc. I know it is on Linux and BSD -- I am not sure about Windows. If you build ghc from source, I believe it is automatically built and installed. If you want to support hugs as well, then they would need hschs-hugs installed. Debian includes that with hugs by default -- not sure about anyone else. j. ps. Also, if it matters, cpphs is typically *not* available by default (but cpp probably is). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Re[2]: [Haskell-cafe] instance Binary Data
Hello Bulat, In the preliminary version of our paper about comparing different approaches to generic programming in Haskell, you can find a number of implementations of serialization of values of arbitrary datatypes to lists of bits. Implementations in Generic Haskell, DrIFT, SYB, and other approaches to generic programming. I'm not sure if this is what you are looking for, but it is at least related. See the paper Comparing approaches to generic programming in Haskell available via http://www.cs.uu.nl/~johanj/publications/publications.html Kind regards, Johan Jeuring On 12-jul-2006, at 8:15, Bulat Ziganshin wrote: Hello Joel, Tuesday, July 11, 2006, 1:44:31 PM, you wrote: thank you. i don't even thought how that can be done. i guess that Data values contains two parts - describing type (Constr?) and value itself. Serializing value is even easier than (already implemented) gshow/gread, and if it can use Binary instance instead of general algorithm whenever possible, it would be ideal Constr (or some type representation) is just value of some type, after all. So, for it's serialization we can use either gshow/gread, or general binary serialization algorithm, or make custom Binary instance that is the general thoughts, i hope that someone knowing better this infrastructure will explain this dark area to me I don't see how this can work for arbitrary types without auto- generating the serialization code. Once the code is generated you can just store the type dictionary at the beginning of the file and use it to deserialize. I'm not sure this can be done on top of Binary since the type tag will determine the Binary instance to use. On Jul 11, 2006, at 7:38 AM, Bulat Ziganshin wrote: Hello Haskell, one Streams library user asked me about support of serialization TOGETHER with type information which means implementation of "instance Binary Data" (any other variants?). can anyone describe me how i can implement this? Binary instance is very like Show/Read, just uses compact binary encoding of values -- http://wagerlabs.com/ -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ 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
[Haskell-cafe] Hackathon hesitation
Hi, I'm interested in attending the Hackathon, but I don't have any previous experience working on compilers. I think it could be a great learning experience, but I certainly don't want to slow progress on any work by just hanging around asking questions. I'm a mathematician/statistician, and my programming experience is limited to high-level languages like Python, R, and Haskell. I can read C (sort of), but I've been too frustrated by the lack of high-level features to do anything useful with it. I've been using Haskell for about 2 years now (every chance I get), and I'm very interested in using it to allow high-performance (preferably parallel) code to be written at a very high level of abstraction. Given this, does it seem there would be much I could help with? Thanks, Chad Scherrer"Time flies like an arrow; fruit flies like a banana" -- Groucho Marx ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Arrows and 'do' syntax
On 7/12/06, Anatoly Zaretsky <[EMAIL PROTECTED]> wrote:> readWriteDoc path = proc input -> do > doc <- readDocument [(a_validate, "0")] path -< inputThat was it. Thanks!-Greg ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Haskore dependency trouble
Hello Simon, Wednesday, July 12, 2006, 6:28:55 PM, you wrote: >> like to be able to say the following: "Cabal, find and use package X >> if it exists. Furthermore, when CPPing source code, set a #define >> HAS_PACKAGE_X so I can do conditional compilation based on the (non-) > I have some changes to Cabal partly finished that will address this. Don't > worry, it's coming. thanks, i will be glad to see it. but it will be GHC66-only? -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Haskell-Cafe Digest, Vol 35, Issue 26
On 7/12/06, henning thielemann wrote: There must be an algorithm for finding the minimal spanning tree or forest. The edges that do not belong to the tree should be the labelled as cycle-breakers. Actually, I don't think that would do it, since you could have an acyclic directed graph like this: a -> b | | \/ \/ c -> d There are no cycles here, but the minimal spanning tree is not the whole thing. -- Chad Scherrer "Time flies like an arrow; fruit flies like a banana" -- Groucho Marx ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Small syntax question
On 12/07/06, Maurício <[EMAIL PROTECTED]> wrote: That's very good for us begginers. It would be great if this could be in the main Haskell site. Add away! The entire site is a wiki. -- -David House, [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Haskore dependency trouble
Bulat Ziganshin wrote: such feature was already requested by Robert Dockins <[EMAIL PROTECTED]> in libraries list at June 8. He wrote: "This brings up a feature I have sometimes wanted from Cabal. I'd like to be able to say the following: "Cabal, find and use package X if it exists. Furthermore, when CPPing source code, set a #define HAS_PACKAGE_X so I can do conditional compilation based on the (non-) avaliablility of package X". Is this possible? Difficult? It seems like a nice way to handle a number of problems, including platform- dependencies (as here) and optional features with external dependencies." you can add your voice to the peoples requesting this feature (i need it, too) I have some changes to Cabal partly finished that will address this. Don't worry, it's coming. Cheers, Simon ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Small syntax question
That's very good for us begginers. It would be great if this could be in the main Haskell site. Doaitse Swierstra wrote: Jeroen Fokker has made Haskell syntax diagrams, which are part of lecture notes for first-year students. Maybe they are helpful to others too, Doaitse http://abaris.zoo.cs.uu.nl:8080/wiki/pub/FP/CourseLiterature/haskellsyntax-main.pdf On Jul 11, 2006, at 4:30 PM, Thiago Arrais wrote: By the way, you can find the syntax specification here http://haskell.org/onlinereport/syntax-iso.html Regards, Thiago Arrais --Mergulhando no Caos - http://thiagoarrais.blogspot.com Pensamentos, idéias e devaneios sobre desenvolvimento de software e tecnologia em geral ___ 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[2]: [Haskell-cafe] Using of C constants in Haskell sources; Determining compilation environment (Unix vs Windows)
Hello Jeremy, Tuesday, July 11, 2006, 10:47:09 PM, you wrote: >> what is a best way to bring C constant (defined in header file) into >> the Haskell source? > If this ^^^ was your entire question, I would say, use hsc2hs. > http://haskell.org/ghc/docs/latest/html/users_guide/hsc2hs.html > Maybe that is still a valid answer for your entire question? I believe that it the simplest way for programmer. But is that the best way for users? i want to make building/installation as simple as possible using Cabal infrastructure. is it possible that some box will have Cabal, but not hsc2hs installed? -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re[2]: [Haskell-cafe] Haskore dependency trouble
Hello Henning, Wednesday, July 12, 2006, 1:23:53 PM, you wrote: > I would like to tell Cabal which modules are required and which are > supported, or recommended, but not needed. I could split Haskore into > several packages, but then again, installation of Haskore and its > sub-packages becomes uncomfortable and the Haddock documentation has no > longer a common table of contents. I tried to write custom Setup code for > finding out which parts of Haskore cannot be installed due to unsatisfied > dependencies, but this is more complicated than I hoped. such feature was already requested by Robert Dockins <[EMAIL PROTECTED]> in libraries list at June 8. He wrote: "This brings up a feature I have sometimes wanted from Cabal. I'd like to be able to say the following: "Cabal, find and use package X if it exists. Furthermore, when CPPing source code, set a #define HAS_PACKAGE_X so I can do conditional compilation based on the (non-) avaliablility of package X". Is this possible? Difficult? It seems like a nice way to handle a number of problems, including platform- dependencies (as here) and optional features with external dependencies." you can add your voice to the peoples requesting this feature (i need it, too) -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskore dependency trouble
On Wed, 12 Jul 2006, Yitzchak Gale wrote: > > > > Setup.lhs: cannot satisfy dependency Hsc-any > > > > This belongs to a SuperCollider wrapper: > > > http://www.slavepianos.org/rd/f/409875/ > > > Thanks! I'll just install the Debian package. > > I installed the supercollider Debian package, > got hsc using darcs and installed it using Cabal. > All seemed to work OK. > > Now the build command for Haskore fails with: > > Could not find module `Hsc.UGen'... > (imported from src/Haskore/Interface/SuperCollider/Example.hs) > > That sounds like you did not say "-package Hsc". If you install Hsc with Cabal, then it is registered and if you compile Haskore with Cabal, Cabal should provide the -package option. If you use the Makefile, this may contain my custom paths, because there is no configure step. I know, it's all still very experimental. > I installed the supercollider-dev Debian package and > re-installed Hsc (unregister, clean, configure, build, install). > It did not help. > > What now? Should I give up and hack all of the Hsc stuff > out of Haskore.cabal? The SuperCollider wrapper is as experimental as the revised Haskore package, so I cannot guarantee that some versions of them work together. I advise commenting out the SuperCollider modules for now. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re[2]: [Haskell-cafe] Re: Why is there no splitBy in the list module?
Hello Donald, Wednesday, July 12, 2006, 12:55:50 PM, you wrote: > Question over whether it should be: > splitBy (=='a') "aabbaca" == ["","","bb","c",""] > or > splitBy (=='a') "aabbaca" == ["bb","c"] > I argue the second form is what people usually want. 1) at least for 'lines' people prefer first 2) second can be easily got from the first -- Best regards, Bulatmailto:[EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Arrows and 'do' syntax
On 7/12/06, Greg Fitzgerald <[EMAIL PROTECTED]> wrote: I'm trying to translate this HXT code to use the Arrow 'do' syntax: readWriteDoc :: String -> IOSLA (XIOState s) b Int readWriteDoc path = readDocument [(a_validate, "0")] path >>> writeDocument [(a_output_encoding, isoLatin1)] "-" >>> getErrStatus This attempt fails to compile: readWriteDoc :: String -> IOSLA (XIOState s) b Int readWriteDoc = proc path -> do doc <- readDocument [(a_validate, "0")] -< path result<- writeDocument [(a_output_encoding, isoLatin1)] "-" -< doc getErrStatus -< result Hi, Greg. Looks like readWriteDoc is not an arrow but a function from strings to arrows. So 'path' is just an argument, not arrow input. Maybe this should work: readWriteDoc :: String -> IOSLA (XIOState s) b Int readWriteDoc path = proc input -> do doc <- readDocument [(a_validate, "0")] path -< input result<- writeDocument [(a_output_encoding, isoLatin1)] "-" -< doc getErrStatus -< result -- Tolik ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskore dependency trouble
Setup.lhs: cannot satisfy dependency Hsc-any This belongs to a SuperCollider wrapper: http://www.slavepianos.org/rd/f/409875/ Thanks! I'll just install the Debian package. I installed the supercollider Debian package, got hsc using darcs and installed it using Cabal. All seemed to work OK. Now the build command for Haskore fails with: Could not find module `Hsc.UGen'... (imported from src/Haskore/Interface/SuperCollider/Example.hs) That sounds like you did not say "-package Hsc". Besides that, just for the fun of it I tried "ghci -package HSc". The result was: Loading package Hsc-0.1 ... linking ... ghc-6.4.1: /usr/lib/Hsc-0.1/ghc-6.4.1/HSHsc-0.1.o: unknown symbol `__stginit_HscziSndFile_' ghc-6.4.1: unable to load package `Hsc-0.1' I installed the supercollider-dev Debian package and re-installed Hsc (unregister, clean, configure, build, install). It did not help. What now? Should I give up and hack all of the Hsc stuff out of Haskore.cabal? Thanks for your help, Yitz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?
Donald Bruce Stewart schrieb: > No parsers! I agree, > I vote for this, currently implemented in Data.ByteString: from which package comes Data.ByteString? > -- | split on characters > split:: Char -> String -> [String] the type for lists should then be: split :: Eq a => a -- ^ seperator -> [a] -- ^ list to split -> [[a]] (as I proposed earlier as "splitOn") > -- | split on predicate * > splitBy :: (Char -> Bool) -> String -> [String] According to Data.PackedString (with splitPS and splitWithPS) the name should be "splitWith" for consistency (or splitWithPS should be renamed as well). > -- | split on a string > tokens :: String -> String -> [String] I don't think, that we need this function for lists. > > Question over whether it should be: > splitBy (=='a') "aabbaca" == ["","","bb","c",""] > or > splitBy (=='a') "aabbaca" == ["bb","c"] > > I argue the second form is what people usually want. Yes, the second form is needed for "words", but the first form is needed for "lines", where one final empty element needs to be removed from your version! Prelude> lines "a\nb\n" ["a","b"] Prelude> lines "a\n\nb\n\n" ["a","","b",""] One more question is whether it should be: splitBy (=='a') "aabbaca" == ["","","bb","c",""] or splitBy (=='a') "aabbaca" == ["","","bb","c"] This second form corresponds to splitPS but the first more general form may be desirable as well. Christian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskore dependency trouble
Henning Thielemann (lemming) wrote: ...Yitz Gale wrote: I am having trouble installing Haskore due to a dependency issue... Cabal... The configure command fails with the following error: Setup.lhs: cannot satisfy dependency Hsc-any This belongs to a SuperCollider wrapper: http://www.slavepianos.org/rd/f/409875/ Thanks! I'll just install the Debian package. It is much easier than mucking around with the Cabal file. I'll decide later whether I actually want to use it. There is no way I would have figured that out without your help, even with Google. Maybe it is time to bring the README file a little more up-to-date. Thanks again, Yitz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Problems installing HDBC-postgresql
Hi, sorry for the delay in replying. You were right -- it was not finding the correct version of the library. In fact, all I had to do was change the order in my LD_LIBRARY_PATH -- but thanks for the suggestion on strace -- I will certainly be using this tool for future problems. Many thanks Martin John Goerzen wrote: On 2006-07-10, Martin Percossi <[EMAIL PROTECTED]> wrote: Hi, I'm having problems using HDBC-postgresql (I've tried both 0.99.2.1 and 1.0.0.0) with postgresql (version 8.1.4, installed in /share/pgsql). I adjust the include-dir and extra-lib-dirs to use the custom location of postgresql, and build: no error messages, everything seems fine. Probably, though, there is something that is not quite fine... However, when I then try to type: ghci -package HDBC -package HDBC-postgresql , I get the error message: Loading package HDBC-postgresql-0.99.2.1 ... linking ... ghc-6.4.2: /home/mpercossi/opt/lib/HDBC-postgresql-0.99.2.1/HSHDBC-postgresql-0.99.2.1.o: unknown symbol `PQserverVersion' ghc-6.4.2: unable to load package `HDBC-postgresql-0.99.2.1' This sounds like it's not finding your PostgreSQL libraries. First, can you confirm that PQserverVersion still occurs in your libpq-fe.h? Next, try strace on your ghci session. Grep for libpq in the output. It may be instructive. In my case, I saw: stat64("/usr/lib/haskell-packages/ghc6/lib/HDBC-postgresql-0.99.2.1/libpq_dyn.so", 0xb763a1e0) = -1 ENOENT (No such file or directory) stat64("/usr/lib/haskell-packages/ghc6/lib/HDBC-postgresql-0.99.2.1/libpq.so", 0xb763a570) = -1 ENOENT (No such file or directory) open("/usr/lib/libpq.so", O_RDONLY) = 3 So we know that the system did successfully open that library. Has anyone seen this error message before? Google didn't turn up anything relevant to haskell -- however there does seem to be a PQserverVersion procedure in the libpq library -- maybe HDBC-postgresql is not seeing this due to the custom install location? This would all be up to your modifications to cabal. Try: ghc-pkg describe HDBC-postgresql You should see: * pq in the extra-libraries line * Your header file location in the include-dirs line * Your extra-lib-dirs path If you don't see those things, then something went wrong with the build or install. I would also suggesting building a program with GHC (not GHCI) that uses HDBC-postgresql for testing. -- John ___ 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] Haskore dependency trouble
On Wed, 12 Jul 2006, Yitzchak Gale wrote: > In order to learn how to do that, I practiced by > installing the ever-important HNOP package. > After a few tries, I found that the following > sequence of commands works: > > ./Setup.hs configure --prefix=/usr > ./Setup.hs build > sudo ./Setup.hs install > > But similar commands for Haskore do > not fair as well. The configure command fails > with the following error: > > Setup.lhs: cannot satisfy dependency Hsc-any This belongs to a SuperCollider wrapper: http://www.slavepianos.org/rd/f/409875/ You don't need to install that wrapper, if you do not want to use SuperCollider. In this case remove the Hsc dependency and the SuperCollider modules from Haskore.cabal. I would like to tell Cabal which modules are required and which are supported, or recommended, but not needed. I could split Haskore into several packages, but then again, installation of Haskore and its sub-packages becomes uncomfortable and the Haddock documentation has no longer a common table of contents. I tried to write custom Setup code for finding out which parts of Haskore cannot be installed due to unsatisfied dependencies, but this is more complicated than I hoped. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Re: Why is there no splitBy in the list module?
> From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Donald > Bruce Stewart > > I vote for this, currently implemented in Data.ByteString: > > -- | split on characters > split:: Char -> String -> [String] > > -- | split on predicate * > splitBy :: (Char -> Bool) -> String -> [String] > > and > -- | split on a string > tokens :: String -> String -> [String] > > Question over whether it should be: > splitBy (=='a') "aabbaca" == ["","","bb","c",""] > or > splitBy (=='a') "aabbaca" == ["bb","c"] > > I argue the second form is what people usually want. Based on...? Does tokens preserve empty fields, like the proposed first form of splitBy? There is a fairly strong case for the first form when looking at CSV file parsers e.g. splitBy (== ',') "a,b,,d" == ["a", "b", "", "d"] In this case you want to correctly notice that a given field is empty. As Christian Maeder notes, it's pretty easy to filter them out afterwards, if that's what you want. OTOH, if tokens does this, then I'm not concerned that splitBy doesn't. Alistair * Confidentiality Note: The information contained in this message, and any attachments, may contain confidential and/or privileged material. It is intended solely for the person(s) or entity to which it is addressed. Any review, retransmission, dissemination, or taking of any action in reliance upon this information by persons or entities other than the intended recipient(s) is prohibited. If you received this in error, please contact the sender and delete the material from any computer. * ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Breaking cycles in a directed graph.
On Wed, 12 Jul 2006, Daniel McAllansmith wrote: > Hello. > > I'm currently using Data.Graph.Inductive to represent a directed graph. > > I want to detect all cycles within the graph and 'break' them by inserting a > minimal number of nodes that are labelled with a special cycle-breaker label. > > Can anyone give me advice on a good algorithm for finding the cycles and > finding the optimum edges to insert the cycle-breaking nodes on? There must be an algorithm for finding the minimal spanning tree or forest. The edges that do not belong to the tree should be the labelled as cycle-breakers. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Why is there no splitBy in the list module?
simonmarhaskell: > >I guess the problem with the splitWith thing is that it's a slippery > >path that leads right up to full-on parsers. > > Exactly, and this is why we didn't reach a concensus last time. > > Would someone like to make a concrete proposal (with code!) for 2-3 > functions we could reasonably add to Data.List? No parsers! I vote for this, currently implemented in Data.ByteString: -- | split on characters split:: Char -> String -> [String] -- | split on predicate * splitBy :: (Char -> Bool) -> String -> [String] and -- | split on a string tokens :: String -> String -> [String] Question over whether it should be: splitBy (=='a') "aabbaca" == ["","","bb","c",""] or splitBy (=='a') "aabbaca" == ["bb","c"] I argue the second form is what people usually want. -- Don ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Small syntax question
Jeroen Fokker has made Haskell syntax diagrams, which are part of lecture notes for first-year students. Maybe they are helpful to others too, Doaitse http://abaris.zoo.cs.uu.nl:8080/wiki/pub/FP/CourseLiterature/ haskellsyntax-main.pdf On Jul 11, 2006, at 4:30 PM, Thiago Arrais wrote: By the way, you can find the syntax specification here http://haskell.org/onlinereport/syntax-iso.html Regards, Thiago Arrais -- Mergulhando no Caos - http://thiagoarrais.blogspot.com Pensamentos, idéias e devaneios sobre desenvolvimento de software e tecnologia em geral ___ 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
[Haskell-cafe] Re: Why is there no splitBy in the list module?
Evan Laforge wrote: >> splitBy :: (a -> Bool) -- ^ whether element is a seperator >> -> [a] -- ^ list to split >> -> [[a]] P.S. inspecting more than one element looks like an over-generalization to me and should be left to parsers or regexp libs. It's more generally useful if you don't drop the separators from the output: splitSepWith f = map (dropWhile f) . splitWith f spaces = splitSepWith Char.isSpace But this still won't let you split on comma and spaces. Either regexes, or pass in a [tok] -> ([conumed], [rest]) type parser: splitWith :: ([a] -> ([a], [a])) -> [a] -> [[a]] ... but why not make it take parsec parsers and put it in a parsec util module or something (if it isn't already there!): splitWith (Parsec.char ',' >> Parsec.spaces) ... of course, then you might ask why not use Parsec.sepBy :) but maybe the "split on elt" concept is easier to learn than "write a whole parser". I guess the problem with the splitWith thing is that it's a slippery path that leads right up to full-on parsers. Exactly, and this is why we didn't reach a concensus last time. Would someone like to make a concrete proposal (with code!) for 2-3 functions we could reasonably add to Data.List? Cheers, Simon ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskore dependency trouble
I am having trouble installing Haskore due to a dependency issue. I am a pampered user of Debian. Thanks to wonderful work by the Cabal people and the Debian package maintainers, I have never had to use Cabal manually to install a package before. In order to learn how to do that, I practiced by installing the ever-important HNOP package. After a few tries, I found that the following sequence of commands works: ./Setup.hs configure --prefix=/usr ./Setup.hs build sudo ./Setup.hs install But similar commands for Haskore do not fair as well. The configure command fails with the following error: Setup.lhs: cannot satisfy dependency Hsc-any How can I satisfy that dependency? I am using ghc on Debian testing. I obtained Haskore from http://cvs.haskell.org/darcs/haskore Thanks! Incidentally, why is Cabal not smart enough to know that with ghc on linux the default prefix is /usr? -Yitz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Breaking cycles in a directed graph.
Hi Daniel, > I want to detect all cycles within the graph and 'break' them by inserting a > minimal number of nodes that are labelled with a special cycle-breaker label. > > Can anyone give me advice on a good algorithm for finding the cycles and > finding the optimum edges to insert the cycle-breaking nodes on? I've had a similar problem as I needed to find all (even-length) cycles in an undirected graph. To the best of my knowledge the algorithm, described in R.C. Read, R.E. Tarjan. Bounds on Backtrack Algorithms for Listing Cycles, Paths and Spanning Trees. Networks 5: 237-252, 1975, has the (currently) best known running time of O(V+E+EN), N being the number of cycles found. As the algorithm is not that easy to understand (at least for me), you should perhaps have a look at section 8.3, "Cycles", of Edward M. Reingold, Jurg Nievergelt, Narsing Deo. Combinatorial Algorithms: Theory and Practice. Prentice-Hall, Englewood Cliffs, 1977. The algorithm described there is easier to understand and implement. You can also find a survey in Prabhaker Mateti, Narsing Deo. On Algorithms for Enumerating All Circuits of a Graph. SIAM Journal on Computing, 5(1): 90-99, 1976. -- Hope this helps, Jens ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe