[Haskell-cafe] how do i resolve these screwy cabal errors
package derive-2.3.0.2-ad85bd58710fede3f840a467e84c403e is unusable due to missing or recursive dependencies: haskell-src-exts-1.9.4-e0f8c55bea9fc97376aa3598dfdca6d6 package derive-2.4.1-415d44d2f93198aab5dff67866c17b64 is unusable due to missing or recursive dependencies: haskell-src-exts-1.9.4-e0f8c55bea9fc97376aa3598dfdca6d6 what does that mean? i reinstalled haskell-src-exts and derive, doesn't seem to make any difference Linking dist/build/derive/derive ... Installing library in /home/anatolyy/.cabal/lib/derive-2.4.1/ghc-6.12.3 Installing executable(s) in /home/anatolyy/.cabal/bin Registering derive-2.4.1... /home/anatolyy/.cabal/lib/haskell-src-exts-1.9.4/ghc-6.12.3 Registering haskell-src-exts-1.9.4... so i cant import Data.DeriveTH ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] RegEx versus (Parsec, TagSoup, others...)
On Fri, Nov 12, 2010 at 03:56:26PM -0800, Michael Litchard wrote: I've been working on a project that requires me to do screen scraping. When I first started this, I worked off of other people's examples. Not one used regex. By luck I found someone at work to help me along this project. His clues and hints don't use regex either. I was at a point where I had to make a decision concerning design, so I asked the guy sitting next to me at work. He's very experienced, and comes from a Perl perspective. I let him into what I was doing, and he opined I should be using pcre. So now I'm second guessing my choices. Why do people choose not to use regex for uri parsing? Never believe anything anyone coming from a Perl perspective says about regular expressions. -Brent ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Curious data family bug
Hey all, While trying to get a commit pushed for Yesod[1], Alexander Dunlap pointed out one of his programs didn't work with the new code. After some investigation, I was able to reproduce the bug with the following code snippet: {-# LANGUAGE TypeFamilies #-} data family Foo a data Bar = Bar data instance Foo Bar = Bar1 | Bar2 | Bar3 | Bar4 | Bar5 | Bar6 | Bar7 | Bar8 | Bar9 deriving Eq This produces: Couldn't match expected type `Main.R:FooBar' against inferred type `Foo Bar' NB: `Foo' is a type function In the first argument of `Main.$con2tag_R:FooBar', namely `a' In the expression: (Main.$con2tag_R:FooBar a) In the expression: case (Main.$con2tag_R:FooBar a) of { a# - case (Main.$con2tag_R:FooBar b) of { b# - (a# GHC.Prim.==# b#) } } The especially strange thing about this bug is that it only occurs when there are more than 8 constructors; if I remove Bar9, everything seems to work. Does anyone have experience with this occuring? Michael [1] http://docs.yesodweb.com/blog/please-break-yesod/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Type Directed Name Resolution
On 13/11/2010, at 9:33 AM, Malcolm Wallace wrote: On 12 Nov 2010, at 20:21, Andrew Coppin wrote: On 11/11/2010 08:43 PM, Richard O'Keefe wrote: If length, map, and so on had always been part of a Sequence typeclass, people would not now be talking about It's always puzzled me that Haskell's standard containers almost completely lack any way to use them polymorphically. On the contrary, there is the Edison package of containers and algorithms from which the typeclass name Sequence was drawn... I have a copy of Okasaki's book. There is definitely room for a middle ground in documentation between that book and the Haddock pages for the Edison library. Something that provides an overview of what is there and why you'd use it, with examples. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Type Directed Name Resolution
Yves Parès schrieb: I think this idea is a stairway to duck typing. I exagerate, of course, but here is my point: It shouldn't be difficult to make a class: class HasName a where name :: a - String or class Name a where name :: Accessor a String That gives you read and write access to a record. I think type class based solutions should be implemented in packages and tested in applications first, before adding another extension (exclusively) to GHC. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Concurrent with monads
Hi cafe, I wounder if it is possible to tell a haskell system that two computations with side effects could be executed concurrently. Here is an affected example: Suppose two people want to compare their age, but do not want to leak their personal information. The following program reads one person's age after another then send back compared result. age :: IO () age = do i - readIntFrom a j - readIntFrom b writeTo a (i-j) writeTo b (j-i) How can I express the fact that two readings could be carried out in any order? Best Regards Jiansen ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: how do i resolve these screwy cabal errors
i reinstalled cabal and reinstalled derive package and that fixed it. On Sun, Nov 14, 2010 at 1:40 AM, Anatoly Yakovenko aeyakove...@gmail.com wrote: package derive-2.3.0.2-ad85bd58710fede3f840a467e84c403e is unusable due to missing or recursive dependencies: haskell-src-exts-1.9.4-e0f8c55bea9fc97376aa3598dfdca6d6 package derive-2.4.1-415d44d2f93198aab5dff67866c17b64 is unusable due to missing or recursive dependencies: haskell-src-exts-1.9.4-e0f8c55bea9fc97376aa3598dfdca6d6 what does that mean? i reinstalled haskell-src-exts and derive, doesn't seem to make any difference Linking dist/build/derive/derive ... Installing library in /home/anatolyy/.cabal/lib/derive-2.4.1/ghc-6.12.3 Installing executable(s) in /home/anatolyy/.cabal/bin Registering derive-2.4.1... /home/anatolyy/.cabal/lib/haskell-src-exts-1.9.4/ghc-6.12.3 Registering haskell-src-exts-1.9.4... so i cant import Data.DeriveTH ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Curious data family bug
Hmm, strange. I have a project that uses data families with dozens of constructors per clause/instantiation of the type function. I use GADT syntax to define them though as they also refine one of the parameter type variables. Never had any issues with it, although I haven't tried building that project on GHC 7 yet (as some of its dependencies didn't work last time I tried), so maybe it's a new issue? On Sun, Nov 14, 2010 at 2:15 PM, Michael Snoyman mich...@snoyman.comwrote: Hey all, While trying to get a commit pushed for Yesod[1], Alexander Dunlap pointed out one of his programs didn't work with the new code. After some investigation, I was able to reproduce the bug with the following code snippet: {-# LANGUAGE TypeFamilies #-} data family Foo a data Bar = Bar data instance Foo Bar = Bar1 | Bar2 | Bar3 | Bar4 | Bar5 | Bar6 | Bar7 | Bar8 | Bar9 deriving Eq This produces: Couldn't match expected type `Main.R:FooBar' against inferred type `Foo Bar' NB: `Foo' is a type function In the first argument of `Main.$con2tag_R:FooBar', namely `a' In the expression: (Main.$con2tag_R:FooBar a) In the expression: case (Main.$con2tag_R:FooBar a) of { a# - case (Main.$con2tag_R:FooBar b) of { b# - (a# GHC.Prim.==# b#) } } The especially strange thing about this bug is that it only occurs when there are more than 8 constructors; if I remove Bar9, everything seems to work. Does anyone have experience with this occuring? Michael [1] http://docs.yesodweb.com/blog/please-break-yesod/ ___ 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] Type Directed Name Resolution
On 12/11/2010, at 6:06 PM, Sebastian Fischer wrote: As others have pointed out, type classes are insufficient for overloading record labels because they do not cover record updates. How can we add a special kind of overloading for record labels that also works for updates? Maybe like this: rename :: ((name :: String) @ a) = a - a rename newName someRecord = someRecord { name = newName } Why is nobody talking about records in Clean? Clean is a Haskell-like language, indeed, the latest feature in Clean is an additional front-end so it can compile Haskell directly. Adapting section 5.2 from the Clean 2.1 language specification: A record type is ... an algebraic data type [with] exactly one constructor. ... a field name is attached to each of [its] arguments. Records cannot be used in a curried way. ... selection [is] by field name. When a record is created all arguments of the constructor have to be [provided] but ... in any order. ... When pattern matching ... on a record, one [need only] mention those fields one is interested in. A record can be created via a functional update [where] one [need only] specify the values for this fields that differ from the old record. RecordTypeDef = '::' TypeLhs '=' [UniversalQuantVariables] '{' (FieldName '::' [Strict] Type)-list '}' ... The semantic restrictions [of] algebraic data types also hold for record types. The field names inside one record all have to be different. It is allowed to use the same field name in different records. Record = RecordDenotation | RecordUpdate RecordDenotation = '{' [TypeName '|'] (FieldName '=' Expr)-list '}' A record can only be used if its type has been defined ... the field names must be identical to the field names ... in the corresponding type. ... The order in which the record fields are instantiated is irrelevant, but all fields have to get a value [of the right type]. ... When creating a record, its type [name] can be used to disambiguate [the type]; the type constructor can be left out if there is at least one field name [that is peculiar to the type]. There's a little gotcha there: ::T1 = {x :: Int, y :: Int} ::T2 = {y :: Int, z :: Int} ::T3 = {z :: Int, x :: Int} {x = 1, y = 2} neither x by itself nor y by itself uniquely determines a record type, so Clean 2.1 wanted {T1 | x = 1, y = 2} here. I don't happen to have a copy of the current manual handy, so I don't know if they've fixed this yet. RecordUpdate = '{' [TypeName '|'] [RecordExpr ''] [(FieldName Selection... '=' Expr)-list] '}' Selection = '.' FieldName | '.' '[' Expr-list ']' The record written to the left of the '' ... is the record to be updated. On the right [of] the '' are specified the structures in which the new record differs from the old one. A structure an be any field of the record or a selection of any field or array elements of a record or array stored in this record. Notice that the functional update is not an update in the classical, destructive, sense since a new record is created. The functional update of records is performed very efficient[ly] [so] that we have not added support for destructive updates of records of unique type. The '' operator is strict in its arguments. RecordSelection = RecordExpr ['.'TypeName] '.'FieldName Selection... | RecordExpr ['.'TypeName] '!'FieldName Selection... The ! alternative has to do with Clean's uniqueness typing. An object of [a record] type ... can be specified as [a] pattern. Only those fields [whose] contents one would like to use [on] the right hand side need to be mentioned in the pattern. RecordPattern = '{' [TypeName '|'] (FieldName ['=' Pattern])-list '}' The type of the record must have been defined ... . The field names in the pattern must be identical to the field names [in that definition]. ... The [TypeName] can only be left out if there is at least one field name [which is not defined in any other record type]. See the T1, T2, T3 example above; I repeat that I haven't checked the latest manual and don't know if the obvious fix has been made yet. By the way, Clean can freely use '.' for selection because it uses 'o' for function composition. I remind readers once again that the latest Clean release compiles Haskell as well as Clean, so there is a sense in which records like this *are* available to some Haskell programmers. Do they meet the needs that people have been expressing here? There's no subtyping, but then, I have reasons for not using CAML. The only reason I don't use
Re: [Haskell-cafe] Compiler constraints in cabal
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 11/6/10 23:09 , wren ng thornton wrote: On 11/6/10 6:20 AM, Reiner Pope wrote: I was aware of this condition, but I'm not precisely sure it addresses my requirements. When you run cabal install some-package, cabal reads all version constraints listed in the build-depends field, and chooses which versions of which packages to download from Hackage in order to satisfy these constraints. I want to expose my dependency on a particular version of ghc to cabal's constraint satisfier. The end result I want is that when you type cabal install hmatrix-static with ghc-6.12 installed, then cabal chooses hmatrix-static-0.3; and when you type cabal install hmatrix-static with ghc-7.0 installed, then cabal chooses hmatrix-static-0.4. Clients of hmatrix-static would have to say if impl(ghc = 7.0) Build-Depends: hmatrix-static == 0.4.* else Build-Depends: hmatrix-static == 0.3.* in order to pull in the right dependency for themselves. In order to get the behavior you're after, though, is trickier business. Since every version of GHC ships with a different version of base, you'll have to make use of that knowledge such that users of ghc-7.0 with base-5 will get hmatrix-static-0.4 whereas users of ghc-6.12 with base-4 will get hmatrix-static-0.3 Don't you just rerelease 0.3.x (bump the sub-version) with a dependency on base 5, and release 0.4 with base = 5, and let Cabal work out the above Build-Depends for itself? - -- brandon s. allbery [linux,solaris,freebsd,perl] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.10 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkze5FUACgkQIn7hlCsL25XnkACZAULQcjlaAxsClFxhQRsHcuRX NBkAn2cbZ4FD1+Qtu1qsB7f9mXvPHjMt =Zt6h -END PGP SIGNATURE- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: ANNOUNCE zeno 0.1.0
Oops. It's right there on the site. My eyes skipped over it for some reason. On Sat, Nov 13, 2010 at 2:11 PM, Luke Palmer lrpal...@gmail.com wrote: Is the source code public, so I can run it on my own machine? Luke Hi all, My masters project Zeno was recently mentioned on this mailing list so I thought I'd announce that I've just finished a major update to it, bringing it slightly closer to being something useful. Zeno is a fully automated inductive theorem proving tool for Haskell programs. You can express a property such as takeWhile p xs ++ dropWhile p xs === xs and it will prove it to be true for all values of p :: a - Bool and xs :: [a], over all types a, using only the function definitions. Now that it's updated it can use polymorphic types/functions, and you express properties in Haskell itself (thanks to SPJ for the suggestion). It still can't use all of Haskell's syntax: you can't have internal functions (let/where can only assign values), and you can't use type-classed polymorphic variables in function definitions - you'll have to create a monomorphic instance of the function -but I hope to have these added reasonably soon. It's also still missing primitive-types/IO/imports so it still can't be used with any real-world Haskell code, it's more a bit of theorem proving fun. You can try it out at http://www.doc.ic.ac.uk/~ws506/tryzeno, the code file given there has some provable properties about a few prelude functions among other things. Another feature is that it lists all the sub-properties it has proven within each proof. When it verifies insertion-sort sorted (insertsort xs) === True it also proves the antisymmetry of = and that the insert function preserves the sorted property. Any suggestions or feedback would be greatly appreciated. Cheers, Will -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) iQEcBAEBAgAGBQJM3kzdAAoJEC5dcKNjBzhn6ZgH/24Yy1TBsCCtwmvItROvucms VNlaJ9lAEwbFtQT4X0HJtBX0MaMc/2QcPXhXsTTXm5CG+28N7ohrVDz9WIn3Zmri Tet1c+NFeZ5s4dK9Xjc450r1zlBYu6Uc8y/z9+RRbUTdDKpifGScwoxqFQPeWWYX fUY9zfM6RW4W7A/hTzFIZlRpa2l8/1d4ojBeRw8PnxpPftBk8KvXAVBxq1Nf21Pc pKmcfMFfhTCPAXsroLMXzP22A51XhIXrSREpvE+OgDSHsoaO+0D2/q8VMV+J1zPw PPYvmM/BOYAPcjy/Z34kNv2g6letXKOjH5ofHREr5arHpsrsmJxP+rcveZWQi1A= =58nx -END PGP SIGNATURE- ___ 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] Re: ANNOUNCE zeno 0.1.0
However: You can express a property such as takeWhile p xs ++ dropWhile p xs === xs and it will prove it to be true for all values of p :: a - Bool and xs :: [a], over all types a, using only the function definitions. That is surprising, given that this property does not seem to be true for p = const undefined and xs /= []. Tillmann This is a very interesting observation. When Zeno does induction/case-splitting it does not consider the value _|_ as a potential inhabitant of a type. This could be a feature I might add in a later version or some option for being able to turn this behaviour on/off but thanks for spotting it. Infinite values (lazy-evaluation in general) also give Zeno a problem, since you can no longer use structure as a well-defined ordering for induction. A property such as reverse (reverse xs) === xs does not work for infinite lists, since you can successfully case-analyse values from xs but case-analysing reverse (reverse xs) will give an infinite loop. You could say the values are equal in some sense (maybe given infinite computation time) but they do not behave in the same way. Cheers, Will ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] [ANN] shpider-0.1.1
Shpider is a web automation library for Haskell. It allows you to quickly write crawlers, and for simple cases ( like following links ) even without reading the page source. Shpider is on hackage at http://hackage.haskell.org/package/shpider Shpider development repository is now on github at https://github.com/elginer/shpider Shpider 0.1.1 now compiles on ghc-6.12, with the latest version of tagsoup-parsec. Thanks to Noriyuki OHKAWA for a patch! John Morrice ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] a problem about Regex in Real World Haskell
On 13 November 2010 21:46, Daniel Fischer daniel.is.fisc...@web.de wrote: On Saturday 13 November 2010 03:26:46, wolf python london wrote: hi ,folks , I'm a newbie of haskell and learn haskell using the textbook Real World Haskell. in the page 201, ghci good food =~ .ood :: [String] Should be good food =~ .ood :: [[String]] it works! I think. I don't know if it was an error when the book was written or the regex libs changed. I think so . as ghci pack good food =~ .ood ::[ByteString] doesn't work ,either, but ghcipack good food =~ .ood::[[ByteString]] [[good],[food]] works~~ my output is here https://gist.github.com/675024 it doesn't match what the textbook gives . And I found the ebook of Real World Haskell doesn't match it ,either(just like my output ) . I was wondering How I can fix this problem about Regex. much thanks ~ -- wolf python london(WPL) Do as you soul should do ! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] a problem about Regex in Real World Haskell
On Saturday 13 November 2010 03:26:46, wolf python london wrote: hi ,folks , I'm a newbie of haskell and learn haskell using the textbook Real World Haskell. in the page 201, ghci good food =~ .ood :: [String] Should be good food =~ .ood :: [[String]] I think. I don't know if it was an error when the book was written or the regex libs changed. my output is here https://gist.github.com/675024 it doesn't match what the textbook gives . And I found the ebook of Real World Haskell doesn't match it ,either(just like my output ) . I was wondering How I can fix this problem about Regex. much thanks ~ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] Curious data family bug
Hmm. It works with HEAD (and hence I believe with the 7.0.1 RC2). It looks similar to http://hackage.haskell.org/trac/ghc/ticket/4174, which is fixed. Anyway I've added it as a regression test, so it should never go wrong again. Thanks for mentioning it. Simon | -Original Message- | From: haskell-cafe-boun...@haskell.org [mailto:haskell-cafe-boun...@haskell.org] On | Behalf Of Michael Snoyman | Sent: 14 November 2010 19:16 | To: Haskell Cafe | Subject: [Haskell-cafe] Curious data family bug | | Hey all, | | While trying to get a commit pushed for Yesod[1], Alexander Dunlap | pointed out one of his programs didn't work with the new code. After | some investigation, I was able to reproduce the bug with the following | code snippet: | | {-# LANGUAGE TypeFamilies #-} | data family Foo a | data Bar = Bar | data instance Foo Bar | = Bar1 | Bar2 | Bar3 | Bar4 | Bar5 | Bar6 | Bar7 | Bar8 | Bar9 | deriving Eq | | This produces: | | Couldn't match expected type `Main.R:FooBar' |against inferred type `Foo Bar' | NB: `Foo' is a type function | In the first argument of `Main.$con2tag_R:FooBar', namely `a' | In the expression: (Main.$con2tag_R:FooBar a) | In the expression: | case (Main.$con2tag_R:FooBar a) of { | a# | - case (Main.$con2tag_R:FooBar b) of { | b# - (a# GHC.Prim.==# b#) } } | | The especially strange thing about this bug is that it only occurs | when there are more than 8 constructors; if I remove Bar9, everything | seems to work. Does anyone have experience with this occuring? | | Michael | | [1] http://docs.yesodweb.com/blog/please-break-yesod/ | ___ | 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] Encoding problem (?)
Hello, I have this strange problem, with the same program (simple) behaving differently when run from console and from WinGHCi. Platform is Windows XP. Haskell Platform 2.0.0. The program : import IO import Data.Maybe tfind s = lookup (head s) $ zip \232\222 12 main = do h - readFile g:\\CODE\\rlib\\test.txt putStrLn h print $ tfind h The file test.txt only contains a è (should be \232). Encoding is ANSI. I compile the pgm from WinGHCi : Prelude :! ghc --make ftest2.hs and run it from WinGHCi : Prelude :! ftest2.exe è Just '1' Now if I use the _same_ compiled program from cmd line : g:\CODE\rlibftest2.exe è Just '2' Is there any plausible explanation ? Bruno ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] HUnit Control.Exception assertFailure?
Hi, I'm trying to follow some examples of HUnit from a webpage. Basically I want my _application_ code to call the error function when a certain condition is met (namely when a supplied String to a function is longer than 80 characters). I want my _test_ code to catch this error. Unfortunately the example code that I'm following uses the older style of Exception handling. Does anyone know how to catch this exception using the newer Control.Exception module? Basically I want to 1. Call error msg when String length 80 for some function 2. Catch thrown error from step 1 and do absolutely nothing. (i.e. the expected failure was caught) 3. If the error is uncaught (in step 2; for whatever reason) then call assertFailure somemsg and my _test_ code should fail since the error it was expecting to occur didn't happen. Thanks, Mark Spezzano ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] date parsing and formatting
I've been working with Haskell's Date.Time modules to parse a date like 12-4-1999 or 1-31-1999. I tried: parseDay :: String - Day parseDay s = readTime defaultTimeLocale %m%d%Y s And I think it wants my months and days to have exactly two digits instead of 1 or 2... What's the proper way to do this? Also, I'd like to print out my Day in this format: 12/4/1999 what's the Haskell way to? Thanks for the help. Alex ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Ralf Laemmel's riddle on surviving without the monad transformation library
Hi, Can someone provide me the solution to the following riddle that Ralf asked in his lecture at http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter Riddle: define a custom made monad (only involving (-) and Either String) to survive without the monad transformation library. -- Regards, Kashyap ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Encoding problem (?)
Hello, I have this strange problem, with the same program (simple) behaving differently when run from console and from WinGHCi. Platform is Windows XP. Haskell Platform 2.0.0. The program : import IO import Data.Maybe tfind s = lookup (head s) $ zip \232\222 12 main = do h - readFile g:\\CODE\\rlib\\test.txt putStrLn h print $ tfind h The file test.txt only contains a è (should be \232). Encoding is ANSI. I compile the pgm from WinGHCi : Prelude :! ghc --make ftest2.hs and run it from WinGHCi : Prelude :! ftest2.exe è Just '1' Now if I use the _same_ compiled program from cmd line : g:\CODE\rlibftest2.exe è Just '2' Is there any plausible explanation ? Bruno ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: dynamic loading of code on windows
Hello again, So I followed Kevin's suggestion and installed MinGW along with gcc and autoconf tools needed by hs-plugins. Then it failed with the following error: $ cabal install --enable-documentation plugins Resolving dependencies... Configuring plugins-1.5.1.4... checking build system type... i686-pc-mingw32 checking for ghc... ghc checking for value of __GLASGOW_HASKELL__... 612 checking for ghc library directory... D:\Program Files\Haskell Platform\2010.2.0 .0\lib checking for gcc... gcc checking for C compiler default output file name... a.exe checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... .exe checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ANSI C... none needed checking for arc4random... no checking for a BSD-compatible install... /usr/bin/install -c configure: creating ./config.status config.status: creating config.mk config.status: creating testsuite/makewith/io/TestIO.conf config.status: creating testsuite/makewith/unsafeio/Unsafe.conf config.status: creating config.h Preprocessing library plugins-1.5.1.4... Building plugins-1.5.1.4... [ 1 of 12] Compiling System.Plugins.Process ( src\System\Plugins\Process.hs, dis t\build\System\Plugins\Process.o ) [ 2 of 12] Compiling System.Plugins.Parser ( src\System\Plugins\Parser.hs, dist\ build\System\Plugins\Parser.o ) [ 3 of 12] Compiling System.Plugins.LoadTypes ( src\System\Plugins\LoadTypes.hs, dist\build\System\Plugins\LoadTypes.o ) [ 4 of 12] Compiling System.Plugins.Consts ( src\System\Plugins\Consts.hs, dist\ build\System\Plugins\Consts.o ) src\System\Plugins\Consts.hs:39:22: lexical error in string/character literal at character 'P' cabal.exe: Error: some packages failed to install: plugins-1.5.1.4 failed during the building phase. The exception was: ExitFailure 1 Any clues? Should I try to use latest source tree? I am really interested in the plugins approach, rather than the interpreter approach. What I am trying to achieve is a system similar to Yi as presented in Don Stewart's paper (http://www.cse.unsw.edu.au/~dons/papers/yi.pdf), but much simpler, of course. The system would load modules as found in some known location, run tests found here before really accepting them, then use them, with the possibility of replacing those modules when a newer version is found. The idea is to provide a self-tested and continuously running system for development, something that might be reminiscent of Smalltalk although I never programmed in Smalltalk. Thanks in advance for advises, REgards, Arnaud On Fri, Nov 12, 2010 at 8:49 PM, Alberto G. Corona agocor...@gmail.com wrote: I use Hint for the same purpose. It has been tested under windows 2010/11/12 Arnaud Bailly arnaud.oq...@gmail.com Hello Kevin, Thanks. I understand that this is a toolchain issue, I just got used to the nice feeling of having 'cabal install foo' works seamlessly and flawlessly to get me some magic piece of software :-) I will try to be more patient and try to setup a proper toolchain for installing plugins package. Arnaud On Fri, Nov 12, 2010 at 7:01 PM, Kevin Jardine kevinjard...@gmail.com wrote: This isn't about the plugin functionality, it's about compiling code. As the message says : This requires a Unix compatibility toolchain such as MinGW+MSYS or Cygwin. You'll find that you need such a toolchain to compile much open source software, including many Haskell modules, on Windows. Personally I use MinGW+MSYS on my Windows machine. It works very well. Kevin On Nov 12, 3:20 pm, Arnaud Bailly arnaud.oq...@gmail.com wrote: Hello, I recently tried to cabal install plugins on a windows box and it failed with the following error: Resolving dependencies... Downloading plugins-1.5.1.4... Configuring plugins-1.5.1.4... cabal: The package has a './configure' script. This requires a Unix compatibility toolchain such as MinGW+MSYS or Cygwin. cabal: Error: some packages failed to install: plugins-1.5.1.4 failed during the configure step. The exception was: ExitFailure 1 What solution can I use to load dynamically code in a cross-platform way ? Thanks in advance Arnaud ___ Haskell-Cafe mailing list haskell-c...@haskell.orghttp://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 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] Printing of asynchronous exceptions to stderr
On Wed, Nov 10, 2010 at 5:48 PM, Simon Marlow marlo...@gmail.com wrote: [...] So we should say there are a few things that you can do that guarantee not to call any interruptible operations: - IORef operations - STM transactions that do not use retry - everything from the Foreign.* modules and probably some other things. Maybe we should put this list in the documentation. A list would be very helpful. I am specifically interested in knowing about: - The try family of MVar functions - the forkIO function itself Thanks, Bit Connor ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] [ANNOUNCE] Parallel Haskell project underway
Parallel Haskell project underway GHC HQ and Well-Typed are pleased to report that work has started on the MSR-funded project to push the real-world use of parallel Haskell. We will be working with four industrial partners over the next two years, with the aim of demonstrating that parallel Haskell can be employed successfully in industrial projects. The participating organizations are: * Dragonfly (New Zealand) * IIJ Innovation Institute Inc. (Japan) * Los Alamos National Laboratory (USA) * Willow Garage Inc. (USA) Each group is working on their own project, applying parallel Haskell and their domain-specific expertise. In addition to providing advice on Haskell tools and techniques, we will work with these partners to identify and resolve any issues that are hindering progress. We are prepared to handle issues covering anything from the compiler and runtime system, through to platform, tool and library problems. All the participants are working on complex, real-world problems. Three projects involve scientific problems, and the fourth involves network servers. Three of the projects are targeting single-node SMP systems, while the fourth is targeting clusters. In two cases, Haskell will be directly pitted against existing code written in C or C++. Project progress reports will be posted to the Well-Typed blog [1] and to the new Parallel Haskell mailing list [2]. [1]: http://www.well-typed.com/blog/ [2]: http://groups.google.com/group/parallel-haskell == Dragonfly == http://www.dragonfly.co.nz/ Participants: Finlay Thompson, Edward Abraham Cloudy Bayes: Hierarchical Bayesian modeling in Haskell The Cloudy Bayes project aims to develop a fast Bayesian model fitter that takes advantage of modern multiprocessor machines. It will support model descriptions in the BUGS model description language (WinBUGS, OpenBUGS, and JAGS). It will be implemented as an embedded domain specific language (EDSL) within Haskell. A wide range of model hierarchical Bayesian model structures will be possible, including many of the models used in medical, ecological, and biological sciences. Cloudy Bayes will provide an easy to use interface for describing models, running Monte Carlo Markov chain (MCMC) fitters, diagnosing performance and convergence criteria as it runs, and collecting output for post-processing. Haskell's strong type system will be used to ensure that model descriptions make sense, providing a fast, safe development cycle. == IIJ Innovation Institute Inc. == http://www.iij-ii.co.jp/en/ Participants: Kazu Yamamoto Haskell is suitable for many kinds of domain, and GHC's support for lightweight threads makes it attractive for concurrency applications. An exception has been network server programming because GHC 6.12 and earlier have an IO manager that is limited to 1024 network sockets. The upcoming GHC 7 has a new IO manager implementation that gets rid of this limitation. This project will implement several network servers to demonstrate that Haskell is suitable for network servers that handle a massive number of concurrent connections. == Los Alamos National Laboratory == http://www.lanl.gov/ Participants: Michael Buksas, Timothy M. Kelley This project will use parallel Haskell to implement high-performance Monte Carlo algorithms, a class of algorithms which use randomness to sample large or otherwise intractable solution spaces. The initial goal is a particle-based MC algorithm suitable for modeling the flow of radiation, with application to problems in astrophysics. From this, the project is expected to move to identification of suitable abstractions for expressing a wider variety of Monte Carlo algorithms, and using models for different physical phenomena. == Willow Garage == http://www.willowgarage.com/ Participants: Ryan Grant Distributed Rigid Body Dynamics in ROS Willow Garage seeks a high-level representation for a distributed rigid body dynamics simulation, capable of excellent parallel speedup on current and foreseeable hardware, yet linking to existing optimized libraries for low-level message passing and matrix math. This project will drive API, performance, and profiling tool requirements for Haskell's interface to the Message Passing Interface (MPI) specification, an industry-standard in High Performance Computing (HPC), as used on clusters of many nodes. Competing internal initiatives use C++/MPI and CUDA directly. Willow Garage aims to lay the groundwork for personal robotics applications in everyday life. ROS (Robot Operating System - ROS.org) is an open source, meta-operating system for your robot. -- Dmitry Astapov Well-Typed LLP, http://www.well-typed.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org
Re: [Haskell-cafe] date parsing and formatting
On Sat, Nov 13, 2010 at 4:35 PM, Alex Baranosky alexander.barano...@gmail.com wrote: I've been working with Haskell's Date.Time modules to parse a date like 12-4-1999 or 1-31-1999. I tried: parseDay :: String - Day parseDay s = readTime defaultTimeLocale %m%d%Y s And I think it wants my months and days to have exactly two digits instead of 1 or 2... What's the proper way to do this? Also, I'd like to print out my Day in this format: 12/4/1999 what's the Haskell way to? Something like this, perhaps, parseDate :: String - LocalTime parseDate = readTime defaultTimeLocale %m/%e/%Y printDate :: LocalTime - String printDate = formatTime defaultTimeLocale %m/%-e/%Y Anthony ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Type-Directed Name Resolution for Records?
Two significant points which have emerged from the TDNR thread are: -The wiki page combines two orthogonal proposals: type-directed name resolution, which requires no special syntax, and the x.f syntax, which does not require TDNR. -Implementing both proposals may be a desired fix for the record system, but their use in the rest of the language is more controversial. I would therefore like to propose that TDNR (both parts thereof) be implemented for record accessors. In the fullness of time, the community may come to some consensus regarding the implementation of either or both of these features in the rest of the language. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Curious data family bug
Sorry, I forgot to mention which compiler I was working with: 6.12.3. I'm glad to hear it's working with 7. Michael On Mon, Nov 15, 2010 at 4:58 PM, Simon Peyton-Jones simo...@microsoft.com wrote: Hmm. It works with HEAD (and hence I believe with the 7.0.1 RC2). It looks similar to http://hackage.haskell.org/trac/ghc/ticket/4174, which is fixed. Anyway I've added it as a regression test, so it should never go wrong again. Thanks for mentioning it. Simon | -Original Message- | From: haskell-cafe-boun...@haskell.org [mailto:haskell-cafe-boun...@haskell.org] On | Behalf Of Michael Snoyman | Sent: 14 November 2010 19:16 | To: Haskell Cafe | Subject: [Haskell-cafe] Curious data family bug | | Hey all, | | While trying to get a commit pushed for Yesod[1], Alexander Dunlap | pointed out one of his programs didn't work with the new code. After | some investigation, I was able to reproduce the bug with the following | code snippet: | | {-# LANGUAGE TypeFamilies #-} | data family Foo a | data Bar = Bar | data instance Foo Bar | = Bar1 | Bar2 | Bar3 | Bar4 | Bar5 | Bar6 | Bar7 | Bar8 | Bar9 | deriving Eq | | This produces: | | Couldn't match expected type `Main.R:FooBar' | against inferred type `Foo Bar' | NB: `Foo' is a type function | In the first argument of `Main.$con2tag_R:FooBar', namely `a' | In the expression: (Main.$con2tag_R:FooBar a) | In the expression: | case (Main.$con2tag_R:FooBar a) of { | a# | - case (Main.$con2tag_R:FooBar b) of { | b# - (a# GHC.Prim.==# b#) } } | | The especially strange thing about this bug is that it only occurs | when there are more than 8 constructors; if I remove Bar9, everything | seems to work. Does anyone have experience with this occuring? | | Michael | | [1] http://docs.yesodweb.com/blog/please-break-yesod/ | ___ | 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] [ANNOUNCE] Parallel Haskell project underway
On 15/11/10 15:23, Dmitry Astapov wrote: == Dragonfly == http://www.dragonfly.co.nz/ Participants: Finlay Thompson, Edward Abraham Cloudy Bayes: Hierarchical Bayesian modeling in Haskell The Cloudy Bayes project aims to develop a fast Bayesian model fitter that takes advantage of modern multiprocessor machines. It will support model descriptions in the BUGS model description language (WinBUGS, OpenBUGS, and JAGS). It will be implemented as an embedded domain specific language (EDSL) within Haskell. A wide range of model hierarchical Bayesian model structures will be possible, including many of the models used in medical, ecological, and biological sciences. This is slightly OT, but having used WinBUGS a little, I am very pleased to see this listed as a project. WinBUGS is a commendable piece of work, but is really showing its age these days. Between its really horrible error messages if anything goes wrong, awkward scripting/job-running interface (slightly eased by R2WinBUGS), and of course lack of support for multicore, I think this is a case where parallel Haskell could provide a lot of benefits over the existing software. Also, can you tell us which (if any) of these projects will be released as open-source? Thanks, Neil. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] http://www.haskell.org/ is down !
Hi, is haskell.org being updated or, as I fear, Haskell's HQ has been overrun by a mob of PHPers ? If so, I am ready to fight ! titto P.S. Just need to find my Excalibur, oh god, the wife just sent it to the Dry Cleaner. -- Pasqualino Titto Assini, Ph.D. http://quid2.org/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Opportunity: Spring semester internship on Haskell project at Intel
Dear Haskellers, We're looking for outstanding candidates for an internship in Spring 2011. The internship will be in a suburb of Boston (Hudson, MA). Graduate students and talented undergraduates are welcome to apply, but time is a bit short. We are a small research group run directly by the CTOhttp://www.intel.com/pressroom/kits/bios/plowney.htmof Intel's Developer Products Division. Our group works on high-level parallel programming toolshttp://software.intel.com/en-us/articles/intel-concurrent-collections-for-cc/(including for Haskellhttp://software.intel.com/en-us/blogs/2010/05/27/announcing-intel-concurrent-collections-for-haskell-01/) and applies binary translation http://www.pintool.org/ to various problems; also we collaborate closely with Intel's various developer tools teams (Cilk http://supertech.csail.mit.edu/cilk/, TBBhttp://www.threadingbuildingblocks.org/, etc). We are looking for someone to work on a new, self-contained Haskell project to create an eDSL that targets the ArBB virtual machine (VM) for vectorization. One possible solution is to adapt existing projects that target CUDA (e.g. accelerate http://hackage.haskell.org/package/accelerateand Nikola %20http://www.eecs.harvard.edu/%7Emainland/projects/nikola/). Array Building Blocks (ArBB)http://software.intel.com/en-us/articles/intel-array-building-blocks/is an interesting and ambitious project that attempts to bring metaprogramming and eDSLs to the masses. It's based on research by Michael Mccool at Waterloo that he used to found a company, RapidMindhttp://en.wikipedia.org/wiki/RapidMind, which was later bought by Intel. The basic idea is that the VM abstracts over the thread and vectorization capabilities of CPUs, GPUs, and other manycore chipshttp://www.intel.com/pressroom/archive/releases/20100531comp.htm. The VM defines a restricted compute language and provides a managed (yes, garbage collected) environment. Using the normal eDSL and metaprogramming tricks the user writes a portable program in a host language streams ASTs to the VM at runtime. These vector programs include the usual aggregate array operations and high level transformations (map, fold, etc), and the VM can perform fusion/deforestation optimizations while JITting vector codes. The VM API for generating programs is a simple C APIhttp://software.intel.com/sites/products/documentation/arbb/arbb_manual_win/group__arbb__virtual__machine.htmthat can be called from anywhere. The ArBB team is anxious to demonstrate language frontends for other languages, and Haskell is a good candidate. The official requisition will be available at the Intel Jobs site shortly, but in the meantime if you are interested, please forward your CV to me at ryan.r.new...@intel.com . Cheers, -Ryan LOCATION: Hudson, MA DURATION: 3-6 Months, flexible START: Some flexibility, ~January, 2011 EXPERIENCE: Expert Haskell/GHC programmer. Interest in research a plus. LOCATION NOTE: With a car it is possible to live in Cambridge or Boston and reverse-commute to our location. (Working offsite two days a week is possible.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-Cafe] Parsing bytestream
Hi Felipe, On Tue, Nov 9, 2010 at 3:53 PM, Felipe Almeida Lessa felipe.le...@gmail.com wrote: On Tue, Nov 9, 2010 at 8:10 AM, C K Kashyap ckkash...@gmail.com wrote: ] I think I can restate my problem like this --- ] ] If I have a list of actions as follows - ] ] import Data.Word ] import Data.Binary.Get ] ] data MyAction = A1 (Get Word8) | A2 (Get Word16) ] ] a = A1 getWord8 ] b = A2 getWord16be ] ] listOfActions = [a,b,a] ] ] How can I execute the listOfActions inside of a Get Monad and get ] the output as a list? Do you mean, something like this? import Control.Applicative (($)) data MyAction m = A1 (m Word8) | A2 (m Word16) a = A1 getWord8 b = A2 getWord16be listOfActions = [a,b,a] newtype Id a = Id a getAction :: MyAction Get - Get (MyAction Id) getAction (A1 act) = A1 . Id $ act getAction (A2 act) = A2 . Id $ act getActions :: [MyAction Get] - Get [MyAction Id] getActions = mapM getAction -- Felipe. Could you please give a solution for Put as well ... I need to generate a series of put actions from a list of tuples as follows - [(100,1),(200,2),500,4)] - [putWord8 100, putWord16be 200, putWord32be 500] -- Regards, Kashyap ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Updating Haskell Packages through Archlinux becoming A Pain
Well basically, I haven't update my Haskell libraries for some time now (around a month) so when I finally got around to updating my Haskell packages (which are installed through Archlinux's AUR) my GHC installation broke (again). This has been happening for some time now (I have been having this problem for around a year) Basically it occurs when pacman updates a package using an AUR package, which cabal refuses to install because it can break other packages (yet the package still gets installed according to pacman). So this means I have to manually go through /usr/lib/ghc-6.12.3/package.conf.d and manually updating all the package hashes while doing some manual dependency tracking through ghc-check This honestly starting to become annoying, is there any ideas or plans on how to resolve this issue. The end user shouldn't have to be dealing with this, and if installing a package can break the system, it shouldn't be 'semi' installed in the first place ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: ANNOUNCE zeno 0.1.0
Is the source code public, so I can run it on my own machine? Luke Hi all, My masters project Zeno was recently mentioned on this mailing list so I thought I'd announce that I've just finished a major update to it, bringing it slightly closer to being something useful. Zeno is a fully automated inductive theorem proving tool for Haskell programs. You can express a property such as takeWhile p xs ++ dropWhile p xs === xs and it will prove it to be true for all values of p :: a - Bool and xs :: [a], over all types a, using only the function definitions. Now that it's updated it can use polymorphic types/functions, and you express properties in Haskell itself (thanks to SPJ for the suggestion). It still can't use all of Haskell's syntax: you can't have internal functions (let/where can only assign values), and you can't use type-classed polymorphic variables in function definitions - you'll have to create a monomorphic instance of the function -but I hope to have these added reasonably soon. It's also still missing primitive-types/IO/imports so it still can't be used with any real-world Haskell code, it's more a bit of theorem proving fun. You can try it out at http://www.doc.ic.ac.uk/~ws506/tryzeno, the code file given there has some provable properties about a few prelude functions among other things. Another feature is that it lists all the sub-properties it has proven within each proof. When it verifies insertion-sort sorted (insertsort xs) === True it also proves the antisymmetry of = and that the insert function preserves the sorted property. Any suggestions or feedback would be greatly appreciated. Cheers, Will -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) iQEcBAEBAgAGBQJM3kzdAAoJEC5dcKNjBzhn6ZgH/24Yy1TBsCCtwmvItROvucms VNlaJ9lAEwbFtQT4X0HJtBX0MaMc/2QcPXhXsTTXm5CG+28N7ohrVDz9WIn3Zmri Tet1c+NFeZ5s4dK9Xjc450r1zlBYu6Uc8y/z9+RRbUTdDKpifGScwoxqFQPeWWYX fUY9zfM6RW4W7A/hTzFIZlRpa2l8/1d4ojBeRw8PnxpPftBk8KvXAVBxq1Nf21Pc pKmcfMFfhTCPAXsroLMXzP22A51XhIXrSREpvE+OgDSHsoaO+0D2/q8VMV+J1zPw PPYvmM/BOYAPcjy/Z34kNv2g6letXKOjH5ofHREr5arHpsrsmJxP+rcveZWQi1A= =58nx -END PGP SIGNATURE- ___ 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: [Haskell] intent-typing
I still don't understand what intent typing is, but this particular problem is discussed (with a type-based, statically checked solution) at http://blog.moertel.com/articles/2006/10/18/a-type-based-solution-to-the-strings-problem --Max On Mon, Nov 15, 2010 at 17:17, Marcus Sundman sund...@iki.fi wrote: Hi, how would one go about implementing (or using if it's supported out-of-the-box) intent-typing* for haskell? *) Intent-typing is compiler/verifier/parser enforced typing similar to apps hungarian notation. E.g., say I have a webapp with fields for a user's first name and last name, which I at some point show on another webpage that the user loads, which is a typical XSS vulnerability situation. So I have 2 functions, getParam(...) and setParam(...), which return the value of a user-provided parameter and gives a parameter to the template displayed to the user, respectively. I want to somehow flag the getParam(...)-function as returning a user-provided string (say, unsafe-string), and the setParam(...)-function as requiring a safely encoded string (say, safe-string), so that if I sometimes forget to run the user-provided string through some anti-xss-encoding thingy (which would take an unsafe-string and return a safe-string), and don't (unit-)test this particular aspect of said code, then some verifier thingy (preferably a static verifier) would notice this and show me a warning. Cheers, Marcus ___ Haskell mailing list hask...@haskell.org http://www.haskell.org/mailman/listinfo/haskell ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Opportunity: Spring semester internship on Haskell project at Intel
Update: The job requisition number is 584943. You can submit your full application here: https://intel.taleo.net/careersection/1/jobdetail.ftl?lang=enctx=1job=584943 Please include a cover-letter explaining why you are great for this job. Cheers, -Ryan P.S. It looks like one link below was corrupted, the Nikola project can be found here http://www.eecs.harvard.edu/%7Emainland/projects/nikola/. On Mon, Nov 15, 2010 at 11:02 AM, Ryan Newton rrnew...@gmail.com wrote: Dear Haskellers, We're looking for outstanding candidates for an internship in Spring 2011. The internship will be in a suburb of Boston (Hudson, MA). Graduate students and talented undergraduates are welcome to apply, but time is a bit short. We are a small research group run directly by the CTOhttp://www.intel.com/pressroom/kits/bios/plowney.htmof Intel's Developer Products Division. Our group works on high-level parallel programming toolshttp://software.intel.com/en-us/articles/intel-concurrent-collections-for-cc/(including for Haskellhttp://software.intel.com/en-us/blogs/2010/05/27/announcing-intel-concurrent-collections-for-haskell-01/) and applies binary translation http://www.pintool.org/ to various problems; also we collaborate closely with Intel's various developer tools teams (Cilk http://supertech.csail.mit.edu/cilk/, TBBhttp://www.threadingbuildingblocks.org/, etc). We are looking for someone to work on a new, self-contained Haskell project to create an eDSL that targets the ArBB virtual machine (VM) for vectorization. One possible solution is to adapt existing projects that target CUDA (e.g. acceleratehttp://hackage.haskell.org/package/accelerateand Nikola). Array Building Blocks (ArBB)http://software.intel.com/en-us/articles/intel-array-building-blocks/is an interesting and ambitious project that attempts to bring metaprogramming and eDSLs to the masses. It's based on research by Michael Mccool at Waterloo that he used to found a company, RapidMindhttp://en.wikipedia.org/wiki/RapidMind, which was later bought by Intel. The basic idea is that the VM abstracts over the thread and vectorization capabilities of CPUs, GPUs, and other manycore chipshttp://www.intel.com/pressroom/archive/releases/20100531comp.htm. The VM defines a restricted compute language and provides a managed (yes, garbage collected) environment. Using the normal eDSL and metaprogramming tricks the user writes a portable program in a host language streams ASTs to the VM at runtime. These vector programs include the usual aggregate array operations and high level transformations (map, fold, etc), and the VM can perform fusion/deforestation optimizations while JITting vector codes. The VM API for generating programs is a simple C APIhttp://software.intel.com/sites/products/documentation/arbb/arbb_manual_win/group__arbb__virtual__machine.htmthat can be called from anywhere. The ArBB team is anxious to demonstrate language frontends for other languages, and Haskell is a good candidate. The official requisition will be available at the Intel Jobs site shortly, but in the meantime if you are interested, please forward your CV to me at ryan.r.new...@intel.com . Cheers, -Ryan LOCATION: Hudson, MA DURATION: 3-6 Months, flexible START: Some flexibility, ~January, 2011 EXPERIENCE: Expert Haskell/GHC programmer. Interest in research a plus. LOCATION NOTE: With a car it is possible to live in Cambridge or Boston and reverse-commute to our location. (Working offsite two days a week is possible.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] RegEx versus (Parsec, TagSoup, others...)
I've been working on a project that requires me to do screen scraping. If you are screen scraping HTML I think tagsoup is a very good choice. The use of tagsoup means that you have a real HTML 5 compliant parser underneath, and then you can use whatever technique you wish to split up the page text - and regular expressions/parsec might be a reasonable choice. I've written lots of screen scraping stuff with tagsoup, and it's usually very easy - the manual even walks you through a couple of examples: http://community.haskell.org/~ndm/darcs/tagsoup/tagsoup.htm He's very experienced, and comes from a Perl perspective. I let him into what I was doing, and he opined I should be using pcre. When all you have is a hammer, everything looks like a thumb. Structured manipulation of algebraic data types is trivial in Haskell, and much less natural in Perl, so they use different techniques in different places. So now I'm second guessing my choices. Why do people choose not to use regex for uri parsing? If you mean HTML parsing, then it's because it's a nightmare to get right, and people on the web do all kinds of crazy stuff. A correct regular expression to match an HTML tag is lots of work. Given that it's a solved problem, why go to all that effort. It is possible to do with regular expressions, but not pleasant. Thanks, Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Updating Haskell Packages through Archlinux becoming A Pain
This is an example of what happens Proceed with installation? [Y/n] Y checking package integrity... (1/1) checking for file conflicts [##] 100% ghc-pkg: unregistering gio-0.11.1 would break the following packages: ltk-0.8.0.8 gtksourceview2-0.12.1 gtk-0.11.2 (use --force to override) error: command failed to execute correctly (1/1) upgrading haskell-gio [##] 100% Reading package info from stdin ... done. In other words, pacman still syncs the package (puts the files on the system) and causes GHC to break, and if you do this for a big update, you have to manually go through and fix it all ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Error handling with safer-file-handling
How am I supposed to write an exception handle for an invocation of System.IO.SaferFileHandles.openFile? Currently, I have got this: case req of Open path - do handle -openFile (asAbsPath path) ReadMode liftIO $ forcePut result Success run handle Follwing safer-file-handling-examples, I rewrote it to: case req of Open path - do (do runRegionT $ do handle -openFile (asAbsPath path) ReadMode liftIO $ forcePut result Success run handle) `catch` \(e :: IOException) - do liftIO $ forcePut result $ Failure $ show e (I would rather like to apply the handler to the openFile invocation only, but the above matches the example code more closely.) But this gives me a nice error message: Handles.hs:48:17: Could not deduce (Control.Monad.CatchIO.MonadCatchIO (RegionT s IO)) from the context () arising from a use of `catch' at Handles.hs:(48,17)-(54,50) Possible fix: add (Control.Monad.CatchIO.MonadCatchIO (RegionT s IO)) to the context of the polymorphic type `forall s. RegionT s pr α' or add an instance declaration for (Control.Monad.CatchIO.MonadCatchIO (RegionT s IO)) In the expression: do { (do { runRegionT $ do { handle - openFile (asAbsPath path) ReadMode; } }) } `catch` \ (e :: IOException) - do { liftIO $ forcePut result $ Failure $ show e } In a case alternative: Open path - do { (do { runRegionT $ do { ... } }) } `catch` \ (e :: IOException) - do { liftIO $ forcePut result $ Failure $ show e } In the expression: case req of { Open path - do { (do { runRegionT $ ... }) } `catch` \ (e :: IOException) - do { ... } Close - return () _ - liftIO $ forcePut result $ Failure handle not open } safer-file-handling-examples results in similar error messages, after applying the s/runTopRegion/runRegionT/ fix. This is with GHC 6.12.1, with ScopedTypeVariables enabled. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Better Records was Re: [Haskell-cafe] Type Directed Name Resolution
On Fri, Nov 12, 2010 at 22:48, Jonathan Geddes geddes.jonat...@gmail.com wrote: Records do leave quite a bit to be desired. But does anybody actually have a concrete alternative proposal yet? A few months ago I proposed a couple of extensions [1] on -cafe. [snip] Consider what this would do for nested updates: UpdateTripleInner :: (Inner-Inner) - MyTriplyNestedRecord - MyTriplyNestedRecord UpdateTripleInner f = \{inner1 = \{inner2 = \{inner3 = f }}} I cringe to imagine what the equivalent is in current Haskell syntax. Anyone want to try it? Not me! You can do this very conveniently already using the fclabels package: updateTrippleInner = modL (inner3 . inner2 . inner1) Here, inner1/2/3 are not record fields, but Lenses. You have to construct the lenses themselves, but this is very easy, and can be automated using Template Haskell. Other packages like data-accessor have similar functionality. Erik ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Concurrent with monads
From: Jiansen He jianse...@googlemail.com Hi cafe, I wounder if it is possible to tell a haskell system that two computations with side effects could be executed concurrently. Here is an affected example: Suppose two people want to compare their age, but do not want to leak their personal information. The following program reads one person's age after another then send back compared result. age :: IO () age = do i - readIntFrom a j - readIntFrom b writeTo a (i-j) writeTo b (j-i) How can I express the fact that two readings could be carried out in any order? The best approach is probably to fork a thread for each concurrent evaluation. There are a few packages on Hackage that can help with this; I've used threads[1] and spawn[2] successfully. If the readIntFrom function is meant to be responding to a client, a threaded model may make sense organizationally, but for this to be a performance benefit there needs to be sufficient work for each thread to carry out. Haskell threads are lighter than Posix threads, but there's still overhead involved. There is an alternative I hesitate to mention because it involves some voodoo, but Roman Leshchinskiy came up with a clever technique that might be appropriate if you want the behavior of par but for IO[3]. [1] http://hackage.haskell.org/package/threads [2] http://hackage.haskell.org/package/spawn [3] http://unlines.wordpress.com/2010/04/21/sparking-imperatives/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] xml packages
First question. As I saw in sources, both hxt and haxml uses [Char]'s. this is very inefficient. I want to know, does any effective parser for haskell, written in haskell, exists. The TagSoup parser can generate ByteString syntax trees - but they're quite a bit slower than [Char] versions. I am planning to speed up the ByteString version in the future: http://code.google.com/p/ndmitchell/issues/detail?id=290 Efficient means using ByteString to store strings and possibly building representations that shares one string for all similiary named elements. If there is no, is anyone interested in writing one? I intend to do that in TagSoup, and it can even be done now by running a Map state over the available strings with fmap. Thanks, Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Making monadic code more concise
Hi, I'm fairly new to Haskell and recently came across some programming tricks for reducing monadic overhead, and am wondering what higher-level concepts they map to. It would be great to get some pointers to related work. Background: I'm a graduate student whose research interests include methods for implementing domain specific languages. Recently, I have been trying to get more familiar with Haskell and implementing DSLs in it. I'm coming from having a fair bit of experience in Python so I know the basics of functional programming. However, I'm much less familiar with Haskell. In particular I have little to no internal map from existing DSL implementation techniques to the Haskell extensions that would no doubt make DSL implementations easier (and when they are *not* needed). I also don't have a complete picture of the functional programming research that would inform these techniques. I would greatly appreciate it if I could get pointers to the appropriate references so I can really get going on this. Specifically: There are some DSLs that can be largely expressed as monads, that inherently play nicely with expressions on non-monadic values. We'd like to use the functions that already work on the non-monadic values for monadic values without calls to liftM all over the place. The probability monad is a good example. import Control.Monad import Data.List newtype Prob a = Prob { getDist :: [(a, Float)] } deriving (Eq, Show) multiply :: Prob (Prob a) - Prob a multiply (Prob xs) = Prob $ concat $ map multAll xs where multAll (Prob innerxs, p) = map (\(x, r) - (x, p * r)) innerxs instance Functor Prob where fmap f (Prob xs) = Prob $ map (\(x, p) - (f x, p)) xs instance Monad Prob where return x = Prob [(x, 1.0)] x = f = multiply (fmap f x) In this monad, = hides the multiplying-out of conditional probabilities that happen during the composition of a random variable with a conditional distribution. coin x = Prob [(1, x), (0, 1 - x)] test = do x - (coin 0.5) y - (coin 0.5) return $ x + y *Main test Prob {getDist = [(2,0.25),(1,0.25),(1,0.25),(0,0.25)]} We can use a 'sum out' function to get more useful results: sumOut :: (Ord a) = Prob a - Prob a sumOut (Prob xs) = Prob $ map (\kvs - foldr1 sumTwoPoints kvs) eqValues where eqValues = groupBy (\x y - (fst x == fst y)) $ sortBy compare xs sumTwoPoints (v1, p1) (v2, p2) = (v1, p1 + p2) *Main sumOut test Prob {getDist = [(0,0.25),(1,0.5),(2,0.25)]} I'm interested in shortening the description of 'test', as it is really just a 'formal addition' of random variables. One can use liftM for that: test = liftM2 (+) (coin 0.5) (coin 0.5) It seems what I'm leading into here is making functions on ordinary values polymorphic over their monadic versions; I think this is the desire for 'autolifting' or 'monadification' that has been mentioned in works such as HaRE http://www.haskell.org/pipermail/haskell/2005-March/015557.html One alternate way of doing this, however, is instancing the typeclasses of the ordinary values with their monadic versions: instance (Num a) = Num (Prob a) where (+) = liftM2 (+) (*) = liftM2 (*) abs = liftM abs signum = liftM signum fromInteger = return . fromInteger instance (Fractional a) = Fractional (Prob a) where fromRational = return . fromRational (/) = liftM2 (/) Note that already, even though each function in the typeclass had to be manually lifted, this eliminates more overhead compared to lifting every function used, because any function with a general enough type bound can work with both monadic and non-monadic values, not just the ones in the typeclass: *Main sumOut $ (coin 0.5) + (coin 0.5) + (coin 0.5) Prob {getDist = [(0,0.125),(1,0.375),(2,0.375),(3,0.125)]} *Main let foo x y z = (x + y) * z *Main sumOut $ foo (coin 0.5) (coin 0.5) (coin 0.5) Prob {getDist = [(0,0.625),(1,0.25),(2,0.125)]} Because of the implementation of fromInteger as return . fromInteger, we also 'luck out' and have the ability to mix ordinary and non-monadic values in the same expression: *Main 1 + coin 0.5 / 2 Prob {getDist = [(1.5,0.5),(1.0,0.5)]} My question is, what are the higher-level concepts at play here? The motivation is that it should be possible to automatically do this typeclass instancing, letting us get the benefits of concise monadic expressions without manually instancing the typeclasses. Indeed, I didn't have this idea in Haskell; I'm coming from Python where one can realize the automatic instances: if we take the view that classes in Python are combined datatypes and instanced typeclasses, we can use the meta-object protocol to look inside one class's representation and output another class with liftM-ed (or return . -ed) methods and a custom constructor. I realize Template Haskell gives you the ability to reify instance/class declarations, but perhaps there's a
Re: [Haskell-cafe] RegEx versus (Parsec, TagSoup, others...)
On 13 November 2010 16:46, Neil Mitchell ndmitch...@gmail.com wrote: I've been working on a project that requires me to do screen scraping. If you are screen scraping HTML I think tagsoup is a very good choice. The use of tagsoup means that you have a real HTML 5 compliant parser underneath, and then you can use whatever technique you wish to split up the page text - and regular expressions/parsec might be a reasonable choice. I've written lots of screen scraping stuff with tagsoup, and it's usually very easy - the manual even walks you through a couple of examples: http://community.haskell.org/~ndm/darcs/tagsoup/tagsoup.htm Agreed, the tagsoup library just works. I've used it plenty of times for my scraping needs. E.g. scraping from paste sites: https://github.com/chrisdone/amelie/blob/master/src/Amelie/Import.hs#L84 https://github.com/chrisdone/hpaste-feed/blob/master/main.hs#L65 You can always regex match on what tagsoup gives you, too. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Making HList's field access operators (#) and (.!.) left-associative?
Hello, In experimenting with HList's very impressive extensible records, I discovered that the field access operators (#) and (.!.) have right associativity; this means I can't write (r # f1 # f2) to access field f2 of the record stored in field f1 of r. If (#) and (.!) had left-associativity instead, then I could write such nested record operations. As far as I can tell, the right-associative binding would only make sense if attempting to store field labels inside a record, which seems much more unlikely. I wrote to the author of HList about this issue, and he agreed that this sounded reasonable, but he wanted me to confirm via haskell-cafe that nobody had code which relied on the existing behavior. Comments? Objections? Thanks, Josh Triplett ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe From hot-requirements-of-usa+bnccimz-5o1hxcg5yxnbboeyny...@googlegroups.com Mon Nov 15 09:49:26 2010 Return-path: hot-requirements-of-usa+bnccimz-5o1hxcg5yxnbboeyny...@googlegroups.com Envelope-to: arch...@mail-archive.com Delivery-date: Mon, 15 Nov 2010 09:49:26 -0800 Received: from exprod5mx249.postini.com ([64.18.0.169] helo=psmtp.com) by mail-archive.com with smtp (Exim 4.69) (envelope-from hot-requirements-of-usa+bnccimz-5o1hxcg5yxnbboeyny...@googlegroups.com) id 1PI3BG-0007ob-0c for arch...@mail-archive.com; Mon, 15 Nov 2010 09:49:26 -0800 Received: from source ([74.125.82.55]) by exprod5mx249.postini.com ([64.18.4.10]) with SMTP; Mon, 15 Nov 2010 09:49:25 PST Received: by wwb29 with SMTP id 29sf2190809wwb.0 for arch...@mail-archive.com; Mon, 15 Nov 2010 09:49:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=beta; h=domainkey-signature:received:x-beenthere:received:received:received :received:received-spf:received:received:mime-version:received:from :date:message-id:subject:x-original-sender :x-original-authentication-results:reply-to:precedence:mailing-list :list-id:list-post:list-help:list-archive:sender:list-subscribe :list-unsubscribe:content-type; bh=KcJVe36lBeqWCkV1zFOzvwjNxU9OpSXCdVH2KMfHyTg=; b=ZsmkM9Ef5IomOAzE09YFxEn3wKJMFm0yANkgZhYEIlSQ+hzJT2DEHkJkUEpudiNnrl DuA311CP5aBqgWsW6NYPodXO2BwjUn98aouRFCEqBqIJ1H0pu5uNt57/rVZM8MBhBisU qSOyv/mS3xtbm5HCwB0fvoo0rfyStSrqhCJ9k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlegroups.com; s=beta; h=x-beenthere:received-spf:mime-version:from:date:message-id:subject :x-original-sender:x-original-authentication-results:reply-to :precedence:mailing-list:list-id:list-post:list-help:list-archive :sender:list-subscribe:list-unsubscribe:content-type; b=OpiJSLfWcfnIfK2F4becc298v1pb3PPlRnoNv4jmXUqZC/FAJcTDe6hpiedXKEu0v+ BbZWV7h0yRtvy+Nzl5WJ2z4P1HeVJ9imPGZ6S2nh0bhvWEzYV0pZP7nX3pkETyTTg7/3 z1naJGNUtSPVC7hTieAfNtWMFFKHJju/pQJMs= Received: by 10.216.140.24 with SMTP id d24mr721870wej.3.1289843360097; Mon, 15 Nov 2010 09:49:20 -0800 (PST) X-BeenThere: hot-requirements-of-...@googlegroups.com Received: by 10.14.10.75 with SMTP id 51ls1112259eeu.6.p; Mon, 15 Nov 2010 09:49:17 -0800 (PST) Received: by 10.14.37.6 with SMTP id x6mr792065eea.15.1289843357796; Mon, 15 Nov 2010 09:49:17 -0800 (PST) Received: by 10.14.37.6 with SMTP id x6mr792064eea.15.1289843357773; Mon, 15 Nov 2010 09:49:17 -0800 (PST) Received: from mail-ew0-f54.google.com (mail-ew0-f54.google.com [209.85.215.54]) by gmr-mx.google.com with ESMTP id v14si72014eeh.5.2010.11.15.09.49.16; Mon, 15 Nov 2010 09:49:16 -0800 (PST) Received-SPF: pass (google.com: domain of accmgrin...@gmail.com designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by mail-ew0-f54.google.com with SMTP id 3so1484673ewy.27 for hot-requirements-of-...@googlegroups.com; Mon, 15 Nov 2010 09:49:16 -0800 (PST) Received: by 10.216.133.159 with SMTP id q31mt7129858wei.108.1289843348490; Mon, 15 Nov 2010 09:49:08 -0800 (PST) MIME-Version: 1.0 Received: by 10.216.154.82 with HTTP; Mon, 15 Nov 2010 09:48:48 -0800 (PST) From: Chandra accmgrin...@gmail.com Date: Mon, 15 Nov 2010 12:48:48 -0500 Message-ID: aanlktins7ssd401k26-vevybmmgwpmc7-0efxxh_d...@mail.gmail.com Subject: [Hot-Requirements-of-Usa] Welcome Freshers Experienced. X-Original-Sender: accmgrin...@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of accmgrin...@gmail.com designates 209.85.215.54 as permitted sender) smtp.mail=accmgrin...@gmail.com; dkim=pass (test mode) header...@gmail.com Reply-To: hot-requirements-of-...@googlegroups.com Precedence: list Mailing-list: list hot-requirements-of-...@googlegroups.com; contact hot-requirements-of-usa+own...@googlegroups.com List-ID:
Re: [Haskell-cafe] http://www.haskell.org/ is down !
On 13 November 2010 20:16, Pasqualino Titto Assini tittoass...@gmail.com wrote: is haskell.org being updated or It's back up now. As far as I'm aware, it is being updated. But I'm not sure on the progress of it and whether the server transfer is related. If so, I am ready to fight ! Lambda knights, assemble! P.S. Just need to find my Excalibur, oh god, the wife just sent it to the Dry Cleaner. Oh, uh. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: ANNOUNCE zeno 0.1.0
I was wondering, Zeno capable of proving just equational statements, or is it able to prove more general statements about programs? In particular, it would be interesting if Zeno would be able to prove that a function is total by verifying that it uses only structural (inductive) recursion (on a well defined inductive type), i.e. each recursive function call must be on a syntactic subcomponent of its parameter. And dually, one might want to prove that a function is corecursive, meaning that each recursive call is guarded by a constructor. Best regards, Petr Yeah as it is Zeno can only prove equality properties, but I would love to extend it with these other proof features. I'm currently working on a more general notion of well-founded ordering within the program (so that it can hopefully verify quicksort/mergesort) and I guess I could expose this feature so one could prove the totality of functions in the way you said. Cheers, Will ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Is there any way to prevent a computation from being shared?
I've came upon very a strange situation with memory consumption. The smallest test case I've been able to come up with is the following: import Data.List wtf d = head . dropWhile ( 10^100) . map (*d) $ enumFrom 2 main = do print $ wtf 1 print $ wtf 2 -- Everything is ok without this line Expected result is that program runs in constant space. What really happening is that the program consumes memory until killed. If second call to wtf is removed, memory usage stays constant while the program is working. The problem is in that list returned from enumFrom is being saved between calls to wtf. Is there any way to overcome this? -- Regards, Petr ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Making monadic code more concise
On Nov 15, 2010, at 9:43 AM, Ling Yang wrote: Specifically: There are some DSLs that can be largely expressed as monads, that inherently play nicely with expressions on non-monadic values. This, to me, is a big hint that applicative functors could be useful. Every monad is an applicative functor. Given a monad instance for F, you can do: instance Applicative F where pure = return (*) = ap $ is an alias of fmap. * can be interpreted as a kind of lifting product operator (Examine the types as you learn it. The notation will become transparent once you get it). So you write expressions like: data F a = F a -- We'll assume F is instantiated as a monad data Foo = Foo Int Int Int foo :: F Foo foo = Foo $ monad_action_that_returns_an_int_for_your_first_argument * monad_action_that_returns_an_int_for_your_second_argument * monad_action_that_etc Your test test = liftM2 (+) (coin 0.5) (coin 0.5) translates to: test = (+) $ (coin 0.5) * (coin 0.5) You can't really express a test in 5 arguments (I think there's no liftM5...) but it's easy with $ and *: test = Five $ one * two * three * four * five ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Announcement: the Haskell.org committee has formed
= The haskell.org committee has formed = http://haskellorg.wordpress.com/2010/11/15/the-haskell-org-committee-has-formed/ In recent years, haskell.org has started to receive assets, e.g. Google Summer Of Code funds, donations for Hackathons, and a Sparc machine for use in GHC development. We have also started spending this money: on the community server, on a server to take over hosting haskell.org itself, and on the haskell.org domain name. There is also interest in running fundraising drives for specific things such as Hackathon sponsorship and hosting fees. To resolve who is responsible for haskell.org’s infrastructure development, open nominations were held to form a haskell.org committee, based on representatives from the open source Haskell community. Nominations were received, and we are pleased to announce that the new committee has formed. The current members of the committee are: • Don Stewart [chair] • Edward Z. Yang • Ganesh Sittampalam • Ian Lynagh • Johan Tibell • Malcolm Wallace • Vo Minh Thu Members are expected to serve a 3 year term, and terms are staggered so that 2 or 3 members step down each year. = What we’re working on = Over the past year, two of the core infrastructure nodes: www.haskell.org (which hosts the main wiki), and code.haskell.org (which hosts a lot of project repositories) have become increasingly unreliable. To address this, a new high-spec, dedicated host was purchased, which will be used to replace both services. The commitee is now working directly to solve these issues: • Moving www.haskell.org (and the mailing lists) from Yale to the new dedicated host. • Migrating the code.haskell.org host to a VM on the new machine. More news on this work shortly. = Stay up to date = To help people better keep up to date on the status of the haskell.org infrastructure, stay up to date via: • Online: http://haskellorg.wordpress.com/ • Twitter:http://twitter.com/haskellorg - get status updates about haskell.org services via twitter. • Email: commit...@haskell.org - To get in touch with the committee, use the committee @ haskell.org address. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is there any way to prevent a computation from being shared?
On Sat, Nov 13, 2010 at 2:55 PM, Petr Prokhorenkov prokhoren...@gmail.com wrote: Is there any way to overcome this? You can add {-# NOINLINE wtf #-} That will prevent the sharing. But I'm not sure if this is the best solution. Cheers, -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Bracket around every IO computation monad
Hi! On Mon, Nov 8, 2010 at 1:50 AM, Felipe Almeida Lessa felipe.le...@gmail.com wrote: (I won't answer your main question, I'll just write some notes on your current code.) Thanks. This also helped. But is it possible to define a Monad like I described? So that all actions would be wrapped in a bracket, which would be stacked? Mitar ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Bracket around every IO computation monad
Well, I guess you could try something like: {-# LANGUAGE GADTs #-} import Control.Exception (bracketOnError) import Control.Monad ((=)) -- from package 'operational' import Control.Monad.Operational data BracketedOperation a where Bracketed :: IO a - (a - IO b) - BracketedOperation a type BracketedProgram a = ProgramT BracketedOperation IO a interpret :: BracketedProgram a - IO a interpret = viewT = eval where eval :: ProgramViewT BracketedOperation IO a - IO a eval (Return a) = return a eval (Bracketed acquire release := is) = bracketOnError acquire release $ interpret . is Now you could have: ] attachN :: Nerve n - BracketedProgram (LiveNeuron n) ] attachN n = singleton (Bracketed (attach n) dettach) And your code would become: ] neurons - interpret $ do ] attachN nerve1 ] attachN nerve2 ] attachN nerve3 Note that I haven't tested this code, but it compiles :). Cheers! -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Making monadic code more concise
On Mon, Nov 15, 2010 at 12:43 PM, Ling Yang ly...@cs.stanford.edu wrote: Specifically: There are some DSLs that can be largely expressed as monads, that inherently play nicely with expressions on non-monadic values. We'd like to use the functions that already work on the non-monadic values for monadic values without calls to liftM all over the place. It's worth noting that using liftM is possibly the worst possible way to do this, aesthetically speaking. To start with, liftM is just fmap with a gratuitous Monad constraint added on top. Any instance of Monad can (and should) also be an instance of Functor, and if the instances aren't buggy, then liftM f = (= return . f) = fmap f. Additionally, in many cases readability is improved by using ($), an operator synonym for fmap, found in Control.Applicative, I believe. The probability monad is a good example. [snip] I'm interested in shortening the description of 'test', as it is really just a 'formal addition' of random variables. One can use liftM for that: test = liftM2 (+) (coin 0.5) (coin 0.5) Also on the subject of Control.Applicative, note that independent probabilities like this don't actually require a monad, merely the ability to lift currying into the underlying functor, which is what Applicative provides. The operator ((*) :: f (a - b) - f a - f b) is convenient for writing such expressions, e.g.: test = (+) $ coin 0.5 * coin 0.5 Monads are only required for lifting control flow into the functor, which in this case amounts to conditional probability. You would not, for example, be able to easily use simple lifted functions to write roll a 6-sided die, flip a coin as many times as the die shows, then count how many flips were heads. I think a good question as a starting point is whether it's possible to do this 'monadic instance transformation' for any typeclass, and whether or not we were lucky to have been able to instance Num so easily (as Num, Fractional can just be seen as algebras over some base type plus a coercion function, making them unusually easy to lift if most typeclasses actually don't fit this description). Part of the reason Num was so easy is that all the functions produce values whose type is the class parameter. Your Num instance could almost be completely generic for any ((Applicative f, Num a) = f a), except that Num demands instances of Eq and Show, neither of which can be blindly lifted the way the numeric operations can. I imagine it should be fairly obvious why you can't write a non-trivial generic instance (Show a) = Show (M a) that would work for any possible monad M--you'd need a function (show :: M a - String) which is impossible for abstract types like IO, as well as function types like the State monad. The same applies to (==), of course. Trivial instances are always possible, e.g. show _ = [not showable], but then you don't get sensible behavior when a non-trivial instance does exist, such as for Maybe or []. Note that if we consider this in a 'monadification' context, where we are making some choice for each lifted function, treating it as entering, exiting, or computing in the monad, instancing the typeclass leads to very few choices for each: the monadic versions of +, -, * must be obtained with liftM2,the monadic versions of negate, abs, signum must be obtained with liftM, and the monadic version of fromInteger must be obtained with return . Again, this is pretty much the motivation and purpose of Control.Applicative. Depending on how you want to look at it, the underlying concept is either lifting multi-argument functions into the functor step by step, or lifting tuples into the functor, e.g. (f a, f b) - f (a, b); the equivalence is recovered using fmap with either (curry id) or (uncurry id). Note that things do get more complicated if you have to deal with the full monadic structure, but since you're lifting functions that have no knowledge of the functor whatsoever they pretty much have to be independent of it. I suppose I'm basically suggesting that the 'next step' is to somehow do this calculation of types on real type values, and use an inductive programming tool like Djinn to realize the type signatures. I think the general programming technique this is getting at is an orthogonal version of LISP style where one goes back and forth between types and functions, rather than data and code. I would also appreciate any pointers to works in that area. Well, I don't think there's any good way to do this in Haskell directly, in general. There's a GHC extension that can automatically derive Functor for many types, but nothing to automatically derive Applicative as far as I know (other than in trivial cases with newtype deriving)--I suspect due to Applicative instances being far less often uniquely determined than for Functor. And while a fully generic instance can be written and used for any Applicative and Num, the impossibility of sensible instances for Show and Eq,
Re: [Haskell-cafe] Bracket around every IO computation monad
On Mon, Nov 8, 2010 at 1:40 AM, Mitar mmi...@gmail.com wrote: Hi! I have a class Neuron which has (among others) two functions: attach and deattach. I would like to make a way to call a list/stack/bunch of attach functions in a way that if any of those fail (by exception), deattach for previously already attached values (called attach on them) are deattached (called deattach on them). I have come up with such way: data Growable where Growable :: Neuron n = LiveNeuron n - Growable growNeurons :: [IO Growable] - IO [Growable] growNeurons attaches = growNeurons' attaches [] where growNeurons' [] ls = return ls growNeurons' (a:ats) ls = bracketOnError a (\(Growable l) - deattach l) (\l - growNeurons' ats (l:ls)) So I give growNeurons a list of attach actions and it returns a list of attached values ((live)neurons). This works nice, but syntax to use it is ugly: neurons - growNeurons [ do { a - attach nerve1; return $ Growable a }, do { a - attach nerve2; return $ Growable a }, do { a - attach nerve3; return $ Growable a } ] Types of attach and deattach are (if I simplify): attach :: Nerve n - IO (LiveNeuron n) deattach :: LiveNeuron n - IO () Growable is only used so that I can put actions of different type in the list. It seems to me that all this could be wrapped into a monad. So that I would be able to call something like: neurons - growNeurons' $ do attach nerve1 attach nerve2 attach nerve3 Where I would be allowed to call actions of a special type class which defined also clean-up function (in my case called deattach). And which would be called if there was any exception thrown (and then at the end rethrown). Otherwise, the result would be a list of all computed values. In my case all this in IO monad. So it is possible that evaluation of monad actions would be stacked inside of bracketOnError and in a case of error clean-up functions would be called, otherwise returns a list of results? Mitar This can be solved by using Lightweight Monadic Regions as implemented in my regions package[1]. What follows is an example module that demonstrates the idea: module SaveNeurons (Nerve, SaveNeuron, saveAttach, someSaveOperation) where -- -- Imports: -- from base: import Control.Monad ( liftM ) -- from monad-peel: import Control.Exception.Peel ( block ) import Control.Monad.IO.Peel ( MonadPeelIO ) -- from transformers: import Control.Monad.IO.Class ( MonadIO(liftIO) ) -- from regions: import Control.Monad.Trans.Region ( RegionT, runRegionT , Dup(dup) , AncestorRegion ) import Control.Monad.Trans.Region.OnExit ( FinalizerHandle, onExit ) -- -- Your existing types and functions: data Nerve n = Nerve data LiveNeuron n = LiveNeuron attach :: Nerve n - IO (LiveNeuron n) attach = undefined deattach :: LiveNeuron n - IO () deattach = undefined -- You probably also defined some operations on LiveNeurons: someOperation :: LiveNeuron n - IO () someOperation = undefined -- -- Save regional layer: data SaveNeuron n r = SaveNeuron (LiveNeuron n) (FinalizerHandle r) saveAttach :: MonadPeelIO pr = Nerve n - RegionT s pr (SaveNeuron n (RegionT s pr)) saveAttach nerve = block $ do n - liftIO $ attach nerve fh - onExit $ deattach n return $ SaveNeuron n fh someSaveOperation :: (AncestorRegion pr cr, MonadIO cr) = SaveNeuron n pr - cr () someSaveOperation (SaveNeuron ln _) = liftIO $ someOperation ln instance Dup (SaveNeuron n) where dup (SaveNeuron ln fh) = liftM (SaveNeuron ln) $ dup fh -- -- Example: example :: IO () example = runRegionT $ do sn1 - saveAttach Nerve someSaveOperation sn1 -- When one of these operations fail, -- all attached nerves will be detached automatically. sn2 - saveAttach Nerve sn3 - saveAttach Nerve someSaveOperation sn2 someSaveOperation sn3 -- We can also nest regions. runRegionT $ do someSaveOperation sn1 sn4 - saveAttach Nerve sn5 - saveAttach Nerve someSaveOperation sn4 someSaveOperation sn5 -- When a regions terminates all attached nerves will -- be detached automatically. Note that is a type error -- to return a save neuron from a regions: -- 'return sn5' gives a type error for example. -- If you really wish to return a save neuron you can --
[Haskell-cafe] Making monadic code more concise
This, to me, is a big hint that applicative functors could be useful. Indeed, the ideas here also apply to applicative functors; it is just the lifting primitives that will be different; instead of having liftMN, we can use $ and * to lift the functions. We could have done this for Num and Maybe (suppose Maybe is an instance of Applicative): instance (Num a) = Num (Maybe a) where (+) = \x y - (+) $ x * y (-) = \x y - (-) $ x * y (*) = \x y - (+) $ x * y abs = abs $ signum = signum $ fromInteger = pure . fromInteger The larger goal remains the same: autolifting in a principled manner. However, you actually bring up a very good point; what if it is really only the applicative functors that this method works on in general, that there is no 'use case' for considering this autolifting for monads in particular? I think the answer lies in the fact that monads can be 'flattened;' that is, realizations of the type m (m a) - m a are mechanical (in the form of 'join') given that = is defined. This is important when we have a typeclass that also has monadic signatures. To be more concrete, consider how this function could be used in a 'monadic DSL': enter x = case x of 0 - Nothing _ - Just hi The type of 'enter' is one case of the general from 'a - M b'. If we were instancing a typeclass that had an 'a - M b' function, we'd need a function of type 'M a - M b'. This would be accomplished by enter' = join . liftM enter So the set of lifting primitives must include at least some way to get M a - M b from 'a - M b'---which requires that M is a monad, not just an applicative functor. Thanks for the mention of applicative functors; I should have included them in the original post. Lingfeng Yang lyang at cs dot stanford dot edu ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Making monadic code more concise
See my reply to Alex's post for my perspective on how this relates to applicative functors, reproduced here: This, to me, is a big hint that applicative functors could be useful. Indeed, the ideas here also apply to applicative functors; it is just the lifting primitives that will be different; instead of having liftMN, we can use $ and * to lift the functions. We could have done this for Num and Maybe (suppose Maybe is an instance of Applicative): instance (Num a) = Num (Maybe a) where (+) = \x y - (+) $ x * y (-) = \x y - (-) $ x * y (*) = \x y - (+) $ x * y abs = abs $ signum = signum $ fromInteger = pure . fromInteger The larger goal remains the same: autolifting in a principled manner. However, you actually bring up a very good point; what if it is really only the applicative functors that this method works on in general, that there is no 'use case' for considering this autolifting for monads in particular? I think the answer lies in the fact that monads can be 'flattened;' that is, realizations of the type m (m a) - m a are mechanical (in the form of 'join') given that = is defined. This is important when we have a typeclass that also has monadic signatures. To be more concrete, consider how this function could be used in a 'monadic DSL': enter x = case x of 0 - Nothing _ - Just hi The type of 'enter' is one case of the general from 'a - M b'. If we were instancing a typeclass that had an 'a - M b' function, we'd need a function of type 'M a - M b'. This would be accomplished by enter' = join . liftM enter So the set of lifting primitives must include at least some way to get M a - M b from 'a - M b'---which requires that M is a monad, not just an applicative functor. Thanks for the mention of applicative functors; I should have included them in the original post. Lingfeng Yang lyang at cs dot stanford dot edu I should have included a mention of Applicative in my original post. Part of the reason Num was so easy is that all the functions produce values whose type is the class parameter. Your Num instance could almost be completely generic for any ((Applicative f, Num a) = f a), except that Num demands instances of Eq and Show, neither of which can be blindly lifted the way the numeric operations can. I imagine it should be fairly obvious why you can't write a non-trivial generic instance (Show a) = Show (M a) that would work for any possible monad M--you'd need a function (show :: M a - String) which is impossible for abstract types like IO, as well as function types like the State monad. The same applies to (==), of course. Trivial instances are always possible, e.g. show _ = [not showable], but then you don't get sensible behavior when a non-trivial instance does exist, such as for Maybe or []. Good point. This is where we can start defining restrictions for when this automatic lifting can or cannot take place. I reference the concept of 'runnable monads' here, from [Erwig and Ren 2004] Monadification of Functional Programs A 'runnable monad' is a monad with an exit function: class (Monad m) = Runnable m where exit : m a - a And yes, for monads like IO, no one would really have a need for 'exit' outside of the cases where they need unsafePerformIO. However, for Maybe and Prob, 'exit' is extremely useful. In fact, in the probability monad, if you could not exit the monad, you could not get anything done, as the real use is around sampling and computing probabilities, which are of non-monadic types. Provided M is a runnable monad, class (Show a) = Show (M a) where show = show . exit I'm aware of the limitations of this approach; I just want to come up with a set of primitives that characterize the cases where autolifting/monadic instancing is useful. On Mon, Nov 15, 2010 at 11:19 AM, C. McCann c...@uptoisomorphism.net wrote: On Mon, Nov 15, 2010 at 12:43 PM, Ling Yang ly...@cs.stanford.edu wrote: Specifically: There are some DSLs that can be largely expressed as monads, that inherently play nicely with expressions on non-monadic values. We'd like to use the functions that already work on the non-monadic values for monadic values without calls to liftM all over the place. It's worth noting that using liftM is possibly the worst possible way to do this, aesthetically speaking. To start with, liftM is just fmap with a gratuitous Monad constraint added on top. Any instance of Monad can (and should) also be an instance of Functor, and if the instances aren't buggy, then liftM f = (= return . f) = fmap f. Additionally, in many cases readability is improved by using ($), an operator synonym for fmap, found in Control.Applicative, I believe. The probability monad is a good example. [snip] I'm interested in shortening the description of 'test', as it is really just a 'formal addition' of random variables. One can use liftM for that: test = liftM2 (+) (coin 0.5)
[Haskell-cafe] Hood on Hackage is an interesting way to see intermediate data structures.
Hood on Hackage is an interesting way to see intermediate data structures. {-# LANGUAGE NoMonomorphismRestriction #-} -- Fold Behaviour Observed module Folding where -- See Hood on Hackage import Observe import Data.List n = 10::Int fr = foldr (observe Add (+)) 0 [1..n] fl = foldl (observe Add (+)) 0 [1..n] frr = foldr (observe Add (+)) 0 (reverse [1..n]) flr = foldl (observe Add (+)) 0 (reverse [1..n]) fro = printO fr flo = printO fl frro = printO frr flro = printO flr fl' = foldl' (observe Add (+)) 0 [1..n] flr' = foldl' (observe Add (+)) 0 (reverse [1..n]) flo' = printO fl' flro' = printO flr' ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Bracket around every IO computation monad
On Sun, Nov 7, 2010 at 7:40 PM, Mitar mmi...@gmail.com wrote: I have a class Neuron which has (among others) two functions: attach and deattach. I would like to make a way to call a list/stack/bunch of attach functions in a way that if any of those fail (by exception), deattach for previously already attached values (called attach on them) are deattached (called deattach on them). Perhaps I'm misunderstanding how this works, but it seems like this could all be done fairly simply using standard combinators in Control.Monad. growNeurons :: [IO Growable] - IO [Growable] growNeurons attaches = growNeurons' attaches [] where growNeurons' [] ls = return ls growNeurons' (a:ats) ls = bracketOnError a (\(Growable l) - deattach l) (\l - growNeurons' ats (l:ls)) Isn't this mostly a reimplementation of mapM? Given a list of [IO Growable], you map over it to put a bracket around each one, then sequence the result (which I believe performs exactly the sort of nested monadic recursion you're doing here). I think that something like this ought to be equivalent: growNeurons :: [IO Growable] - IO [Growable] growNeurons = mapM (\a - bracketOnError a (\(Growable l) - deattach l) return) So I give growNeurons a list of attach actions and it returns a list of attached values ((live)neurons). This works nice, but syntax to use it is ugly: neurons - growNeurons [ do { a - attach nerve1; return $ Growable a }, do { a - attach nerve2; return $ Growable a }, do { a - attach nerve3; return $ Growable a } ] Along the lines of what Felipe suggested, this could possibly be simplified to something like: growNeurons $ map (fmap Growable . attach) [nerve1, nerve2, nerve3] ...except that this won't work if the nerves have different types. In many cases there's a trivial translation to get rid of existential types, and I suspect it would work here, but I'm not sure what else you might be doing with them. Existential types tend to be more trouble than they're worth, in my experience. It seems to me that all this could be wrapped into a monad. So that I would be able to call something like: neurons - growNeurons' $ do attach nerve1 attach nerve2 attach nerve3 I'm not sure why you'd want to do it this way, relying on the monad to provide the sequencing. Isn't it more convenient to use a list of neurons, as above? - C. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is there any way to prevent a computation from being shared?
On 11/13/2010 08:55 AM, Petr Prokhorenkov wrote: import Data.List wtf d = head . dropWhile ( 10^100) . map (*d) $ enumFrom 2 main = do print $ wtf 1 print $ wtf 2 -- Everything is ok without this line Is there any way to overcome this? I think this phenomenon is called the full laziness transform: an optimization that GHC will apply to avoid redundant computation. More details in: Let-Floating: Moving Bindings to Give Faster Programs http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.30.9079 So I think you're seeing bug http://hackage.haskell.org/trac/ghc/ticket/917 where the increased sharing only leads to space leaks. You could try the workaround, passing -fno-full-laziness (it might need to come after -O on the command line). I'm not sure if this'd be more or less fragile than disabling inlining as Felipe suggested. I'd also suggest adding yourself as a CC: on bug 917 so GHC HQ knows how many people are being affected by this kind of behavior. Hope this helps, -Brian ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Concurrent with monads
On 10-11-14 07:36 PM, Jiansen He wrote: Hi cafe, I wounder if it is possible to tell a haskell system that two computations with side effects could be executed concurrently. Here is an affected example: Suppose two people want to compare their age, but do not want to leak their personal information. The following program reads one person's age after another then send back compared result. age :: IO () age = do i - readIntFrom a j - readIntFrom b writeTo a (i-j) writeTo b (j-i) How can I express the fact that two readings could be carried out in any order? You can use the monad-parallel package. Your example could be written as import qualified Monad.Parallel as MP age :: IO () age = do (i, j) - MP.liftM2 (,) (readIntFrom a) (readIntFrom b) writeTo a (i-j) writeTo b (j-i) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Making monadic code more concise
On Mon, Nov 15, 2010 at 6:43 PM, Ling Yang ly...@cs.stanford.edu wrote: ... One alternate way of doing this, however, is instancing the typeclasses of the ordinary values with their monadic versions: instance (Num a) = Num (Prob a) where (+) = liftM2 (+) (*) = liftM2 (*) abs = liftM abs signum = liftM signum fromInteger = return . fromInteger instance (Fractional a) = Fractional (Prob a) where fromRational = return . fromRational (/) = liftM2 (/) You may also like to look at Conal Elliott's applicative-numbers package: http://hackage.haskell.org/package/applicative-numbers Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Making monadic code more concise
I like your autolifting stuff, and the runnable concept. 2010/11/15 Ling Yang ly...@cs.stanford.edu See my reply to Alex's post for my perspective on how this relates to applicative functors, reproduced here: This, to me, is a big hint that applicative functors could be useful. Indeed, the ideas here also apply to applicative functors; it is just the lifting primitives that will be different; instead of having liftMN, we can use $ and * to lift the functions. We could have done this for Num and Maybe (suppose Maybe is an instance of Applicative): instance (Num a) = Num (Maybe a) where (+) = \x y - (+) $ x * y (-) = \x y - (-) $ x * y (*) = \x y - (+) $ x * y abs = abs $ signum = signum $ fromInteger = pure . fromInteger The larger goal remains the same: autolifting in a principled manner. However, you actually bring up a very good point; what if it is really only the applicative functors that this method works on in general, that there is no 'use case' for considering this autolifting for monads in particular? I think the answer lies in the fact that monads can be 'flattened;' that is, realizations of the type m (m a) - m a are mechanical (in the form of 'join') given that = is defined. This is important when we have a typeclass that also has monadic signatures. To be more concrete, consider how this function could be used in a 'monadic DSL': enter x = case x of 0 - Nothing _ - Just hi The type of 'enter' is one case of the general from 'a - M b'. If we were instancing a typeclass that had an 'a - M b' function, we'd need a function of type 'M a - M b'. This would be accomplished by enter' = join . liftM enter So the set of lifting primitives must include at least some way to get M a - M b from 'a - M b'---which requires that M is a monad, not just an applicative functor. Thanks for the mention of applicative functors; I should have included them in the original post. Lingfeng Yang lyang at cs dot stanford dot edu I should have included a mention of Applicative in my original post. Part of the reason Num was so easy is that all the functions produce values whose type is the class parameter. Your Num instance could almost be completely generic for any ((Applicative f, Num a) = f a), except that Num demands instances of Eq and Show, neither of which can be blindly lifted the way the numeric operations can. I imagine it should be fairly obvious why you can't write a non-trivial generic instance (Show a) = Show (M a) that would work for any possible monad M--you'd need a function (show :: M a - String) which is impossible for abstract types like IO, as well as function types like the State monad. The same applies to (==), of course. Trivial instances are always possible, e.g. show _ = [not showable], but then you don't get sensible behavior when a non-trivial instance does exist, such as for Maybe or []. Good point. This is where we can start defining restrictions for when this automatic lifting can or cannot take place. I reference the concept of 'runnable monads' here, from [Erwig and Ren 2004] Monadification of Functional Programs A 'runnable monad' is a monad with an exit function: class (Monad m) = Runnable m where exit : m a - a And yes, for monads like IO, no one would really have a need for 'exit' outside of the cases where they need unsafePerformIO. However, for Maybe and Prob, 'exit' is extremely useful. In fact, in the probability monad, if you could not exit the monad, you could not get anything done, as the real use is around sampling and computing probabilities, which are of non-monadic types. Provided M is a runnable monad, class (Show a) = Show (M a) where show = show . exit I'm aware of the limitations of this approach; I just want to come up with a set of primitives that characterize the cases where autolifting/monadic instancing is useful. On Mon, Nov 15, 2010 at 11:19 AM, C. McCann c...@uptoisomorphism.net wrote: On Mon, Nov 15, 2010 at 12:43 PM, Ling Yang ly...@cs.stanford.edu wrote: Specifically: There are some DSLs that can be largely expressed as monads, that inherently play nicely with expressions on non-monadic values. We'd like to use the functions that already work on the non-monadic values for monadic values without calls to liftM all over the place. It's worth noting that using liftM is possibly the worst possible way to do this, aesthetically speaking. To start with, liftM is just fmap with a gratuitous Monad constraint added on top. Any instance of Monad can (and should) also be an instance of Functor, and if the instances aren't buggy, then liftM f = (= return . f) = fmap f. Additionally, in many cases readability is improved by using ($), an operator synonym for fmap, found in Control.Applicative, I believe. The probability monad is a good example.
Re: [Haskell-cafe] Ralf Laemmel's riddle on surviving without the monad transformation library
I haven't watched the lecture. But what does he mean survive? Does it mean to do anything that you can do with mtl? On Mon, Nov 15, 2010 at 12:53 AM, C K Kashyap ckkash...@gmail.com wrote: Hi, Can someone provide me the solution to the following riddle that Ralf asked in his lecture at http://channel9.msdn.com/Shows/Going+Deep/C9-Lectures-Dr-Ralf-Lmmel-Advanced-Functional-Programming-Evolution-of-an-Interpreter Riddle: define a custom made monad (only involving (-) and Either String) to survive without the monad transformation library. -- Regards, Kashyap ___ 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] Error handling with safer-file-handling
On Sun, Nov 14, 2010 at 12:38 PM, Florian Weimer f...@deneb.enyo.de wrote: How am I supposed to write an exception handle for an invocation of System.IO.SaferFileHandles.openFile? Currently, I have got this: case req of Open path - do handle -openFile (asAbsPath path) ReadMode liftIO $ forcePut result Success run handle Follwing safer-file-handling-examples, I rewrote it to: case req of Open path - do (do runRegionT $ do handle -openFile (asAbsPath path) ReadMode liftIO $ forcePut result Success run handle) `catch` \(e :: IOException) - do liftIO $ forcePut result $ Failure $ show e (I would rather like to apply the handler to the openFile invocation only, but the above matches the example code more closely.) You should be able to apply 'catch' directly to the openFile invocation. Do note that a RegionT doesn't have an instance for MonadCatchIO anymore. In regions-0.8[1] I switched to using MonadPeelIO from monad-peel[2] instead. So import 'catch' from Control.Exception.Peel. But this gives me a nice error message: Handles.hs:48:17: Could not deduce (Control.Monad.CatchIO.MonadCatchIO (RegionT s IO)) from the context () arising from a use of `catch' at Handles.hs:(48,17)-(54,50) Possible fix: add (Control.Monad.CatchIO.MonadCatchIO (RegionT s IO)) to the context of the polymorphic type `forall s. RegionT s pr α' or add an instance declaration for (Control.Monad.CatchIO.MonadCatchIO (RegionT s IO)) In the expression: do { (do { runRegionT $ do { handle - openFile (asAbsPath path) ReadMode; } }) } `catch` \ (e :: IOException) - do { liftIO $ forcePut result $ Failure $ show e } In a case alternative: Open path - do { (do { runRegionT $ do { ... } }) } `catch` \ (e :: IOException) - do { liftIO $ forcePut result $ Failure $ show e } In the expression: case req of { Open path - do { (do { runRegionT $ ... }) } `catch` \ (e :: IOException) - do { ... } Close - return () _ - liftIO $ forcePut result $ Failure handle not open } safer-file-handling-examples results in similar error messages, after applying the s/runTopRegion/runRegionT/ fix. Thanks for reporting this! I forgot to update the safer-file-handles-examples[3]. They should be fine now. Regards, Bas [1] http://hackage.haskell.org/package/regions-0.8 [2] http://hackage.haskell.org/package/monad-peel-0.1 [3] darcs get http://code.haskell.org/~basvandijk/code/safer-file-handles-examples ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: dynamic loading of code on windows
Hello Arnaud, I also faced this problem with the plugins package. This particular error comes from the backslashes in the ghc library directory not being escaped. But even after patching this, I had trouble with missing imports and some other stuff. It seams that this package is not much used/tested under Windows. At the end I gave up using it and switched to hint (like Alberto pointed out before). Mathias Am 13.11.2010 19:41, schrieb Arnaud Bailly: Hello again, So I followed Kevin's suggestion and installed MinGW along with gcc and autoconf tools needed by hs-plugins. Then it failed with the following error: $ cabal install --enable-documentation plugins Resolving dependencies... Configuring plugins-1.5.1.4... checking build system type... i686-pc-mingw32 checking for ghc... ghc checking for value of __GLASGOW_HASKELL__... 612 checking for ghc library directory... D:\Program Files\Haskell Platform\2010.2.0 .0\lib checking for gcc... gcc checking for C compiler default output file name... a.exe checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... .exe checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ANSI C... none needed checking for arc4random... no checking for a BSD-compatible install... /usr/bin/install -c configure: creating ./config.status config.status: creating config.mk config.status: creating testsuite/makewith/io/TestIO.conf config.status: creating testsuite/makewith/unsafeio/Unsafe.conf config.status: creating config.h Preprocessing library plugins-1.5.1.4... Building plugins-1.5.1.4... [ 1 of 12] Compiling System.Plugins.Process ( src\System\Plugins\Process.hs, dis t\build\System\Plugins\Process.o ) [ 2 of 12] Compiling System.Plugins.Parser ( src\System\Plugins\Parser.hs, dist\ build\System\Plugins\Parser.o ) [ 3 of 12] Compiling System.Plugins.LoadTypes ( src\System\Plugins\LoadTypes.hs, dist\build\System\Plugins\LoadTypes.o ) [ 4 of 12] Compiling System.Plugins.Consts ( src\System\Plugins\Consts.hs, dist\ build\System\Plugins\Consts.o ) src\System\Plugins\Consts.hs:39:22: lexical error in string/character literal at character 'P' cabal.exe: Error: some packages failed to install: plugins-1.5.1.4 failed during the building phase. The exception was: ExitFailure 1 Any clues? Should I try to use latest source tree? I am really interested in the plugins approach, rather than the interpreter approach. What I am trying to achieve is a system similar to Yi as presented in Don Stewart's paper (http://www.cse.unsw.edu.au/~dons/papers/yi.pdf), but much simpler, of course. The system would load modules as found in some known location, run tests found here before really accepting them, then use them, with the possibility of replacing those modules when a newer version is found. The idea is to provide a self-tested and continuously running system for development, something that might be reminiscent of Smalltalk although I never programmed in Smalltalk. Thanks in advance for advises, REgards, Arnaud On Fri, Nov 12, 2010 at 8:49 PM, Alberto G. Corona agocor...@gmail.com wrote: I use Hint for the same purpose. It has been tested under windows 2010/11/12 Arnaud Bailly arnaud.oq...@gmail.com Hello Kevin, Thanks. I understand that this is a toolchain issue, I just got used to the nice feeling of having 'cabal install foo' works seamlessly and flawlessly to get me some magic piece of software :-) I will try to be more patient and try to setup a proper toolchain for installing plugins package. Arnaud On Fri, Nov 12, 2010 at 7:01 PM, Kevin Jardine kevinjard...@gmail.com wrote: This isn't about the plugin functionality, it's about compiling code. As the message says : This requires a Unix compatibility toolchain such as MinGW+MSYS or Cygwin. You'll find that you need such a toolchain to compile much open source software, including many Haskell modules, on Windows. Personally I use MinGW+MSYS on my Windows machine. It works very well. Kevin On Nov 12, 3:20 pm, Arnaud Bailly arnaud.oq...@gmail.com wrote: Hello, I recently tried to cabal install plugins on a windows box and it failed with the following error: Resolving dependencies... Downloading plugins-1.5.1.4... Configuring plugins-1.5.1.4... cabal: The package has a './configure' script. This requires a Unix compatibility toolchain such as MinGW+MSYS or Cygwin. cabal: Error: some packages failed to install: plugins-1.5.1.4 failed during the configure step. The exception was: ExitFailure 1 What solution can I use to load dynamically code in a cross-platform way ? Thanks in advance Arnaud ___ Haskell-Cafe mailing list
Re: [Haskell-cafe] Bracket around every IO computation monad
Hi! On Mon, Nov 15, 2010 at 9:07 PM, C. McCann c...@uptoisomorphism.net wrote: Isn't this mostly a reimplementation of mapM? Given a list of [IO Growable], you map over it to put a bracket around each one, then sequence the result No. There is a trick. It stacks up attach and deattach. So if for third attach something fails then both deattach for second and first nerve is called. In your example this would not happen. So the idea is that in a case of an error all computations (which are of some type class which defines necessary prepare and cleanup functions) are unwinded. In a case of success the resulting list is returned. Mitar ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Bracket around every IO computation monad
Hi! Felipe and Bas, thank you for your suggestions. They really opened two new worlds to me. ;-) I didn't know about those libraries. I was hopping of succeeding making a bracketing monad by hand, to learn something and to make my first monad. But was not successful. I hope those approaches with libraries will be a good guide to me. Mitar ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Bracket around every IO computation monad
On Mon, Nov 15, 2010 at 9:44 PM, Mitar mmi...@gmail.com wrote: I was hopping of succeeding making a bracketing monad by hand, to learn something and to make my first monad. But was not successful. I hope those approaches with libraries will be a good guide to me. My approach using 'operational' package is equivalent to creating your own monad. The beauty of 'operational' is that you don't need to worry about the pumbling of the monad, you just need to specify what to do with your operations. That said, I don't know what 'regions' may do for you that the simple monad I presented doesn't. Bas, what are the advantages? As one disadvantage, I'd say that using regions sound more complicated than just using 'operational' =). Cheers! =D -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Bracket around every IO computation monad
Hi! My approach using 'operational' package is equivalent to creating your own monad. The beauty of 'operational' is that you don't need to worry about the pumbling of the monad, you just need to specify what to do with your operations. True. Approach with operational is really beautiful. And it is really great when you want things done. But for me, Haskell novice who wants to learn more, it hides too much. So it is probably something I would use in my code, but on the other hand I would like an exercise of doing things by hand. So first 100 monads by hand and then such libraries are useful, but also you exactly understand what are they doing - what are they automating, which process you have been doing by hand before. So thank you for your approach. I didn't know that this can be automated in so elegant way. Mitar ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is there any way to prevent a computation from being shared?
On Mon, Nov 15, 2010 at 11:27 PM, Brian Bloniarz brian.bloni...@gmail.com wrote: So I think you're seeing bug http://hackage.haskell.org/trac/ghc/ticket/917 where the increased sharing only leads to space leaks. You could try the workaround, passing -fno-full-laziness (it might need to come after -O on the command line). I'm not sure if this'd be more or less fragile than disabling inlining as Felipe suggested. I'd also suggest adding yourself as a CC: on bug 917 so GHC HQ knows how many people are being affected by this kind of behavior. Hope this helps, -Brian Thank you a lot, that is definitely it. I still reckon it would not be resolved anytime soon :( -- Regards, Petr ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Bracket around every IO computation monad
On Mon, Nov 15, 2010 at 10:15 PM, Mitar mmi...@gmail.com wrote: True. Approach with operational is really beautiful. And it is really great when you want things done. But for me, Haskell novice who wants to learn more, it hides too much. So it is probably something I would use in my code, but on the other hand I would like an exercise of doing things by hand. So first 100 monads by hand and then such libraries are useful, but also you exactly understand what are they doing - what are they automating, which process you have been doing by hand before. That's true, doing it yourself manually helps to see that there's no magic under the hood =). After implementing the monad, I would suggest trying to prove that the monad laws hold [1]. Sometimes you think you have a monad but you don't [2]. [1] http://www.haskell.org/haskellwiki/Monad_Laws [2] http://blog.sigfpe.com/2006/11/why-isnt-listt-monad.html Cheers! -- Felipe. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Bracket around every IO computation monad
On Nov 15, 2010, at 4:15 PM, Mitar wrote: True. Approach with operational is really beautiful. And it is really great when you want things done. But for me, Haskell novice who wants to learn more, it hides too much. So it is probably something I would use in my code, but on the other hand I would like an exercise of doing things by hand. Check out: http://apfelmus.nfshost.com/articles/operational-monad.html It's the paper that inspired the operational module.___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Bracket around every IO computation monad
On Tue, Nov 16, 2010 at 12:50 AM, Felipe Almeida Lessa felipe.le...@gmail.com wrote: That said, I don't know what 'regions' may do for you that the simple monad I presented doesn't. Bas, what are the advantages? My suggestion to use regions is based on an assumption which I'm not sure is right. Mitar can answer that... The assumption being that Mitar's Nerves are scarce resources (like files for example). Meaning: 1) They have an 'open' operation yielding a 'handle' to the 'resource': attach :: Nerve n - IO (LiveNeuron n) Compare this with: openFile :: FilePath - IOMode - IO Handle 2) There are one or more operations defined on these handles: someOperation :: LiveNeuron n - IO () (I'm not sure Mitar actually has this...) Compare this with: hFileSize :: Handle - IO Integer 3) They have a 'close' operation: deattach :: LiveNeuron n - IO () Compare with: hClose :: Handle - IO () 4) It's important not to leave handles open (or in this case leave nerves attached) when they don't need to be. In the case of files when you leave a file open when you're not using it anymore, other processes may not be able to use the file. (I'm not sure this is a requirement for Nerves...) 5) It's an error to apply the operations to closed handles. In the case of files, the following program is an error for example: main = do h - openFile foo.txt ReadMode hClose h hFileSize h -- error: h is already closed! (Again, I'm not sure a similar requirement exists for LiveNeurons) When these five requirements apply, you may find the regions package useful. When you write a correct 'regional' layer around your scarce resources like I showed earlier, regions will provide the following guarantees: * Resources are opened in a 'region'. When the region terminates (whether normally or by raising an exception) all opened resources will be closed automatically (this was Mitar's original requirement) * It's a type-error to reference closed resources. This ensures no operations can be applied to closed resources (deattached neurons). Besides these guarantees the regions package is very expressive. It allows you to nest regions inside each other and it allows you to 'duplicate' handles to ancestor regions. This allows you to use a resource, which was opened in a nested region, in the parent of that region, as in: example :: IO () example = runRegionT $ do sn' - runRegionT $ do sn - saveAttach Nerve -- We can't 'return sn' because the neuron will be deattached -- when the regions terminates. -- Instead we have to 'duplicate' it which ensures it stays -- attached in the current region and will only be deattached -- in the parent region: sn' - dup sn return sn' -- Back in the parent region we can safely apply some operation -- to the duplicated neuron: someSaveOperation sn' To read more about regions, see both the API docs of regions: http://hackage.haskell.org/package/regions and some packages that define 'regional' layers over existing scarce resources like: * http://hackage.haskell.org/package/safer-file-handles * http://hackage.haskell.org/package/regional-pointers * http://hackage.haskell.org/package/usb-safe Finally, I can also recommend Oleg's and Chung-chieh's paper about Lightweight monadic regions: http://okmij.org/ftp/Haskell/regions.html#light-weight Regards, Bas P.S. Please apply /s/save/safe to my previously posted code. It's late... ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Ralf Laemmel's riddle on surviving without the monad transformation library
On Tue, Nov 16, 2010 at 3:58 AM, Luke Palmer lrpal...@gmail.com wrote: I haven't watched the lecture. But what does he mean survive? Does it mean to do anything that you can do with mtl? Yes ... to understand monad transformers better, he suggested trying to wrap a monad inside another (I am not sure if I am saying it correctly) without using mtl. -- Regards, Kashyap ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] typeclass namespace rational?
cafe, Data Constructors and Type Constructors don't share the same namespace. You see code like the following all the time: data MyRecord = MyRecord {...} This is possible because Data Constructors are used in different parts of the code than Type Constructors so there's never any ambiguity. Type Classes, on the other hand, share the same namespace as Type Constructors. You can't define this: class String s where ... instance String String where ... instance String ByteString where ... instance String Text where ... Not that I'm running out of valid haskell identifiers or anything :P, I'm just wondering: what's the rationale behind keeping Type Classes and Type Constructors in the same namespace? I can't think of any ambiguity there would be if they each had their own namespace. And In some cases it would be convenient to be able to define both a concrete representation and an abstract one with the same name as in the String class example above. --Jonathan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: typeclass namespace rational?
2 seconds after sending I realized the issue is in module exports: Module String where (String(..)) is that exporting some concrete ADT with all of its constructors or an abstract type class with all of its methods? Its too bad that Classes and ADTs overlap in export syntax and as such must share a namespace. I would much prefer Module String where (class String(..), data String(..), someOtherFunction) which I think is easier for the reader anyway. --Jonathan On Mon, Nov 15, 2010 at 8:31 PM, Jonathan Geddes geddes.jonat...@gmail.com wrote: cafe, Data Constructors and Type Constructors don't share the same namespace. You see code like the following all the time: data MyRecord = MyRecord {...} This is possible because Data Constructors are used in different parts of the code than Type Constructors so there's never any ambiguity. Type Classes, on the other hand, share the same namespace as Type Constructors. You can't define this: class String s where ... instance String String where ... instance String ByteString where ... instance String Text where ... Not that I'm running out of valid haskell identifiers or anything :P, I'm just wondering: what's the rationale behind keeping Type Classes and Type Constructors in the same namespace? I can't think of any ambiguity there would be if they each had their own namespace. And In some cases it would be convenient to be able to define both a concrete representation and an abstract one with the same name as in the String class example above. --Jonathan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Error installing hp2any-graph on Snow Leopard
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 On 11/8/10 04:52 , Ivan Lazar Miljenovic wrote: I'm not sure how MacPorts does packaging, so you may require to install a -dev or development version of glut to get the relevant headers and library files. MacPorts always builds from source, so always installs libraries with their development headers and libraries. A -devel package in MacPorts is usually the latest alpha/beta release of the corresponding non-devel package. - -- brandon s. allbery [linux,solaris,freebsd,perl] allb...@kf8nh.com system administrator [openafs,heimdal,too many hats] allb...@ece.cmu.edu electrical and computer engineering, carnegie mellon university KF8NH -BEGIN PGP SIGNATURE- Version: GnuPG v2.0.10 (Darwin) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkziAKkACgkQIn7hlCsL25VB4ACgr02BjAcI9m0Ju7jYzxE8W63V Er8AmgJ4FyO2SbGBBffyYRDeyOXdrUDw =gKN1 -END PGP SIGNATURE- ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: dynamic loading of code on windows
OK, here is a short summary: - installed MinGW + GCC 4.5 toolchain - downloaded latest code from darcs - Run ./Setup.lhs configure - got another failure Setup.lhs:2:2: Warning: In the use of `defaultUserHooks' (imported from Distribution.Simple): Deprecated: Use simpleUserHooks or autoconfUserHooks, unless you need Cabal compatibility in which case you must stick with defaultUserHooks Warning: plugins.cabal: The field hs-source-dir is deprecated, please use hs-source-dirs Warning: defaultUserHooks in Setup script is deprecated. Configuring plugins-1.0... Warning: No 'build-type' specified. If you do not need a custom Setup.hs or ./configure script then use 'build-type: Simple'. checking build system type... i686-pc-mingw32 checking for ghc... ghc checking for value of __GLASGOW_HASKELL__... 612 checking for ghc library directory... D:\Program Files\Haskell Platform\2010.2.0.0\lib checking for tex... tex checking for tex2page... no configure: WARNING: tex2page is needed to build some of the documentation http://www.ccs.neu.edu/home/dorai/tex2page/tex2page-doc.html checking for gcc... gcc checking for C compiler default output file name... a.exe checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... .exe checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ANSI C... none needed checking for arc4random... no checking for a BSD-compatible install... /usr/bin/install -c configure: creating ./config.status config.status: creating config.mk config.status: creating testsuite/makewith/io/TestIO.conf config.status: creating testsuite/makewith/unsafeio/Unsafe.conf config.status: creating config.h config.status: config.h is unchanged Setup.lhs: Missing dependency on a foreign library: * Missing header file: Linker.h This problem can usually be solved by installing the system package that provides this library (you may need the -dev version). If the library is already installed but in a non-standard location then you can use the flags --extra-include-dirs= and --extra-lib-dirs= to specify where it is. So it seems really I will have to 1) fix this myself or 2) gave up. I would really like to go for 1) but my knowledge of GHC's internals is rather limited, so I must stick with 2). I will try to adapt hint. I have one question regarding hint: does it handle reloading of modules? Thanks a lot for the various answers so far, Best regards, Arnaud On Mon, Nov 15, 2010 at 11:45 PM, Mathias Weber mat_we...@t-online.de wrote: Hello Arnaud, I also faced this problem with the plugins package. This particular error comes from the backslashes in the ghc library directory not being escaped. But even after patching this, I had trouble with missing imports and some other stuff. It seams that this package is not much used/tested under Windows. At the end I gave up using it and switched to hint (like Alberto pointed out before). Mathias Am 13.11.2010 19:41, schrieb Arnaud Bailly: Hello again, So I followed Kevin's suggestion and installed MinGW along with gcc and autoconf tools needed by hs-plugins. Then it failed with the following error: $ cabal install --enable-documentation plugins Resolving dependencies... Configuring plugins-1.5.1.4... checking build system type... i686-pc-mingw32 checking for ghc... ghc checking for value of __GLASGOW_HASKELL__... 612 checking for ghc library directory... D:\Program Files\Haskell Platform\2010.2.0 .0\lib checking for gcc... gcc checking for C compiler default output file name... a.exe checking whether the C compiler works... yes checking whether we are cross compiling... no checking for suffix of executables... .exe checking for suffix of object files... o checking whether we are using the GNU C compiler... yes checking whether gcc accepts -g... yes checking for gcc option to accept ANSI C... none needed checking for arc4random... no checking for a BSD-compatible install... /usr/bin/install -c configure: creating ./config.status config.status: creating config.mk config.status: creating testsuite/makewith/io/TestIO.conf config.status: creating testsuite/makewith/unsafeio/Unsafe.conf config.status: creating config.h Preprocessing library plugins-1.5.1.4... Building plugins-1.5.1.4... [ 1 of 12] Compiling System.Plugins.Process ( src\System\Plugins\Process.hs, dis t\build\System\Plugins\Process.o ) [ 2 of 12] Compiling System.Plugins.Parser ( src\System\Plugins\Parser.hs, dist\ build\System\Plugins\Parser.o ) [ 3 of 12] Compiling System.Plugins.LoadTypes ( src\System\Plugins\LoadTypes.hs, dist\build\System\Plugins\LoadTypes.o ) [ 4 of 12] Compiling System.Plugins.Consts ( src\System\Plugins\Consts.hs, dist\ build\System\Plugins\Consts.o ) src\System\Plugins\Consts.hs:39:22:
Re: [Haskell-cafe] Re: Updating Haskell Packages through Archlinux becoming A Pain
Personally I gave up on installing haskell packages through AUR, I pretty much stick to Cabal now. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: typeclass namespace rational?
If I were to guess, I'd say it's because there are two major spaces in Haskell, the type level and the value level. They never interact directly (their terms are never juxtaposed) so there's not much chance for confusion. Typeclass constructors and type constructors do however live in the same space. The fact that you propose instance String String might be odd to some. It's still unambiguous, but isn't necessarily the most clear: (with higher-sorted kind polymorphism, MPTCs, type families, and GADTs) instance String String String String String where data String String String String String where String :: String String String String String :-) On Mon, Nov 15, 2010 at 10:37 PM, Jonathan Geddes geddes.jonat...@gmail.com wrote: 2 seconds after sending I realized the issue is in module exports: Module String where (String(..)) is that exporting some concrete ADT with all of its constructors or an abstract type class with all of its methods? Its too bad that Classes and ADTs overlap in export syntax and as such must share a namespace. I would much prefer Module String where (class String(..), data String(..), someOtherFunction) which I think is easier for the reader anyway. --Jonathan On Mon, Nov 15, 2010 at 8:31 PM, Jonathan Geddes geddes.jonat...@gmail.com wrote: cafe, Data Constructors and Type Constructors don't share the same namespace. You see code like the following all the time: data MyRecord = MyRecord {...} This is possible because Data Constructors are used in different parts of the code than Type Constructors so there's never any ambiguity. Type Classes, on the other hand, share the same namespace as Type Constructors. You can't define this: class String s where ... instance String String where ... instance String ByteString where ... instance String Text where ... Not that I'm running out of valid haskell identifiers or anything :P, I'm just wondering: what's the rationale behind keeping Type Classes and Type Constructors in the same namespace? I can't think of any ambiguity there would be if they each had their own namespace. And In some cases it would be convenient to be able to define both a concrete representation and an abstract one with the same name as in the String class example above. --Jonathan ___ 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] Re: Updating Haskell Packages through Archlinux becoming A Pain
Yeah I used to do that as well, but then that kind of fails on packages that provides both libraries and binaries (and other issues as well) On 16/11/2010 4:53 PM, James Sanders jimmyjaz...@gmail.com wrote: Personally I gave up on installing haskell packages through AUR, I pretty much stick to Cabal now. ___ 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] Quasiquoter invocation no longer requires/allows a leading dollar sign.
I'm guessing this did *not* make it into 7.0.1, correct? Is there still a chance that it will be in 7.0.2, and therefore the next HP release? Michael On Fri, Nov 12, 2010 at 10:38 AM, Simon Peyton-Jones simo...@microsoft.com wrote: Good point. I've done this. (Ian, could you merge) Fri Nov 12 08:30:52 GMT 2010 simo...@microsoft.com * Allow the old [$foo| ... |] syntax for quasi-quotes This is just a backward-compatibility thing, to be removed eventually. Simon | -Original Message- | From: haskell-cafe-boun...@haskell.org [mailto:haskell-cafe-boun...@haskell.org] On | Behalf Of Michael Snoyman | Sent: 11 November 2010 22:08 | To: Haskell Cafe | Subject: [Haskell-cafe] Quasiquoter invocation no longer requires/allows a leading | dollar sign. | | Sorry, maybe I missed the memo on this one, but I just noticed this | change to quasi-quotation syntax on the GHC 7 upgrade page[1]. So if | GHC 6.12 *requires* the dollar sign, and GHC 7 *rejects* the dollar | sign, is there any way to write code that will run on both? Is there a | reason we can't keep the dollar sign as supported syntax for a release | or two to make for a cleaner migration? | | Michael | | [1] | http://haskell.org/haskellwiki/Upgrading_packages/Updating_to_GHC_7#Quasiquotation:_. | 5B.24foo.7C7C.5D_-.3E_.5Bfoo.7C7C.5D | ___ | 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] Re: Updating Haskell Packages through Archlinux becoming A Pain
On Sun, Nov 14, 2010 at 00:32, Mathew de Detrich dete...@gmail.com wrote: This is an example of what happens Proceed with installation? [Y/n] Y checking package integrity... (1/1) checking for file conflicts [##] 100% ghc-pkg: unregistering gio-0.11.1 would break the following packages: ltk-0.8.0.8 gtksourceview2-0.12.1 gtk-0.11.2 (use --force to override) error: command failed to execute correctly (1/1) upgrading haskell-gio [##] 100% Reading package info from stdin ... done. In other words, pacman still syncs the package (puts the files on the system) and causes GHC to break, and if you do this for a big update, you have to manually go through and fix it all May I suggest you post this to the arch-haskell mailinglist[1] instead? The team managing the haskell packages on AUR are more likely to take note of your bug report if it's posted there. /M [1]: http://www.haskell.org/mailman/listinfo/arch-haskell -- 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