From alpmestan at gmail.com Sun Jun 1 06:36:24 2014 From: alpmestan at gmail.com (Alp Mestanogullari) Date: Sun, 1 Jun 2014 08:36:24 +0200 Subject: [Haskell-cafe] MacOS testing? In-Reply-To: References: Message-ID: Ian, I am running OS X, so let me know if I can run some programs or tests for you. Le 31 mai 2014 12:44, "Ian Ross" a ?crit : > Hi all, > > Does anyone know of a good solution for MacOS testing that doesn't cost > much? (Ideally, that costs nothing...) I've been getting a lot of > MacOS-specific issues on the C2HS that I maintain and, since I don't have a > Mac myself, testing and fixing these things is a bit of a problem. There > is no equivalent of Amazon's EC2 for MacOS. There are some hosting > services out there, but they're not all that practical, since they cost, > they're set up for continuous hosting rather than intermittent use for > bug-fixing, and you can't save a machine image snapshot once you've > installed all the software you need (as you can on AWS) so you either need > to keep your instance running or reinstall everything every time you want > to test something. > > Any ideas? The only thought I've had so far was to try to do something > horrible using Travis (Kiwamu Okabe has some slides about building and > testing Haskell code on Travis: > http://www.slideshare.net/master_q/20131109-kof2013-travisciosx). That's > not a good solution for debugging though. > > Thanks for any thoughts you might have, > > Ian. > > -- > Ian Ross Tel: +43(0)6804451378 ian at skybluetrades.net > www.skybluetrades.net > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From capn.freako at gmail.com Mon Jun 2 01:40:31 2014 From: capn.freako at gmail.com (David Banas) Date: Sun, 1 Jun 2014 18:40:31 -0700 Subject: [Haskell-cafe] Haskell jobs in the Silicon Valley? Message-ID: <38DE4CF7-65D8-460A-A4EE-FD3D8A8942D4@gmail.com> Hi all, Just pinging to see if anyone knows of a Haskell job opening in the Silicon Valley. Thanks, -db From john at repetae.net Mon Jun 2 18:47:23 2014 From: john at repetae.net (John Meacham) Date: Mon, 2 Jun 2014 11:47:23 -0700 Subject: [Haskell-cafe] ANNOUNCE: jhc 0.8.2 Message-ID: Lots of internal improvements in this one, so may be of more interest to developers http://repetae.net/computer/jhc/ - completely replaced the front end parser/lexer with a new more flexible one. My rewritten one is about 3,250 lines shorter. - The new one uses a general precedence parser for application as well as infix operators, allowing consistent handling of bang, irrefutable, and @ patterns and allows prefix and infix operators with a higher precedence than application to be defined. Incidentally, this allows for ~ and @ in expressions. (~) = negate (prefixr 11) gives us a nice strongly binding negative and @ (infixr 12) is perfect for type directed name resolution without further overloading the humble dot. they parse exactly the same as they do in patterns so no new magic is being added to the symbols other than allowing them in expressions. - Layout algorithm is fully in the lexer now, no lexer/parser interaction needed and useful transformations happen between the two simplifying the parser. - updated a lot of the external libraries to new versions - improvements to the build based on feedback, now gives much better error messages about what went wrong. - include an experimental utility to automatically download 3rd party packages from hackage and install them, it has some kinks, but even if it can't do it automatically, it provides a template for easily modifying the package to work. - removed the last of the cabal-cruft from the library build system. - fixed a lot of bugs relating to errors not being caught early by jhc so they produce a cryptic message from the compiler later, attach source location to more errors for better reporting. - ghc 7.8 compatibilty contributed by others. (thanks!) - infix type constructor extension supported - field punning extension now supported - new option -fno-sugar to turn off all desugaring that would introduce any hidden dependencies, all literals are unboxed under it. WYSIWYG. - unboxed kinds now more general, work in more places - record field names may overlap - more efficient binary representation using LEB128 - Data.String added with mild magic. -- John Meacham - http://notanumber.net/ From nikita at karetnikov.org Mon Jun 2 20:31:14 2014 From: nikita at karetnikov.org (Nikita Karetnikov) Date: Tue, 03 Jun 2014 00:31:14 +0400 Subject: [Haskell-cafe] Happstack: moving the uploaded file Message-ID: <87ppirkq99.fsf@karetnikov.org> I?m trying to create a trivial Happstack application based on the example from the ?File Uploads? section of the Happstack book [1]. It should work as follows: 1. If there is no file called ?foo? on disk, show the upload form at any page. 2. If the file exists, show its contents at ?localhost:8000/file? and the upload form at any other page. The difficulty is that initially the uploaded file is placed to a temporary location, but since I want to read the file later, I have to move it somewhere. ?UploadFile-working.hs? uses two handlers for that, which doesn?t look right. I?d like the code to look like ?UploadFile.hs?, but it doesn?t work properly. Could anyone explain why? [1] http://happstack.com/docs/crashcourse/index.html -------------- next part -------------- A non-text attachment was scrubbed... Name: UploadFile-working.hs Type: text/x-haskell Size: 1694 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: UploadFile.hs Type: text/x-haskell Size: 1265 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 835 bytes Desc: not available URL: From tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Mon Jun 2 21:15:21 2014 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Mon, 2 Jun 2014 22:15:21 +0100 Subject: [Haskell-cafe] Happstack: moving the uploaded file In-Reply-To: <87ppirkq99.fsf@karetnikov.org> References: <87ppirkq99.fsf@karetnikov.org> Message-ID: <20140602211521.GT2054@henry> On Tue, Jun 03, 2014 at 12:31:14AM +0400, Nikita Karetnikov wrote: > I?d like the code to look like ?UploadFile.hs?, but it doesn?t work > properly. Could anyone explain why? Yes, you can't receive the client's request containing the form data in the reponse that sends out the form! > tempFile :: ServerPart Response > tempFile = do > (tmpFile, _, _) <- lookFile "file_upload" > liftIO $ renameFile tmpFile permFileLoc > file <- liftIO $ readFile permFileLoc > showFile file > > permFile :: ServerPart Response > permFile = do > file <- liftIO $ readFile permFileLoc > showFile file Why not merge these with something like (unchecked!) readFile :: ServerPart Response readFile = do flip (<|>) (return ()) $ do (tmpFile, _, _) <- lookFile "file_upload" liftIO $ renameFile tmpFile permFileLoc file <- liftIO $ readFile permFileLoc showFile file Tom From jeremy at n-heptane.com Mon Jun 2 21:55:14 2014 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Mon, 2 Jun 2014 16:55:14 -0500 Subject: [Haskell-cafe] Happstack: moving the uploaded file In-Reply-To: <87ppirkq99.fsf@karetnikov.org> References: <87ppirkq99.fsf@karetnikov.org> Message-ID: You code does not work correctly because what you are trying to do really requires three separate requests. You want the client to be able to: 1. do a GET request to receive the form 2. do a POST request to upload the file 3. do another GET request to view the file after it has been uploaded In UploadFile.hs you have the first two steps merged together in uploadForm. In UploadFile-working -- you have steps 2 and 3 oddly separated and merged at the same time. I have created a modified version that probably does what you want. - jeremy On Mon, Jun 2, 2014 at 3:31 PM, Nikita Karetnikov wrote: > I?m trying to create a trivial Happstack application based on the > example from the ?File Uploads? section of the Happstack book [1]. > It should work as follows: > > 1. If there is no file called ?foo? on disk, show the upload form at any > page. > > 2. If the file exists, show its contents at ?localhost:8000/file? and > the upload form at any other page. > > The difficulty is that initially the uploaded file is placed to a > temporary location, but since I want to read the file later, I have to > move it somewhere. ?UploadFile-working.hs? uses two handlers for that, > which doesn?t look right. I?d like the code to look like > ?UploadFile.hs?, but it doesn?t work properly. Could anyone explain > why? > > [1] http://happstack.com/docs/crashcourse/index.html > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- A non-text attachment was scrubbed... Name: UploadFile-more-correct.hs Type: text/x-haskell Size: 1864 bytes Desc: not available URL: From nikita at karetnikov.org Tue Jun 3 18:05:08 2014 From: nikita at karetnikov.org (Nikita Karetnikov) Date: Tue, 03 Jun 2014 22:05:08 +0400 Subject: [Haskell-cafe] Happstack: moving the uploaded file In-Reply-To: (Jeremy Shaw's message of "Mon, 2 Jun 2014 16:55:14 -0500") References: <87ppirkq99.fsf@karetnikov.org> Message-ID: <8738flkgx7.fsf@karetnikov.org> > I have created a modified version that probably does what you want. Thanks, but it fails when a user tries to access ?/view? before uploading a file. Also, I want the file to be available only at ?/view?. I?ve attached a version that?s based on yours, can it be further improved? For instance, is there a need for ?seeOther?? -------------- next part -------------- A non-text attachment was scrubbed... Name: FileUpload-even-more-correct.hs Type: text/x-haskell Size: 2350 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 835 bytes Desc: not available URL: From nikita at karetnikov.org Tue Jun 3 18:10:48 2014 From: nikita at karetnikov.org (Nikita Karetnikov) Date: Tue, 03 Jun 2014 22:10:48 +0400 Subject: [Haskell-cafe] Happstack: moving the uploaded file In-Reply-To: <8738flkgx7.fsf@karetnikov.org> (Nikita Karetnikov's message of "Tue, 03 Jun 2014 22:05:08 +0400") References: <87ppirkq99.fsf@karetnikov.org> <8738flkgx7.fsf@karetnikov.org> Message-ID: <87vbshj23b.fsf@karetnikov.org> > file <- liftIO $ readFile permFileLoc Sorry, this line is not needed. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 835 bytes Desc: not available URL: From jeremy at n-heptane.com Tue Jun 3 18:31:48 2014 From: jeremy at n-heptane.com (Jeremy Shaw) Date: Tue, 3 Jun 2014 13:31:48 -0500 Subject: [Haskell-cafe] Happstack: moving the uploaded file In-Reply-To: <8738flkgx7.fsf@karetnikov.org> References: <87ppirkq99.fsf@karetnikov.org> <8738flkgx7.fsf@karetnikov.org> Message-ID: On Tue, Jun 3, 2014 at 1:05 PM, Nikita Karetnikov wrote: > > Thanks, but it fails when a user tries to access ?/view? before > uploading a file. Yeah, I didn't bother to implement error handling. > Also, I want the file to be available only at > ?/view?. The version I provided meets that requirement for viewing the file. Perhaps you also want the the POST address to be /view? Ultimately, you need three end points: 1. a url to GET the file 2. a url to POST the file 3. a url that shows the form How you arrange that depends a lot on your design goals and requirements. If you only allow the user to upload the file once, then you could have: 1. GET /view, shows the form if the file does not yet exist 2. POST /view handles the file upload 3. GET /view shows the file if it has been uploaded This does not provide a way to view the form again once the file has been uploaded. You could also do something like; 1. GET /file/upload_form, shows upload form 2. POST /file, handles submission 3. GET /file shows file if it exists, or redirects to /file/upload_form Or.. whatever you want. > I?ve attached a version that?s based on yours, can it be > further improved? For instance, is there a need for ?seeOther?? After the file is upload -- you need to return some sort of Response to the user. One logical choice is to redirect to the client to GET the resource that was just uploaded. In theory, at the end of handleUpload you could call readFile+output directly to show the file. But if the user then refreshes the page, it will attempt to POST the data again. If you have the redirect in there, then when they reload the page, it will simply perform the GET request again. As for 'improving' the code -- I think it mostly comes down to personal taste at this point. - jeremy From trupill at gmail.com Tue Jun 3 19:13:49 2014 From: trupill at gmail.com (Alejandro Serrano Mena) Date: Tue, 3 Jun 2014 21:13:49 +0200 Subject: [Haskell-cafe] Getting list of constructors of a Type Message-ID: Dear Haskell-Caf?, As part of my Google Summer of Code, I need to get the list of data constructors of a certain data type on a specific scenario. In my case, I'm getting a value of type Type (by calling exprType). I was expecting to be able to call getInfo directly on that value of type Type, but it doesn't have a name nor the constructors of Type are public. Thus, I'm not able to get that information :( Thanks in advance, Alejandro -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at nils.cc Tue Jun 3 22:01:18 2014 From: mail at nils.cc (Nils Schweinsberg) Date: Wed, 04 Jun 2014 00:01:18 +0200 Subject: [Haskell-cafe] Getting list of constructors of a Type In-Reply-To: References: Message-ID: <538E45AE.5060306@nils.cc> I'm not sure what exactly you're trying to do, but with Template Haskell it's easy: > test :: Name -> Q [Dec] > test name = do > info <- reify name > ... Then call it from another module with the type name as argument (double single quotes): > data Test = A | B > > test ''Test The `Info` type returned by `reify` is described in: http://hackage.haskell.org/package/template-haskell-2.9.0.0/docs/Language-Haskell-TH-Syntax.html#t:Info - Nils Am 03.06.2014 21:13, schrieb Alejandro Serrano Mena: > Dear Haskell-Caf?, > As part of my Google Summer of Code, I need to get the list of data > constructors of a certain data type on a specific scenario. > In my case, I'm getting a value of type Type (by calling exprType). I > was expecting to be able to call getInfo directly on that value of type > Type, but it doesn't have a name nor the constructors of Type are > public. Thus, I'm not able to get that information :( > > Thanks in advance, > Alejandro > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From john at repetae.net Wed Jun 4 01:29:26 2014 From: john at repetae.net (John Meacham) Date: Tue, 3 Jun 2014 18:29:26 -0700 Subject: [Haskell-cafe] improved jhc manual Message-ID: Hi all, I just wanted to show off the new jhc manual http://repetae.net/computer/jhc/manual.html If anyone has any feedback, that would be great, even better would be patches of course :) Manual writing is not my strong point. The entire manual is in the darcs repo as markdown formatted files or as literate code embedded in the source files. Something I need to figure out is how to get haddock to not barf on jhc's input files. A problem with haddock is that it tries to replicate ghc's module chasing algorithm and falls down when anything is slightly off, jhc's ability to handle recursive modules throws it for a loop. Now I can easily get jhc to spit out fully resolved module names, it does so with the --annotate-source option, but need some sort of hook into haddock saying "don't try to resolve module names, here they all are." Even haddock just having a 'keep going' option would be great to get something out there. Or even improving haddock to handle recursive module imports. John -- John Meacham - http://notanumber.net/ From andrew.gibiansky at gmail.com Wed Jun 4 04:54:06 2014 From: andrew.gibiansky at gmail.com (Andrew Gibiansky) Date: Tue, 3 Jun 2014 21:54:06 -0700 Subject: [Haskell-cafe] Getting list of constructors of a Type In-Reply-To: <538E45AE.5060306@nils.cc> References: <538E45AE.5060306@nils.cc> Message-ID: Alejandro, If I understand correctly, you're using the InteractiveEval module from the GHC API. That module exposes a very specific interface, and sometimes you'll need to do things beyond that - my approach has then been to look at the implementation of these things, copy/paste code, and follow the types. This will take you through other modules like HscTypes and so on, but you might be able to figure out how to do what you want. The GHC source code isn't great, but is fairly understandable if you stare at it for long enough. I also very highly encourage you to document what you did on the wiki page for GHC API. The GHC API is in **dire** need of more explained example code using it. -- Andrew On Tue, Jun 3, 2014 at 3:01 PM, Nils Schweinsberg wrote: > I'm not sure what exactly you're trying to do, but with Template Haskell > it's easy: > > test :: Name -> Q [Dec] >> test name = do >> info <- reify name >> ... >> > > Then call it from another module with the type name as argument (double > single quotes): > > data Test = A | B >> >> test ''Test >> > > The `Info` type returned by `reify` is described in: > > http://hackage.haskell.org/package/template-haskell-2.9. > 0.0/docs/Language-Haskell-TH-Syntax.html#t:Info > > > - Nils > > Am 03.06.2014 21:13, schrieb Alejandro Serrano Mena: > >> Dear Haskell-Caf?, >> As part of my Google Summer of Code, I need to get the list of data >> constructors of a certain data type on a specific scenario. >> In my case, I'm getting a value of type Type (by calling exprType). I >> was expecting to be able to call getInfo directly on that value of type >> Type, but it doesn't have a name nor the constructors of Type are >> public. Thus, I'm not able to get that information :( >> >> Thanks in advance, >> Alejandro >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From anthony_clayden at clear.net.nz Wed Jun 4 05:33:43 2014 From: anthony_clayden at clear.net.nz (AntC) Date: Wed, 4 Jun 2014 05:33:43 +0000 (UTC) Subject: [Haskell-cafe] Getting list of constructors of a Type References: Message-ID: > Alejandro Serrano Mena gmail.com> writes: > > Dear Haskell-Caf?,As part of my Google Summer of Code, I need to get the list of data constructors of a certain data type on a specific scenario. Hi Alejandro, have you considered Data/Typeable or Generics? I'm not quite sure what you're looking for, but see my (similar?) requests: http://www.haskell.org/pipermail/haskell-cafe/2013-October/111133.html http://www.haskell.org/pipermail/generics/2013-December/000549.html And the helpful replies. Beware re Nils' suggestion that I think TH has changed with GHC7.8 such that type inspection at compile time is not so easy. (Sorry to be vague, and others will no doubt correct me.) AntC From john at repetae.net Wed Jun 4 06:26:52 2014 From: john at repetae.net (John Meacham) Date: Tue, 3 Jun 2014 23:26:52 -0700 Subject: [Haskell-cafe] PROPOSAL: Record field type inference Message-ID: This is also available as html at http://repetae.net/computer/jhc/record_inference.html Record Type Inference ===================== An extension to the named field mechanism that will greatly enhance the utility of them when combined with the existing `DisambiguateRecordFields`, `RecordPuns`, and `RecordWildCards`. The proposal is to allow the types of record fields to be inferred by the normal type inference engine. It would look like ~~~~ {.haskell} data Rec = Rec {fieldA,fieldB,fieldC} f Rec { .. } = Rec { .. } where fieldA = True fieldB = 4 ~~~~ This would infer the types `Bool`, `Int`, and `forall a . a` for the fields of the record constructor and `f :: Rec -> Rec` for f. For the purposes of type checking the fields are treated as monomorphic and not generalized but defaulted like normal after typechecking the module. Other than infering the types of the record fields, the records have the normal syntax. The extensions `RecordPuns`, `RecordWildCards` and `DisambiguateRecordFields` will be enabled when record field inference is enabled. Selector functions will not be created for infered records, as in, the names are field labels and not functions. This means they do not share a namespace with functions and do not conflict with each other. Multiple records may have the same field names in the same module. This means the following is fine. ~~~~ {.haskell} data Rec1 = Rec1 {input, withFoo, withoutFoo } data Rec2 = Rec2 {input, withBar, withoutBar } f Rec1 { .. } = case input of [] -> Rec1 { .. } (x:xs) -> if hasFoo x then Rec1 { withFoo = x:withFoo, .. } else Rec1 { withoutFoo = x:withoutFoo, .. } ~~~~ Possible extensions ------------------- ### as-pattern disambiguation In order to make the disambiguation of record fields more useful without relying on the type checker for disambiguation, We can declare that variables explicitly bound to a constsructor in a pattern match use that constructor to disambiguate fields for operations on the variable. This is a purely syntactic transformation that can happen before typechecking. It can be used as follows. ~~~~ {.haskell} -- use the input bound by a Rec1 to update the input bound by a Rec2 f r1 at Rec1 { input } r2 at Rec2 {} = case input of xs | any hasBar xs = f r1 { input = [] } r2 { input } ~~~~ ### Field label inference It is concievable that we may want to infer the fields themselves of a record, as in: ~~~~ {.haskell} -- infer that R has the field labels bob and susan data R = R { ..} f x at R {bob} = R {susan = bob} ~~~~ In order to implement this, a pass through the file will collect every field label that is used with an explicit R constructor and treat the record as if it were declared with those names as infered fields. From carter.schonwald at gmail.com Wed Jun 4 06:33:48 2014 From: carter.schonwald at gmail.com (Carter Schonwald) Date: Wed, 4 Jun 2014 02:33:48 -0400 Subject: [Haskell-cafe] PROPOSAL: Record field type inference In-Reply-To: References: Message-ID: Hey John in some respects, this sounds like syntax sugar around https://ghc.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields have you had a look at that? (its not quite merged into HEAD yet, but that due soon i'm told) On Wed, Jun 4, 2014 at 2:26 AM, John Meacham wrote: > This is also available as html at > > http://repetae.net/computer/jhc/record_inference.html > > Record Type Inference > ===================== > > An extension to the named field mechanism that will greatly enhance the > utility of them when combined with the existing `DisambiguateRecordFields`, > `RecordPuns`, and `RecordWildCards`. > > The proposal is to allow the types of record fields to be inferred by the > normal type inference engine. It would look like > > ~~~~ {.haskell} > data Rec = Rec {fieldA,fieldB,fieldC} > > f Rec { .. } = Rec { .. } where > fieldA = True > fieldB = 4 > ~~~~ > > This would infer the types `Bool`, `Int`, and `forall a . a` for the > fields of > the record constructor and `f :: Rec -> Rec` for f. For the purposes of > type > checking the fields are treated as monomorphic and not generalized but > defaulted like normal after typechecking the module. Other than infering > the > types of the record fields, the records have the normal syntax. The > extensions > `RecordPuns`, `RecordWildCards` and `DisambiguateRecordFields` will be > enabled > when record field inference is enabled. > > Selector functions will not be created for infered records, as in, the > names > are field labels and not functions. This means they do not share a > namespace > with functions and do not conflict with each other. Multiple records may > have > the same field names in the same module. This means the following is fine. > > ~~~~ {.haskell} > data Rec1 = Rec1 {input, withFoo, withoutFoo } > data Rec2 = Rec2 {input, withBar, withoutBar } > > f Rec1 { .. } = case input of > [] -> Rec1 { .. } > (x:xs) -> if hasFoo x > then Rec1 { withFoo = x:withFoo, .. } > else Rec1 { withoutFoo = x:withoutFoo, .. } > ~~~~ > > Possible extensions > ------------------- > > ### as-pattern disambiguation > > In order to make the disambiguation of record fields more useful without > relying on the type checker for disambiguation, We can declare that > variables > explicitly bound to a constsructor in a pattern match use that constructor > to > disambiguate fields for operations on the variable. This is a purely > syntactic > transformation that can happen before typechecking. It can be used as > follows. > > ~~~~ {.haskell} > -- use the input bound by a Rec1 to update the input bound by a Rec2 > f r1 at Rec1 { input } r2 at Rec2 {} = case input of > xs | any hasBar xs = f r1 { input = [] } r2 { input } > ~~~~ > > ### Field label inference > > It is concievable that we may want to infer the fields themselves of a > record, > as in: > > ~~~~ {.haskell} > -- infer that R has the field labels bob and susan > data R = R { ..} > f x at R {bob} = R {susan = bob} > ~~~~ > > In order to implement this, a pass through the file will collect every > field > label that is used with an explicit R constructor and treat the record as > if > it were declared with those names as infered fields. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From john at repetae.net Wed Jun 4 07:03:01 2014 From: john at repetae.net (John Meacham) Date: Wed, 4 Jun 2014 00:03:01 -0700 Subject: [Haskell-cafe] PROPOSAL: Record field type inference In-Reply-To: References: Message-ID: Yeah, I am familier with that, this is fairly orthogonal actually and both can be used together to good effect. This proposal is more about making records 'lightweight', as in, I have a recursive function that takes 5 or so recursive values and they all have to be passed as independent options (or a tuple) right now which is error prone, by making a lightweight inferred record we get named parameters that are infered just like they were listed as options and CPR analysis will even ensure there is no run time penalty, the fields will be expanded out as positional parameters internally. An issue with OverloadedRecordFields is that it relies on a lot of type system complexity, This builds on the existing DisambiguateRecordFields extension and simply removes the restriction that the records with the same field names be defined in different modules. since field names declared this way don't share a namespace with functions this isn't an issue. Notably, everything to disambiguate fields can take place in the renamer and the fields can be typechecked exactly as if they were top level pattern bindings. Another possible extension is allowing it to infer scoped type variables as well for a parameterized record type. working on something concrete for that with my jhc implementation, the issue is that the record will have to be parameterized by a type to keep them from escaping. Perhaps just a single type parameter that is existentially instantiated, syntax being data R t = R {fa,fb,fc} or putting the data declaration in a local where or let binding. but that will require some more work. (and scoped type variables in jhc are a little iffy at the moment as is) John On Tue, Jun 3, 2014 at 11:33 PM, Carter Schonwald wrote: > Hey John > in some respects, this sounds like syntax sugar around > https://ghc.haskell.org/trac/ghc/wiki/Records/OverloadedRecordFields > have you had a look at that? (its not quite merged into HEAD yet, but that > due soon i'm told) > > > On Wed, Jun 4, 2014 at 2:26 AM, John Meacham wrote: >> >> This is also available as html at >> >> http://repetae.net/computer/jhc/record_inference.html >> >> Record Type Inference >> ===================== >> >> An extension to the named field mechanism that will greatly enhance the >> utility of them when combined with the existing >> `DisambiguateRecordFields`, >> `RecordPuns`, and `RecordWildCards`. >> >> The proposal is to allow the types of record fields to be inferred by the >> normal type inference engine. It would look like >> >> ~~~~ {.haskell} >> data Rec = Rec {fieldA,fieldB,fieldC} >> >> f Rec { .. } = Rec { .. } where >> fieldA = True >> fieldB = 4 >> ~~~~ >> >> This would infer the types `Bool`, `Int`, and `forall a . a` for the >> fields of >> the record constructor and `f :: Rec -> Rec` for f. For the purposes of >> type >> checking the fields are treated as monomorphic and not generalized but >> defaulted like normal after typechecking the module. Other than infering >> the >> types of the record fields, the records have the normal syntax. The >> extensions >> `RecordPuns`, `RecordWildCards` and `DisambiguateRecordFields` will be >> enabled >> when record field inference is enabled. >> >> Selector functions will not be created for infered records, as in, the >> names >> are field labels and not functions. This means they do not share a >> namespace >> with functions and do not conflict with each other. Multiple records may >> have >> the same field names in the same module. This means the following is fine. >> >> ~~~~ {.haskell} >> data Rec1 = Rec1 {input, withFoo, withoutFoo } >> data Rec2 = Rec2 {input, withBar, withoutBar } >> >> f Rec1 { .. } = case input of >> [] -> Rec1 { .. } >> (x:xs) -> if hasFoo x >> then Rec1 { withFoo = x:withFoo, .. } >> else Rec1 { withoutFoo = x:withoutFoo, .. } >> ~~~~ >> >> Possible extensions >> ------------------- >> >> ### as-pattern disambiguation >> >> In order to make the disambiguation of record fields more useful without >> relying on the type checker for disambiguation, We can declare that >> variables >> explicitly bound to a constsructor in a pattern match use that constructor >> to >> disambiguate fields for operations on the variable. This is a purely >> syntactic >> transformation that can happen before typechecking. It can be used as >> follows. >> >> ~~~~ {.haskell} >> -- use the input bound by a Rec1 to update the input bound by a Rec2 >> f r1 at Rec1 { input } r2 at Rec2 {} = case input of >> xs | any hasBar xs = f r1 { input = [] } r2 { input } >> ~~~~ >> >> ### Field label inference >> >> It is concievable that we may want to infer the fields themselves of a >> record, >> as in: >> >> ~~~~ {.haskell} >> -- infer that R has the field labels bob and susan >> data R = R { ..} >> f x at R {bob} = R {susan = bob} >> ~~~~ >> >> In order to implement this, a pass through the file will collect every >> field >> label that is used with an explicit R constructor and treat the record as >> if >> it were declared with those names as infered fields. >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- John Meacham - http://notanumber.net/ From tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Wed Jun 4 08:46:56 2014 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Wed, 4 Jun 2014 09:46:56 +0100 Subject: [Haskell-cafe] ZuriHac -- Any Thursday arrivals? In-Reply-To: References: Message-ID: <20140604084656.GO2054@henry> I'm arriving in Zurich on Thursday (tomorrow) morning. If any ZuriHac attendees would like to meet up on Thursday let me know! Tom From trupill at gmail.com Wed Jun 4 12:30:38 2014 From: trupill at gmail.com (Alejandro Serrano Mena) Date: Wed, 4 Jun 2014 14:30:38 +0200 Subject: [Haskell-cafe] Getting list of constructors of a Type In-Reply-To: <538E45AE.5060306@nils.cc> References: <538E45AE.5060306@nils.cc> Message-ID: My aim is to extend the capabilities of ghc-mod to do case split. For that matter, I'm using the GHC module of the ghc package (the same ghc-mod uses). Via the exprType function I get a Type value. Then, I would like to be able to call getInfo (everything from the GHC module) to get the information of that type. I'm not sure if using Template Haskell is something I can use, but I will definitely try :) 2014-06-04 0:01 GMT+02:00 Nils Schweinsberg : > I'm not sure what exactly you're trying to do, but with Template Haskell > it's easy: > > test :: Name -> Q [Dec] >> test name = do >> info <- reify name >> ... >> > > Then call it from another module with the type name as argument (double > single quotes): > > data Test = A | B >> >> test ''Test >> > > The `Info` type returned by `reify` is described in: > > http://hackage.haskell.org/package/template-haskell-2.9. > 0.0/docs/Language-Haskell-TH-Syntax.html#t:Info > > > - Nils > > Am 03.06.2014 21:13, schrieb Alejandro Serrano Mena: > >> Dear Haskell-Caf?, >> As part of my Google Summer of Code, I need to get the list of data >> constructors of a certain data type on a specific scenario. >> In my case, I'm getting a value of type Type (by calling exprType). I >> was expecting to be able to call getInfo directly on that value of type >> Type, but it doesn't have a name nor the constructors of Type are >> public. Thus, I'm not able to get that information :( >> >> Thanks in advance, >> Alejandro >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From adam at bergmark.nl Wed Jun 4 13:20:27 2014 From: adam at bergmark.nl (Adam Bergmark) Date: Wed, 4 Jun 2014 15:20:27 +0200 Subject: [Haskell-cafe] ZuriHac -- Any Thursday arrivals? In-Reply-To: <20140604084656.GO2054@henry> References: <20140604084656.GO2054@henry> Message-ID: A bunch of us are meeting up for drinks in the evening around 9pm, I'll tweet our location [1] once we find a good place, everyone's welcome to join! [1] https://twitter.com/adambergmark On Wed, Jun 4, 2014 at 10:46 AM, Tom Ellis < tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk> wrote: > I'm arriving in Zurich on Thursday (tomorrow) morning. If any ZuriHac > attendees would like to meet up on Thursday let me know! > > Tom > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From omari at smileystation.com Wed Jun 4 14:34:22 2014 From: omari at smileystation.com (Omari Norman) Date: Wed, 4 Jun 2014 10:34:22 -0400 Subject: [Haskell-cafe] Is there a name for this property: x + x - x == x Message-ID: It's not quite idempotence, because more than one function is involved. It's a common property and I figure I can write a higher order function to build QuickCheck tests for it. I was just wondering if it has a name. -------------- next part -------------- An HTML attachment was scrubbed... URL: From davidleothomas at gmail.com Wed Jun 4 14:42:29 2014 From: davidleothomas at gmail.com (David Thomas) Date: Wed, 4 Jun 2014 07:42:29 -0700 Subject: [Haskell-cafe] Is there a name for this property: x + x - x == x In-Reply-To: References: Message-ID: If you have associativity, this seems roughly the same as saying there is an additive inverse for every x, because x + x - x = x => x + (x - x) = x => x + 0 = x. On Wed, Jun 4, 2014 at 7:34 AM, Omari Norman wrote: > It's not quite idempotence, because more than one function is involved. > > It's a common property and I figure I can write a higher order function to > build QuickCheck tests for it. I was just wondering if it has a name. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From akamaus at gmail.com Wed Jun 4 14:45:29 2014 From: akamaus at gmail.com (Dmitry Vyal) Date: Wed, 04 Jun 2014 18:45:29 +0400 Subject: [Haskell-cafe] Is there a name for this property: x + x - x == x In-Reply-To: References: Message-ID: <538F3109.7000305@gmail.com> On 06/04/2014 06:34 PM, Omari Norman wrote: > It's not quite idempotence, because more than one function is involved. > > It's a common property and I figure I can write a higher order > function to build QuickCheck tests for it. I was just wondering if it > has a name. Hello Omari, I guess it's a corollary of two group axioms. There exists an identity element e such what for any a a + e == e + a == a. And for any element a inverse element -a exists, such that a + (-a) == e. Take a look at http://en.wikipedia.org/wiki/Group_%28mathematics%29 Why not compose a name out of these two? :) From welcometothechango at gmail.com Wed Jun 4 14:46:02 2014 From: welcometothechango at gmail.com (Ezequiel Alvarez) Date: Wed, 4 Jun 2014 11:46:02 -0300 Subject: [Haskell-cafe] Is there a name for this property: x + x - x == x In-Reply-To: References: Message-ID: Exactly, it's 3 properties: associativity, inverse and identity. On Wed, Jun 4, 2014 at 11:42 AM, David Thomas wrote: > If you have associativity, this seems roughly the same as saying there > is an additive inverse for every x, because x + x - x = x => x + (x - > x) = x => x + 0 = x. > > On Wed, Jun 4, 2014 at 7:34 AM, Omari Norman > wrote: > > It's not quite idempotence, because more than one function is involved. > > > > It's a common property and I figure I can write a higher order function > to > > build QuickCheck tests for it. I was just wondering if it has a name. > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From omari at smileystation.com Wed Jun 4 14:46:49 2014 From: omari at smileystation.com (Omari Norman) Date: Wed, 4 Jun 2014 10:46:49 -0400 Subject: [Haskell-cafe] Is there a name for this property: x + x - x == x In-Reply-To: References: Message-ID: Is there a more general name for it? Here's what I'm thinking of. I would think there's a name for it rather than "inversion", which I made up. module Builders where import Test.QuickCheck -- | Takes a single value, x. Applies a function to that value, -- and then applies a second function to the result of the -- application of the first function. Passes if the result of the -- second function equals the original value. inversion :: (Eq a, Show a) => (a -> b) -- ^ Apply this function to the original value -> (b -> a) -- ^ Apply this function to the result of the first function -> a -> Property inversion f1 f2 a = f2 (f1 a) === a On Wed, Jun 4, 2014 at 10:42 AM, David Thomas wrote: > If you have associativity, this seems roughly the same as saying there > is an additive inverse for every x, because x + x - x = x => x + (x - > x) = x => x + 0 = x. > > On Wed, Jun 4, 2014 at 7:34 AM, Omari Norman > wrote: > > It's not quite idempotence, because more than one function is involved. > > > > It's a common property and I figure I can write a higher order function > to > > build QuickCheck tests for it. I was just wondering if it has a name. > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex at lagoa.com Wed Jun 4 14:56:25 2014 From: alex at lagoa.com (Alexander Vieth) Date: Wed, 4 Jun 2014 10:56:25 -0400 Subject: [Haskell-cafe] Is there a name for this property: x + x - x == x In-Reply-To: References: Message-ID: Inversion seems like the right name. That's typically what people call it when f . g = g . f = id So in the case of x + (x - x) = x we can think of it as (f . g) x where f y = x + y and g y = y - x, and all we're saying is that f . g = g . f = id i.e. f and g are inverse. Alex On 2014-06-04, at 10:46 AM, Omari Norman wrote: > Is there a more general name for it? Here's what I'm thinking of. I would think there's a name for it rather than "inversion", which I made up. > > module Builders where > > import Test.QuickCheck > > -- | Takes a single value, x. Applies a function to that value, > -- and then applies a second function to the result of the > -- application of the first function. Passes if the result of the > -- second function equals the original value. > > inversion > :: (Eq a, Show a) > => (a -> b) > -- ^ Apply this function to the original value > -> (b -> a) > -- ^ Apply this function to the result of the first function > -> a > -> Property > inversion f1 f2 a = f2 (f1 a) === a > > > > On Wed, Jun 4, 2014 at 10:42 AM, David Thomas wrote: > If you have associativity, this seems roughly the same as saying there > is an additive inverse for every x, because x + x - x = x => x + (x - > x) = x => x + 0 = x. > > On Wed, Jun 4, 2014 at 7:34 AM, Omari Norman wrote: > > It's not quite idempotence, because more than one function is involved. > > > > It's a common property and I figure I can write a higher order function to > > build QuickCheck tests for it. I was just wondering if it has a name. > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From eir at cis.upenn.edu Wed Jun 4 14:59:43 2014 From: eir at cis.upenn.edu (Richard Eisenberg) Date: Wed, 4 Jun 2014 10:59:43 -0400 Subject: [Haskell-cafe] Getting list of constructors of a Type In-Reply-To: References: <538E45AE.5060306@nils.cc> Message-ID: Hi Alejandro, From your use case, it looks like you need splitTyConApp (from GHC's Type module). Then, tyConDataCons will do the trick. Perhaps splitTyConApp should be in the GHC module itself. If you think so, submit a bug report and patch, please! I don't think Template Haskell will work for you here -- mixing calls from the GHC module and TH is a recipe for disaster. I hope this helps, Richard On Jun 4, 2014, at 8:30 AM, Alejandro Serrano Mena wrote: > My aim is to extend the capabilities of ghc-mod to do case split. For that matter, I'm using the GHC module of the ghc package (the same ghc-mod uses). Via the exprType function I get a Type value. Then, I would like to be able to call getInfo (everything from the GHC module) to get the information of that type. > > I'm not sure if using Template Haskell is something I can use, but I will definitely try :) > > > 2014-06-04 0:01 GMT+02:00 Nils Schweinsberg : > I'm not sure what exactly you're trying to do, but with Template Haskell it's easy: > > test :: Name -> Q [Dec] > test name = do > info <- reify name > ... > > Then call it from another module with the type name as argument (double single quotes): > > data Test = A | B > > test ''Test > > The `Info` type returned by `reify` is described in: > > http://hackage.haskell.org/package/template-haskell-2.9.0.0/docs/Language-Haskell-TH-Syntax.html#t:Info > > > - Nils > > Am 03.06.2014 21:13, schrieb Alejandro Serrano Mena: > Dear Haskell-Caf?, > As part of my Google Summer of Code, I need to get the list of data > constructors of a certain data type on a specific scenario. > In my case, I'm getting a value of type Type (by calling exprType). I > was expecting to be able to call getInfo directly on that value of type > Type, but it doesn't have a name nor the constructors of Type are > public. Thus, I'm not able to get that information :( > > Thanks in advance, > Alejandro > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuuzetsu at fuuzetsu.co.uk Wed Jun 4 15:23:37 2014 From: fuuzetsu at fuuzetsu.co.uk (Mateusz Kowalczyk) Date: Wed, 04 Jun 2014 17:23:37 +0200 Subject: [Haskell-cafe] improved jhc manual In-Reply-To: References: Message-ID: <538F39F9.5090705@fuuzetsu.co.uk> On 06/04/2014 03:29 AM, John Meacham wrote: > Hi all, I just wanted to show off the new jhc manual > http://repetae.net/computer/jhc/manual.html > > If anyone has any feedback, that would be great, even better would be > patches of course :) Manual writing is not my strong point. > > The entire manual is in the darcs repo as markdown formatted files or > as literate code embedded in the source files. > > Something I need to figure out is how to get haddock to not barf on > jhc's input files. A problem with haddock is that it tries to > replicate ghc's module chasing algorithm and falls down when anything > is slightly off, jhc's ability to handle recursive modules throws it > for a loop. Now I can easily get jhc to spit out fully resolved module > names, it does so with the --annotate-source option, but need some > sort of hook into haddock saying "don't try to resolve module names, > here they all are." > > Even haddock just having a 'keep going' option would be great to get > something out there. Or even improving haddock to handle recursive > module imports. > > John > Hi, You're correct that there's no such feature at the moment. If you want something, please open an issue on [1]. Note that I have never used JHC or looked into how it works so I will need very careful description of what I need to do to replicate it all, including small test case, any flags that need to be passed in for Haddock to work with JHC, expected behaviour, a small case where there are no recursive modules so I can confirm it works in simple case &c. If it turns out to not be too complicated then you could have it in the next non-minor release (2.15.x). Are there no other problems with JHC modules? We use GHC fairly heavily in Haddock so I'd imagine it wouldn't all just magically work but again, I have zero experience there. Thanks [1]: https://github.com/haskell/haddock/issues -- Mateusz K. From roma at ro-che.info Wed Jun 4 17:21:41 2014 From: roma at ro-che.info (Roman Cheplyaka) Date: Wed, 4 Jun 2014 20:21:41 +0300 Subject: [Haskell-cafe] Is there a name for this property: x + x - x == x In-Reply-To: References: Message-ID: <20140604172141.GB28660@sniper> * Omari Norman [2014-06-04 10:34:22-0400] > It's not quite idempotence, because more than one function is involved. > > It's a common property and I figure I can write a higher order function to > build QuickCheck tests for it. I was just wondering if it has a name. This is similar to the inverse semigroup definition (but note the different order of the operands). https://en.wikipedia.org/wiki/Inverse_semigroup Roman -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From hans at hanshoglund.se Thu Jun 5 02:02:59 2014 From: hans at hanshoglund.se (=?iso-8859-1?Q?Hans_H=F6glund?=) Date: Thu, 5 Jun 2014 04:02:59 +0200 Subject: [Haskell-cafe] ANNOUNCE: music-suite 1.7 Message-ID: <7C04DCCD-1923-4D76-AF2C-C6E2DDB92BE3@hanshoglund.se> I am pleased to announce the release of Music Suite v1.7. The Music Suite is a collection of Haskell libraries for composition, analysis and manipulation of music. It is generic enough to handle electronic music and non-Western music theory, as well as most aspects of common music notation. It can read and write many standard representations such as MIDI, MusicXML, Lilypond and ABC notation. Getting it Install the Suite from Hackage: cabal install music-suite Documentation and examples: http://music-suite.github.io The source code is available on Github: https://github.com/music-suite For bug reports, please use the relevant Github tracker: https://github.com/music-suite/music-score/issues For questions, feedback and general discussion, see music-suite-discuss at googlegroups.com http://groups.google.com/d/forum/music-suite-discuss Highlights Some highlights of this release include: Many new time containers, including more fine-grained versions of Score and Behavior Better interface for Score, Voice and Chord Better interface to musical aspects (i.e. parts, pitches, dynamics and articulations) using lenses and traversals Polymorphic update of musical aspects, so representation can change mid-traversal Now supports phrase-wise traversals of scores and voices New SuperCollider backend Restructuring of backend code in terms of a single class HasBackend Backend can now be parameterized on container type, rather than just note type Better notation of dynamics and articulation For the full notes, see: https://github.com/music-suite/music-docs/blob/master/releases/Notes.md Stability Please note that the Suite is quite usable, parts of it are still experimental, and we expect the API to change slightly with every release up to v2.0.0 (think of it as optimistic versioning). If you have any problems with upgrading from a previous version, please post to the group below. Contributing If you are interested in contributing to the Suite, please join the Github organization (see the link above). In addition to code, we appreciate contributions in the form of tutorials, examples or musical compositions. Hopefully we may soon have a showcase of works created with Music Suite, like Diagram's gallery. Sincerly, Hans - Hans H?glund Composer, conductor and developer hans [at] hanshoglund.se hanshoglund.com https://twitter.com/hanshogl https://soundcloud.com/hanshoglund http://github.com/hanshoglund -------------- next part -------------- An HTML attachment was scrubbed... URL: From anthony_clayden at clear.net.nz Thu Jun 5 09:20:31 2014 From: anthony_clayden at clear.net.nz (AntC) Date: Thu, 5 Jun 2014 09:20:31 +0000 (UTC) Subject: [Haskell-cafe] PROPOSAL: Record field type inference References: Message-ID: > John Meacham repetae.net> writes: > ... > An extension to the named field mechanism that will greatly enhance the > utility of them when combined with the existing > `DisambiguateRecordFields`, `RecordPuns`, and `RecordWildCards`. > ... Thank you John, + 1 to: > Selector functions will not be created for infered records, as in, the names are field labels and not functions. This means they do not share a namespace with functions and do not conflict with each other. Multiple records may have the same field names in the same module. https://ghc.haskell.org/trac/ghc/wiki/Records/DeclaredOverloadedRecordFields/N oMonoRecordFields (I agree with you [John] in not seeing a great deal of similarity to the OverloadedRecordFields work. My earlier suggestion of not creating Selector functions is exactly to free up the namespace. That suggestion is part of (and largely orthogonal to) an alternative records proposal which also relies heavily on the type system.) AntC From hsyl20 at gmail.com Thu Jun 5 09:53:12 2014 From: hsyl20 at gmail.com (Sylvain Henry) Date: Thu, 5 Jun 2014 11:53:12 +0200 Subject: [Haskell-cafe] ANNOUNCE: music-suite 1.7 In-Reply-To: <7C04DCCD-1923-4D76-AF2C-C6E2DDB92BE3@hanshoglund.se> References: <7C04DCCD-1923-4D76-AF2C-C6E2DDB92BE3@hanshoglund.se> Message-ID: Hi Hans, This looks awesome! I haven't seen any example of drums scores (I have been using Lilypond to write some some time ago). Is it possible to write them or how hard would it be to add support for them? Basically it requires: 1) several "melodies" on the same part: some with stems up and some with stems down 2) changing some note symbols (cross, circled note, etc.), enclosing some in parentheses (ghost notes) 3) support for annotations over/under the part (R and L for hands/foots) and some notes (open hi-hat, etc.) 4) the ability to display only the middle line of the staff (e.g. for snare drum parts) (see http://web.mit.edu/merolish/Public/drums.pdf ) Best regards, Sylvain 2014-06-05 4:02 GMT+02:00 Hans H?glund : > I am pleased to announce the release of Music Suite v1.7. > > The Music Suite is a collection of Haskell libraries for composition, > analysis and manipulation of music. It is generic enough to handle > electronic music and non-Western music theory, as well as most aspects of > common music notation. It can read and write many standard representations > such as MIDI, MusicXML , Lilypond > and ABC notation . > Getting it > > - > > Install the Suite from Hackage: > > cabal install music-suite > - > > Documentation and examples: > > http://music-suite.github.io > - > > The source code is available on Github: > > https://github.com/music-suite > - > > For bug reports, please use the relevant Github tracker: > > https://github.com/music-suite/music-score/issues > - > > For questions, feedback and general discussion, see > > music-suite-discuss at googlegroups.com > > http://groups.google.com/d/forum/music-suite-discuss > > Highlights > > Some highlights of this release include: > > - Many new *time containers*, including more fine-grained versions of > Score and Behavior > - Better interface for Score, Voice and Chord > - Better interface to musical *aspects* (i.e. parts, pitches, dynamics > and articulations) using lenses and traversals > - Polymorphic update of musical aspects, so representation can change > mid-traversal > - > > Now supports phrase-wise traversals of scores and voices > - New SuperCollider backend > - Restructuring of backend code in terms of a single class HasBackend > - Backend can now be parameterized on container type, rather than just > note type > - > > Better notation of dynamics and articulation > > For the full notes, see: > > https://github.com/music-suite/music-docs/blob/master/releases/Notes.md > > Stability > > Please note that the Suite is quite usable, parts of it are still > experimental, and we expect the API to change slightly with every release > up to v2.0.0 (think of it as optimistic versioning ). > If you have any problems with upgrading from a previous version, please > post to the group below. > Contributing > > If you are interested in contributing to the Suite, please join the Github > organization (see the link above). In addition to code, we appreciate > contributions in the form of tutorials, examples or musical compositions. > Hopefully we may soon have a showcase of works created with Music Suite, > like Diagram's gallery > . > > Sincerly, > > Hans > > - > > Hans H?glund > *Composer, conductor and developer* > > hans [at] hanshoglund.se > hanshoglund.com > https://twitter.com/hanshogl > https://soundcloud.com/hanshoglund > http://github.com/hanshoglund > > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hans at hanshoglund.se Thu Jun 5 13:37:06 2014 From: hans at hanshoglund.se (=?iso-8859-1?Q?Hans_H=F6glund?=) Date: Thu, 5 Jun 2014 15:37:06 +0200 Subject: [Haskell-cafe] ANNOUNCE: music-suite 1.7 In-Reply-To: References: <7C04DCCD-1923-4D76-AF2C-C6E2DDB92BE3@hanshoglund.se> Message-ID: Thank you, Percussion notation (both drum set and orchestral) is a big missing feature, you can see the tracking issue here: https://github.com/music-suite/music-parts/issues/2. The core principle in the suite is to have a logical/semantic internal representation, so I would like to represent percussion notes as some sort of record of instrument/player/technique and then convert it to one of the standard notations at export time (tmy bible on the subject is http://howto.szsolomon.com/). If you have specific needs or ideas please write on the list or on the issue. Pseudo-code etc is also useful. Regards, Hans - Hans H?glund Composer, conductor and developer hans [at] hanshoglund.se hanshoglund.com https://twitter.com/hanshogl https://soundcloud.com/hanshoglund http://github.com/hanshoglund On 5 jun 2014, at 11:53, Sylvain Henry wrote: > Hi Hans, > > This looks awesome! > > I haven't seen any example of drums scores (I have been using Lilypond to write some some time ago). Is it possible to write them or how hard would it be to add support for them? Basically it requires: > 1) several "melodies" on the same part: some with stems up and some with stems down > 2) changing some note symbols (cross, circled note, etc.), enclosing some in parentheses (ghost notes) > 3) support for annotations over/under the part (R and L for hands/foots) and some notes (open hi-hat, etc.) > 4) the ability to display only the middle line of the staff (e.g. for snare drum parts) > > (see http://web.mit.edu/merolish/Public/drums.pdf ) > > Best regards, > Sylvain > > > 2014-06-05 4:02 GMT+02:00 Hans H?glund : > I am pleased to announce the release of Music Suite v1.7. > > The Music Suite is a collection of Haskell libraries for composition, analysis and manipulation of music. It is generic enough to handle electronic music and non-Western music theory, as well as most aspects of common music notation. It can read and write many standard representations such as MIDI, MusicXML, Lilypond and ABC notation. > > Getting it > > Install the Suite from Hackage: > > cabal install music-suite > > Documentation and examples: > > http://music-suite.github.io > > The source code is available on Github: > > https://github.com/music-suite > > For bug reports, please use the relevant Github tracker: > > https://github.com/music-suite/music-score/issues > > For questions, feedback and general discussion, see > > music-suite-discuss at googlegroups.com > > http://groups.google.com/d/forum/music-suite-discuss > > Highlights > > Some highlights of this release include: > > Many new time containers, including more fine-grained versions of Score and Behavior > Better interface for Score, Voice and Chord > Better interface to musical aspects (i.e. parts, pitches, dynamics and articulations) using lenses and traversals > Polymorphic update of musical aspects, so representation can change mid-traversal > Now supports phrase-wise traversals of scores and voices > > New SuperCollider backend > Restructuring of backend code in terms of a single class HasBackend > Backend can now be parameterized on container type, rather than just note type > Better notation of dynamics and articulation > > For the full notes, see: > > https://github.com/music-suite/music-docs/blob/master/releases/Notes.md > Stability > > Please note that the Suite is quite usable, parts of it are still experimental, and we expect the API to change slightly with every release up to v2.0.0 (think of it as optimistic versioning). If you have any problems with upgrading from a previous version, please post to the group below. > > Contributing > > If you are interested in contributing to the Suite, please join the Github organization (see the link above). In addition to code, we appreciate contributions in the form of tutorials, examples or musical compositions. Hopefully we may soon have a showcase of works created with Music Suite, like Diagram's gallery. > > Sincerly, > > Hans > > > - > > Hans H?glund > Composer, conductor and developer > > hans [at] hanshoglund.se > hanshoglund.com > https://twitter.com/hanshogl > https://soundcloud.com/hanshoglund > http://github.com/hanshoglund > > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at joachim-breitner.de Thu Jun 5 14:01:08 2014 From: mail at joachim-breitner.de (Joachim Breitner) Date: Thu, 05 Jun 2014 16:01:08 +0200 Subject: [Haskell-cafe] ZuriHac -- Any Thursday arrivals? In-Reply-To: References: <20140604084656.GO2054@henry> Message-ID: <1401976868.16125.0.camel@kirk> Hi, Am Mittwoch, den 04.06.2014, 15:20 +0200 schrieb Adam Bergmark: > A bunch of us are meeting up for drinks in the evening around 9pm, > I'll tweet our location [1] once we find a good place, everyone's > welcome to join! I?ll arrive in Zurich at 8pm, will check in and then try to find you. Don?t forget the Tweet (or send me a mail :-)). Greetings, Joachim -- Joachim ?nomeata? Breitner mail at joachim-breitner.de ? http://www.joachim-breitner.de/ Jabber: nomeata at joachim-breitner.de ? GPG-Key: 0xF0FBF51F Debian Developer: nomeata at debian.org -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: This is a digitally signed message part URL: From ekmett at gmail.com Thu Jun 5 15:57:19 2014 From: ekmett at gmail.com (Edward Kmett) Date: Thu, 5 Jun 2014 17:57:19 +0200 Subject: [Haskell-cafe] ZuriHac -- Any Thursday arrivals? In-Reply-To: <1401976868.16125.0.camel@kirk> References: <20140604084656.GO2054@henry> <1401976868.16125.0.camel@kirk> Message-ID: I'm also already in town. -Edward On Thu, Jun 5, 2014 at 4:01 PM, Joachim Breitner wrote: > Hi, > > Am Mittwoch, den 04.06.2014, 15:20 +0200 schrieb Adam Bergmark: > > A bunch of us are meeting up for drinks in the evening around 9pm, > > I'll tweet our location [1] once we find a good place, everyone's > > welcome to join! > > I?ll arrive in Zurich at 8pm, will check in and then try to find you. > Don?t forget the Tweet (or send me a mail :-)). > > Greetings, > Joachim > > > -- > Joachim ?nomeata? Breitner > mail at joachim-breitner.de ? http://www.joachim-breitner.de/ > Jabber: nomeata at joachim-breitner.de ? GPG-Key: 0xF0FBF51F > Debian Developer: nomeata at debian.org > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From john at repetae.net Thu Jun 5 23:17:13 2014 From: john at repetae.net (John Meacham) Date: Thu, 5 Jun 2014 16:17:13 -0700 Subject: [Haskell-cafe] PROPOSAL: Record field type inference In-Reply-To: References: Message-ID: On Thu, Jun 5, 2014 at 2:20 AM, AntC wrote: > (I agree with you [John] in not seeing a great deal of similarity to the > OverloadedRecordFields work. My earlier suggestion of not creating Selector > functions is exactly to free up the namespace. That suggestion is part of (and > largely orthogonal to) an alternative records proposal which also relies > heavily on the type system.) A simple backwards compatible extension would be to just not report an error when there are multiple definitions of the same name when they are all generated selectors. Then let name resolution happen like normal, just reporting an ambiguous name if one is attempted to be used as a selector the same way an ambiguous name is reported when there are multiple definitions in scope for anything. This would just require dropping the unique top level check. This would be useful as the behavior will degrade to the current behavior if no field names happen to overlap. John -- John Meacham - http://notanumber.net/ From komendantskaya at gmail.com Sat Jun 7 16:30:49 2014 From: komendantskaya at gmail.com (Ekaterina Komendantskaya) Date: Sat, 7 Jun 2014 17:30:49 +0100 Subject: [Haskell-cafe] Postdoctoral Research Position: Type Inference in Functional Programming Message-ID: Hello, I am looking for a postdoctoral researcher to work on developing new algorithms for type inference in functional languages. Position is based at the School of Computing, University of Dundee, Scotland. Closing date for applications is 20 June 2014; starting date is flexible. Salary scale: ?27,837 to ?36,661 per annum. More details are available here: https://docs.google.com/document/d/1UUuf-BllmQ925vLV6jtzKreDcZYEOsF96dtj_IKVvj0/edit?usp=sharing Please re-forward to potential applicants. Cheers, Katya Ekaterina Komendantskaya Senior Lecturer, Head of PhD Studies Room 1.04, Queen Mother Building School of Computing, University of Dundee Scotland, DD14HN Tel: (+44) 01382384820 -------------- next part -------------- An HTML attachment was scrubbed... URL: From almeidaraf at gmail.com Sat Jun 7 18:50:36 2014 From: almeidaraf at gmail.com (Rafael Almeida) Date: Sat, 7 Jun 2014 15:50:36 -0300 Subject: [Haskell-cafe] Using quickcheck with test-framework (collect doesn't work) Message-ID: Hello, I'm trying to use quickcheck with test-framework. QuickCheck site says I can use a function called collect to see statistics of data generation. The function "collect" doesn't seem to print anything, though. This is the output I get after running cabal test: Running 1 test suites... Test suite reference: RUNNING... Test suite reference: PASS Test suite logged to: dist/test/100doors-0.1-reference.log 1 of 1 test suites (1 of 1 test cases) passed. This is what I see inside the log: Test suite reference: RUNNING... Main: flipped door is different state: [OK, passed 100 tests] flipDoors creates a different list of doors unless empty: [OK, passed 100 tests] Properties Total Passed 2 2 Failed 0 0 Total 2 2 Test suite reference: PASS Test suite logged to: dist/test/100doors-0.1-reference.log This is my test code (stripping out the boring parts): instance Arbitrary Door where arbitrary = elements [Opened, Closed] prop_flipped_door_is_different_state door = door /= flipDoor door prop_flipDoors_creates_a_different_list_of_doors_unless_empty n doors = collect n $ (not $ null doors) ==> doors /= (flipDoors n doors) []'s Rafael -------------- next part -------------- An HTML attachment was scrubbed... URL: From almeidaraf at gmail.com Sat Jun 7 18:56:42 2014 From: almeidaraf at gmail.com (Rafael Almeida) Date: Sat, 7 Jun 2014 15:56:42 -0300 Subject: [Haskell-cafe] Using quickcheck to check for errors Message-ID: Hello, Let's say we want to quickcheck the function !!. Passing a negative index to it is an error. However, how can you make a check that it indeed errors in such situation? prop_negative_index_generates_error list = forAll negativeIndex \x -> ... What should I write in ...? []'s Rafael -------------- next part -------------- An HTML attachment was scrubbed... URL: From benjamin.foppa at gmail.com Sat Jun 7 19:01:18 2014 From: benjamin.foppa at gmail.com (Ben Foppa) Date: Sat, 7 Jun 2014 15:01:18 -0400 Subject: [Haskell-cafe] open-union Message-ID: Hi cafe. On a use case whim, I made the open-union package ( https://github.com/RobotGymnast/open-union), copying the basic idea from extensible-effects:Data.OpenUnion1. I haven't uploaded to hackage yet, on the chance that there's already something like this around. Here's the basic functionality: {-# LANGUAGE TypeOperators #-} {-# LANGUAGE ScopedTypeVariables #-} import Data.OpenUnion type MyUnion = Union (Char :| Int :| [()] :| Void) showMyUnion :: MyUnion -> String showMyUnion = (\(c :: Char) -> "char: " ++ show c) @> (\(i :: Int) -> "int: " ++ show i) @> (\(l :: [()]) -> "list length: " ++ show (length l)) @> typesExhausted main :: IO () main = do putStrLn $ showMyUnion $ liftUnion (4 :: Int) putStrLn $ showMyUnion $ liftUnion 'a' putStrLn $ showMyUnion $ liftUnion [(), ()] If any of the (@>) cases is omitted, a compile-time error occurs. If you try to lift a bad value to the union, a compile-time error occurs. Any thoughts? Is there already something like this around? -------------- next part -------------- An HTML attachment was scrubbed... URL: From carter.schonwald at gmail.com Sat Jun 7 19:18:28 2014 From: carter.schonwald at gmail.com (Carter Schonwald) Date: Sat, 7 Jun 2014 15:18:28 -0400 Subject: [Haskell-cafe] open-union In-Reply-To: References: Message-ID: In some respects, I think both vinyl and hlist are more general. But I could be wrong. On Saturday, June 7, 2014, Ben Foppa wrote: > Hi cafe. On a use case whim, I made the open-union package ( > https://github.com/RobotGymnast/open-union), copying the basic idea from > extensible-effects:Data.OpenUnion1. I haven't uploaded to hackage yet, on > the chance that there's already something like this around. Here's the > basic functionality: > > {-# LANGUAGE TypeOperators #-} > {-# LANGUAGE ScopedTypeVariables #-} > import Data.OpenUnion > > type MyUnion = Union (Char :| Int :| [()] :| Void) > > showMyUnion :: MyUnion -> String > showMyUnion > = (\(c :: Char) -> "char: " ++ show c) > @> (\(i :: Int) -> "int: " ++ show i) > @> (\(l :: [()]) -> "list length: " ++ show (length l)) > @> typesExhausted > > main :: IO () > main = do > putStrLn $ showMyUnion $ liftUnion (4 :: Int) > putStrLn $ showMyUnion $ liftUnion 'a' > putStrLn $ showMyUnion $ liftUnion [(), ()] > > > If any of the (@>) cases is omitted, a compile-time error occurs. If you > try to lift a bad value to the union, a compile-time error occurs. > > Any thoughts? Is there already something like this around? > -------------- next part -------------- An HTML attachment was scrubbed... URL: From carter.schonwald at gmail.com Sat Jun 7 19:18:47 2014 From: carter.schonwald at gmail.com (Carter Schonwald) Date: Sat, 7 Jun 2014 15:18:47 -0400 Subject: [Haskell-cafe] open-union In-Reply-To: References: Message-ID: There's also compdata On Saturday, June 7, 2014, Ben Foppa wrote: > Hi cafe. On a use case whim, I made the open-union package ( > https://github.com/RobotGymnast/open-union), copying the basic idea from > extensible-effects:Data.OpenUnion1. I haven't uploaded to hackage yet, on > the chance that there's already something like this around. Here's the > basic functionality: > > {-# LANGUAGE TypeOperators #-} > {-# LANGUAGE ScopedTypeVariables #-} > import Data.OpenUnion > > type MyUnion = Union (Char :| Int :| [()] :| Void) > > showMyUnion :: MyUnion -> String > showMyUnion > = (\(c :: Char) -> "char: " ++ show c) > @> (\(i :: Int) -> "int: " ++ show i) > @> (\(l :: [()]) -> "list length: " ++ show (length l)) > @> typesExhausted > > main :: IO () > main = do > putStrLn $ showMyUnion $ liftUnion (4 :: Int) > putStrLn $ showMyUnion $ liftUnion 'a' > putStrLn $ showMyUnion $ liftUnion [(), ()] > > > If any of the (@>) cases is omitted, a compile-time error occurs. If you > try to lift a bad value to the union, a compile-time error occurs. > > Any thoughts? Is there already something like this around? > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ky3 at atamo.com Sat Jun 7 19:40:50 2014 From: ky3 at atamo.com (Kim-Ee Yeoh) Date: Sun, 8 Jun 2014 02:40:50 +0700 Subject: [Haskell-cafe] Using quickcheck to check for errors In-Reply-To: References: Message-ID: On Sun, Jun 8, 2014 at 1:56 AM, Rafael Almeida wrote: > Let's say we want to quickcheck the function !!. Passing a negative index > to it is an error. However, how can you make a check that it indeed errors > in such situation? The problem is that (!!) is a partial function, like head. How would you check that head [] is an error? What you could do is quickcheck a safe version of (!!) -- see Safe.atMay -- that returns a Maybefied type. -- Kim-Ee -------------- next part -------------- An HTML attachment was scrubbed... URL: From benjamin.foppa at gmail.com Sat Jun 7 19:47:32 2014 From: benjamin.foppa at gmail.com (Ben Foppa) Date: Sat, 7 Jun 2014 15:47:32 -0400 Subject: [Haskell-cafe] open-union In-Reply-To: References: Message-ID: Thanks, I wasn't aware of vinyl and compdata. I'll check them out. I'm not very familiar with HList, but I was under the impression that it provided intersection, not union, i.e. for every type in { x1 x2 ..}, an HList has an element vs for SOME type in {x1 x2 ..} a Union has an element.. On Sat, Jun 7, 2014 at 3:18 PM, Carter Schonwald wrote: > There's also compdata > > > On Saturday, June 7, 2014, Ben Foppa wrote: > >> Hi cafe. On a use case whim, I made the open-union package ( >> https://github.com/RobotGymnast/open-union), copying the basic idea from >> extensible-effects:Data.OpenUnion1. I haven't uploaded to hackage yet, on >> the chance that there's already something like this around. Here's the >> basic functionality: >> >> {-# LANGUAGE TypeOperators #-} >> {-# LANGUAGE ScopedTypeVariables #-} >> import Data.OpenUnion >> >> type MyUnion = Union (Char :| Int :| [()] :| Void) >> >> showMyUnion :: MyUnion -> String >> showMyUnion >> = (\(c :: Char) -> "char: " ++ show c) >> @> (\(i :: Int) -> "int: " ++ show i) >> @> (\(l :: [()]) -> "list length: " ++ show (length l)) >> @> typesExhausted >> >> main :: IO () >> main = do >> putStrLn $ showMyUnion $ liftUnion (4 :: Int) >> putStrLn $ showMyUnion $ liftUnion 'a' >> putStrLn $ showMyUnion $ liftUnion [(), ()] >> >> >> If any of the (@>) cases is omitted, a compile-time error occurs. If you >> try to lift a bad value to the union, a compile-time error occurs. >> >> Any thoughts? Is there already something like this around? >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at nh2.me Sat Jun 7 20:11:21 2014 From: mail at nh2.me (=?ISO-8859-1?Q?Niklas_Hamb=FCchen?=) Date: Sat, 07 Jun 2014 21:11:21 +0100 Subject: [Haskell-cafe] Using quickcheck to check for errors In-Reply-To: References: Message-ID: <539371E9.5080000@nh2.me> On 07/06/14 19:56, Rafael Almeida wrote: > Let's say we want to quickcheck the function !!. Passing a negative > index to it is an error. However, how can you make a check that it > indeed errors in such situation? Hello! You can do so with the divine unsafePerformIO-try-evaluate-force combo. -- Code also at https://gist.github.com/nh2/1ce734759b196c3483fa {-# LANGUAGE ScopedTypeVariables #-} import Control.Exception import Control.DeepSeq import Data.List (isPrefixOf) import System.IO.Unsafe (unsafePerformIO) import Test.QuickCheck main :: IO () main = quickCheck $ property $ \(list :: [Char], n :: Int) -> n >= length list ==> throwsIndexError (list !! n) throwsIndexError :: (NFData a) => a -> Bool throwsIndexError expr = unsafePerformIO $ do res <- try $ evaluate (force expr) case res of Left (ErrorCall msg) -> return $ "Prelude.(!!): index too large" `isPrefixOf` msg Right _ -> return False -- no exception -- End of code `force` makes sure that the expression is evaluated all the way to the bottom, and nothing is left lazily unevaluated. If you don't desire that, you can leave `force` out. We use `isPrefixOf` because for some reason, the exception contains a newline. In case you are not familiar with deepseq, the `NFData a` requirement makes sure that the expression can be evaluated all the way down. If you don't want/need to use `force`, you can drop that one. The use of `unsafePerformIO` is OK here because it is referentially transparent: We use it only to wrap a pure function, and perform no further IO in it. Hope that helps! Niklas From bob at redivi.com Sat Jun 7 20:16:57 2014 From: bob at redivi.com (Bob Ippolito) Date: Sat, 7 Jun 2014 13:16:57 -0700 Subject: [Haskell-cafe] Using quickcheck to check for errors In-Reply-To: <539371E9.5080000@nh2.me> References: <539371E9.5080000@nh2.me> Message-ID: There's a slightly cleaner way to do it. Of course it also uses `unsafePerformIO` under the hood, but you can let Test.QuickCheck.Monadic worry about that :) Something like this: https://gist.github.com/etrepum/d450420a7fd8c2e73aec import Data.Either (isLeft) import Control.Exception (try, evaluate, SomeException) import Test.QuickCheck (Property, quickCheck) import Test.QuickCheck.Monadic (monadicIO, run, assert) isFailure :: a -> IO Bool isFailure = fmap isLeft . tryEval where tryEval :: a -> IO (Either SomeException a) tryEval = try . evaluate prop_empty_list :: Int -> Property prop_empty_list idx = monadicIO (run (isFailure ([] !! idx)) >>= assert) prop_unexpected_success :: Int -> Property prop_unexpected_success idx = monadicIO (run (isFailure ([()] !! idx)) >>= assert) main :: IO () main = mapM_ quickCheck [ prop_empty_list, prop_unexpected_success ] On Sat, Jun 7, 2014 at 1:11 PM, Niklas Hamb?chen wrote: > On 07/06/14 19:56, Rafael Almeida wrote: > > Let's say we want to quickcheck the function !!. Passing a negative > > index to it is an error. However, how can you make a check that it > > indeed errors in such situation? > > Hello! > > You can do so with the divine unsafePerformIO-try-evaluate-force combo. > > -- Code also at https://gist.github.com/nh2/1ce734759b196c3483fa > {-# LANGUAGE ScopedTypeVariables #-} > > import Control.Exception > import Control.DeepSeq > import Data.List (isPrefixOf) > import System.IO.Unsafe (unsafePerformIO) > import Test.QuickCheck > > main :: IO () > main = quickCheck $ property $ \(list :: [Char], n :: Int) -> > n >= length list ==> throwsIndexError (list !! n) > > > throwsIndexError :: (NFData a) => a -> Bool > throwsIndexError expr = unsafePerformIO $ do > res <- try $ evaluate (force expr) > case res of > Left (ErrorCall msg) -> return $ "Prelude.(!!): index too large" > `isPrefixOf` msg > Right _ -> return False -- no exception > > > -- End of code > > `force` makes sure that the expression is evaluated all the way to the > bottom, and nothing is left lazily unevaluated. If you don't desire > that, you can leave `force` out. > > We use `isPrefixOf` because for some reason, the exception contains a > newline. > > In case you are not familiar with deepseq, the `NFData a` requirement > makes sure that the expression can be evaluated all the way down. If you > don't want/need to use `force`, you can drop that one. > > The use of `unsafePerformIO` is OK here because it is referentially > transparent: We use it only to wrap a pure function, and perform no > further IO in it. > > Hope that helps! > Niklas > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From carter.schonwald at gmail.com Sat Jun 7 20:31:07 2014 From: carter.schonwald at gmail.com (Carter Schonwald) Date: Sat, 7 Jun 2014 16:31:07 -0400 Subject: [Haskell-cafe] open-union In-Reply-To: References: Message-ID: Id be surprised if there's not a way to encode a union like structure using hlist. On Saturday, June 7, 2014, Ben Foppa wrote: > Thanks, I wasn't aware of vinyl and compdata. I'll check them out. > I'm not very familiar with HList, but I was under the impression that it > provided intersection, not union, i.e. for every type in { x1 x2 ..}, an > HList has an element vs for SOME type in {x1 x2 ..} a Union has an > element.. > > > On Sat, Jun 7, 2014 at 3:18 PM, Carter Schonwald < > carter.schonwald at gmail.com > > wrote: > >> There's also compdata >> >> >> On Saturday, June 7, 2014, Ben Foppa > > wrote: >> >>> Hi cafe. On a use case whim, I made the open-union package ( >>> https://github.com/RobotGymnast/open-union), copying the basic idea >>> from extensible-effects:Data.OpenUnion1. I haven't uploaded to hackage yet, >>> on the chance that there's already something like this around. Here's the >>> basic functionality: >>> >>> {-# LANGUAGE TypeOperators #-} >>> {-# LANGUAGE ScopedTypeVariables #-} >>> import Data.OpenUnion >>> >>> type MyUnion = Union (Char :| Int :| [()] :| Void) >>> >>> showMyUnion :: MyUnion -> String >>> showMyUnion >>> = (\(c :: Char) -> "char: " ++ show c) >>> @> (\(i :: Int) -> "int: " ++ show i) >>> @> (\(l :: [()]) -> "list length: " ++ show (length l)) >>> @> typesExhausted >>> >>> main :: IO () >>> main = do >>> putStrLn $ showMyUnion $ liftUnion (4 :: Int) >>> putStrLn $ showMyUnion $ liftUnion 'a' >>> putStrLn $ showMyUnion $ liftUnion [(), ()] >>> >>> >>> If any of the (@>) cases is omitted, a compile-time error occurs. If you >>> try to lift a bad value to the union, a compile-time error occurs. >>> >>> Any thoughts? Is there already something like this around? >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From omari at smileystation.com Sat Jun 7 21:13:03 2014 From: omari at smileystation.com (Omari Norman) Date: Sat, 7 Jun 2014 17:13:03 -0400 Subject: [Haskell-cafe] Using quickcheck with test-framework (collect doesn't work) In-Reply-To: References: Message-ID: On Sat, Jun 7, 2014 at 2:50 PM, Rafael Almeida wrote: > Hello, > > I'm trying to use quickcheck with test-framework. QuickCheck site says I > can use a function called collect to see statistics of data generation. The > function "collect" doesn't seem to print anything, though. This is the > output I get after running cabal test: > > Try it with tasty. test-framework has many old unfixed bugs and is not maintained. -------------- next part -------------- An HTML attachment was scrubbed... URL: From vogt.adam at gmail.com Sun Jun 8 01:37:29 2014 From: vogt.adam at gmail.com (adam vogt) Date: Sat, 7 Jun 2014 21:37:29 -0400 Subject: [Haskell-cafe] open-union In-Reply-To: References: Message-ID: Hi Ben, http://hackage.haskell.org/package/HList-0.3.4.1/docs/Data-HList-TIC.html is very similar, though it uses -XDataKinds for the type-level list and has fewer operations. For the next release we're changing the type-indexed collections (TIP, TIC) to share most of the implementation with Record and Variant respectively. I believe it's unnecessary to involve Typeable. Since there's a list of possible types, you can store (Int, Any), where the Int is an index into that list, instead of using TypeRep for that index. http://code.haskell.org/~aavogt/HList/Data/HList/Variant.hs has that implementation. Leaving out Typeable makes a difference as far as what is allowed, because Records using promoted strings as the labels do not have a Typeable instance in ghc-7.8.2. Regards, Adam On Sat, Jun 7, 2014 at 3:47 PM, Ben Foppa wrote: > Thanks, I wasn't aware of vinyl and compdata. I'll check them out. > I'm not very familiar with HList, but I was under the impression that it > provided intersection, not union, i.e. for every type in { x1 x2 ..}, an > HList has an element vs for SOME type in {x1 x2 ..} a Union has an > element.. > > > On Sat, Jun 7, 2014 at 3:18 PM, Carter Schonwald > wrote: >> >> There's also compdata >> >> >> On Saturday, June 7, 2014, Ben Foppa wrote: >>> >>> Hi cafe. On a use case whim, I made the open-union package >>> (https://github.com/RobotGymnast/open-union), copying the basic idea from >>> extensible-effects:Data.OpenUnion1. I haven't uploaded to hackage yet, on >>> the chance that there's already something like this around. Here's the basic >>> functionality: >>> >>> {-# LANGUAGE TypeOperators #-} >>> {-# LANGUAGE ScopedTypeVariables #-} >>> import Data.OpenUnion >>> >>> type MyUnion = Union (Char :| Int :| [()] :| Void) >>> >>> showMyUnion :: MyUnion -> String >>> showMyUnion >>> = (\(c :: Char) -> "char: " ++ show c) >>> @> (\(i :: Int) -> "int: " ++ show i) >>> @> (\(l :: [()]) -> "list length: " ++ show (length l)) >>> @> typesExhausted >>> >>> main :: IO () >>> main = do >>> putStrLn $ showMyUnion $ liftUnion (4 :: Int) >>> putStrLn $ showMyUnion $ liftUnion 'a' >>> putStrLn $ showMyUnion $ liftUnion [(), ()] >>> >>> >>> If any of the (@>) cases is omitted, a compile-time error occurs. If you >>> try to lift a bad value to the union, a compile-time error occurs. >>> >>> Any thoughts? Is there already something like this around? > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From benjamin.foppa at gmail.com Sun Jun 8 02:25:19 2014 From: benjamin.foppa at gmail.com (Ben Foppa) Date: Sat, 7 Jun 2014 22:25:19 -0400 Subject: [Haskell-cafe] open-union In-Reply-To: References: Message-ID: Cool, thanks for the info! On Jun 7, 2014 9:37 PM, "adam vogt" wrote: > Hi Ben, > > http://hackage.haskell.org/package/HList-0.3.4.1/docs/Data-HList-TIC.html > is very similar, though it uses -XDataKinds for the type-level list > and has fewer operations. For the next release we're changing the > type-indexed collections (TIP, TIC) to share most of the > implementation with Record and Variant respectively. > > I believe it's unnecessary to involve Typeable. Since there's a list > of possible types, you can store (Int, Any), where the Int is an index > into that list, instead of using TypeRep for that index. > http://code.haskell.org/~aavogt/HList/Data/HList/Variant.hs has that > implementation. Leaving out Typeable makes a difference as far as what > is allowed, because Records using promoted strings as the labels do > not have a Typeable instance in ghc-7.8.2. > > Regards, > Adam > > On Sat, Jun 7, 2014 at 3:47 PM, Ben Foppa > wrote: > > Thanks, I wasn't aware of vinyl and compdata. I'll check them out. > > I'm not very familiar with HList, but I was under the impression that it > > provided intersection, not union, i.e. for every type in { x1 x2 ..}, an > > HList has an element vs for SOME type in {x1 x2 ..} a Union has an > > element.. > > > > > > On Sat, Jun 7, 2014 at 3:18 PM, Carter Schonwald > > wrote: > >> > >> There's also compdata > >> > >> > >> On Saturday, June 7, 2014, Ben Foppa wrote: > >>> > >>> Hi cafe. On a use case whim, I made the open-union package > >>> (https://github.com/RobotGymnast/open-union), copying the basic idea > from > >>> extensible-effects:Data.OpenUnion1. I haven't uploaded to hackage yet, > on > >>> the chance that there's already something like this around. Here's the > basic > >>> functionality: > >>> > >>> {-# LANGUAGE TypeOperators #-} > >>> {-# LANGUAGE ScopedTypeVariables #-} > >>> import Data.OpenUnion > >>> > >>> type MyUnion = Union (Char :| Int :| [()] :| Void) > >>> > >>> showMyUnion :: MyUnion -> String > >>> showMyUnion > >>> = (\(c :: Char) -> "char: " ++ show c) > >>> @> (\(i :: Int) -> "int: " ++ show i) > >>> @> (\(l :: [()]) -> "list length: " ++ show (length l)) > >>> @> typesExhausted > >>> > >>> main :: IO () > >>> main = do > >>> putStrLn $ showMyUnion $ liftUnion (4 :: Int) > >>> putStrLn $ showMyUnion $ liftUnion 'a' > >>> putStrLn $ showMyUnion $ liftUnion [(), ()] > >>> > >>> > >>> If any of the (@>) cases is omitted, a compile-time error occurs. If > you > >>> try to lift a bad value to the union, a compile-time error occurs. > >>> > >>> Any thoughts? Is there already something like this around? > > > > > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From emax at chalmers.se Mon Jun 9 07:55:53 2014 From: emax at chalmers.se (Emil Axelsson) Date: Mon, 9 Jun 2014 09:55:53 +0200 Subject: [Haskell-cafe] open-union In-Reply-To: References: Message-ID: <53956889.6020404@chalmers.se> Similar functionality is provided by the `Dynamic` type in Syntactic: https://github.com/emilaxelsson/syntactic/blob/master/src/Data/Syntactic/TypeUniverse/TypeUniverse.hs (This is in the master branch, which is not on Hackage yet.) For a small showcase, see this reply: http://stackoverflow.com/questions/22876370/combining-data-dynamic-and-type-classes/22989262#22989262 One advantage of `Dynamic` in Syntactic is that it has a proper `Show` instance, so you don't need to define functions like `showMyUnion`: instance Witness Show ts ts => Show (Dynamic ts) That is, if you can make a `Show` witness for the types in the open union, then you have a `Show` instance for `Dynamic`. I haven't seen any other implementation where this is possible (but would like to know if there is any). It doesn't hurt to have many alternative solutions on Hackage. I'd say upload your package! / Emil 2014-06-07 21:01, Ben Foppa skrev: > Hi cafe. On a use case whim, I made the open-union package ( > https://github.com/RobotGymnast/open-union), copying the basic idea from > extensible-effects:Data.OpenUnion1. I haven't uploaded to hackage yet, on > the chance that there's already something like this around. Here's the > basic functionality: > > {-# LANGUAGE TypeOperators #-} > {-# LANGUAGE ScopedTypeVariables #-} > import Data.OpenUnion > > type MyUnion = Union (Char :| Int :| [()] :| Void) > > showMyUnion :: MyUnion -> String > showMyUnion > = (\(c :: Char) -> "char: " ++ show c) > @> (\(i :: Int) -> "int: " ++ show i) > @> (\(l :: [()]) -> "list length: " ++ show (length l)) > @> typesExhausted > > main :: IO () > main = do > putStrLn $ showMyUnion $ liftUnion (4 :: Int) > putStrLn $ showMyUnion $ liftUnion 'a' > putStrLn $ showMyUnion $ liftUnion [(), ()] > > > If any of the (@>) cases is omitted, a compile-time error occurs. If you > try to lift a bad value to the union, a compile-time error occurs. > > Any thoughts? Is there already something like this around? > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From sean at functionaljobs.com Mon Jun 9 16:00:01 2014 From: sean at functionaljobs.com (Functional Jobs) Date: Mon, 9 Jun 2014 12:00:01 -0400 Subject: [Haskell-cafe] New Functional Programming Job Opportunities Message-ID: <5395da0652bb8@functionaljobs.com> Here are some functional programming job opportunities that were posted recently: Sr. Software Engineer at Clutch Analytics http://functionaljobs.com/jobs/8720-sr-software-engineer-at-clutch-analytics Cheers, Sean Murphy FunctionalJobs.com From frode at nerbraten.no Mon Jun 9 18:36:38 2014 From: frode at nerbraten.no (=?UTF-8?Q?Frode_Nerbr=C3=A5ten?=) Date: Mon, 9 Jun 2014 20:36:38 +0200 Subject: [Haskell-cafe] Problems using ghc 7.8.2 with options -staticlib and -threaded on osx Message-ID: Hi, I'm having trouble building my Haskell library with GHC 7.8.2 and Cabal 1.20.0.2 on OSX 10.9.3 with both -staticlib and -threaded enabled. The library I'm building exports several functions using FFI to be called from ObjectiveC in an Xcode project. This works fine with just -staticlib enabled, but now I realize I need to call into my Haskell library from multiple OS-threads simultaneously. But when I add -threaded to ghc-options I get an error when linking: error: libtool: can't locate file for: -lpthread error: libtool: file: -lpthread is not an object file (not allowed in a library) The linker command that fails looks like this (... replaces a bunch of -l and -L options): libtool -static -o liba.a dist/build/HsCocoa.o ... -lCffi -lpthread In /usr/lib I have a libpthread.dylib that links to libSystem.dylib, but no libpthread.a. I was under the impression that libpthread was included with the system install. Is this supposed to work or am I misunderstanding something basic? :) Any help would be greatly appreciated! The project source is available on github: https://github.com/froden/digipostarkiv (I asked the same question on stackoverflow: http://stackoverflow.com/q/24096257/777411) Best regards, Frode Nerbr?ten From bob at redivi.com Mon Jun 9 19:33:18 2014 From: bob at redivi.com (Bob Ippolito) Date: Mon, 9 Jun 2014 12:33:18 -0700 Subject: [Haskell-cafe] Problems using ghc 7.8.2 with options -staticlib and -threaded on osx In-Reply-To: References: Message-ID: This seems like a bug, you shouldn't need to link to libpthread at all on Mac. /usr/lib/libpthread.dylib is just a symlink to libSystem? Not sure how to get around the issue without rebuilding GHC, it looks like iOS is special cased in the compiler (OSiOS) but not Mac OS X (OSDarwin) [1]. [1] https://github.com/ghc/ghc/blob/master/compiler/main/DriverPipeline.hs#L1869-L1873 On Mon, Jun 9, 2014 at 11:36 AM, Frode Nerbr?ten wrote: > Hi, > > I'm having trouble building my Haskell library with GHC 7.8.2 and > Cabal 1.20.0.2 on OSX 10.9.3 with both -staticlib and -threaded > enabled. > > The library I'm building exports several functions using FFI to be > called from ObjectiveC in an Xcode project. This works fine with just > -staticlib enabled, but now I realize I need to call into my Haskell > library from multiple OS-threads simultaneously. But when I add > -threaded to ghc-options I get an error when linking: > > error: libtool: can't locate file for: -lpthread > error: libtool: file: -lpthread is not an object file (not allowed > in a library) > > The linker command that fails looks like this (... replaces a bunch of > -l and -L options): > > libtool -static -o liba.a dist/build/HsCocoa.o ... -lCffi -lpthread > > In /usr/lib I have a libpthread.dylib that links to libSystem.dylib, > but no libpthread.a. I was under the impression that libpthread was > included with the system install. > > Is this supposed to work or am I misunderstanding something basic? :) > Any help would be greatly appreciated! > > The project source is available on github: > https://github.com/froden/digipostarkiv > (I asked the same question on stackoverflow: > http://stackoverflow.com/q/24096257/777411) > > Best regards, > Frode Nerbr?ten > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob at redivi.com Mon Jun 9 19:49:13 2014 From: bob at redivi.com (Bob Ippolito) Date: Mon, 9 Jun 2014 12:49:13 -0700 Subject: [Haskell-cafe] Problems using ghc 7.8.2 with options -staticlib and -threaded on osx In-Reply-To: References: Message-ID: After patching your Xcode project file to use $(PROJECT_DIR) instead of /Users/frode/dev/haskell/digipostarkiv I was able to build this. I changed the "libtool command" in my lib/ghc-7.8.2/settings to a shim that removes -lpthread and then calls /usr/bin/libtool. Not pretty but it worked, I'm sure there's a better workaround, but I think the real solution should be to simply special-case OSDarwin in the same way as OSiOS in GHC. On Mon, Jun 9, 2014 at 12:33 PM, Bob Ippolito wrote: > This seems like a bug, you shouldn't need to link to libpthread at all on > Mac. /usr/lib/libpthread.dylib is just a symlink to libSystem? Not sure how > to get around the issue without rebuilding GHC, it looks like iOS is > special cased in the compiler (OSiOS) but not Mac OS X (OSDarwin) [1]. > > [1] > https://github.com/ghc/ghc/blob/master/compiler/main/DriverPipeline.hs#L1869-L1873 > > > On Mon, Jun 9, 2014 at 11:36 AM, Frode Nerbr?ten > wrote: > >> Hi, >> >> I'm having trouble building my Haskell library with GHC 7.8.2 and >> Cabal 1.20.0.2 on OSX 10.9.3 with both -staticlib and -threaded >> enabled. >> >> The library I'm building exports several functions using FFI to be >> called from ObjectiveC in an Xcode project. This works fine with just >> -staticlib enabled, but now I realize I need to call into my Haskell >> library from multiple OS-threads simultaneously. But when I add >> -threaded to ghc-options I get an error when linking: >> >> error: libtool: can't locate file for: -lpthread >> error: libtool: file: -lpthread is not an object file (not allowed >> in a library) >> >> The linker command that fails looks like this (... replaces a bunch of >> -l and -L options): >> >> libtool -static -o liba.a dist/build/HsCocoa.o ... -lCffi -lpthread >> >> In /usr/lib I have a libpthread.dylib that links to libSystem.dylib, >> but no libpthread.a. I was under the impression that libpthread was >> included with the system install. >> >> Is this supposed to work or am I misunderstanding something basic? :) >> Any help would be greatly appreciated! >> >> The project source is available on github: >> https://github.com/froden/digipostarkiv >> (I asked the same question on stackoverflow: >> http://stackoverflow.com/q/24096257/777411) >> >> Best regards, >> Frode Nerbr?ten >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bkovach5 at uga.edu Mon Jun 9 21:06:51 2014 From: bkovach5 at uga.edu (Benjamin J Kovach) Date: Mon, 9 Jun 2014 21:06:51 +0000 Subject: [Haskell-cafe] Announcement: Bang, a drum DSL for Haskell Message-ID: Hi haskell-cafe, I've been working on "Bang" on and off for about a month or two now, and finally thought it was "good enough" to open-source and show to the public! I've been having fun with it, and hopefully some of you will, too. It currently supports basically all of the primitive transformations that I could think of doing on a drum sequence, such as reversing, mirroring, changing duration and tempo. There are a bunch of operators built in that make it easy to write things like polyrhythms, and infinite sequences of notes are possible as well. The source code and basic tutorial are up on Github: https://github.com/5outh/Bang And the package + more detailed documentation is up on Hackage: http://hackage.haskell.org/package/Bang Let me know if you have any questions, comments, and/or suggestions. I'd love to hear them. Thanks! 5outh? -------------- next part -------------- An HTML attachment was scrubbed... URL: From magicloud.magiclouds at gmail.com Tue Jun 10 05:41:22 2014 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Tue, 10 Jun 2014 13:41:22 +0800 Subject: [Haskell-cafe] XMonad and xinput.d. Message-ID: Hi, I am using Ubuntu, in which, X input method (ibus, for me) is started by xinput.d scripts. This works fine with KDE, Unity, etc. But when I switch to xmonad, there is no input method window, tray icon. And hotkeys not work, either. Ibus processes are there. Seems like I have to kill the ones started by xinput.d, and restart it myself in xmonad. What did I do wrong? -- ??????? ??????? And for G+, please use magiclouds#gmail.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: From waldmann at imn.htwk-leipzig.de Tue Jun 10 08:15:31 2014 From: waldmann at imn.htwk-leipzig.de (J. Waldmann) Date: Tue, 10 Jun 2014 08:15:31 +0000 (UTC) Subject: [Haskell-cafe] Announcement: Bang, a drum DSL for Haskell References: Message-ID: Benjamin J Kovach uga.edu> writes: > https://github.com/5outh/Bang nice. - two thoughts: * the basic object is a sequence of (MIDI) events, where duration is always implicit (computed by concatenation)? It might be useful to have explicit duration, so you can have an event "with (later) echoes" that still acts as just one event in concatenations (the echoes overlap with the following events - so you can say "apply echo to this drum" without destroying the timing of the pattern.) * (as with all Haskell EDSLs for music) a basic inconvenience in writing and reading is that the "space" symbol is application, while we actually want it for concatenation, to write a sequence of events without extra syntax (concatenation operators, or commas in list literals). I guess this requires a parser (as 'tidal' does it), or even template haskell (because we want to refer to user-defined Haskell values from inside the pattern). - J.W. From robstewart57 at gmail.com Tue Jun 10 08:59:50 2014 From: robstewart57 at gmail.com (Rob Stewart) Date: Tue, 10 Jun 2014 09:59:50 +0100 Subject: [Haskell-cafe] Cross compiling Haskell from Linux to Windows with GHCs LLVM backend? Message-ID: Hi, I compile my code with GHC on Linux, and don't have ready access to a Windows or a Mac operating system. Is it possible to use the GHC LLVM backend as a means to cross compile Haskell code to target multiple operating systems? I had envisaged it possible to generate the LLVM IR using GHCs -keep-llvm-files flag, and using LLVMs target triple flag to specify the CPU architecture and operating system of the users machine. I'd like to compile on Linux, to target WIndows and Mac machines. Strangely I cannot find blog posts or tutorials online for cross-compiling Haskell with GHC via LLVM. Is it possible? Thanks, -- Rob From frode at nerbraten.no Tue Jun 10 09:15:56 2014 From: frode at nerbraten.no (=?UTF-8?Q?Frode_Nerbr=C3=A5ten?=) Date: Tue, 10 Jun 2014 11:15:56 +0200 Subject: [Haskell-cafe] Problems using ghc 7.8.2 with options -staticlib and -threaded on osx In-Reply-To: References: Message-ID: Thank you Bob! I tried your workaround (and fixed the lib path in my project) and it worked perfectly. Calling my Haskell functions from multiple ObjectiveC threads now works as expected. You saved my day :) I'll report this as a bug in GHC. Thank you for the source link. Regards, Frode On Mon, Jun 9, 2014 at 9:49 PM, Bob Ippolito wrote: > After patching your Xcode project file to use $(PROJECT_DIR) instead of > /Users/frode/dev/haskell/digipostarkiv I was able to build this. I changed > the "libtool command" in my lib/ghc-7.8.2/settings to a shim that removes > -lpthread and then calls /usr/bin/libtool. Not pretty but it worked, I'm > sure there's a better workaround, but I think the real solution should be to > simply special-case OSDarwin in the same way as OSiOS in GHC. > > > On Mon, Jun 9, 2014 at 12:33 PM, Bob Ippolito wrote: >> >> This seems like a bug, you shouldn't need to link to libpthread at all on >> Mac. /usr/lib/libpthread.dylib is just a symlink to libSystem? Not sure how >> to get around the issue without rebuilding GHC, it looks like iOS is special >> cased in the compiler (OSiOS) but not Mac OS X (OSDarwin) [1]. >> >> [1] >> https://github.com/ghc/ghc/blob/master/compiler/main/DriverPipeline.hs#L1869-L1873 >> >> >> On Mon, Jun 9, 2014 at 11:36 AM, Frode Nerbr?ten >> wrote: >>> >>> Hi, >>> >>> I'm having trouble building my Haskell library with GHC 7.8.2 and >>> Cabal 1.20.0.2 on OSX 10.9.3 with both -staticlib and -threaded >>> enabled. >>> >>> The library I'm building exports several functions using FFI to be >>> called from ObjectiveC in an Xcode project. This works fine with just >>> -staticlib enabled, but now I realize I need to call into my Haskell >>> library from multiple OS-threads simultaneously. But when I add >>> -threaded to ghc-options I get an error when linking: >>> >>> error: libtool: can't locate file for: -lpthread >>> error: libtool: file: -lpthread is not an object file (not allowed >>> in a library) >>> >>> The linker command that fails looks like this (... replaces a bunch of >>> -l and -L options): >>> >>> libtool -static -o liba.a dist/build/HsCocoa.o ... -lCffi -lpthread >>> >>> In /usr/lib I have a libpthread.dylib that links to libSystem.dylib, >>> but no libpthread.a. I was under the impression that libpthread was >>> included with the system install. >>> >>> Is this supposed to work or am I misunderstanding something basic? :) >>> Any help would be greatly appreciated! >>> >>> The project source is available on github: >>> https://github.com/froden/digipostarkiv >>> (I asked the same question on stackoverflow: >>> http://stackoverflow.com/q/24096257/777411) >>> >>> Best regards, >>> Frode Nerbr?ten >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe at haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > From kiwamu at debian.or.jp Tue Jun 10 10:13:15 2014 From: kiwamu at debian.or.jp (Kiwamu Okabe) Date: Tue, 10 Jun 2014 19:13:15 +0900 Subject: [Haskell-cafe] [Rejected Paper] Experience Report: Writing NetBSD Sound Drivers in Haskell Message-ID: Hi jhc-hackers, I have written a paper "Experience Report: Writing NetBSD Sound Drivers in Haskell". http://metasepi.org/papers.html It explains Ajhc customized jhc GC, and sometime useful to develop jhc. Thank's, -- Kiwamu Okabe at METASEPI DESIGN From frode at nerbraten.no Tue Jun 10 10:26:38 2014 From: frode at nerbraten.no (=?UTF-8?Q?Frode_Nerbr=C3=A5ten?=) Date: Tue, 10 Jun 2014 12:26:38 +0200 Subject: [Haskell-cafe] Problems using ghc 7.8.2 with options -staticlib and -threaded on osx In-Reply-To: References: Message-ID: https://ghc.haskell.org/trac/ghc/ticket/9189 On Tue, Jun 10, 2014 at 11:15 AM, Frode Nerbr?ten wrote: > Thank you Bob! I tried your workaround (and fixed the lib path in my > project) and it worked perfectly. Calling my Haskell functions from > multiple ObjectiveC threads now works as expected. You saved my day :) > > I'll report this as a bug in GHC. Thank you for the source link. > > Regards, > Frode > > On Mon, Jun 9, 2014 at 9:49 PM, Bob Ippolito wrote: >> After patching your Xcode project file to use $(PROJECT_DIR) instead of >> /Users/frode/dev/haskell/digipostarkiv I was able to build this. I changed >> the "libtool command" in my lib/ghc-7.8.2/settings to a shim that removes >> -lpthread and then calls /usr/bin/libtool. Not pretty but it worked, I'm >> sure there's a better workaround, but I think the real solution should be to >> simply special-case OSDarwin in the same way as OSiOS in GHC. >> >> >> On Mon, Jun 9, 2014 at 12:33 PM, Bob Ippolito wrote: >>> >>> This seems like a bug, you shouldn't need to link to libpthread at all on >>> Mac. /usr/lib/libpthread.dylib is just a symlink to libSystem? Not sure how >>> to get around the issue without rebuilding GHC, it looks like iOS is special >>> cased in the compiler (OSiOS) but not Mac OS X (OSDarwin) [1]. >>> >>> [1] >>> https://github.com/ghc/ghc/blob/master/compiler/main/DriverPipeline.hs#L1869-L1873 >>> >>> >>> On Mon, Jun 9, 2014 at 11:36 AM, Frode Nerbr?ten >>> wrote: >>>> >>>> Hi, >>>> >>>> I'm having trouble building my Haskell library with GHC 7.8.2 and >>>> Cabal 1.20.0.2 on OSX 10.9.3 with both -staticlib and -threaded >>>> enabled. >>>> >>>> The library I'm building exports several functions using FFI to be >>>> called from ObjectiveC in an Xcode project. This works fine with just >>>> -staticlib enabled, but now I realize I need to call into my Haskell >>>> library from multiple OS-threads simultaneously. But when I add >>>> -threaded to ghc-options I get an error when linking: >>>> >>>> error: libtool: can't locate file for: -lpthread >>>> error: libtool: file: -lpthread is not an object file (not allowed >>>> in a library) >>>> >>>> The linker command that fails looks like this (... replaces a bunch of >>>> -l and -L options): >>>> >>>> libtool -static -o liba.a dist/build/HsCocoa.o ... -lCffi -lpthread >>>> >>>> In /usr/lib I have a libpthread.dylib that links to libSystem.dylib, >>>> but no libpthread.a. I was under the impression that libpthread was >>>> included with the system install. >>>> >>>> Is this supposed to work or am I misunderstanding something basic? :) >>>> Any help would be greatly appreciated! >>>> >>>> The project source is available on github: >>>> https://github.com/froden/digipostarkiv >>>> (I asked the same question on stackoverflow: >>>> http://stackoverflow.com/q/24096257/777411) >>>> >>>> Best regards, >>>> Frode Nerbr?ten >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe at haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >>> >> From john at repetae.net Tue Jun 10 10:55:21 2014 From: john at repetae.net (John Meacham) Date: Tue, 10 Jun 2014 03:55:21 -0700 Subject: [Haskell-cafe] [Rejected Paper] Experience Report: Writing NetBSD Sound Drivers in Haskell In-Reply-To: References: Message-ID: Oooh. and you documented jhc's RTS while you were at it. that is great :) I have been thinking about a way to extend JGC to seamlessly handle interfaces that utilize stack allocated C structs. The main target being GMP. Right now I can do pretty well by having a 'self-pointing' 'self-cleaning' ForeignPtr. The definition of ForeignPtr is > data ForeginPtr = ForeignPtr Addr_ However, it is a little magic in that you can allocate it in a larger space than it would naturally take up, I can then have Addr_ point to the word following it directly in memory. The garbage collector treats it just like normal and needs no finalizer, as long as the ForeginPtr is live, the area it points to is live since they are the same space, as far as the code is concerned it could be pointing to an external C structure. This is very efficient and a very fast way to throw around C structures without having to worry about whether they were allocated in haskell or in C. However, things like GMP require the memory region to be initialized and freed since it may have internal pointers. I could just continue with standard foreign pointers, attaching a destructor, but this has a couple problems - I have to initialize the memory area, this is hard to do without invoking the IO monad to ensure proper sequencing, for the result of an addition, that seems heavy, it is hard for the complier to "see through" an unsafePerformIO when optimizing. - every Integer will have to carry around two extra words, a self pointer that always points to its own memory location, and a pointer to a destructor that is always going to be the same. - memory will be destructed when it is likely to immediately be re-used as an Integer, it would be good to deforest this destruct-construct pair. To solve both I was thinking of assosciating a contructor/destructor with a type rather than a value. By creating an entire block of the same type, it can initialize the entire block at once, then delay the destructor until the entire block is freed. since GMP ints can be re-used in place, it would get rid of almost all initialization and destruction overhead. A 'delayed destructor' if you will, that only needs to be called if the memory location is going to be used for a different type. Allocations in jhc are already tagged by type so this isn't difficult to keep track of. I was thinking something like data {-# CCONSTRUCTOR "init_integer" #-} {-# CDESTRUCTOR delayed "fini_integer" #-} Integer_ :: # data Integer = Integer Integer_ since Integer_ is unboxed, we can ensure they are only created in the right heap by using a primitive to do so, there is no way for a user to conjure up an unboxed type that doesn't take part in unboxed num polymorphism so can be represented by 0# 1# etc. John On Tue, Jun 10, 2014 at 3:13 AM, Kiwamu Okabe wrote: > Hi jhc-hackers, > > I have written a paper "Experience Report: Writing NetBSD Sound > Drivers in Haskell". > > http://metasepi.org/papers.html > > It explains Ajhc customized jhc GC, and sometime useful to develop jhc. > > Thank's, > -- > Kiwamu Okabe at METASEPI DESIGN > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- John Meacham - http://notanumber.net/ From kiwamu at debian.or.jp Tue Jun 10 11:19:51 2014 From: kiwamu at debian.or.jp (Kiwamu Okabe) Date: Tue, 10 Jun 2014 20:19:51 +0900 Subject: [Haskell-cafe] [Rejected Paper] Experience Report: Writing NetBSD Sound Drivers in Haskell In-Reply-To: References: Message-ID: Hi John, On Tue, Jun 10, 2014 at 7:55 PM, John Meacham wrote: > Oooh. and you documented jhc's RTS while you were at it. that is great :) BTW. How do you think about jgc having multiple "arena" with the context? It can realize reentrant GC on jhc. Of cause, I know you feel bad about the cost initializing jgc every call C=>Haskell. Do you have some idea for the multiple "arena"? Best regards, -- Kiwamu Okabe at METASEPI DESIGN From john at repetae.net Tue Jun 10 11:26:32 2014 From: john at repetae.net (John Meacham) Date: Tue, 10 Jun 2014 04:26:32 -0700 Subject: [Haskell-cafe] [Rejected Paper] Experience Report: Writing NetBSD Sound Drivers in Haskell In-Reply-To: References: Message-ID: Hmm.. what were you thinking of in terms of how it would change the API? By reentrant do you mean you want C functions that were called by haskell to be able to call back into haskell again? what is the issue with the context that is stowed. or are you talking about SMP/lightweight threads? On Tue, Jun 10, 2014 at 4:19 AM, Kiwamu Okabe wrote: > Hi John, > > On Tue, Jun 10, 2014 at 7:55 PM, John Meacham wrote: >> Oooh. and you documented jhc's RTS while you were at it. that is great :) > > BTW. > How do you think about jgc having multiple "arena" with the context? > It can realize reentrant GC on jhc. > Of cause, I know you feel bad about the cost initializing jgc every > call C=>Haskell. > > Do you have some idea for the multiple "arena"? > > Best regards, > -- > Kiwamu Okabe at METASEPI DESIGN -- John Meacham - http://notanumber.net/ From john at repetae.net Tue Jun 10 11:28:16 2014 From: john at repetae.net (John Meacham) Date: Tue, 10 Jun 2014 04:28:16 -0700 Subject: [Haskell-cafe] [Rejected Paper] Experience Report: Writing NetBSD Sound Drivers in Haskell In-Reply-To: References: Message-ID: Ah. I think I see what you mean by reentrant in your paper. Can you point me to your context switching code in ajhc? Is SMP a concern for you or are you mainly concerned about hardware interrupts? On Tue, Jun 10, 2014 at 4:26 AM, John Meacham wrote: > Hmm.. what were you thinking of in terms of how it would change the API? > > By reentrant do you mean you want C functions that were called by > haskell to be able to call back into haskell again? what is the issue > with the context that is stowed. or are you talking about > SMP/lightweight threads? > > > > On Tue, Jun 10, 2014 at 4:19 AM, Kiwamu Okabe wrote: >> Hi John, >> >> On Tue, Jun 10, 2014 at 7:55 PM, John Meacham wrote: >>> Oooh. and you documented jhc's RTS while you were at it. that is great :) >> >> BTW. >> How do you think about jgc having multiple "arena" with the context? >> It can realize reentrant GC on jhc. >> Of cause, I know you feel bad about the cost initializing jgc every >> call C=>Haskell. >> >> Do you have some idea for the multiple "arena"? >> >> Best regards, >> -- >> Kiwamu Okabe at METASEPI DESIGN > > > > -- > John Meacham - http://notanumber.net/ -- John Meacham - http://notanumber.net/ From kiwamu at debian.or.jp Tue Jun 10 11:42:46 2014 From: kiwamu at debian.or.jp (Kiwamu Okabe) Date: Tue, 10 Jun 2014 20:42:46 +0900 Subject: [Haskell-cafe] [Rejected Paper] Experience Report: Writing NetBSD Sound Drivers in Haskell In-Reply-To: References: Message-ID: Hi John, On Tue, Jun 10, 2014 at 8:28 PM, John Meacham wrote: > Ah. I think I see what you mean by reentrant in your paper. Can you > point me to your context switching code in ajhc? Here is. https://github.com/ajhc/ajhc/blob/arafura/rts/rts/conc.c#L33 It's a sample with pthread. But CLHs can choose any thread style with calling C code that generate context switch. > Is SMP a concern for you or are you mainly concerned about hardware interrupts? Both thread on SMP and interrupt. Former uses active context switch, and the example is the above. Later uses passive context switch, however the interrupt context begins on C context. The C context create new "arena" when calling C => Haskell. Thank's, -- Kiwamu Okabe at METASEPI DESIGN From john at repetae.net Tue Jun 10 11:49:19 2014 From: john at repetae.net (John Meacham) Date: Tue, 10 Jun 2014 04:49:19 -0700 Subject: [Haskell-cafe] [Rejected Paper] Experience Report: Writing NetBSD Sound Drivers in Haskell In-Reply-To: References: Message-ID: Hmm... if we allocate the gc_stack on an aligned boundry, can we recover the arena by keeping a pointer at its base? sort of like I recover the cache block pointer from an arbitrary heap location by rounding down to the block boundry. The main issue would be how it affects allocation speed, its okay to make the GC slower as long as allocation is still fast, Before pre-populating the cache pointers sped things up considerably, how would it make sure to use one from the current arena without slowing down allocation in general? John On Tue, Jun 10, 2014 at 4:42 AM, Kiwamu Okabe wrote: > Hi John, > > On Tue, Jun 10, 2014 at 8:28 PM, John Meacham wrote: >> Ah. I think I see what you mean by reentrant in your paper. Can you >> point me to your context switching code in ajhc? > > Here is. > > https://github.com/ajhc/ajhc/blob/arafura/rts/rts/conc.c#L33 > > It's a sample with pthread. > But CLHs can choose any thread style with calling C code that generate > context switch. > > >> Is SMP a concern for you or are you mainly concerned about hardware interrupts? > > Both thread on SMP and interrupt. > Former uses active context switch, and the example is the above. > Later uses passive context switch, however the interrupt context > begins on C context. > The C context create new "arena" when calling C => Haskell. > > Thank's, > -- > Kiwamu Okabe at METASEPI DESIGN -- John Meacham - http://notanumber.net/ From kiwamu at debian.or.jp Tue Jun 10 11:58:08 2014 From: kiwamu at debian.or.jp (Kiwamu Okabe) Date: Tue, 10 Jun 2014 20:58:08 +0900 Subject: [Haskell-cafe] [Rejected Paper] Experience Report: Writing NetBSD Sound Drivers in Haskell In-Reply-To: References: Message-ID: Hi John, On Tue, Jun 10, 2014 at 8:49 PM, John Meacham wrote: > The main issue would be how it affects allocation speed, its okay to > make the GC slower as long as allocation is still fast, Before > pre-populating the cache pointers sped things up considerably, how > would it make sure to use one from the current arena without slowing > down allocation in general? So I don't have any benchmark for it today. I worry about the cost initializing arena when C=>Haskell. Current jgc has no cost, but my jgc initializes arena when C=>Haskell everytime. Please imagine the cost call all of find_cache(). Regards, -- Kiwamu Okabe at METASEPI DESIGN From john at repetae.net Tue Jun 10 12:07:03 2014 From: john at repetae.net (John Meacham) Date: Tue, 10 Jun 2014 05:07:03 -0700 Subject: [Haskell-cafe] [Rejected Paper] Experience Report: Writing NetBSD Sound Drivers in Haskell In-Reply-To: References: Message-ID: Yeah, find_cache is fairly slow. In fact, just checking if it is NULL noticibly slows things down. So, something that could be done is generate a struct with each cache used as offsets in it, basically putting the entire generate s_cache table in a struct then initializing them all when the arena is allocated. that would add a single redirect thruogh the arena to the caches which might not be too bad... what would be better is to use a thread or processor local register. John On Tue, Jun 10, 2014 at 4:58 AM, Kiwamu Okabe wrote: > Hi John, > > On Tue, Jun 10, 2014 at 8:49 PM, John Meacham wrote: >> The main issue would be how it affects allocation speed, its okay to >> make the GC slower as long as allocation is still fast, Before >> pre-populating the cache pointers sped things up considerably, how >> would it make sure to use one from the current arena without slowing >> down allocation in general? > > So I don't have any benchmark for it today. > I worry about the cost initializing arena when C=>Haskell. > Current jgc has no cost, but my jgc initializes arena when C=>Haskell everytime. > Please imagine the cost call all of find_cache(). > > Regards, > -- > Kiwamu Okabe at METASEPI DESIGN -- John Meacham - http://notanumber.net/ From carter.schonwald at gmail.com Tue Jun 10 13:31:25 2014 From: carter.schonwald at gmail.com (Carter Schonwald) Date: Tue, 10 Jun 2014 09:31:25 -0400 Subject: [Haskell-cafe] Cross compiling Haskell from Linux to Windows with GHCs LLVM backend? In-Reply-To: References: Message-ID: You'll have much the same challenges as cross compiling using fllvm as fasm. I'm not sure if cross compiling has been tested much aside from in the Intel -> Arm case. On Tuesday, June 10, 2014, Rob Stewart wrote: > Hi, > > I compile my code with GHC on Linux, and don't have ready access to a > Windows or a Mac operating system. Is it possible to use the GHC LLVM > backend as a means to cross compile Haskell code to target multiple > operating systems? I had envisaged it possible to generate the LLVM IR > using GHCs -keep-llvm-files flag, and using LLVMs target triple flag > to specify the CPU architecture and operating system of the users > machine. I'd like to compile on Linux, to target WIndows and Mac > machines. > > Strangely I cannot find blog posts or tutorials online for > cross-compiling Haskell with GHC via LLVM. > > Is it possible? Thanks, > > -- > Rob > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From john at repetae.net Tue Jun 10 14:16:29 2014 From: john at repetae.net (John Meacham) Date: Tue, 10 Jun 2014 07:16:29 -0700 Subject: [Haskell-cafe] [Rejected Paper] Experience Report: Writing NetBSD Sound Drivers in Haskell In-Reply-To: References: Message-ID: Hmm.. well in any case, collecting the whole context into a handy struct is a good cleanup anyway, even if there is just a single global one. So I should backport that as well as the pthreads code. On Tue, Jun 10, 2014 at 5:07 AM, John Meacham wrote: > Yeah, find_cache is fairly slow. In fact, just checking if it is NULL > noticibly slows things down. > > So, something that could be done is generate a struct with each cache > used as offsets in it, basically putting the entire generate s_cache > table in a struct then initializing them all when the arena is > allocated. that would add a single redirect thruogh the arena to the > caches which might not be too bad... > > what would be better is to use a thread or processor local register. > > John > > On Tue, Jun 10, 2014 at 4:58 AM, Kiwamu Okabe wrote: >> Hi John, >> >> On Tue, Jun 10, 2014 at 8:49 PM, John Meacham wrote: >>> The main issue would be how it affects allocation speed, its okay to >>> make the GC slower as long as allocation is still fast, Before >>> pre-populating the cache pointers sped things up considerably, how >>> would it make sure to use one from the current arena without slowing >>> down allocation in general? >> >> So I don't have any benchmark for it today. >> I worry about the cost initializing arena when C=>Haskell. >> Current jgc has no cost, but my jgc initializes arena when C=>Haskell everytime. >> Please imagine the cost call all of find_cache(). >> >> Regards, >> -- >> Kiwamu Okabe at METASEPI DESIGN > > > > -- > John Meacham - http://notanumber.net/ -- John Meacham - http://notanumber.net/ From kiwamu at debian.or.jp Tue Jun 10 14:22:49 2014 From: kiwamu at debian.or.jp (Kiwamu Okabe) Date: Tue, 10 Jun 2014 23:22:49 +0900 Subject: [Haskell-cafe] [Rejected Paper] Experience Report: Writing NetBSD Sound Drivers in Haskell In-Reply-To: References: Message-ID: Hi John, Thank's for your advice. On Tue, Jun 10, 2014 at 11:16 PM, John Meacham wrote: > Hmm.. well in any case, collecting the whole context into a handy > struct is a good cleanup anyway, even if there is just a single global > one. So I should backport that as well as the pthreads code. I think strongly depending on pthread is bad idea, because it will destroy jhc's minimalism. Ajhc is result that is chosen with the design of selectable thread arch, but slow than jhc... I should think more and more to merge CLHs into jhc... Thank's, -- Kiwamu Okabe at METASEPI DESIGN From richard.lewis at gold.ac.uk Tue Jun 10 15:00:31 2014 From: richard.lewis at gold.ac.uk (Richard Lewis) Date: Tue, 10 Jun 2014 16:00:31 +0100 Subject: [Haskell-cafe] JOB: AHRC Doctoral Studentship in Computational Musicology Message-ID: <8538fcbyi8.wl%richard.lewis@gold.ac.uk> STUDENTSHIP ADVERTISEMENT With apologies for cross posting AHRC Doctoral Studentship in Computational Musicology http://www.transforming-musicology.org/news/2014-06-03_ahrc-doctoral-studentship-in-computational-musicology/ London, UK (with UK residency requirement unfortunately) Although this is not an explicitly Haskell programming job, the student would be free to work in whatever language they wish. Furthermore, there would be encouragement to consider a functional and/or logic programming approach to research. Award: fees and tax-free stipend at ?15,726 p.a. (inc. of London weighting) Application deadline: Tuesday 1 July 2014 Expected start date: October 2014 We invite applications for a Doctoral Studentship, funded by the Arts and Humanities Research Council, in Computational Musicology, located at Queen Mary University of London, under the supervision of Professor Geraint Wiggins. The studentship is part of the "Transforming Musicology" project, including Goldsmiths, University of London, Queen Mary University of London, the University of Oxford and Lancaster University. This project, led by Prof Tim Crawford in the Computing Department of Goldsmiths, University of London, brings together 15 researchers to effect a Digital Transformation of the discipline of musicology. The aim of the open studentship is to research and develop new methods for the representation of, and inference about, music-theoretic and perceptual aspects of music, based on, but not restricted to, past work by Prof. Wiggins and colleagues. This will be deployed using Semantic Web technology. The studentship will be located in a very rich research environment, first within the Transforming Musicology project, but also within the Computational Creativity Lab at QMUL, and the successful candidate will be encouraged to interact with other researchers in both of these contexts. This studentship, funded by an AHRC Doctoral Training Account, is for fees plus a tax-free stipend starting at ?15,726 per annum. Further details of the AHRC scheme including terms and conditions can be found here: http://www.ahrc.ac.uk/Funding-Opportunities/Postgraduate-funding/Pages/Current-award-holders.aspx Applicants must satisfy the AHRC's UK residence requirements: http://www.ahrc.ac.uk/Funding-Opportunities/Documents/Guide%20to%20Student%20Eligibility.pdf Candidates must have a first class or 2.1 undergraduate degree or equivalent, either with a significant component of music theory, in which case evidence of exceptionally well-developed practical expertise in computing, including programming, will be required, or in computer science or equivalent, in which case evidence of formal training in music theory (e.g. to grade V or equivalent) will be required. Candidates with relevant postgraduate qualifications will be particularly welcome, especially if they are qualified in both music and computer science. Other relevant qualifications and/or areas of expertise include (but are not limited to): artificial intelligence, informatics, formal logic and automated reasoning, musicology, knowledge representation, deductive database theory. The successful applicant may be required to undertake relevant undergraduate and postgraduate interdisciplinary courses as part of the programme of study. Informal enquiries can be made by email to Prof. Geraint Wiggins (geraint.wiggins at qmul.ac.uk). Please note that Prof. Wiggins is unable to advise, prior to interview, whether an applicant is likely to be selected. To apply please follow the on-line process (see http://www.qmul.ac.uk/postgraduate/howtoapply/) by selecting "Electronic Engineering" in the "A-Z list of research opportunities" and following the instructions on the right hand side of the web page. Please note that instead of the 'Research Proposal' we request a 'Statement of Research Interests'. Your Statement of Research Interest should answer two questions: (i) Why are you interested in the proposed area? (ii) What is your experience in the proposed area? Your statement should be brief: no more than 500 words or one side of A4 paper. In addition we would also like you to send a sample of your written work, such as your final year dissertation. More details can be found at: http://www.eecs.qmul.ac.uk/phd/how-to-apply Applications must be received by Tuesday 1 July 2014. Interviews are expected to take place during July 2014. -- -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= Richard Lewis Computing, Goldsmiths' College t: +44 (0)20 7078 5203 @: lewisrichard http://www.transforming-musicology.org/ 905C D796 12CD 4C6E CBFB 69DA EFCE DCDF 71D7 D455 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= From schlepptop at henning-thielemann.de Tue Jun 10 21:33:43 2014 From: schlepptop at henning-thielemann.de (Henning Thielemann) Date: Tue, 10 Jun 2014 23:33:43 +0200 Subject: [Haskell-cafe] [jhc] [Rejected Paper] Experience Report: Writing NetBSD Sound Drivers in Haskell In-Reply-To: References: Message-ID: <539779B7.8000404@henning-thielemann.de> Am 10.06.2014 12:13, schrieb Kiwamu Okabe: > Hi jhc-hackers, > > I have written a paper "Experience Report: Writing NetBSD Sound > Drivers in Haskell". > > http://metasepi.org/papers.html Since you are concerned with low-level Haskell programming, what do you think about the Reduceron project? I also wondered whether it would be possible to teach functional programming to processors with customizable machine code like the Transmeta processors. I don't know whether comparable projects are still alive. From ok at cs.otago.ac.nz Tue Jun 10 22:27:58 2014 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Wed, 11 Jun 2014 10:27:58 +1200 Subject: [Haskell-cafe] Announcement: Bang, a drum DSL for Haskell In-Reply-To: References: Message-ID: On 10/06/2014, at 8:15 PM, J. Waldmann wrote: > * (as with all Haskell EDSLs for music) a basic inconvenience in writing and > reading is that the "space" symbol is application, while we actually want it > for concatenation, to write a sequence of events without extra syntax > (concatenation operators, or commas in list literals). So you can't write a, a b, a b c, a b c d, and so on meaning concatenation every time, but can't you use the ideas of http://okmij.org/ftp/Haskell/polyvariadic.html#polyvar-fn to write f a, f a b, f a b c, f a b c d, and so on? From semen at trygub.com Tue Jun 10 23:17:49 2014 From: semen at trygub.com (Semen Trygubenko / =?utf-8?B?0KHQtdC80LXQvSDQotGA0LjQs9GD0LHQtdC9?= =?utf-8?B?0LrQvg==?=) Date: Wed, 11 Jun 2014 00:17:49 +0100 Subject: [Haskell-cafe] non-exhaustive pattern match(es)? Message-ID: <20140610231749.GA7670@inanna.trygub.com> Dear Haskell Cafe, In the following program f :: Int -> [(Int,Int)] -> [(Int,Int)] -> [(Int,Int)] f _ cs [] = cs f _ [] _ = [] f i (c:cs) ((i',t):os) | i < i' = [] | i == i' = [] | i > i' = [] -- | otherwise = [] main :: IO () main = do print $ f 0 [] [] without the "otherwise" clause (commented) I get the warning example.hs:2:1: Warning: Pattern match(es) are non-exhaustive In an equation for `f': Patterns not matched: _ (_ : _) ((_, _) : _) Could someone help me uncover which cases that are not? erm? covered by the above patterns? Many thanks, Semen PS This definition, on the other hand, f _ cs [] = cs f _ [] _ = [] f i (c:cs) ((i',t):os) = [] is exhaustive? -- ????? ?????????? http://trygub.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available URL: From mail at nh2.me Tue Jun 10 23:25:11 2014 From: mail at nh2.me (=?UTF-8?B?TmlrbGFzIEhhbWLDvGNoZW4=?=) Date: Wed, 11 Jun 2014 00:25:11 +0100 Subject: [Haskell-cafe] non-exhaustive pattern match(es)? In-Reply-To: <20140610231749.GA7670@inanna.trygub.com> References: <20140610231749.GA7670@inanna.trygub.com> Message-ID: <539793D7.9090807@nh2.me> Hi, to the compiler, (<), (==) and (>) are just functions. It doesn't know that they have anything to do with each other. Its totality checking works solely on all alternatives given in data type declarations (separated by `|`s). Have a look at http://community.haskell.org/~ndm/catch/ for a try to go beyond that. Niklas On 11/06/14 00:17, Semen Trygubenko / ????? ?????????? wrote: > Could someone help me uncover which cases that are not? erm? > covered by the above patterns? From bertram.felgenhauer at googlemail.com Tue Jun 10 23:25:48 2014 From: bertram.felgenhauer at googlemail.com (Bertram Felgenhauer) Date: Wed, 11 Jun 2014 01:25:48 +0200 Subject: [Haskell-cafe] Announcement: Bang, a drum DSL for Haskell In-Reply-To: References: Message-ID: <20140610232548.GB11986@24f89f8c-e6a1-4e75-85ee-bb8a3743bb9f> Richard A. O'Keefe wrote: > > On 10/06/2014, at 8:15 PM, J. Waldmann wrote: > > * (as with all Haskell EDSLs for music) a basic inconvenience in writing and > > reading is that the "space" symbol is application, while we actually want it > > for concatenation, to write a sequence of events without extra syntax > > (concatenation operators, or commas in list literals). > > So you can't write a, a b, a b c, a b c d, and so on meaning > concatenation every time, but can't you use the ideas of > http://okmij.org/ftp/Haskell/polyvariadic.html#polyvar-fn > to write f a, f a b, f a b c, f a b c d, and so on? You can do something similar without type classes, as I learned from http://www.cs.uu.nl/wiki/Afp/Assignments#Assignment_2 : begin cont = cont (return ()) a m cont = cont (m >> putStrLn "a") b m cont = cont (m >> putStrLn "b") c m cont = cont (m >> putStrLn "c") end m = m main = begin a b c a b a end Cheers, Bertram From lambda.fairy at gmail.com Tue Jun 10 23:26:57 2014 From: lambda.fairy at gmail.com (Chris Wong) Date: Wed, 11 Jun 2014 11:26:57 +1200 Subject: [Haskell-cafe] non-exhaustive pattern match(es)? In-Reply-To: <20140610231749.GA7670@inanna.trygub.com> References: <20140610231749.GA7670@inanna.trygub.com> Message-ID: Hi there, The problem is in these lines: > | i < i' = [] > | i == i' = [] > | i > i' = [] Comparisons are defined by the library, not the language. There is no way for the compiler to know they're mutually exclusive, short of solving the halting problem. In fact, it is possible to write this: instance Ord MyType where _ < _ = False _ == _ = False _ > _ = False and your f will fail at run time. The solution is to either replace your last comparison with "otherwise" (since it must be True anyway), or use `compare`: f i (c:cs) ((i',t):os) = case i `compare` i' of LT -> ... EQ -> ... GT -> ... Since these cases *are* mutually exclusive, it will pass the warning. > > main :: IO () > main = do print $ f 0 [] [] > > > without the "otherwise" clause (commented) I get the warning > > example.hs:2:1: Warning: > Pattern match(es) are non-exhaustive > In an equation for `f': > Patterns not matched: _ (_ : _) ((_, _) : _) > > Could someone help me uncover which cases that are not? erm? covered > by the above patterns? > > Many thanks, > Semen > > PS This definition, on the other hand, > > f _ cs [] = cs > f _ [] _ = [] > f i (c:cs) ((i',t):os) = [] > > is exhaustive? > > > -- > ????? ?????????? http://trygub.com > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From mail at nh2.me Tue Jun 10 23:27:25 2014 From: mail at nh2.me (=?UTF-8?B?TmlrbGFzIEhhbWLDvGNoZW4=?=) Date: Wed, 11 Jun 2014 00:27:25 +0100 Subject: [Haskell-cafe] non-exhaustive pattern match(es)? In-Reply-To: <539793D7.9090807@nh2.me> References: <20140610231749.GA7670@inanna.trygub.com> <539793D7.9090807@nh2.me> Message-ID: <5397945D.4040400@nh2.me> To propose an actual solution to your problem: You can use the `compare` function from Data.Ord. It returns a `data Ordering = LT | EQ | GT`, which you can pattern match on with a totality check. From kiwamu at debian.or.jp Wed Jun 11 00:03:38 2014 From: kiwamu at debian.or.jp (Kiwamu Okabe) Date: Wed, 11 Jun 2014 09:03:38 +0900 Subject: [Haskell-cafe] [jhc] [Rejected Paper] Experience Report: Writing NetBSD Sound Drivers in Haskell In-Reply-To: <539779B7.8000404@henning-thielemann.de> References: <539779B7.8000404@henning-thielemann.de> Message-ID: Hi Henning, On Wed, Jun 11, 2014 at 6:33 AM, Henning Thielemann wrote: > Since you are concerned with low-level Haskell programming, what do you > think about the Reduceron project? I also wondered whether it would be > possible to teach functional programming to processors with customizable > machine code like the Transmeta processors. I don't know whether comparable > projects are still alive. http://www.cs.york.ac.uk/fp/reduceron/ Oh, I hasn't know it. Thank's. I am not good to talk about HDL. However,a part of jhc's runtime can be designed with HDL, perhaps. Main part of jhc's runtime is GC. The GC clears bit marking array before marking. The clearing can be executed by HDL in parallel. Regards, -- Kiwamu Okabe at METASEPI DESIGN From semen at trygub.com Wed Jun 11 09:44:56 2014 From: semen at trygub.com (Semen Trygubenko / =?utf-8?B?0KHQtdC80LXQvSDQotGA0LjQs9GD0LHQtdC9?= =?utf-8?B?0LrQvg==?=) Date: Wed, 11 Jun 2014 10:44:56 +0100 Subject: [Haskell-cafe] non-exhaustive pattern match(es)? In-Reply-To: References: <20140610231749.GA7670@inanna.trygub.com> Message-ID: <20140611094456.GB14502@inanna.trygub.com> Niklas and Chris: On Wed, Jun 11, 2014 at 11:26:57AM +1200, Chris Wong wrote: > The problem is in these lines: > > > | i < i' = [] > > | i == i' = [] > > | i > i' = [] Thank you for your replies ? it all makes sense now! I arrived at the solution (addition of otherwise) by trial and error; the pattern in the last definition, namely, i (c :cs) ((i',t) :os) looks pretty exhaustive, so when the compiler issued a warning, proposing the addition of _ (_ : _) ((_, _) : _) , I scratched my head a bit before realizing the problem was not with the pattern, but with the comparisons further down, in the guards. And, of course, "patterns not matched" included many patterns that _were_ matched (in this case, everything :)). Wouldn't it be great if it was something like Patterns not matched: _ (_ : _) ((_, _) : _) | otherwise = instead? On Wed, Jun 11, 2014 at 12:17:49AM +0100, Semen Trygubenko / ????? ?????????? wrote: > > example.hs:2:1: Warning: > > Pattern match(es) are non-exhaustive > > In an equation for `f': > > Patterns not matched: _ (_ : _) ((_, _) : _) -- ????? ?????????? http://trygub.com -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 196 bytes Desc: not available URL: From corentin.dupont at gmail.com Wed Jun 11 10:24:21 2014 From: corentin.dupont at gmail.com (Corentin Dupont) Date: Wed, 11 Jun 2014 11:24:21 +0100 Subject: [Haskell-cafe] Deploy Haskell application Message-ID: Hi guys! Is there a procedure to deploy a Haskell application? I have an Amazon EC2 micro instance to run my application, but it's way too small to compile it using cabal (compilation takes half a day rouhgly), so I compile it on my computer. Is there a convenient way to bundle the executable with the resources and ship it to the server? Thanks! Corentin -------------- next part -------------- An HTML attachment was scrubbed... URL: From tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Wed Jun 11 10:29:31 2014 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Wed, 11 Jun 2014 11:29:31 +0100 Subject: [Haskell-cafe] Announcement: Bang, a drum DSL for Haskell In-Reply-To: <20140610232548.GB11986@24f89f8c-e6a1-4e75-85ee-bb8a3743bb9f> References: <20140610232548.GB11986@24f89f8c-e6a1-4e75-85ee-bb8a3743bb9f> Message-ID: <20140611102931.GA1466@henry> On Wed, Jun 11, 2014 at 01:25:48AM +0200, Bertram Felgenhauer wrote: > Richard A. O'Keefe wrote: > > On 10/06/2014, at 8:15 PM, J. Waldmann wrote: > > > * (as with all Haskell EDSLs for music) a basic inconvenience in writing and > > > reading is that the "space" symbol is application, while we actually want it > > > for concatenation, to write a sequence of events without extra syntax > > > (concatenation operators, or commas in list literals). > > > > So you can't write a, a b, a b c, a b c d, and so on meaning > > concatenation every time, but can't you use the ideas of > > http://okmij.org/ftp/Haskell/polyvariadic.html#polyvar-fn > > to write f a, f a b, f a b c, f a b c d, and so on? > > You can do something similar without type classes, as I learned from > http://www.cs.uu.nl/wiki/Afp/Assignments#Assignment_2 : > > > begin cont = cont (return ()) > a m cont = cont (m >> putStrLn "a") > b m cont = cont (m >> putStrLn "b") > c m cont = cont (m >> putStrLn "c") > end m = m > > main = begin a b c a b a end This is fantastic! From noteed at gmail.com Wed Jun 11 10:33:14 2014 From: noteed at gmail.com (Vo Minh Thu) Date: Wed, 11 Jun 2014 12:33:14 +0200 Subject: [Haskell-cafe] Deploy Haskell application In-Reply-To: References: Message-ID: Hi, These days, an increasingly popular solution to package an application with its dependencies is to use Docker. You can build the Docker image locally and push it to a Docker registry and retrieve it on your remote machine, or you can dump it as a tarball and load it on your remote machine. You have different ways to create the Docker image, one of which would be similar to pushing your Haskell binary to your remote machine. That way is simply to compile your exectuable locally, and copy it to the remote machine with is assets if any (you might even move it to a .cabal directory as if it was installed through `cabal install`). By default your executable will be statically linked, except for libgmp that you have to install on the remote machine. I recommand you look into Docker. You will be able to e-use its knowledge to package increasingly complex applications (that might have more numerous dependencies that you wouldn't have to manage on the host). HTH, Thu 2014-06-11 12:24 GMT+02:00 Corentin Dupont : > Hi guys! > Is there a procedure to deploy a Haskell application? > I have an Amazon EC2 micro instance to run my application, but it's way too > small to compile it using cabal (compilation takes half a day rouhgly), so I > compile it on my computer. > Is there a convenient way to bundle the executable with the resources and > ship it to the server? > > Thanks! > Corentin > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From tanielsen at gmail.com Wed Jun 11 10:47:41 2014 From: tanielsen at gmail.com (Tom Nielsen) Date: Wed, 11 Jun 2014 11:47:41 +0100 Subject: [Haskell-cafe] Deploy Haskell application In-Reply-To: References: Message-ID: We package up the executables and other files into a Debain .deb package using fpm after running cabal. Here is an example Makefile which runs cabal, creates the debian package and adds it to our apt server: https://github.com/openbrainsrc/debcd/blob/master/Makefile This is run by our CI server after every commit to GitHub. Tom On Wed, Jun 11, 2014 at 11:33 AM, Vo Minh Thu wrote: > Hi, > > These days, an increasingly popular solution to package an application > with its dependencies is to use Docker. You can build the Docker image > locally and push it to a Docker registry and retrieve it on your > remote machine, or you can dump it as a tarball and load it on your > remote machine. > > You have different ways to create the Docker image, one of which would > be similar to pushing your Haskell binary to your remote machine. That > way is simply to compile your exectuable locally, and copy it to the > remote machine with is assets if any (you might even move it to a > .cabal directory as if it was installed through `cabal install`). By > default your executable will be statically linked, except for libgmp > that you have to install on the remote machine. > > I recommand you look into Docker. You will be able to e-use its > knowledge to package increasingly complex applications (that might > have more numerous dependencies that you wouldn't have to manage on > the host). > > HTH, > Thu > > 2014-06-11 12:24 GMT+02:00 Corentin Dupont : > > Hi guys! > > Is there a procedure to deploy a Haskell application? > > I have an Amazon EC2 micro instance to run my application, but it's way > too > > small to compile it using cabal (compilation takes half a day rouhgly), > so I > > compile it on my computer. > > Is there a convenient way to bundle the executable with the resources and > > ship it to the server? > > > > Thanks! > > Corentin > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From corentin.dupont at gmail.com Wed Jun 11 14:18:03 2014 From: corentin.dupont at gmail.com (Corentin Dupont) Date: Wed, 11 Jun 2014 15:18:03 +0100 Subject: [Haskell-cafe] Deploy Haskell application In-Reply-To: References: Message-ID: Thanks for your response! Is there a way to ask Cabal to just deploy the resources and not compile everything? On Wed, Jun 11, 2014 at 11:47 AM, Tom Nielsen wrote: > We package up the executables and other files into a Debain .deb package > using fpm after running cabal. Here is an example Makefile which runs > cabal, creates the debian package and adds it to our apt server: > > https://github.com/openbrainsrc/debcd/blob/master/Makefile > > This is run by our CI server after every commit to GitHub. > > Tom > > > On Wed, Jun 11, 2014 at 11:33 AM, Vo Minh Thu wrote: > >> Hi, >> >> These days, an increasingly popular solution to package an application >> with its dependencies is to use Docker. You can build the Docker image >> locally and push it to a Docker registry and retrieve it on your >> remote machine, or you can dump it as a tarball and load it on your >> remote machine. >> >> You have different ways to create the Docker image, one of which would >> be similar to pushing your Haskell binary to your remote machine. That >> way is simply to compile your exectuable locally, and copy it to the >> remote machine with is assets if any (you might even move it to a >> .cabal directory as if it was installed through `cabal install`). By >> default your executable will be statically linked, except for libgmp >> that you have to install on the remote machine. >> >> I recommand you look into Docker. You will be able to e-use its >> knowledge to package increasingly complex applications (that might >> have more numerous dependencies that you wouldn't have to manage on >> the host). >> >> HTH, >> Thu >> >> 2014-06-11 12:24 GMT+02:00 Corentin Dupont : >> > Hi guys! >> > Is there a procedure to deploy a Haskell application? >> > I have an Amazon EC2 micro instance to run my application, but it's way >> too >> > small to compile it using cabal (compilation takes half a day rouhgly), >> so I >> > compile it on my computer. >> > Is there a convenient way to bundle the executable with the resources >> and >> > ship it to the server? >> > >> > Thanks! >> > Corentin >> > >> > _______________________________________________ >> > Haskell-Cafe mailing list >> > Haskell-Cafe at haskell.org >> > http://www.haskell.org/mailman/listinfo/haskell-cafe >> > >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tanielsen at gmail.com Wed Jun 11 14:40:08 2014 From: tanielsen at gmail.com (Tom Nielsen) Date: Wed, 11 Jun 2014 15:40:08 +0100 Subject: [Haskell-cafe] Deploy Haskell application In-Reply-To: References: Message-ID: Not sure what you mean - cabal doesn't do any deployment, or at least I have not found a useful way of making it do so. In our case the deployment is done by running apt-get update && apt-get install on the server. Tom On Wed, Jun 11, 2014 at 3:18 PM, Corentin Dupont wrote: > Thanks for your response! > Is there a way to ask Cabal to just deploy the resources and not compile > everything? > > > > On Wed, Jun 11, 2014 at 11:47 AM, Tom Nielsen wrote: > >> We package up the executables and other files into a Debain .deb package >> using fpm after running cabal. Here is an example Makefile which runs >> cabal, creates the debian package and adds it to our apt server: >> >> https://github.com/openbrainsrc/debcd/blob/master/Makefile >> >> This is run by our CI server after every commit to GitHub. >> >> Tom >> >> >> On Wed, Jun 11, 2014 at 11:33 AM, Vo Minh Thu wrote: >> >>> Hi, >>> >>> These days, an increasingly popular solution to package an application >>> with its dependencies is to use Docker. You can build the Docker image >>> locally and push it to a Docker registry and retrieve it on your >>> remote machine, or you can dump it as a tarball and load it on your >>> remote machine. >>> >>> You have different ways to create the Docker image, one of which would >>> be similar to pushing your Haskell binary to your remote machine. That >>> way is simply to compile your exectuable locally, and copy it to the >>> remote machine with is assets if any (you might even move it to a >>> .cabal directory as if it was installed through `cabal install`). By >>> default your executable will be statically linked, except for libgmp >>> that you have to install on the remote machine. >>> >>> I recommand you look into Docker. You will be able to e-use its >>> knowledge to package increasingly complex applications (that might >>> have more numerous dependencies that you wouldn't have to manage on >>> the host). >>> >>> HTH, >>> Thu >>> >>> 2014-06-11 12:24 GMT+02:00 Corentin Dupont : >>> > Hi guys! >>> > Is there a procedure to deploy a Haskell application? >>> > I have an Amazon EC2 micro instance to run my application, but it's >>> way too >>> > small to compile it using cabal (compilation takes half a day >>> rouhgly), so I >>> > compile it on my computer. >>> > Is there a convenient way to bundle the executable with the resources >>> and >>> > ship it to the server? >>> > >>> > Thanks! >>> > Corentin >>> > >>> > _______________________________________________ >>> > Haskell-Cafe mailing list >>> > Haskell-Cafe at haskell.org >>> > http://www.haskell.org/mailman/listinfo/haskell-cafe >>> > >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe at haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From corentin.dupont at gmail.com Wed Jun 11 15:00:51 2014 From: corentin.dupont at gmail.com (Corentin Dupont) Date: Wed, 11 Jun 2014 16:00:51 +0100 Subject: [Haskell-cafe] Deploy Haskell application In-Reply-To: References: Message-ID: In the .cabal file you can put a directive "data-files" and they will be deployed in ~/.cabal/share... I want to trigger only this. On Wed, Jun 11, 2014 at 3:40 PM, Tom Nielsen wrote: > Not sure what you mean - cabal doesn't do any deployment, or at least I > have not found a useful way of making it do so. In our case the deployment > is done by running apt-get update && apt-get install on the server. > > Tom > > > > > On Wed, Jun 11, 2014 at 3:18 PM, Corentin Dupont < > corentin.dupont at gmail.com> wrote: > >> Thanks for your response! >> Is there a way to ask Cabal to just deploy the resources and not compile >> everything? >> >> >> >> On Wed, Jun 11, 2014 at 11:47 AM, Tom Nielsen >> wrote: >> >>> We package up the executables and other files into a Debain .deb package >>> using fpm after running cabal. Here is an example Makefile which runs >>> cabal, creates the debian package and adds it to our apt server: >>> >>> https://github.com/openbrainsrc/debcd/blob/master/Makefile >>> >>> This is run by our CI server after every commit to GitHub. >>> >>> Tom >>> >>> >>> On Wed, Jun 11, 2014 at 11:33 AM, Vo Minh Thu wrote: >>> >>>> Hi, >>>> >>>> These days, an increasingly popular solution to package an application >>>> with its dependencies is to use Docker. You can build the Docker image >>>> locally and push it to a Docker registry and retrieve it on your >>>> remote machine, or you can dump it as a tarball and load it on your >>>> remote machine. >>>> >>>> You have different ways to create the Docker image, one of which would >>>> be similar to pushing your Haskell binary to your remote machine. That >>>> way is simply to compile your exectuable locally, and copy it to the >>>> remote machine with is assets if any (you might even move it to a >>>> .cabal directory as if it was installed through `cabal install`). By >>>> default your executable will be statically linked, except for libgmp >>>> that you have to install on the remote machine. >>>> >>>> I recommand you look into Docker. You will be able to e-use its >>>> knowledge to package increasingly complex applications (that might >>>> have more numerous dependencies that you wouldn't have to manage on >>>> the host). >>>> >>>> HTH, >>>> Thu >>>> >>>> 2014-06-11 12:24 GMT+02:00 Corentin Dupont : >>>> > Hi guys! >>>> > Is there a procedure to deploy a Haskell application? >>>> > I have an Amazon EC2 micro instance to run my application, but it's >>>> way too >>>> > small to compile it using cabal (compilation takes half a day >>>> rouhgly), so I >>>> > compile it on my computer. >>>> > Is there a convenient way to bundle the executable with the resources >>>> and >>>> > ship it to the server? >>>> > >>>> > Thanks! >>>> > Corentin >>>> > >>>> > _______________________________________________ >>>> > Haskell-Cafe mailing list >>>> > Haskell-Cafe at haskell.org >>>> > http://www.haskell.org/mailman/listinfo/haskell-cafe >>>> > >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe at haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>> >>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From corentin.dupont at gmail.com Wed Jun 11 16:07:58 2014 From: corentin.dupont at gmail.com (Corentin Dupont) Date: Wed, 11 Jun 2014 17:07:58 +0100 Subject: [Haskell-cafe] Deploy Haskell application In-Reply-To: References: Message-ID: Hi, it seems that 'cabal configure' fails if some dependencies are missing. Then cabal copy complains that I should run 'cabal configure' first... On Wed, Jun 11, 2014 at 4:23 PM, Tom Feron wrote: > Hi Corentin, > > I think you're searching for `cabal configure && cabal copy`. It will > still have an exit code of 1 if you don't compile anything but it will copy > the files from data-files (and alike). > > On my machine, it copies share/index.html into > .cabal-sandbox/share/x86_64-openbsd-ghc-7.6.3/dummy-0.1.0.0/share/index.html. > > Tom > > > On 11 June 2014 16:00, Corentin Dupont wrote: > >> In the .cabal file you can put a directive "data-files" and they will be >> deployed in ~/.cabal/share... >> I want to trigger only this. >> >> >> On Wed, Jun 11, 2014 at 3:40 PM, Tom Nielsen wrote: >> >>> Not sure what you mean - cabal doesn't do any deployment, or at least I >>> have not found a useful way of making it do so. In our case the deployment >>> is done by running apt-get update && apt-get install on the server. >>> >>> Tom >>> >>> >>> >>> >>> On Wed, Jun 11, 2014 at 3:18 PM, Corentin Dupont < >>> corentin.dupont at gmail.com> wrote: >>> >>>> Thanks for your response! >>>> Is there a way to ask Cabal to just deploy the resources and not >>>> compile everything? >>>> >>>> >>>> >>>> On Wed, Jun 11, 2014 at 11:47 AM, Tom Nielsen >>>> wrote: >>>> >>>>> We package up the executables and other files into a Debain .deb >>>>> package using fpm after running cabal. Here is an example Makefile which >>>>> runs cabal, creates the debian package and adds it to our apt server: >>>>> >>>>> https://github.com/openbrainsrc/debcd/blob/master/Makefile >>>>> >>>>> This is run by our CI server after every commit to GitHub. >>>>> >>>>> Tom >>>>> >>>>> >>>>> On Wed, Jun 11, 2014 at 11:33 AM, Vo Minh Thu >>>>> wrote: >>>>> >>>>>> Hi, >>>>>> >>>>>> These days, an increasingly popular solution to package an application >>>>>> with its dependencies is to use Docker. You can build the Docker image >>>>>> locally and push it to a Docker registry and retrieve it on your >>>>>> remote machine, or you can dump it as a tarball and load it on your >>>>>> remote machine. >>>>>> >>>>>> You have different ways to create the Docker image, one of which would >>>>>> be similar to pushing your Haskell binary to your remote machine. That >>>>>> way is simply to compile your exectuable locally, and copy it to the >>>>>> remote machine with is assets if any (you might even move it to a >>>>>> .cabal directory as if it was installed through `cabal install`). By >>>>>> default your executable will be statically linked, except for libgmp >>>>>> that you have to install on the remote machine. >>>>>> >>>>>> I recommand you look into Docker. You will be able to e-use its >>>>>> knowledge to package increasingly complex applications (that might >>>>>> have more numerous dependencies that you wouldn't have to manage on >>>>>> the host). >>>>>> >>>>>> HTH, >>>>>> Thu >>>>>> >>>>>> 2014-06-11 12:24 GMT+02:00 Corentin Dupont >>>>> >: >>>>>> > Hi guys! >>>>>> > Is there a procedure to deploy a Haskell application? >>>>>> > I have an Amazon EC2 micro instance to run my application, but it's >>>>>> way too >>>>>> > small to compile it using cabal (compilation takes half a day >>>>>> rouhgly), so I >>>>>> > compile it on my computer. >>>>>> > Is there a convenient way to bundle the executable with the >>>>>> resources and >>>>>> > ship it to the server? >>>>>> > >>>>>> > Thanks! >>>>>> > Corentin >>>>>> > >>>>>> > _______________________________________________ >>>>>> > Haskell-Cafe mailing list >>>>>> > Haskell-Cafe at haskell.org >>>>>> > http://www.haskell.org/mailman/listinfo/haskell-cafe >>>>>> > >>>>>> _______________________________________________ >>>>>> Haskell-Cafe mailing list >>>>>> Haskell-Cafe at haskell.org >>>>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>>>> >>>>> >>>>> >>>> >>> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From elliot.robinson at argiopetech.com Wed Jun 11 16:16:30 2014 From: elliot.robinson at argiopetech.com (Elliot Robinson) Date: Wed, 11 Jun 2014 12:16:30 -0400 Subject: [Haskell-cafe] Deploy Haskell application In-Reply-To: References: Message-ID: `cabal install --only-dependencies`, possibly with a sandbox set, should fix that issue. Then configure and move from there. --- Elliot Robinson Phone: (321) 252-9660 Site: www.argiopetech.com Email: elliot.robinson at argiopetech.com PGP Fingerprint: 0xD1E72E6A9D0610FFBBF838A6FFB5205A9FEDE59A On Wed, Jun 11, 2014 at 12:07 PM, Corentin Dupont wrote: > Hi, > it seems that 'cabal configure' fails if some dependencies are missing. > Then cabal copy complains that I should run 'cabal configure' first... > > > On Wed, Jun 11, 2014 at 4:23 PM, Tom Feron wrote: > >> Hi Corentin, >> >> I think you're searching for `cabal configure && cabal copy`. It will >> still have an exit code of 1 if you don't compile anything but it will copy >> the files from data-files (and alike). >> >> On my machine, it copies share/index.html into >> .cabal-sandbox/share/x86_64-openbsd-ghc-7.6.3/dummy-0.1.0.0/share/index.html. >> >> Tom >> >> >> On 11 June 2014 16:00, Corentin Dupont wrote: >> >>> In the .cabal file you can put a directive "data-files" and they will be >>> deployed in ~/.cabal/share... >>> I want to trigger only this. >>> >>> >>> On Wed, Jun 11, 2014 at 3:40 PM, Tom Nielsen >>> wrote: >>> >>>> Not sure what you mean - cabal doesn't do any deployment, or at least I >>>> have not found a useful way of making it do so. In our case the deployment >>>> is done by running apt-get update && apt-get install on the server. >>>> >>>> Tom >>>> >>>> >>>> >>>> >>>> On Wed, Jun 11, 2014 at 3:18 PM, Corentin Dupont < >>>> corentin.dupont at gmail.com> wrote: >>>> >>>>> Thanks for your response! >>>>> Is there a way to ask Cabal to just deploy the resources and not >>>>> compile everything? >>>>> >>>>> >>>>> >>>>> On Wed, Jun 11, 2014 at 11:47 AM, Tom Nielsen >>>>> wrote: >>>>> >>>>>> We package up the executables and other files into a Debain .deb >>>>>> package using fpm after running cabal. Here is an example Makefile which >>>>>> runs cabal, creates the debian package and adds it to our apt server: >>>>>> >>>>>> https://github.com/openbrainsrc/debcd/blob/master/Makefile >>>>>> >>>>>> This is run by our CI server after every commit to GitHub. >>>>>> >>>>>> Tom >>>>>> >>>>>> >>>>>> On Wed, Jun 11, 2014 at 11:33 AM, Vo Minh Thu >>>>>> wrote: >>>>>> >>>>>>> Hi, >>>>>>> >>>>>>> These days, an increasingly popular solution to package an >>>>>>> application >>>>>>> with its dependencies is to use Docker. You can build the Docker >>>>>>> image >>>>>>> locally and push it to a Docker registry and retrieve it on your >>>>>>> remote machine, or you can dump it as a tarball and load it on your >>>>>>> remote machine. >>>>>>> >>>>>>> You have different ways to create the Docker image, one of which >>>>>>> would >>>>>>> be similar to pushing your Haskell binary to your remote machine. >>>>>>> That >>>>>>> way is simply to compile your exectuable locally, and copy it to the >>>>>>> remote machine with is assets if any (you might even move it to a >>>>>>> .cabal directory as if it was installed through `cabal install`). By >>>>>>> default your executable will be statically linked, except for libgmp >>>>>>> that you have to install on the remote machine. >>>>>>> >>>>>>> I recommand you look into Docker. You will be able to e-use its >>>>>>> knowledge to package increasingly complex applications (that might >>>>>>> have more numerous dependencies that you wouldn't have to manage on >>>>>>> the host). >>>>>>> >>>>>>> HTH, >>>>>>> Thu >>>>>>> >>>>>>> 2014-06-11 12:24 GMT+02:00 Corentin Dupont < >>>>>>> corentin.dupont at gmail.com>: >>>>>>> > Hi guys! >>>>>>> > Is there a procedure to deploy a Haskell application? >>>>>>> > I have an Amazon EC2 micro instance to run my application, but >>>>>>> it's way too >>>>>>> > small to compile it using cabal (compilation takes half a day >>>>>>> rouhgly), so I >>>>>>> > compile it on my computer. >>>>>>> > Is there a convenient way to bundle the executable with the >>>>>>> resources and >>>>>>> > ship it to the server? >>>>>>> > >>>>>>> > Thanks! >>>>>>> > Corentin >>>>>>> > >>>>>>> > _______________________________________________ >>>>>>> > Haskell-Cafe mailing list >>>>>>> > Haskell-Cafe at haskell.org >>>>>>> > http://www.haskell.org/mailman/listinfo/haskell-cafe >>>>>>> > >>>>>>> _______________________________________________ >>>>>>> Haskell-Cafe mailing list >>>>>>> Haskell-Cafe at haskell.org >>>>>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>>>>> >>>>>> >>>>>> >>>>> >>>> >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe at haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >>> >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From manoj.dc at gmail.com Wed Jun 11 17:04:50 2014 From: manoj.dc at gmail.com (Manoj Chaudhari) Date: Wed, 11 Jun 2014 22:34:50 +0530 Subject: [Haskell-cafe] Opening for OpenGL, C++ Development. Message-ID: Hello, We are looking for Software Developers with OpenGL experience. - Should have experience in C++/Xcode, OpenGL/DirectX/IOS. - Experience with Shafer programming, Multi-threaded applications, Graphics in CAD domain. - The role is of Software Development on primary CAD application like CATIA. - Good skills in Geometry, algorithms, Mathematics, API's, Graphics-will be a added advantage. Experience : 2 to 6 years. If anyone is interested on learning more about this opportunity and potential salary ranges, please email me at : manoj_chaudhari2 at 3dplmsoftware.com Regards, Manoj Chaudhari -------------- next part -------------- An HTML attachment was scrubbed... URL: From bertram.felgenhauer at googlemail.com Wed Jun 11 19:30:58 2014 From: bertram.felgenhauer at googlemail.com (Bertram Felgenhauer) Date: Wed, 11 Jun 2014 21:30:58 +0200 Subject: [Haskell-cafe] Announcement: Bang, a drum DSL for Haskell In-Reply-To: <20140611102931.GA1466@henry> References: <20140610232548.GB11986@24f89f8c-e6a1-4e75-85ee-bb8a3743bb9f> <20140611102931.GA1466@henry> Message-ID: <20140611193058.GC11986@24f89f8c-e6a1-4e75-85ee-bb8a3743bb9f> Tom Ellis wrote: > On Wed, Jun 11, 2014 at 01:25:48AM +0200, Bertram Felgenhauer wrote: > > begin cont = cont (return ()) > > a m cont = cont (m >> putStrLn "a") > > b m cont = cont (m >> putStrLn "b") > > c m cont = cont (m >> putStrLn "c") > > end m = m > > > > main = begin a b c a b a end > > This is fantastic! Unfortunately this causes performance problems with ghc's type checker: main = begin a a a a a a a a a a a a a a a a a end takes more than a second to type-check under ghc 7.8.2, and every additional 'a' adds a factor of two. Interestingly, ghc 7.6.3 does not show this behaviour. Note that the instantiated types of 'a' grow exponentially: The first 'a' in 'begin a end' and 'begin a a end' have types M -> (M -> M) -> M and M -> (M -> (M -> M) -> M) -> (M -> M) -> M respectively, where 'M' abbreviates IO (), and each additional 'a' turns M -> r into M -> (M -> r) -> r, doubling the type's size. Cheers, Bertram P.S. a related way for causing bad type checking performance is the innocent looking main = id id id id id id id id id id id id id id id id id id id id id id (return ()) where again, the type of the first 'id' grows exponentially in the number of 'id' calls. In this case, ghc-7.6.3 performs just as badly as ghc-7.8.2. From gautier.difolco at gmail.com Wed Jun 11 19:31:07 2014 From: gautier.difolco at gmail.com (Gautier DI FOLCO) Date: Wed, 11 Jun 2014 21:31:07 +0200 Subject: [Haskell-cafe] Unable to make a HList-like to deal with Kleisli Arrows and State Message-ID: Hi all, My goal is to compose Kleisli arrows with (State s) as parameteric Monadic type. So, I end up with the following code: data REnv :: [*] -> * -> * -> (* -> * -> *) -> ((* -> *) -> * -> * -> *) -> * where Last :: k (s t) i o -> REnv (t ': '[]) i o s k RCons :: k (s t) i o' -> REnv ts o' o s k -> REnv (t ': ts) i o s k Which, of course, gives me the following error when I try to play with it: *H> :t Last genRanking :1:6: Kind incompatibility when matching types: s :: * -> * -> * StateT Ranking :: (* -> *) -> * -> * Expected type: Kleisli (s t) Ticket Ranking Actual type: Kleisli (State Ranking) Ticket Ranking In the first argument of ?Last?, namely ?genRanking? In the expression: Last genRanking :1:6: Kind incompatibility when matching types: t :: * Data.Functor.Identity.Identity :: * -> * Expected type: Kleisli (s t) Ticket Ranking Actual type: Kleisli (State Ranking) Ticket Ranking In the first argument of ?Last?, namely ?genRanking? In the expression: Last genRanking*H> :t LastLast :: k (s t) i o -> REnv '[t] i o s k*H> :t genRanking genRanking :: Kleisli (State Ranking) Ticket Ranking I understand why it fails (State is * -> * -> *, while s is * -> *), but I can't figure out how to write this, I tried (s t o), but it isn't correct because k waits for a (* -> *). If you have any ideas, I'm curious to read them. Thanks in advance for your help. -------------- next part -------------- An HTML attachment was scrubbed... URL: From vogt.adam at gmail.com Thu Jun 12 01:42:43 2014 From: vogt.adam at gmail.com (adam vogt) Date: Wed, 11 Jun 2014 21:42:43 -0400 Subject: [Haskell-cafe] Unable to make a HList-like to deal with Kleisli Arrows and State In-Reply-To: References: Message-ID: Hi Gautier, It seems like `type State s = StateT s Identity` causes the problem. You could supply Identity as an argument: data REnv (ts :: [*]) (i :: *) (o :: *) (s :: * -> (* -> *) -> * -> *) (k :: (* -> *) -> * -> * -> *) where Last :: k (s t Identity) i o -> REnv (t ': '[]) i o s k RCons :: k (s t Identity) i o' -> REnv ts o' o s k -> REnv (t ': ts) i o s k Or I guess you could keep the original REnv, and require a newtype newtype MyState s a = MyState (State s a) deriving (MonadState s, Monad) Regards, Adam On Wed, Jun 11, 2014 at 3:31 PM, Gautier DI FOLCO wrote: > Hi all, > > My goal is to compose Kleisli arrows with (State s) as parameteric Monadic > type. > So, I end up with the following code: > > data REnv :: [*] -> * -> * -> (* -> * -> *) -> ((* -> *) -> * -> * -> *) -> > * where > Last :: k (s t) i o -> REnv (t ': '[]) i o s k > RCons :: k (s t) i o' -> REnv ts o' o s k -> REnv (t ': ts) i o s k > > > Which, of course, gives me the following error when I try to play with it: > > *H> :t Last genRanking > > :1:6: > Kind incompatibility when matching types: > s :: * -> * -> * > StateT Ranking :: (* -> *) -> * -> * > Expected type: Kleisli (s t) Ticket Ranking > Actual type: Kleisli (State Ranking) Ticket Ranking > In the first argument of ?Last?, namely ?genRanking? > In the expression: Last genRanking > > :1:6: > Kind incompatibility when matching types: > t :: * > Data.Functor.Identity.Identity :: * -> * > Expected type: Kleisli (s t) Ticket Ranking > Actual type: Kleisli (State Ranking) Ticket Ranking > In the first argument of ?Last?, namely ?genRanking? > In the expression: Last genRanking > *H> :t Last > Last :: k (s t) i o -> REnv '[t] i o s k > *H> :t genRanking > genRanking :: Kleisli (State Ranking) Ticket Ranking > > > I understand why it fails (State is * -> * -> *, while s is * -> *), but I > can't figure out how to write this, I tried (s t o), but it isn't correct > because k waits for a (* -> *). > > > If you have any ideas, I'm curious to read them. > > Thanks in advance for your help. > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dstcruz at gmail.com Thu Jun 12 02:23:22 2014 From: dstcruz at gmail.com (Daniel Santa Cruz) Date: Wed, 11 Jun 2014 22:23:22 -0400 Subject: [Haskell-cafe] Haskell Weekly News: Issue 296 Message-ID: Welcome to issue 296 of the HWN, an issue covering crowd-sourced bits of information about Haskell from around the web. This issue covers from May 25 to June 7, 2014 Quotes of the Week * mbrock: then you get into a whole thing about the epistemology of abstract algebra, and someone brings up Wittgenstein, somebody brings out a bottle of wine, and it's yet another one of those nights Top Reddit Stories * An alternative Haskell home page Domain: chrisdone.com, Score: 160, Comments: 57 Original: [1] http://goo.gl/Yw2G3a On Reddit: [2] http://goo.gl/m19Ujx * Third generation of the attoparsec parsing library Domain: serpentine.com, Score: 82, Comments: 22 Original: [3] http://goo.gl/kk8i50 On Reddit: [4] http://goo.gl/LZzevb * Music-Suite Domain: music-suite.github.io, Score: 81, Comments: 44 Original: [5] http://goo.gl/u69ybm On Reddit: [6] http://goo.gl/EYKMwI * Erik Meijer: Introduction to Functional Programming Domain: edx.org, Score: 79, Comments: 11 Original: [7] http://goo.gl/YrfbA3 On Reddit: [8] http://goo.gl/oLRm6k * The abject failure of weak typing Domain: techblog.realestate.com.au, Score: 72, Comments: 28 Original: [9] http://goo.gl/h5XDVZ On Reddit: [10] http://goo.gl/nfnLNN * Lazy Dynamic Programming Domain: jelv.is, Score: 64, Comments: 12 Original: [11] http://goo.gl/kdSbkh On Reddit: [12] http://goo.gl/I6XVa8 * First Person 3D Navigation, written in Elm Domain: github.com, Score: 62, Comments: 0 Original: [13] http://goo.gl/qLM3FD On Reddit: [14] http://goo.gl/CRNW6M * Haskell Platform Redesign Domain: self.haskell, Score: 57, Comments: 39 Original: [15] http://goo.gl/A2OqV4 On Reddit: [16] http://goo.gl/A2OqV4 * Benjamin Pierce on clean-slate security architectures Domain: intelligence.org, Score: 54, Comments: 2 Original: [17] http://goo.gl/dCWGlr On Reddit: [18] http://goo.gl/ns7SF6 * Idris 0.9.13 released, featuring a new erasure implementation, Haddock- and Hoogle-inspired tools, and improved IDE support Domain: idris-lang.org, Score: 53, Comments: 6 Original: [19] http://goo.gl/rf9i2U On Reddit: [20] http://goo.gl/tByoYR * Brilliant explanation of Free Monad + Interpreter pattern. Domain: programmers.stackexchange.com, Score: 52, Comments: 16 Original: [21] http://goo.gl/5wVfG1 On Reddit: [22] http://goo.gl/bCb0tD * I got lenses in my Functor Domain: izbicki.me, Score: 52, Comments: 35 Original: [23] http://goo.gl/9xAo4g On Reddit: [24] http://goo.gl/kZBcK8 * The GHC Runtime System [pdf] Domain: scs.stanford.edu, Score: 50, Comments: 15 Original: [25] http://goo.gl/J2iH4W On Reddit: [26] http://goo.gl/B2AiSo * The typeparams library provides a lens-like interface for type level parameters; it allows unboxing unboxed vectors (with benchmarks indicating a 25% performance gain) and supercompilation-like optimizations (with benchmarks showing 40x performance gain in some cases) Domain: github.com, Score: 49, Comments: 14 Original: [27] http://goo.gl/jzIn2E On Reddit: [28] http://goo.gl/fdiRHU * LiquidHaskell: Pointers Gone Wild Domain: goto.ucsd.edu, Score: 48, Comments: 16 Original: [29] http://goo.gl/aKyRnQ On Reddit: [30] http://goo.gl/pexvtf * Sed implementation in Haskell - Episode 6 [youtube] Domain: youtube.com, Score: 45, Comments: 5 Original: [31] http://goo.gl/JQ2ONf On Reddit: [32] http://goo.gl/vLQWVJ * Call Arity [pdf]: A new analysis implemented in GHC Domain: joachim-breitner.de, Score: 44, Comments: 6 Original: [33] http://goo.gl/BdEFfs On Reddit: [34] http://goo.gl/OSv5Rb Top StackOverflow Questions * Understanding Haskell's Bool Deriving an Ord votes: 17, answers: 2 Read on SO: [35] http://goo.gl/7W9WRb * Precise flow control in Haskell votes: 14, answers: 0 Read on SO: [36] http://goo.gl/uoA9i1 * Why aren't there existentially quantified type variables in GHC Haskell votes: 14, answers: 2 Read on SO: [37] http://goo.gl/ZeBJTK * Is the concept of an ?interleaved homomorphism? a real thing? votes: 14, answers: 3 Read on SO: [38] http://goo.gl/gpIH6b * Is it possible to get `-=` working with literals? votes: 12, answers: 1 Read on SO: [39] http://goo.gl/R40i7q * How much overhead does sparking incur? votes: 11, answers: 1 Read on SO: [40] http://goo.gl/ixWkKL Until next time, [41]+Daniel Santa Cruz References 1. http://chrisdone.com/posts/haskell-lang 2. http://www.reddit.com/r/haskell/comments/26rilp/an_alternative_haskell_home_page/ 3. http://www.serpentine.com/blog/2014/05/31/attoparsec/ 4. http://www.reddit.com/r/haskell/comments/26xyah/third_generation_of_the_attoparsec_parsing_library/ 5. http://music-suite.github.io/docs/ref/ 6. http://www.reddit.com/r/haskell/comments/27djwy/musicsuite/ 7. https://www.edx.org/course/delftx/delftx-fp101x-introduction-functional-2126 8. http://www.reddit.com/r/haskell/comments/27bnt7/erik_meijer_introduction_to_functional_programming/ 9. http://techblog.realestate.com.au/the-abject-failure-of-weak-typing/ 10. http://www.reddit.com/r/haskell/comments/26pi5b/the_abject_failure_of_weak_typing/ 11. http://jelv.is/blog/Lazy-Dynamic-Programming 12. http://www.reddit.com/r/haskell/comments/26jh2w/lazy_dynamic_programming/ 13. https://github.com/evancz/first-person-elm#first-person-3d-navigation-in-elm 14. http://www.reddit.com/r/haskell/comments/26mjak/first_person_3d_navigation_written_in_elm/ 15. http://www.reddit.com/r/haskell/comments/26g9y8/haskell_platform_redesign/ 16. http://www.reddit.com/r/haskell/comments/26g9y8/haskell_platform_redesign/ 17. http://intelligence.org/2014/05/11/benjamin-pierce/ 18. http://www.reddit.com/r/haskell/comments/274k69/benjamin_pierce_on_cleanslate_security/ 19. http://www.idris-lang.org/idris-0-9-13-released/ 20. http://www.reddit.com/r/haskell/comments/279wl7/idris_0913_released_featuring_a_new_erasure/ 21. http://programmers.stackexchange.com/questions/242795/what-is-the-free-monad-interpreter-pattern 22. http://www.reddit.com/r/haskell/comments/2788cw/brilliant_explanation_of_free_monad_interpreter/ 23. http://izbicki.me/blog/i-got-lenses-in-my-functors 24. http://www.reddit.com/r/haskell/comments/27h0wk/i_got_lenses_in_my_functor/ 25. http://www.scs.stanford.edu/14sp-cs240h/slides/ghc-rts.pdf 26. http://www.reddit.com/r/haskell/comments/26qshw/the_ghc_runtime_system_pdf/ 27. https://github.com/mikeizbicki/typeparams#the-typeparams-library 28. http://www.reddit.com/r/haskell/comments/27avw8/the_typeparams_library_provides_a_lenslike/ 29. http://goto.ucsd.edu/~rjhala/liquid/haskell/blog/blog/2014/05/28/pointers-gone-wild.lhs/ 30. http://www.reddit.com/r/haskell/comments/26redl/liquidhaskell_pointers_gone_wild/ 31. https://www.youtube.com/watch?v=GKRjVITL_oA 32. http://www.reddit.com/r/haskell/comments/26th92/sed_implementation_in_haskell_episode_6_youtube/ 33. http://www.joachim-breitner.de/publications/CallArity-TFP.pdf 34. http://www.reddit.com/r/haskell/comments/26fdxq/call_arity_pdf_a_new_analysis_implemented_in_ghc/ 35. http://stackoverflow.com/questions/23880626/understanding-haskells-bool-deriving-an-ord 36. http://stackoverflow.com/questions/23869547/precise-flow-control-in-haskell 37. http://stackoverflow.com/questions/23940487/why-arent-there-existentially-quantified-type-variables-in-ghc-haskell 38. http://stackoverflow.com/questions/24090758/is-the-concept-of-an-interleaved-homomorphism-a-real-thing 39. http://stackoverflow.com/questions/23875471/is-it-possible-to-get-working-with-literals 40. http://stackoverflow.com/questions/23877737/how-much-overhead-does-sparking-incur 41. https://plus.google.com/105107667630152149014/about -------------- next part -------------- An HTML attachment was scrubbed... URL: From vigalchin at gmail.com Thu Jun 12 04:25:53 2014 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Wed, 11 Jun 2014 23:25:53 -0500 Subject: [Haskell-cafe] HP's "The Machine" Message-ID: a google of "The Machine" ... https://www.google.com/search?q=HP+%22The+Machine%22&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&channel=sb Let's assume this paradigm actually will work, what are the implications for FPLs in general and Haskell in particular?? Regards, Vasili -------------- next part -------------- An HTML attachment was scrubbed... URL: From vigalchin at gmail.com Thu Jun 12 04:26:52 2014 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Wed, 11 Jun 2014 23:26:52 -0500 Subject: [Haskell-cafe] HP's "The Machine" In-Reply-To: References: Message-ID: e.g. lazy evaluation? On Wed, Jun 11, 2014 at 11:25 PM, Vasili I. Galchin wrote: > a google of "The Machine" ... > https://www.google.com/search?q=HP+%22The+Machine%22&ie=utf-8&oe=utf-8&aq=t&rls=org.mozilla:en-US:official&client=firefox-a&channel=sb > > Let's assume this paradigm actually will work, what are the implications > for FPLs in general and Haskell in particular?? > > Regards, > > Vasili > -------------- next part -------------- An HTML attachment was scrubbed... URL: From vigalchin at gmail.com Thu Jun 12 04:30:12 2014 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Wed, 11 Jun 2014 23:30:12 -0500 Subject: [Haskell-cafe] =?utf-8?b?6Ieq5Yqo5Zue5aSN77yaIEhQJ3MgIlRoZSBNYWNo?= =?utf-8?q?ine=22?= In-Reply-To: <20140612042626.28FA265031A@mda05.fmail.tg.sinanode.com> References: <20140612042626.28FA265031A@mda05.fmail.tg.sinanode.com> Message-ID: 2014-06-11 23:26 GMT-05:00 : > ??????????????????? I too speak/read Chinese .. we can share info :-) -------------- next part -------------- An HTML attachment was scrubbed... URL: From gautier.difolco at gmail.com Thu Jun 12 06:40:49 2014 From: gautier.difolco at gmail.com (Gautier DI FOLCO) Date: Thu, 12 Jun 2014 08:40:49 +0200 Subject: [Haskell-cafe] Unable to make a HList-like to deal with Kleisli Arrows and State In-Reply-To: References: Message-ID: 2014-06-12 3:42 GMT+02:00 adam vogt : > Hi Gautier, > > It seems like `type State s = StateT s Identity` causes the problem. > You could supply Identity as an argument: > > data REnv (ts :: [*]) > (i :: *) > (o :: *) > (s :: * -> (* -> *) -> * -> *) > (k :: (* -> *) -> * -> * -> *) where > Last :: k (s t Identity) i o -> REnv (t ': '[]) i o s k > RCons :: k (s t Identity) i o' -> REnv ts o' o s k -> REnv (t ': ts) i o > s k > > > Or I guess you could keep the original REnv, and require a newtype > > newtype MyState s a = MyState (State s a) > deriving (MonadState s, Monad) > > Regards, > Adam > > > On Wed, Jun 11, 2014 at 3:31 PM, Gautier DI FOLCO > wrote: > > Hi all, > > > > My goal is to compose Kleisli arrows with (State s) as parameteric > Monadic > > type. > > So, I end up with the following code: > > > > data REnv :: [*] -> * -> * -> (* -> * -> *) -> ((* -> *) -> * -> * -> *) > -> > > * where > > Last :: k (s t) i o -> REnv (t ': '[]) i o s k > > RCons :: k (s t) i o' -> REnv ts o' o s k -> REnv (t ': ts) i o s k > > > > > > Which, of course, gives me the following error when I try to play with > it: > > > > *H> :t Last genRanking > > > > :1:6: > > Kind incompatibility when matching types: > > s :: * -> * -> * > > StateT Ranking :: (* -> *) -> * -> * > > Expected type: Kleisli (s t) Ticket Ranking > > Actual type: Kleisli (State Ranking) Ticket Ranking > > In the first argument of ?Last?, namely ?genRanking? > > In the expression: Last genRanking > > > > :1:6: > > Kind incompatibility when matching types: > > t :: * > > Data.Functor.Identity.Identity :: * -> * > > Expected type: Kleisli (s t) Ticket Ranking > > Actual type: Kleisli (State Ranking) Ticket Ranking > > In the first argument of ?Last?, namely ?genRanking? > > In the expression: Last genRanking > > *H> :t Last > > Last :: k (s t) i o -> REnv '[t] i o s k > > *H> :t genRanking > > genRanking :: Kleisli (State Ranking) Ticket Ranking > > > > > > I understand why it fails (State is * -> * -> *, while s is * -> *), but > I > > can't figure out how to write this, I tried (s t o), but it isn't correct > > because k waits for a (* -> *). > > > > > > If you have any ideas, I'm curious to read them. > > > > Thanks in advance for your help. > > > > > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > Hi adam, Thanks for your answer, I didn't realized that Identity could cause that. Thanks, Regards. -------------- next part -------------- An HTML attachment was scrubbed... URL: From apfelmus at quantentunnel.de Thu Jun 12 09:51:20 2014 From: apfelmus at quantentunnel.de (Heinrich Apfelmus) Date: Thu, 12 Jun 2014 11:51:20 +0200 Subject: [Haskell-cafe] Opening for OpenGL, C++ Development. In-Reply-To: References: Message-ID: Manoj Chaudhari wrote: > We are looking for Software Developers with OpenGL experience. > > - Should have experience in C++/Xcode, OpenGL/DirectX/IOS. > - Experience with Shafer programming, Multi-threaded applications, Graphics > in CAD domain. > - The role is of Software Development on primary CAD application like CATIA. > - Good skills in Geometry, algorithms, Mathematics, API's, Graphics-will be > a added advantage. > > Experience : 2 to 6 years. Wrong forum? This is a Haskell mailing list, not a Pascal mailing list. Best regards, Heinrich Apfelmus -- http://apfelmus.nfshost.com From ky3 at atamo.com Thu Jun 12 10:17:41 2014 From: ky3 at atamo.com (Kim-Ee Yeoh) Date: Thu, 12 Jun 2014 17:17:41 +0700 Subject: [Haskell-cafe] [Haskell] ANN: io-memoize 1.1 In-Reply-To: References: Message-ID: On Thu, Jun 12, 2014 at 4:47 PM, Dan Burton wrote: > Have you ever wanted to restrict an IO action such that it could only be > invoked once? Now you can with System.IO.Memoize.once (formerly known as > ioMemo). > (Moving to cafe for dicussion ...) I may want a one-time only IO action, although so far the need hasn't arisen yet. ;) In the spirit of pilfering while the buns are still hot out of the oven, is there a backstory for this package you could possibly sketch out? Some canonical use case maybe? -- Kim-Ee -------------- next part -------------- An HTML attachment was scrubbed... URL: From jnf at arcor.de Thu Jun 12 10:26:38 2014 From: jnf at arcor.de (=?UTF-8?Q?J=C3=BCrgen_Nicklisch=2DFranken?=) Date: Thu, 12 Jun 2014 12:26:38 +0200 Subject: [Haskell-cafe] Deleting mailing list Message-ID: I want to delete the mailman mailing list for leksah (leksah at projects.haskell.org.), since it is not used anymore and only collects spam. It looks as I can't do this on my own, so I need help. My mails to support at community.haskell.org didn't produce any response. So I try this for years now. Please! Is someone out there that can help me? Kind regards J?rgen Nicklisch-Franken -------------- next part -------------- An HTML attachment was scrubbed... URL: From sol at typeful.net Thu Jun 12 10:28:42 2014 From: sol at typeful.net (Simon Hengel) Date: Thu, 12 Jun 2014 18:28:42 +0800 Subject: [Haskell-cafe] [Haskell] ANN: io-memoize 1.1 In-Reply-To: References: Message-ID: <20140612102842.GD24616@x200> Hi Kim-Ee, > I may want a one-time only IO action, although so far the need hasn't > arisen yet. ;) > > In the spirit of pilfering while the buns are still hot out of the oven, is > there a backstory for this package you could possibly sketch out? Some > canonical use case maybe? I use it to implement beforeAll/beforeAllWith[1] in Hspec[2]. I have been reluctant to add them because used in the wrong way they lead to bad/order dependent test cases. But there are some valid use cases. So I decided to finally add them. Cheers, Simon [1] https://github.com/hspec/hspec/pull/173 [2] http://hspec.github.io/ From oleg at okmij.org Thu Jun 12 15:27:15 2014 From: oleg at okmij.org (oleg at okmij.org) Date: 12 Jun 2014 15:27:15 -0000 Subject: [Haskell-cafe] Simple but slow, and complex but fast Forth emulation [Was: Bang, a drum DSL for Haskell] Message-ID: <20140612152715.53135.qmail@www1.g3.pair.com> Emulation of a simple subset of Forth in Haskell seems easy. The trick, continuation-passing style, has been known for a long time. The trick underlies `functional unparsing' by Olivier Danvy. http://www.brics.dk/RS/98/12/BRICS-RS-98-12.pdf (published in JFP in 1998). Chris Okasaki later extended the technique http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.121.1890 http://dl.acm.org/citation.cfm?id=581699 He also noted huge types and slow compilation times. But there is another way. It is far more complex, and far fast. It is used in HSXML, which handles polyvariadic functions with literally thousands of arguments (some of my web pages are long). The following complete code illustrates the idea. {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE FlexibleInstances, FlexibleContexts #-} {-# LANGUAGE TypeFamilies #-} -- Simple Forth module SimpleForth where -- The simple way: Danvy's Functional unparsing begin k = k () n st x k = k ((x::Int),st) add (n1,(n2,st)) k = k (n1+n2,st) end (top,st) = top t1 = begin n 1 n 2 add end -- Uncomment the following to get a hint why t2 is too slow -- t1 = begin _h n 1 n 2 add end -- Uncomment the following only if you are prepared to wait {- t2 = begin n 1 n 2 n 3 n 4 n 5 n 6 n 7 n 8 n 9 add add add add add add add add end -} -- A more complex but faster way -- Start with a stack 'stack' and then continue class Forth stack r where build :: stack -> r data End = End instance (a ~ stack) => Forth stack (End -> a) where build stack _ = stack data Add = Add -- Start with (Int, (Int, stack)), see Add and continue with (Int,stack) instance Forth (Int,stack) r => Forth (Int,(Int,stack)) (Add -> r) where build (n1,(n2,stack)) _ = build (n1+n2,stack) data N = N instance (a ~ Int, Forth (Int,stack) r) => Forth stack (N -> a -> r) where build stack _ n = build (n,stack) -- All of the following typecheck instantaneously, even on my slow -- laptop tt1 = build () N 1 N 2 Add End tt2 = build () N 1 N 2 N 3 N 4 N 5 N 6 N 7 N 8 N 9 Add Add Add Add Add Add Add Add End tt3 = build () N 1 N 2 Add N 3 Add N 4 Add N 5 Add N 6 Add N 7 Add N 8 Add N 9 Add End From jpmoresmau at gmail.com Thu Jun 12 15:47:36 2014 From: jpmoresmau at gmail.com (JP Moresmau) Date: Thu, 12 Jun 2014 17:47:36 +0200 Subject: [Haskell-cafe] ghc-options: -dynamic in package refused by Hackage Message-ID: Hello, what's the recommended way to make a package dynamic? 1. I need to make the executable in my package dynamic otherwise I run into https://ghc.haskell.org/trac/ghc/ticket/8376 2. I've set ghc-options: -dynamic in my Cabal file and that solves my issues. 3. I can't upload my package to Hackage, I get a "'ghc-options: -d*' debug flags are not appropriate for a distributed package" error. I hadn't realized -dynamic is for debugging purposes... So is there another way to make my package dynamic and uploadable to Hackage? Or should I just not put the flag in the cabal flag and let my users pass the flag when they install? Thanks! JP -- JP Moresmau http://jpmoresmau.blogspot.com/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From vagif.verdi at gmail.com Thu Jun 12 16:25:48 2014 From: vagif.verdi at gmail.com (Vagif Verdi) Date: Thu, 12 Jun 2014 09:25:48 -0700 (PDT) Subject: [Haskell-cafe] Troubles installing EclipseFP Message-ID: Hi, i'm trying to install eclipsefp. Ubuntu 14.04, ghc 7.6.3, cabal-install 1.20. I did it with a fresh .cabal and .ghc folders. Nothing else was installed. After restarting eclipse it started doenloading and building haskell libs, and stopped with this error: Cabal==1.16.0/installed-c6e..., SourceGraph => Cabal<1.7) rejecting: SourceGraph-0.2, 0.1 (conflict: buildwrapper => Cabal==1.16.0/installed-c6e..., SourceGraph => Cabal<1.5) Backjump limit reached (change with --max-backjumps). Note: when using a sandbox, all packages are required to have consistent dependencies. Try reinstalling/unregistering the offending packages or recreating the sandbox. -------------- next part -------------- An HTML attachment was scrubbed... URL: From danburton.email at gmail.com Thu Jun 12 19:16:32 2014 From: danburton.email at gmail.com (Dan Burton) Date: Thu, 12 Jun 2014 19:16:32 +0000 Subject: [Haskell-cafe] [Haskell] ANN: io-memoize 1.1 References: <20140612102842.GD24616@x200> Message-ID: I created io-memoize a few years ago, around the same time that I also created runmemo . I was interested in "memoization" at the time, and was exploring various memoization techniques. It was just for theory/fun and had no motivating use case at the time. I've been following various pipes/conduit discussions, and one particular discussion about WAI involved an interest in a "call once" callback. It's hard to enforce that sort of thing at the compile time without using hardcore solutions such as linear types or indexed monads, so the obvious solution is to use something like io-memoize to enforce it at runtime instead. http://www.reddit.com/r/haskell/comments/246e39/disemboweling_wai_aka_gutting_out_conduit/ch4cv55 Something else I've been working on lately is "the observer pattern" in Haskell. When you subscribe to an observer, it will give you a "subscription", which is just an action you can run to "unsubscribe" yourself. Again, there's potential for "once" to be useful here for implementing the unsubscribe action. If I manage to create something solid and novel out of this observer pattern stuff, then I'll release it to hackage as the "observable" package, or something like that. Coincidentally, Simon pinged me about io-memoize with his use case in HSpec. So it's something that's been on my mind, but Simon came to me with a fresh Real Code use case that motivated the recent tweaks and the 1.1 release. On Thu Jun 12 2014 at 3:28:47 AM, Simon Hengel wrote: > Hi Kim-Ee, > > > I may want a one-time only IO action, although so far the need hasn't > > arisen yet. ;) > > > > In the spirit of pilfering while the buns are still hot out of the oven, > is > > there a backstory for this package you could possibly sketch out? Some > > canonical use case maybe? > > I use it to implement beforeAll/beforeAllWith[1] in Hspec[2]. I have > been reluctant to add them because used in the wrong way they lead to > bad/order dependent test cases. But there are some valid use cases. So > I decided to finally add them. > > Cheers, > Simon > > [1] https://github.com/hspec/hspec/pull/173 > [2] http://hspec.github.io/ > -------------- next part -------------- An HTML attachment was scrubbed... URL: From n3gb0y at gmail.com Thu Jun 12 19:19:50 2014 From: n3gb0y at gmail.com (Hamid) Date: Thu, 12 Jun 2014 23:49:50 +0430 Subject: [Haskell-cafe] Opening for OpenGL, C++ Development. In-Reply-To: References: Message-ID: Do people on Pascal mailing lists send non-related job offers ? :D On Thu, Jun 12, 2014 at 2:21 PM, Heinrich Apfelmus < apfelmus at quantentunnel.de> wrote: > Manoj Chaudhari wrote: > >> We are looking for Software Developers with OpenGL experience. >> >> - Should have experience in C++/Xcode, OpenGL/DirectX/IOS. >> - Experience with Shafer programming, Multi-threaded applications, >> Graphics >> in CAD domain. >> - The role is of Software Development on primary CAD application like >> CATIA. >> - Good skills in Geometry, algorithms, Mathematics, API's, Graphics-will >> be >> a added advantage. >> >> Experience : 2 to 6 years. >> > > Wrong forum? This is a Haskell mailing list, not a Pascal mailing list. > > > Best regards, > Heinrich Apfelmus > > -- > http://apfelmus.nfshost.com > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Cheers, Hamid. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ky3 at atamo.com Fri Jun 13 03:31:23 2014 From: ky3 at atamo.com (Kim-Ee Yeoh) Date: Fri, 13 Jun 2014 10:31:23 +0700 Subject: [Haskell-cafe] [Haskell] ANN: io-memoize 1.1 In-Reply-To: References: <20140612102842.GD24616@x200> Message-ID: SimonM, SimonH, Dan: thank you all for the responses! Really helpful when deciding to use this package. -- Kim-Ee On Fri, Jun 13, 2014 at 2:16 AM, Dan Burton wrote: > I created io-memoize a few years ago, around the same time that I also > created runmemo . I was > interested in "memoization" at the time, and was exploring various > memoization techniques. It was just for theory/fun and had no motivating > use case at the time. > > I've been following various pipes/conduit discussions, and one particular > discussion about WAI involved an interest in a "call once" callback. It's > hard to enforce that sort of thing at the compile time without using > hardcore solutions such as linear types or indexed monads, so the obvious > solution is to use something like io-memoize to enforce it at runtime > instead. > > > http://www.reddit.com/r/haskell/comments/246e39/disemboweling_wai_aka_gutting_out_conduit/ch4cv55 > > Something else I've been working on lately is "the observer pattern" in > Haskell. When you subscribe to an observer, it will give you a > "subscription", which is just an action you can run to "unsubscribe" > yourself. Again, there's potential for "once" to be useful here for > implementing the unsubscribe action. If I manage to create something solid > and novel out of this observer pattern stuff, then I'll release it to > hackage as the "observable" package, or something like that. > > Coincidentally, Simon pinged me about io-memoize with his use case in > HSpec. So it's something that's been on my mind, but Simon came to me with > a fresh Real Code use case that motivated the recent tweaks and the 1.1 > release. > > > On Thu Jun 12 2014 at 3:28:47 AM, Simon Hengel wrote: > >> Hi Kim-Ee, >> >> > I may want a one-time only IO action, although so far the need hasn't >> > arisen yet. ;) >> > >> > In the spirit of pilfering while the buns are still hot out of the >> oven, is >> > there a backstory for this package you could possibly sketch out? Some >> > canonical use case maybe? >> >> I use it to implement beforeAll/beforeAllWith[1] in Hspec[2]. I have >> been reluctant to add them because used in the wrong way they lead to >> bad/order dependent test cases. But there are some valid use cases. So >> I decided to finally add them. >> >> Cheers, >> Simon >> >> [1] https://github.com/hspec/hspec/pull/173 >> [2] http://hspec.github.io/ >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From john at repetae.net Fri Jun 13 05:33:54 2014 From: john at repetae.net (John Meacham) Date: Thu, 12 Jun 2014 22:33:54 -0700 Subject: [Haskell-cafe] improved jhc manual In-Reply-To: <538F39F9.5090705@fuuzetsu.co.uk> References: <538F39F9.5090705@fuuzetsu.co.uk> Message-ID: On Wed, Jun 4, 2014 at 8:23 AM, Mateusz Kowalczyk wrote: > You're correct that there's no such feature at the moment. If you want > something, please open an issue on [1]. Note that I have never used JHC > or looked into how it works so I will need very careful description of > what I need to do to replicate it all, including small test case, any > flags that need to be passed in for Haddock to work with JHC, expected > behaviour, a small case where there are no recursive modules so I can > confirm it works in simple case &c. If it turns out to not be too > complicated then you could have it in the next non-minor release (2.15.x). What would be easiest is to just bypass much of Haddocks middle end, as in, I don't want it to attempt to follow dependencies or figure out types or call ghc by itself at all. rather I want to give it a pre-digested pap of resolved names and types (and whatever else it needs) but let haddock still parse the file and generate the documention with its back end. This would be more generally useful as a haddock feature than trying to have it emulate other compilers as any compiler or tool can output this general metainfo format. John -- John Meacham - http://notanumber.net/ From gtener at gmail.com Fri Jun 13 06:03:36 2014 From: gtener at gmail.com (=?UTF-8?Q?Krzysztof_Skrz=C4=99tnicki?=) Date: Fri, 13 Jun 2014 08:03:36 +0200 Subject: [Haskell-cafe] Cross compiling Haskell from Linux to Windows with GHCs LLVM backend? In-Reply-To: References: Message-ID: In the past I have succesfully compiled with Windows build of GHC simply by using Wine. It might work for you as well. It worked surprisingly well and without a single problem at the time. I was using GHC 6.8.2 back then. -- Krzysztof On Tue, Jun 10, 2014 at 10:59 AM, Rob Stewart wrote: > Hi, > > I compile my code with GHC on Linux, and don't have ready access to a > Windows or a Mac operating system. Is it possible to use the GHC LLVM > backend as a means to cross compile Haskell code to target multiple > operating systems? I had envisaged it possible to generate the LLVM IR > using GHCs -keep-llvm-files flag, and using LLVMs target triple flag > to specify the CPU architecture and operating system of the users > machine. I'd like to compile on Linux, to target WIndows and Mac > machines. > > Strangely I cannot find blog posts or tutorials online for > cross-compiling Haskell with GHC via LLVM. > > Is it possible? Thanks, > > -- > Rob > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gtener at gmail.com Fri Jun 13 07:33:40 2014 From: gtener at gmail.com (=?UTF-8?Q?Krzysztof_Skrz=C4=99tnicki?=) Date: Fri, 13 Jun 2014 09:33:40 +0200 Subject: [Haskell-cafe] [Haskell] ANN: io-memoize 1.1 In-Reply-To: References: <20140612102842.GD24616@x200> Message-ID: I have also used this package as a quick-and-dirty-but-working solution to loading external resources at runtime and performing caching if needed. This was something like this: loadConfigFile :: IO SomeDataType loadConfigFile = once (read <$> readFile "foo.config.txt") Except that config file was actually ~50 MB long and parsed slowly. There are obviously cases where caching such file is wrong or should be done in some structured fashion (like in Haxl). Yet still, in other cases this is perfect tool to cut down development time. -- Krzysztof On Fri, Jun 13, 2014 at 5:31 AM, Kim-Ee Yeoh wrote: > SimonM, SimonH, Dan: thank you all for the responses! Really helpful when > deciding to use this package. > > -- Kim-Ee > > > On Fri, Jun 13, 2014 at 2:16 AM, Dan Burton > wrote: > >> I created io-memoize a few years ago, around the same time that I also >> created runmemo . I was >> interested in "memoization" at the time, and was exploring various >> memoization techniques. It was just for theory/fun and had no motivating >> use case at the time. >> >> I've been following various pipes/conduit discussions, and one particular >> discussion about WAI involved an interest in a "call once" callback. It's >> hard to enforce that sort of thing at the compile time without using >> hardcore solutions such as linear types or indexed monads, so the obvious >> solution is to use something like io-memoize to enforce it at runtime >> instead. >> >> >> http://www.reddit.com/r/haskell/comments/246e39/disemboweling_wai_aka_gutting_out_conduit/ch4cv55 >> >> Something else I've been working on lately is "the observer pattern" in >> Haskell. When you subscribe to an observer, it will give you a >> "subscription", which is just an action you can run to "unsubscribe" >> yourself. Again, there's potential for "once" to be useful here for >> implementing the unsubscribe action. If I manage to create something solid >> and novel out of this observer pattern stuff, then I'll release it to >> hackage as the "observable" package, or something like that. >> >> Coincidentally, Simon pinged me about io-memoize with his use case in >> HSpec. So it's something that's been on my mind, but Simon came to me with >> a fresh Real Code use case that motivated the recent tweaks and the 1.1 >> release. >> >> >> On Thu Jun 12 2014 at 3:28:47 AM, Simon Hengel wrote: >> >>> Hi Kim-Ee, >>> >>> > I may want a one-time only IO action, although so far the need hasn't >>> > arisen yet. ;) >>> > >>> > In the spirit of pilfering while the buns are still hot out of the >>> oven, is >>> > there a backstory for this package you could possibly sketch out? Some >>> > canonical use case maybe? >>> >>> I use it to implement beforeAll/beforeAllWith[1] in Hspec[2]. I have >>> been reluctant to add them because used in the wrong way they lead to >>> bad/order dependent test cases. But there are some valid use cases. So >>> I decided to finally add them. >>> >>> Cheers, >>> Simon >>> >>> [1] https://github.com/hspec/hspec/pull/173 >>> [2] http://hspec.github.io/ >>> >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ivanperezdominguez at gmail.com Fri Jun 13 10:10:03 2014 From: ivanperezdominguez at gmail.com (Ivan Perez) Date: Fri, 13 Jun 2014 12:10:03 +0200 Subject: [Haskell-cafe] Cross compiling Haskell from Linux to Windows with GHCs LLVM backend? In-Reply-To: References: Message-ID: Hi Not that this will get your hopes up, but my two cents... I have never been able to get wine to play along. GHC tends to fail when I use wine (exceptions, dll's that misbehave). Maybe it behaves better now. If you manage to make it work, please, let us know. I use hudson to recompile packages for multiple architectures, and windows gives me most of the headaches. If you use llvm's backend, I wonder what would happen the moment you use Template Haskell. I have just recently started to use the Android backend, and I expect problems. (But maybe I'm mistaken.) So far I use Windows in a VirtualBox VM. That approach (obviously) works. I'll celebrate the day when ReactOS works as a full replacement of Windows. Ivan On 13 June 2014 08:03, Krzysztof Skrz?tnicki wrote: > In the past I have succesfully compiled with Windows build of GHC simply > by using Wine. It might work for you as well. It worked surprisingly well > and without a single problem at the time. I was using GHC 6.8.2 back then. > > -- > Krzysztof > > > On Tue, Jun 10, 2014 at 10:59 AM, Rob Stewart > wrote: > >> Hi, >> >> I compile my code with GHC on Linux, and don't have ready access to a >> Windows or a Mac operating system. Is it possible to use the GHC LLVM >> backend as a means to cross compile Haskell code to target multiple >> operating systems? I had envisaged it possible to generate the LLVM IR >> using GHCs -keep-llvm-files flag, and using LLVMs target triple flag >> to specify the CPU architecture and operating system of the users >> machine. I'd like to compile on Linux, to target WIndows and Mac >> machines. >> >> Strangely I cannot find blog posts or tutorials online for >> cross-compiling Haskell with GHC via LLVM. >> >> Is it possible? Thanks, >> >> -- >> Rob >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gautier.difolco at gmail.com Fri Jun 13 13:03:15 2014 From: gautier.difolco at gmail.com (Gautier DI FOLCO) Date: Fri, 13 Jun 2014 15:03:15 +0200 Subject: [Haskell-cafe] Splitting HList Message-ID: Hello, I want to know if it is possible to split a HList? I want to have a function like this: splitV :: HList (s ++ s') -> (HList s, HList s') splitV = _ So I have begun by something which I thought simple: type family HSplit (ts :: [k]) (xs :: [k]) :: ([k], [k]) type instance HSplit ts xs = ([xs], SndHSplit ts xs) type family SndHSplit (ts :: [k]) (xs :: [k]) :: [k] type instance SndHSplit ts '[] = ts type instance SndHSplit (t ': ts) (x ': xs) = SndHSplit ts xs But I get the following error: H.hs:133:50: The second argument of ?SndHSplit? should have kind ?[k0]?, but ?xs? has kind ?*? In the type ?([xs], SndHSplit ts xs)? In the type instance declaration for ?HSplit? I don't understand why because xs and the first element of the tuple have the same kind ([k]). Thanks by advance for your help/explanations. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gtener at gmail.com Fri Jun 13 14:07:12 2014 From: gtener at gmail.com (=?UTF-8?Q?Krzysztof_Skrz=C4=99tnicki?=) Date: Fri, 13 Jun 2014 16:07:12 +0200 Subject: [Haskell-cafe] Cross compiling Haskell from Linux to Windows with GHCs LLVM backend? In-Reply-To: References: Message-ID: Interesting. On my Arch Linux with wine ver. 1.7.19 it seems to work nicely, at least for simple cases. To test it I have just installed latest Haskell Platform, then upgraded cabal-install to latest version and finally I run sandboxed Yesod installation. All appears to be ok. Everything is seem to be slower, compared to native Linux, but that is a minor issue and rather expected. I would expect some building problems with native libraries, but this is always more problematic than just plain Haskell builds. -- Krzysztof On Fri, Jun 13, 2014 at 12:10 PM, Ivan Perez wrote: > Hi > > Not that this will get your hopes up, but my two cents... > > I have never been able to get wine to play along. GHC tends to fail when I > use wine (exceptions, dll's that misbehave). Maybe it behaves better now. > If you manage to make it work, please, let us know. I use hudson to > recompile packages for multiple architectures, and windows gives me most of > the headaches. > > If you use llvm's backend, I wonder what would happen the moment you use > Template Haskell. I have just recently started to use the Android backend, > and I expect problems. (But maybe I'm mistaken.) > > So far I use Windows in a VirtualBox VM. That approach (obviously) works. > > I'll celebrate the day when ReactOS works as a full replacement of Windows. > > Ivan > > > On 13 June 2014 08:03, Krzysztof Skrz?tnicki wrote: > >> In the past I have succesfully compiled with Windows build of GHC simply >> by using Wine. It might work for you as well. It worked surprisingly well >> and without a single problem at the time. I was using GHC 6.8.2 back then. >> >> -- >> Krzysztof >> >> >> On Tue, Jun 10, 2014 at 10:59 AM, Rob Stewart >> wrote: >> >>> Hi, >>> >>> I compile my code with GHC on Linux, and don't have ready access to a >>> Windows or a Mac operating system. Is it possible to use the GHC LLVM >>> backend as a means to cross compile Haskell code to target multiple >>> operating systems? I had envisaged it possible to generate the LLVM IR >>> using GHCs -keep-llvm-files flag, and using LLVMs target triple flag >>> to specify the CPU architecture and operating system of the users >>> machine. I'd like to compile on Linux, to target WIndows and Mac >>> machines. >>> >>> Strangely I cannot find blog posts or tutorials online for >>> cross-compiling Haskell with GHC via LLVM. >>> >>> Is it possible? Thanks, >>> >>> -- >>> Rob >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe at haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jkarni at gmail.com Fri Jun 13 16:57:37 2014 From: jkarni at gmail.com (Julian K. Arni) Date: Fri, 13 Jun 2014 18:57:37 +0200 Subject: [Haskell-cafe] Not in scope Message-ID: <20140613165737.GA31772@jkarni.celeraone.com> I have a lot of boilerplate code that th-desugar has made significantly more manageable (thanks Richard!). Somewhere in the midst of it, I have: >> type_equal (DContT n1) (DContT n2) = {...} Which, when I compile with cabal, gives me: src/Language/Haskell/TH/Alpha.hs:180:13: Not in scope: data constructor ?DContT? Perhaps you meant one of these: ?DConT? (imported from Language.Haskell.TH.Desugar), ?DConE? (imported from Language.Haskell.TH.Desugar), ?DConPa? (imported from Language.Haskell.TH.Desugar) src/Language/Haskell/TH/Alpha.hs:180:25: Not in scope: data constructor ?DContT? Perhaps you meant one of these: ?DConT? (imported from Language.Haskell.TH.Desugar), ?DConE? (imported from Language.Haskell.TH.Desugar), ?DConPa? (imported from Language.Haskell.TH.Desugar) Huh? Of course 'DConT' is what I meant - that's exactly what I wrote! What in the world is going on? GHC is happy with all the other constructors! I tried rewriting, just to be sure I didn't *somehow* get a tricky unicode character in there... From allbery.b at gmail.com Fri Jun 13 16:59:35 2014 From: allbery.b at gmail.com (Brandon Allbery) Date: Fri, 13 Jun 2014 12:59:35 -0400 Subject: [Haskell-cafe] Not in scope In-Reply-To: <20140613165737.GA31772@jkarni.celeraone.com> References: <20140613165737.GA31772@jkarni.celeraone.com> Message-ID: On Fri, Jun 13, 2014 at 12:57 PM, Julian K. Arni wrote: > I have a lot of boilerplate code that th-desugar has made significantly > more > manageable (thanks Richard!). Somewhere in the midst of it, I have: > > >> type_equal (DContT n1) (DContT n2) = {...} (...) > Huh? Of course 'DConT' is what I meant - that's exactly what I wrote! > You sure of that? -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From jkarni at gmail.com Fri Jun 13 17:02:17 2014 From: jkarni at gmail.com (Julian Arni) Date: Fri, 13 Jun 2014 19:02:17 +0200 Subject: [Haskell-cafe] Not in scope In-Reply-To: References: <20140613165737.GA31772@jkarni.celeraone.com> Message-ID: Haha, how embarrassing. Sorry all On Jun 13, 2014 6:59 PM, "Brandon Allbery" wrote: > On Fri, Jun 13, 2014 at 12:57 PM, Julian K. Arni wrote: > >> I have a lot of boilerplate code that th-desugar has made significantly >> more >> manageable (thanks Richard!). Somewhere in the midst of it, I have: >> >> >> type_equal (DContT n1) (DContT n2) = {...} > > (...) > >> Huh? Of course 'DConT' is what I meant - that's exactly what I wrote! >> > > You sure of that? > > -- > brandon s allbery kf8nh sine nomine > associates > allbery.b at gmail.com > ballbery at sinenomine.net > unix, openafs, kerberos, infrastructure, xmonad > http://sinenomine.net > -------------- next part -------------- An HTML attachment was scrubbed... URL: From simons at cryp.to Fri Jun 13 17:16:23 2014 From: simons at cryp.to (Peter Simons) Date: Fri, 13 Jun 2014 19:16:23 +0200 Subject: [Haskell-cafe] ANN: io-memoize 1.1 References: Message-ID: <87egysivbs.fsf@write-only.cryp.to> Hi Dan, > 1. Create an empty cache with newCache > 2. fetch repeatedly from the cache, each time providing a fallback in > case it is empty. > > Fetching from a Cache is thread safe: only one "fallback" will execute > at a time, and after the first successful fallback, the cached value > will be set and no other fallbacks will be called. I'm not sure whether I get this correctly. If multiple threads fetch values from one cache, will only one of those threads run at a time? Or will those that fetch pairwise different values still run concurrently? In other words, does the cache have a global lock or is there a lock per value? Best regards, Peter From vogt.adam at gmail.com Fri Jun 13 17:36:07 2014 From: vogt.adam at gmail.com (adam vogt) Date: Fri, 13 Jun 2014 13:36:07 -0400 Subject: [Haskell-cafe] Splitting HList In-Reply-To: References: Message-ID: Hi Gautier, It's possible you want: type instance HSplit ts xs = '(xs, SndHSplit ts xs) [xs] stands for the ordinary list type constructor applied to xs ([] xs). But ghci can tell you with ":kind []" that [] :: * -> *. Similarly, (,) in the instance stands for (,) :: * -> * -> *, while the (,) in ([k], [k]) is actually the promoted tuple data constructor '(,) :: k1 -> k2 -> '(k1, k2). As for implementing hSplitV, it probably makes sense to start with: class HSplitAt (n :: HNat) xsys xs ys | n xsys -> xs ys, xs ys -> xsys n where hSplitAt :: Proxy n -> HList xsys -> (HList xs, HList ys) Then hSplitV can be implemented as class HSplitV xsys xs ys | xs ys -> xsys instance (HSplitAt n xsys xs ys, HLength xs ~ n) => HSplitV xsys xs ys where hSplitV = hSplitAt (Proxy :: Proxy n) You can use type families here, but since "| n xsys -> xs ys, xs ys -> xsys n" stands for four superclass constraints that look like ( (xs ++ ys) ~ xsys ), that option isn't as pretty in my opinion. Regards, Adam On Fri, Jun 13, 2014 at 9:03 AM, Gautier DI FOLCO wrote: > Hello, > > I want to know if it is possible to split a HList? > I want to have a function like this: > splitV :: HList (s ++ s') -> (HList s, HList s') > splitV = _ > > So I have begun by something which I thought simple: > type family HSplit (ts :: [k]) (xs :: [k]) :: ([k], [k]) > type instance HSplit ts xs = ([xs], SndHSplit ts xs) > > type family SndHSplit (ts :: [k]) (xs :: [k]) :: [k] > type instance SndHSplit ts '[] = ts > type instance SndHSplit (t ': ts) (x ': xs) = SndHSplit ts xs > > But I get the following error: > H.hs:133:50: > The second argument of ?SndHSplit? should have kind ?[k0]?, > but ?xs? has kind ?*? > In the type ?([xs], SndHSplit ts xs)? > In the type instance declaration for ?HSplit? > > I don't understand why because xs and the first element of the tuple have > the same kind ([k]). > > Thanks by advance for your help/explanations. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From danburton.email at gmail.com Fri Jun 13 17:43:04 2014 From: danburton.email at gmail.com (Dan Burton) Date: Fri, 13 Jun 2014 17:43:04 +0000 Subject: [Haskell-cafe] ANN: io-memoize 1.1 References: <87egysivbs.fsf@write-only.cryp.to> Message-ID: Sorry I wasn't clear about that. The lock is not global, it is per cache. newCache creates a newMVar which serves as the thread safe lock for that cache. Concurrently fetching from different caches can indeed run their separate fallbacks concurrently. On Fri, Jun 13, 2014, 10:16 AM, Peter Simons wrote: > Hi Dan, > > > 1. Create an empty cache with newCache > > 2. fetch repeatedly from the cache, each time providing a fallback in > > case it is empty. > > > > Fetching from a Cache is thread safe: only one "fallback" will execute > > at a time, and after the first successful fallback, the cached value > > will be set and no other fallbacks will be called. > > I'm not sure whether I get this correctly. If multiple threads fetch > values from one cache, will only one of those threads run at a time? Or > will those that fetch pairwise different values still run concurrently? > > In other words, does the cache have a global lock or is there a lock per > value? > > Best regards, > Peter > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gautier.difolco at gmail.com Fri Jun 13 18:30:13 2014 From: gautier.difolco at gmail.com (Gautier DI FOLCO) Date: Fri, 13 Jun 2014 20:30:13 +0200 Subject: [Haskell-cafe] Splitting HList In-Reply-To: References: Message-ID: Hi adam, Thanks for your answer. 2014-06-13 19:36 GMT+02:00 adam vogt : > Hi Gautier, > > It's possible you want: > > type instance HSplit ts xs = '(xs, SndHSplit ts xs) > > [xs] stands for the ordinary list type constructor applied to xs ([] > xs). But ghci can tell you with ":kind []" that [] :: * -> *. > Similarly, (,) in the instance stands for (,) :: * -> * -> *, while > the (,) in ([k], [k]) is actually the promoted tuple data constructor > '(,) :: k1 -> k2 -> '(k1, k2). > So, you mean that there is no way to fit a (* -> * -> *) or so when a (* -> *) is required? For example, this week I worked on a zipWith ($) version for HList, I have this code: data HApL :: [*] -> [*] -> * where Nil2 :: HApL '[] '[] (:**) :: (a -> b) -> HApL as bs -> HApL (a ': as) (b ': bs) infixr 5 :** zipWithHApL :: HApL xs ys -> HList xs -> HList ys zipWithHApL Nil2 HNil = HNil zipWithHApL (x :** xs) (HCons y ys) = x y `HCons` zipWithHApL xs ys It doesn't satisfy me because: 1. I had to create an ad hoc data-type to manage it, instead of [] deal with it out-of-the-box 2. There no easy way to convert HList to HApL There is no way to get HList closer than List? As for implementing hSplitV, it probably makes sense to start with: > > class HSplitAt (n :: HNat) xsys xs ys | n xsys -> xs ys, xs ys -> xsys n > where hSplitAt :: Proxy n -> HList xsys -> (HList xs, HList ys) > > Then hSplitV can be implemented as > > class HSplitV xsys xs ys | xs ys -> xsys > > instance (HSplitAt n xsys xs ys, > HLength xs ~ n) => > HSplitV xsys xs ys > where hSplitV = hSplitAt (Proxy :: Proxy n) > > > You can use type families here, but since "| n xsys -> xs ys, xs ys -> > xsys n" stands for four superclass constraints that look like ( (xs ++ > ys) ~ xsys ), that option isn't as pretty in my opinion. > Got it, but it requires to have a Length concept:/ No problem, but a little less "magic" Thanks by advance for your answers. Regards. -------------- next part -------------- An HTML attachment was scrubbed... URL: From brucker at spamfence.net Fri Jun 13 19:39:51 2014 From: brucker at spamfence.net (Achim D. Brucker) Date: Fri, 13 Jun 2014 21:39:51 +0200 Subject: [Haskell-cafe] Second Call for Papers: OCL 2014 Message-ID: <20140613193951.GA8122@fujikawa.home.brucker.ch> (Apologies for duplicates) CALL FOR PAPERS 14th International Workshop on OCL and Textual Modeling Applications and Case Studies (OCL 2014) Co-located with ACM/IEEE 17th International Conference on Model Driven Engineering Languages and Systems (MODELS 2014) September 28-30 (tbc), 2014, VALENCIA, SPAIN http://www.software.imdea.org/OCL2014/ Modeling started out with UML and its precursors as a graphical notation. Such visual representations enable direct intuitive capturing of reality, but some of their features are difficult to formalize and lack the level of precision required to create complete and unambiguous specifications. Limitations of the graphical notations encouraged the development of text-based modeling languages that either integrate with or replace graphical notations for modeling. Typical examples of such languages are OCL, textual MOF, Epsilon, and Alloy. Textual modeling languages have their roots in formal language paradigms like logic, programming and databases. The goal of this workshop is create a forum where researchers and practitioners interested in building models using OCL or other kinds of textual languages can directly interact, report advances, share results, identify tools for language development, and discuss appropriate standards. In particular, the workshop will encourage discussions for achieving synergy from different modeling language concepts and modeling language use. The close interaction will enable researchers and practitioners to identify common interests and options for potential cooperation. Topics of interest include (but are not limited to) =================================================== - Mappings between textual modeling languages and other languages/formalisms - Algorithms, evaluation strategies and optimizations in the context of textual modeling languages for -- validation, verification, and testing, -- model transformation and code generation, -- metamodeling and DSLs, and -- query and constraint specifications - Alternative graphical/textual notations for textual modeling languages - Evolution, transformation and simplification of textual modeling expressions - Libraries, templates and patterns for textual modeling languages - Complexity results for textual modeling languages - Quality models and benchmarks for comparing and evaluating textual modeling tools and algorithms - Successful applications of textual modeling languages - Case studies on industrial applications of textual modeling languages - Experience reports -- usage of textual modeling languages and tools in complex domains, -- usability of textual modeling languages and tools for end-users - Empirical studies about the benefits and drawbacks of textual modeling languages - Innovative textual modeling tools - Comparison, evaluation and integration of modeling languages - Correlation between modeling languages and modeling tasks This year, we particularly encourage submissions describing applications and case studies of textual modeling as well as test suites and benchmark collections for evaluating textual modeling tools. Venue ===== The workshop will be organized as a part of MODELS 2014 Conference in Valencia, Spain. It continues the series of OCL workshops held at UML/MODELS conferences: York (2000), Toronto (2001), San Francisco (2003), Lisbon (2004), Montego Bay (2005), Genova (2006), Nashville (2007), Toulouse (2008), Denver (2009), Oslo (2010), Zurich (2011, at the TOOLs conference), 2012 in Innsbruck, and 2013 in Miami. Similar to its predecessors, the workshop addresses both people from academia and industry. The aim is to provide a forum for addressing integration of OCL and other textual modeling languages, as well as tools for textual modeling, and for disseminating good practice and discussing the new requirements for textual modeling. Workshop Format =============== The workshop will include short (about 15 min) presentations, parallel sessions of working groups, and sum-up discussions. Submissions =========== Two types of papers will be considered: * short papers (6 pages) and * full papers (10 pages) in LNCS format. Submissions should be uploaded to EasyChair (https://www.easychair.org/conferences/?conf=ocl2014). The program committee will review the submissions (minimum 2 reviews per paper, usually 3 reviews) and select papers according to their relevance and interest for discussions that will take place at the workshop. Accepted papers will be published online in a pre-conference edition of CEUR (http://www.ceur-ws.org). Authors of selected papers will be invited to submit an extended version of their workshop paper to a special issue of the Electronic Communications of the EASST (http://journal.ub.tu-berlin.de/eceasst) Important Dates =============== Submission of papers: July 11, 2014 Notification: August 8, 2014 Workshop date: one day during September 28-30, 2014 Organizers ========== Achim D. Brucker, SAP AG, Germany Carolina Dania, IMDEA Software Institute, Madrid, Spain Geri Georg, Colorado State University, Fort Collins, Colorado, USA Martin Gogolla, University of Bremen, Germany Programme Committee (partly confirmation pending) =================== Michael Altenhofen, SAP AG, Germany Thomas Baar, University of Applied Sciences Berlin, Germany Mira Balaban, Ben-Gurion University of the Negev, Israel Tricia Balfe, Nomos Software, Ireland Fabian Buettner, Ecole des Mines de Nantes, France Achim D. Brucker, SAP AG, Germany Jordi Cabot, INRIA-Ecole des Mines de Nantes, France Yoonsik Cheon, University of Texas, USA Dan Chiorean, Babes-Bolyai University, Romania Robert Clariso, Universitat Oberta de Catalunya, Spain Tony Clark, Middlesex University, UK Manuel Clavel, IMDEA Software Institute, Madrid, Spain Carolina Dania, IMDEA Software Institute, Madrid, Spain Birgit Demuth, Technische Universitat Dresden, Germany Marina Egea, Atos Research, Madrid, Spain Geri Georg, Colorado State University, Fort Collins, Colorado, USA Martin Gogolla, University of Bremen, Germany Pieter Van Gorp, Eindhoven University of Technology, The Netherlands Heinrich Hussmann, LMU Munchen, Germany Tihamer Levendovszky, Vanderbilt University, USA Shahar Maoz, Tel Aviv University, Israel Istvan Rath, Budapest University of Technology and Economics, Hungary Bernhard Rumpe, RWTH Aachen, Germany Shane Sendall, Snowie Research SA, Switzerland Michael Wahler, ABB Switzerland Ltd Corporate Research, Switzerland Claas Wilke, Technische Universitat Dresden, Germany Edward Willink, Willink Transformations Ltd., UK Burkhart Wolff, Univ Paris-Sud, France Steffen Zschaler, King?s College, London, UK -- Dr. Achim D. Brucker, SAP AG, Vincenz-Priessnitz-Str. 1, D-76131 Karlsruhe Phone: +49 6227 7-52595, http://www.brucker.ch/ From vogt.adam at gmail.com Fri Jun 13 19:44:42 2014 From: vogt.adam at gmail.com (adam vogt) Date: Fri, 13 Jun 2014 15:44:42 -0400 Subject: [Haskell-cafe] Splitting HList In-Reply-To: References: Message-ID: Hi Gautier, > So, you mean that there is no way to fit a (* -> * -> *) or so when a (* -> > *) is required? No.If you decide on a kind signature ([k], [k]), you have to use '(,) not (,) when making types for that kind. Similarly if you have a type [xs], the kind of that is * which doesn't match the kind [k] you specify. > For example, this week I worked on a zipWith ($) version for HList, I have > this code: > data HApL :: [*] -> [*] -> * where > Nil2 :: HApL '[] '[] > (:**) :: (a -> b) -> HApL as bs -> HApL (a ': as) (b ': bs) > > infixr 5 :** > > zipWithHApL :: HApL xs ys -> HList xs -> HList ys > zipWithHApL Nil2 HNil = HNil > zipWithHApL (x :** xs) (HCons y ys) = x y `HCons` zipWithHApL xs ys > > It doesn't satisfy me because: > 1. I had to create an ad hoc data-type to manage it, instead of [] deal > with it out-of-the-box > 2. There no easy way to convert HList to HApL > > There is no way to get HList closer than List? I'm not sure. With the HList library on hackage, you can do the equivalent of zipWithDollar xs ys = map ($) (zip xs ys) by defining: data Dollar = Dollar instance (fx ~ (x -> y, x)) => ApplyAB Dollar fx y where applyAB _ (f,x) = f x hZipWithDollar xs ys = hMap Dollar (hZip xs ys) It works like: >>> hZipWithDollar (hBuild (+1) tail) (hBuild 3 "ab") H[4, "b"] But in more complicated cases there is a tendency to need -XAllowAmbiguousTypes, which means writing type signatures (with -XScopedTypeVariables) that should be unnecessary. Regards, Adam From mikhail.vorozhtsov at gmail.com Sat Jun 14 14:48:16 2014 From: mikhail.vorozhtsov at gmail.com (Mikhail Vorozhtsov) Date: Sat, 14 Jun 2014 18:48:16 +0400 Subject: [Haskell-cafe] RFC: Unicode primes and super/subscript characters in GHC Message-ID: <539C60B0.6010007@gmail.com> Hello lists, As some of you may know, GHC's support for Unicode characters in lexemes is rather crude and hence prone to inconsistencies in their handling versus the ASCII counterparts. For example, APOSTROPHE is treated differently from PRIME: ?> data a +' b = Plus a b :3:9: Unexpected type ?b? In the data declaration for ?+? A data declaration should have form data + a b c = ... ?> data a +? b = Plus a b ?> let a' = 1 ?> let a? = 1 :10:8: parse error on input ?=? Also some rather bizarre looking things are accepted: ?> let ?x?y = 1 In the spirit of improving things little by little I would like to propose: 1. Handle single/double/triple/quadruple Unicode PRIMEs the same way as APOSTROPHE, meaning the following alterations to the lexer: primes -> U+2032 | U+2033 | U+2034 | U+2057 symbol -> ascSymbol | uniSymbol (EXCEPT special | _ | " | ' | primes) graphic -> small | large | symbol | digit | special | " | ' | primes varid -> (small { small | large | digit | ' | primes }) (EXCEPT reservedid) conid -> large { small | large | digit | ' | primes } 2. Introduce a new lexer nonterminal "subsup" that would include the Unicode sub/superscript[1] versions of numbers, "-", "+", "=", "(", ")", Latin and Greek letters. And allow these characters to be used in names and operators: symbol -> ascSymbol | uniSymbol (EXCEPT special | _ | " | ' | primes | subsup ) digit -> ascDigit | uniDigit (EXCEPT subsup) small -> ascSmall | uniSmall (EXCEPT subsup) | _ large -> ascLarge | uniLarge (EXCEPT subsup) graphic -> small | large | symbol | digit | special | " | ' | primes | subsup varid -> (small { small | large | digit | ' | primes | subsup }) (EXCEPT reservedid) conid -> large { small | large | digit | ' | primes | subsup } varsym -> (symbol (EXCEPT :) {symbol | subsup}) (EXCEPT reservedop | dashes) consym -> (: {symbol | subsup}) (EXCEPT reservedop) If this proposal is received favorably, I'll write a patch for GHC based on my previous stab at the problem[2]. P.S. I'm CC-ing Cafe for extra attention, but please keep the discussion to the GHC users list. [1] https://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts [2] https://ghc.haskell.org/trac/ghc/ticket/5108 From john at repetae.net Sat Jun 14 23:58:14 2014 From: john at repetae.net (John Meacham) Date: Sat, 14 Jun 2014 16:58:14 -0700 Subject: [Haskell-cafe] RFC: Unicode primes and super/subscript characters in GHC In-Reply-To: <539C60B0.6010007@gmail.com> References: <539C60B0.6010007@gmail.com> Message-ID: I have this feature in jhc, where I have a 'trailing' character class that can appear at the end of both symbols and ids. currently it consists of $trailing = [??????????????????????????] John On Sat, Jun 14, 2014 at 7:48 AM, Mikhail Vorozhtsov wrote: > Hello lists, > > As some of you may know, GHC's support for Unicode characters in lexemes is > rather crude and hence prone to inconsistencies in their handling versus the > ASCII counterparts. For example, APOSTROPHE is treated differently from > PRIME: > > ?> data a +' b = Plus a b > :3:9: > Unexpected type ?b? > In the data declaration for ?+? > A data declaration should have form > data + a b c = ... > ?> data a +? b = Plus a b > > ?> let a' = 1 > ?> let a? = 1 > :10:8: parse error on input ?=? > > Also some rather bizarre looking things are accepted: > > ?> let ?x?y = 1 > > In the spirit of improving things little by little I would like to propose: > > 1. Handle single/double/triple/quadruple Unicode PRIMEs the same way as > APOSTROPHE, meaning the following alterations to the lexer: > > primes -> U+2032 | U+2033 | U+2034 | U+2057 > symbol -> ascSymbol | uniSymbol (EXCEPT special | _ | " | ' | primes) > graphic -> small | large | symbol | digit | special | " | ' | primes > varid -> (small { small | large | digit | ' | primes }) (EXCEPT reservedid) > conid -> large { small | large | digit | ' | primes } > > 2. Introduce a new lexer nonterminal "subsup" that would include the Unicode > sub/superscript[1] versions of numbers, "-", "+", "=", "(", ")", Latin and > Greek letters. And allow these characters to be used in names and operators: > > symbol -> ascSymbol | uniSymbol (EXCEPT special | _ | " | ' | primes | > subsup ) > digit -> ascDigit | uniDigit (EXCEPT subsup) > small -> ascSmall | uniSmall (EXCEPT subsup) | _ > large -> ascLarge | uniLarge (EXCEPT subsup) > graphic -> small | large | symbol | digit | special | " | ' | primes | > subsup > varid -> (small { small | large | digit | ' | primes | subsup }) (EXCEPT > reservedid) > conid -> large { small | large | digit | ' | primes | subsup } > varsym -> (symbol (EXCEPT :) {symbol | subsup}) (EXCEPT reservedop | dashes) > consym -> (: {symbol | subsup}) (EXCEPT reservedop) > > If this proposal is received favorably, I'll write a patch for GHC based on > my previous stab at the problem[2]. > > P.S. I'm CC-ing Cafe for extra attention, but please keep the discussion to > the GHC users list. > > [1] https://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts > [2] https://ghc.haskell.org/trac/ghc/ticket/5108 > _______________________________________________ > Glasgow-haskell-users mailing list > Glasgow-haskell-users at haskell.org > http://www.haskell.org/mailman/listinfo/glasgow-haskell-users -- John Meacham - http://notanumber.net/ From andrew.gibiansky at gmail.com Sun Jun 15 06:16:05 2014 From: andrew.gibiansky at gmail.com (Andrew Gibiansky) Date: Sat, 14 Jun 2014 23:16:05 -0700 Subject: [Haskell-cafe] RFC: Unicode primes and super/subscript characters in GHC In-Reply-To: References: <539C60B0.6010007@gmail.com> Message-ID: I personally like this idea. Mathematica allows all sorts of bizarre names and it'd be cool for Haskell to be similar, so that mathematical Haskell scripts and IHaskell notebooks can be just as fancy and incomprehensible as dense Mathematica code! Since GHC already accepts *some* unicode, I think it'd be a great idea to extend it in this way. On Sat, Jun 14, 2014 at 4:58 PM, John Meacham wrote: > I have this feature in jhc, where I have a 'trailing' character class > that can appear at the end of both symbols and ids. > > currently it consists of > > $trailing = [??????????????????????????] > > John > > On Sat, Jun 14, 2014 at 7:48 AM, Mikhail Vorozhtsov > wrote: > > Hello lists, > > > > As some of you may know, GHC's support for Unicode characters in lexemes > is > > rather crude and hence prone to inconsistencies in their handling versus > the > > ASCII counterparts. For example, APOSTROPHE is treated differently from > > PRIME: > > > > ?> data a +' b = Plus a b > > :3:9: > > Unexpected type ?b? > > In the data declaration for ?+? > > A data declaration should have form > > data + a b c = ... > > ?> data a +? b = Plus a b > > > > ?> let a' = 1 > > ?> let a? = 1 > > :10:8: parse error on input ?=? > > > > Also some rather bizarre looking things are accepted: > > > > ?> let ?x?y = 1 > > > > In the spirit of improving things little by little I would like to > propose: > > > > 1. Handle single/double/triple/quadruple Unicode PRIMEs the same way as > > APOSTROPHE, meaning the following alterations to the lexer: > > > > primes -> U+2032 | U+2033 | U+2034 | U+2057 > > symbol -> ascSymbol | uniSymbol (EXCEPT special | _ | " | ' | primes) > > graphic -> small | large | symbol | digit | special | " | ' | primes > > varid -> (small { small | large | digit | ' | primes }) (EXCEPT > reservedid) > > conid -> large { small | large | digit | ' | primes } > > > > 2. Introduce a new lexer nonterminal "subsup" that would include the > Unicode > > sub/superscript[1] versions of numbers, "-", "+", "=", "(", ")", Latin > and > > Greek letters. And allow these characters to be used in names and > operators: > > > > symbol -> ascSymbol | uniSymbol (EXCEPT special | _ | " | ' | primes | > > subsup ) > > digit -> ascDigit | uniDigit (EXCEPT subsup) > > small -> ascSmall | uniSmall (EXCEPT subsup) | _ > > large -> ascLarge | uniLarge (EXCEPT subsup) > > graphic -> small | large | symbol | digit | special | " | ' | primes | > > subsup > > varid -> (small { small | large | digit | ' | primes | subsup }) (EXCEPT > > reservedid) > > conid -> large { small | large | digit | ' | primes | subsup } > > varsym -> (symbol (EXCEPT :) {symbol | subsup}) (EXCEPT reservedop | > dashes) > > consym -> (: {symbol | subsup}) (EXCEPT reservedop) > > > > If this proposal is received favorably, I'll write a patch for GHC based > on > > my previous stab at the problem[2]. > > > > P.S. I'm CC-ing Cafe for extra attention, but please keep the discussion > to > > the GHC users list. > > > > [1] https://en.wikipedia.org/wiki/Unicode_subscripts_and_superscripts > > [2] https://ghc.haskell.org/trac/ghc/ticket/5108 > > _______________________________________________ > > Glasgow-haskell-users mailing list > > Glasgow-haskell-users at haskell.org > > http://www.haskell.org/mailman/listinfo/glasgow-haskell-users > > > > -- > John Meacham - http://notanumber.net/ > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gautier.difolco at gmail.com Sun Jun 15 10:45:26 2014 From: gautier.difolco at gmail.com (Gautier DI FOLCO) Date: Sun, 15 Jun 2014 12:45:26 +0200 Subject: [Haskell-cafe] Splitting HList In-Reply-To: References: Message-ID: Hi adam, Thanks for your answer. 2014-06-13 21:44 GMT+02:00 adam vogt : > No.If you decide on a kind signature ([k], [k]), you have to use '(,) > not (,) when making types for that kind. Similarly if you have a type > [xs], the kind of that is * which doesn't match the kind [k] you > specify. > ok, I was confused, thanks. > I'm not sure. With the HList library on hackage, you can do the > equivalent of > > zipWithDollar xs ys = map ($) (zip xs ys) > > by defining: > > data Dollar = Dollar > instance (fx ~ (x -> y, x)) => ApplyAB Dollar fx y where > applyAB _ (f,x) = f x > > hZipWithDollar xs ys = hMap Dollar (hZip xs ys) > > It works like: > > >>> hZipWithDollar (hBuild (+1) tail) (hBuild 3 "ab") > H[4, "b"] > > But in more complicated cases there is a tendency to need > -XAllowAmbiguousTypes, which means writing type signatures (with > -XScopedTypeVariables) that should be unnecessary. > ok, that's clear, thanks. Regards. -------------- next part -------------- An HTML attachment was scrubbed... URL: From nikita.y.volkov at mail.ru Sun Jun 15 11:43:53 2014 From: nikita.y.volkov at mail.ru (Nikita Volkov) Date: Sun, 15 Jun 2014 15:43:53 +0400 Subject: [Haskell-cafe] Support of multi-constructor types by UNPACK pragma Message-ID: Currently the pragma only supports single-constructor types. So in the following example it will simply be ignored: data A = A1 Char | A2 {-# UNPACK #-} !B data B = B1 Int | B2 Bool However it seems to be easily solvable by changing the type A to something like the following during unpacking: data A = A1 Char | A2_1 Int | -- from B1 A2_2 Bool -- from B2 Am I missing something? Why is it not implemented? ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From almeidaraf at gmail.com Sun Jun 15 15:10:26 2014 From: almeidaraf at gmail.com (Rafael Almeida) Date: Sun, 15 Jun 2014 12:10:26 -0300 Subject: [Haskell-cafe] Taking a number to a power and taking its mod Message-ID: Hello, I've been trying to do a problem from SPOJ which requires me to find prime numbers in a range. I've been battling with several possibility, so far I have had no luck. I remember primality tests from college. So I looked up the one I knew: fermat's little theorem. It requires me to do this check: a^(p-1) `mod` p == 1 However, taking a number to a large power is very slow. So it was even worse than the solution I was already trying. I'm not here for your guys to give me the solution. But I'm here to understand how can I do that operation quickly. This wiki entry implements powMod http://www.haskell.org/haskellwiki/Testing_primality Calling that funcion with powMod 999999527 2 (999999527-1) is very fast. What's going on? Can someone shed me some light? []'s Rafael -------------- next part -------------- An HTML attachment was scrubbed... URL: From hvr at gnu.org Sun Jun 15 15:34:31 2014 From: hvr at gnu.org (Herbert Valerio Riedel) Date: Sun, 15 Jun 2014 17:34:31 +0200 Subject: [Haskell-cafe] Taking a number to a power and taking its mod In-Reply-To: (Rafael Almeida's message of "Sun, 15 Jun 2014 12:10:26 -0300") References: Message-ID: <87fvj6p4oo.fsf@gnu.org> Hello Rafael, On 2014-06-15 at 17:10:26 +0200, Rafael Almeida wrote: [...] > However, taking a number to a large power is very slow. So it was even > worse than the solution I was already trying. > > I'm not here for your guys to give me the solution. But I'm here to > understand how can I do that operation quickly. This wiki entry implements > powMod > > http://www.haskell.org/haskellwiki/Testing_primality > > Calling that funcion with powMod 999999527 2 (999999527-1) is very fast. > What's going on? Can someone shed me some light? One of the reason that powMod is very fast is because it avoids allocating large integer bignums by http://en.wikipedia.org/wiki/Exponentiation_by_squaring Just for the record (should you want an even more optimized powMod implementation): integer-gmp now exposes a few highly optimized Integer primitives, including a powMod: http://hackage.haskell.org/package/integer-gmp-0.5.1.0/docs/GHC-Integer-GMP-Internals.html#v:powModInteger HTH, hvr From almeidaraf at gmail.com Sun Jun 15 18:32:16 2014 From: almeidaraf at gmail.com (Rafael Almeida) Date: Sun, 15 Jun 2014 15:32:16 -0300 Subject: [Haskell-cafe] Taking a number to a power and taking its mod In-Reply-To: <87fvj6p4oo.fsf@gnu.org> References: <87fvj6p4oo.fsf@gnu.org> Message-ID: Interesting. I had a read on this wikipedia article as well: http://en.wikipedia.org/wiki/Modular_exponentiation It gives us one important theorem: a*b `mod` m == (a*(b `mod` m)) `mod` m That's what makes exponentiation by squaring so appealing. I wrote the function in a way that I found it easier to understand. Take a look: powMod :: Integral a => a -> a -> a -> a powMod _ _ 0 = 1 powMod m x 1 = x `mod` m powMod m x n | even n = powMod m modSquare (n`div`2) | otherwise = (x * powMod m modSquare ((n-1)`div`2)) `mod` m where modSquare = x * (x `mod` m) That funcion does the pow-mod operation much quickier than doing n^k `mod` m. Unfortunately, nothing of those things actually solved the prime1 SPOJ problem :P I mostly gave it up, already. I liked learning those things, though :) On Sun, Jun 15, 2014 at 12:34 PM, Herbert Valerio Riedel wrote: > Hello Rafael, > > On 2014-06-15 at 17:10:26 +0200, Rafael Almeida wrote: > > [...] > > > However, taking a number to a large power is very slow. So it was even > > worse than the solution I was already trying. > > > > I'm not here for your guys to give me the solution. But I'm here to > > understand how can I do that operation quickly. This wiki entry > implements > > powMod > > > > http://www.haskell.org/haskellwiki/Testing_primality > > > > Calling that funcion with powMod 999999527 2 (999999527-1) is very fast. > > What's going on? Can someone shed me some light? > > One of the reason that powMod is very fast is because it avoids > allocating large integer bignums by > > http://en.wikipedia.org/wiki/Exponentiation_by_squaring > > > Just for the record (should you want an even more optimized powMod > implementation): integer-gmp now exposes a few highly optimized Integer > primitives, including a powMod: > > > http://hackage.haskell.org/package/integer-gmp-0.5.1.0/docs/GHC-Integer-GMP-Internals.html#v:powModInteger > > > HTH, > hvr > -------------- next part -------------- An HTML attachment was scrubbed... URL: From glaebhoerl at gmail.com Sun Jun 15 19:47:52 2014 From: glaebhoerl at gmail.com (=?UTF-8?B?R8OhYm9yIExlaGVs?=) Date: Sun, 15 Jun 2014 21:47:52 +0200 Subject: [Haskell-cafe] What are the problems with instances for polymorphic types? Message-ID: In other words instances for forall-types, such as: instance Foo (forall a. [a]) where ... It feels obvious to me that there *would* be problems with this, but I'm curious about what, exactly, they are. Could someone familiar with the matter either elaborate on them, or refer me to an existing explanation, a previous discussion, or something of the sort? I *don't* have any kind of use case in mind, I'm merely seeking a better understanding of the type-system issues involved. (I attempted Google, but didn't have much success.) Thanks in advance. -------------- next part -------------- An HTML attachment was scrubbed... URL: From carter.schonwald at gmail.com Sun Jun 15 20:30:40 2014 From: carter.schonwald at gmail.com (Carter Schonwald) Date: Sun, 15 Jun 2014 16:30:40 -0400 Subject: [Haskell-cafe] Support of multi-constructor types by UNPACK pragma In-Reply-To: References: Message-ID: Are you sure that's not supported? That seems like a bug if so. I'm away from my computer right now so I can't check. What ghc version? How are you checking if the unpack is firing? Ghc 7.8 should by default be unpacking ALL strict small fields. On Sunday, June 15, 2014, Nikita Volkov wrote: > Currently the pragma only supports single-constructor types. So in the > following example it will simply be ignored: > > data A = > A1 Char | > A2 {-# UNPACK #-} !B > > data B = > B1 Int | > B2 Bool > > However it seems to be easily solvable by changing the type A to > something like the following during unpacking: > > data A = > A1 Char | > A2_1 Int | -- from B1 > A2_2 Bool -- from B2 > > Am I missing something? Why is it not implemented? > ? > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From johan.tibell at gmail.com Sun Jun 15 21:02:57 2014 From: johan.tibell at gmail.com (Johan Tibell) Date: Sun, 15 Jun 2014 23:02:57 +0200 Subject: [Haskell-cafe] Support of multi-constructor types by UNPACK pragma In-Reply-To: References: Message-ID: GHC doesn't unpack sums, like B in the example. On Sun, Jun 15, 2014 at 10:30 PM, Carter Schonwald < carter.schonwald at gmail.com> wrote: > Are you sure that's not supported? That seems like a bug if so. I'm away > from my computer right now so I can't check. > > What ghc version? How are you checking if the unpack is firing? > > Ghc 7.8 should by default be unpacking ALL strict small fields. > > > On Sunday, June 15, 2014, Nikita Volkov wrote: > >> Currently the pragma only supports single-constructor types. So in the >> following example it will simply be ignored: >> >> data A = >> A1 Char | >> A2 {-# UNPACK #-} !B >> >> data B = >> B1 Int | >> B2 Bool >> >> However it seems to be easily solvable by changing the type A to >> something like the following during unpacking: >> >> data A = >> A1 Char | >> A2_1 Int | -- from B1 >> A2_2 Bool -- from B2 >> >> Am I missing something? Why is it not implemented? >> ? >> >> > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gautier.difolco at gmail.com Sun Jun 15 22:25:09 2014 From: gautier.difolco at gmail.com (Gautier DI FOLCO) Date: Mon, 16 Jun 2014 00:25:09 +0200 Subject: [Haskell-cafe] type families and type classes Message-ID: Hi all, I have a bunch of data types which are "divided" in other data types as following: type FileName = String data FileWish = File FileName deriving (Show, Eq) data FileFact = FileExist | FileDontExist deriving (Show, Eq) data FileAction = FileCreate deriving (Show, Eq) observe :: FileWish -> [FileFact] observe :: undefined plan :: FileWish -> FileFact -> [FileAction] plan (File _) FileDontExist = [FileCreate] plan (File _) FileExist = [] perform :: FileWish -> [FileAction] -> IO () perform :: undefined I want to have a model as extensible as possible, even if I'm new to Haskell, I think that it's preferable to base parts of system on behavior (type classes) rather than data types. So I have File that give a Wish, a Fact (via observe) and a Action (via plan). I want to put observe, plan and perform in different type classes (let's say Observable, Plannable and Performable). When I create a new thing (like File) I want, for example, that : observe :: Wish e -> [Fact e] where e is File. But I want (Fact e) be an instance of Plannable. And so on. At first glance, I think I have to use this: https://www.fpcomplete.com/school/to-infinity-and-beyond/pick-of-the-week/type-families-and-pokemon But it is coupled to data type and one type class. If you have any hints for me. Maybe I don't take the right way to solve my problem. Thanks in advance. -------------- next part -------------- An HTML attachment was scrubbed... URL: From carter.schonwald at gmail.com Sun Jun 15 22:44:39 2014 From: carter.schonwald at gmail.com (Carter Schonwald) Date: Sun, 15 Jun 2014 18:44:39 -0400 Subject: [Haskell-cafe] Support of multi-constructor types by UNPACK pragma In-Reply-To: References: Message-ID: Woops. I misread the original email then! Yeah, unpacking sums could have an exponential blowup right? On Sunday, June 15, 2014, Johan Tibell wrote: > GHC doesn't unpack sums, like B in the example. > > > On Sun, Jun 15, 2014 at 10:30 PM, Carter Schonwald < > carter.schonwald at gmail.com > > wrote: > >> Are you sure that's not supported? That seems like a bug if so. I'm away >> from my computer right now so I can't check. >> >> What ghc version? How are you checking if the unpack is firing? >> >> Ghc 7.8 should by default be unpacking ALL strict small fields. >> >> >> On Sunday, June 15, 2014, Nikita Volkov > > wrote: >> >>> Currently the pragma only supports single-constructor types. So in the >>> following example it will simply be ignored: >>> >>> data A = >>> A1 Char | >>> A2 {-# UNPACK #-} !B >>> >>> data B = >>> B1 Int | >>> B2 Bool >>> >>> However it seems to be easily solvable by changing the type A to >>> something like the following during unpacking: >>> >>> data A = >>> A1 Char | >>> A2_1 Int | -- from B1 >>> A2_2 Bool -- from B2 >>> >>> Am I missing something? Why is it not implemented? >>> ? >>> >>> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuuzetsu at fuuzetsu.co.uk Sun Jun 15 22:47:03 2014 From: fuuzetsu at fuuzetsu.co.uk (Mateusz Kowalczyk) Date: Mon, 16 Jun 2014 00:47:03 +0200 Subject: [Haskell-cafe] improved jhc manual In-Reply-To: References: <538F39F9.5090705@fuuzetsu.co.uk> Message-ID: <539E2267.8040503@fuuzetsu.co.uk> On 06/13/2014 07:33 AM, John Meacham wrote: > On Wed, Jun 4, 2014 at 8:23 AM, Mateusz Kowalczyk > wrote: >> You're correct that there's no such feature at the moment. If you want >> something, please open an issue on [1]. Note that I have never used JHC >> or looked into how it works so I will need very careful description of >> what I need to do to replicate it all, including small test case, any >> flags that need to be passed in for Haddock to work with JHC, expected >> behaviour, a small case where there are no recursive modules so I can >> confirm it works in simple case &c. If it turns out to not be too >> complicated then you could have it in the next non-minor release (2.15.x). > > What would be easiest is to just bypass much of Haddocks middle end, > as in, I don't want it to attempt to follow dependencies or figure out > types or call ghc by itself at all. rather I want to give it a > pre-digested pap of resolved names and types (and whatever else it > needs) but let haddock still parse the file and generate the > documention with its back end. GHC does the parsing of stuff for us, as well as module loading, package finding, name resolution, renaming, ?. What we do parse is the things that GHC tells us are Haddock comments (the stuff you actually write). What you'd need to produce for us to use XHtml backend is [Interface] where Interface is defined in Haddock.Types. Notably, this involves LHsDecl which is a GHC type which the back-end inspects and decides what to do with. What's more, we use some pretty printing functions from GHC to actually render the stuff. Basically, GHC does the bulk of work and we massage whatever we get back into a friendlier format for humans to read. If you don't want to involve GHC at all then it's not feasible to use Haddock. There *are* plans to splice out the parts that don't need GHC to a separate package (currently unimaginatively called haddock-library) and I have already done so with the comment parser (so you can turn String into Haddock doc type) but there are no plans to just not use GHC all together, it is too much work. We are planning to make writing new back-ends easier but the GHC dependency will not go away. So the short version is, there is no GHC middle-end, it is GHC from the beginning to the end. One way to work around this would be to pre-process what we get out of GHC into Haddock types that no longer refer to the GHC data types that we can expose and back-ends can work with but this is rather a lot of work. It seems like a correct thing to do but I don't think the amount of effort justifies it, at least for me. We just don't have the manpower for this: we're *very* understaffed for such a core project. If you know people who would like to work towards such goal though, I'd love to hear about it. > This would be more generally useful as > a haddock feature than trying to have it emulate other compilers as > any compiler or tool can output this general metainfo format. > > John > -- Mateusz K. From kyagrd at gmail.com Mon Jun 16 04:33:21 2014 From: kyagrd at gmail.com (Ki Yung Ahn) Date: Sun, 15 Jun 2014 21:33:21 -0700 Subject: [Haskell-cafe] BNFC-meta being maintained? Is there public src repo? Message-ID: <539E7391.6040300@gmail.com> Dear BNFC-meta developers and users, I've been using BNFC-meta for the parser of my experimental language Nax language implementation ( https://github.com/kyagrd/mininax ). It's very cool 'cause you don't need to write makefile or cabal entries to call the command line tools (bnfc, alex, happy), and you get quasiquoters for free, which really makes the early development pleasant. But due to the bug fixed in recent versions of BNFC, probably after latest BNFC-meta release, I'll have to switch back to using plain BNFC at some point. (FYI,the bug is that block comments arn't working). If there is a source repository that has ported more recent versions of BNFC into BNFC-meta, it'll be helpful for people like me. Or, if the source repository has open access and easy to participate (e.g., putting on github or something like that), we can draw community support maintaining BNFC-meta to keep up with the recent BNFC (and also happy and alex) versions. -- Ki Yung Ahn From musicdenotation at gmail.com Mon Jun 16 05:10:41 2014 From: musicdenotation at gmail.com (musicdenotation at gmail.com) Date: Mon, 16 Jun 2014 12:10:41 +0700 Subject: [Haskell-cafe] improved jhc manual In-Reply-To: References: Message-ID: <7C77AAFA-D81D-43C7-BC2C-61A1F60F602F@gmail.com> The implementation of unboxed types and defined kinds in JHC appears to be incompatible with GHC (`Int_` instead of `Int#`, `data kind` instead of just `data` and promote every suitable type). Please fix this. From john at repetae.net Mon Jun 16 06:14:14 2014 From: john at repetae.net (John Meacham) Date: Sun, 15 Jun 2014 23:14:14 -0700 Subject: [Haskell-cafe] improved jhc manual In-Reply-To: <7C77AAFA-D81D-43C7-BC2C-61A1F60F602F@gmail.com> References: <7C77AAFA-D81D-43C7-BC2C-61A1F60F602F@gmail.com> Message-ID: On Sun, Jun 15, 2014 at 10:10 PM, wrote: > The implementation of unboxed types and defined kinds in JHC appears to be incompatible with GHC (`Int_` instead of `Int#`, `data kind` instead of just `data` and promote every suitable type). Please fix this. They are different because they are somewhat different things. GHC and jhc have very different intermediate and back end languages, ghc's is based on system F with a backend distantly descended from the G machine and jhc has an intermediate language based on a PTS similar to the lambda-cube* and a backend descended from boquit's GRIN intermediate language and these decisions constrain the semantics of unboxed values for both compilers. Likewise, the type systems are different in some ways, for instance jhc supports polymorphism of unboxed types so there is no need for 1# and 1## being different types. It has a different kind hierarchy because in the back end 'evaluation' and 'case matching' are independent operations which in ghc they are intertwined, so you can directly branch on a value if you know it is already evaluated which is a particularly advantagous. jhc unboxed constructors are normal so no special Hash syntax is needed to denote them. Since jhc has no run-time it's unboxed values need to be at a lower level than GHC's to take advantage of optimizations based on that. For instance, ghc has independent types for unboxed Int's and Word's, however, as far as a CPU is concerned there are only values of a certain bit width and no signendedness information is on the type. Jhc follows CPU operations. It just happens that the instance Num Word in jhc uses unsigned primitives and the instance Num Int uses signed ones but they both are boxed 'Bits32_' underneath. The kind extensions were independently developed hence the different syntax, I am not a fan of eating syntax or filling the data tables with most likely unused kinds automatically... but I may change my mind on that in the future, User defined kinds are still fairly new so I want to see more how they are used in practice for a while, In any case, PolyKinds are next up in the kind system for implementation. *My IL is very similar to and was inspired by Henk actually (http://www.staff.science.uu.nl/~jeuri101/MSc/jwroorda/) -- John Meacham - http://notanumber.net/ From ariep at xs4all.nl Mon Jun 16 08:44:30 2014 From: ariep at xs4all.nl (Arie Peterson) Date: Mon, 16 Jun 2014 10:44:30 +0200 Subject: [Haskell-cafe] Uploading to hackage fails: bad file names in tarball Message-ID: <1853638.yjM1Shc7FX@u017021> Since some time, I have been unable to upload packages to Hackage, via either the 'cabal upload' command, or using the web form. The error message it gives is this: ==== ? ==== Hackage username: AriePeterson Hackage password: Uploading dist/np-linear-0.1.1.1.tar.gz... Error: dist/np-linear-0.1.1.1.tar.gz: 400 Bad Request Error: Invalid package Invalid windows file name in tar archive: "np-linear-0.1.1.1\\src\\Aux.hs". For portability, hackage requires that file names be valid on both Unix and Windows systems, and not refer outside of the tarball. ==== ? ==== The tarball is created by 'cabal sdist': cabal-install version 1.18.0.2 using version 1.18.1.1 of the Cabal library. I also installed the newest cabal-install, on another machine, but this did not help (same error). I also tried to create a tarball by hand, using 'tar --format=ustar', but this again resulted in the same error message. By the way, I'm on linux, not Windows, so it is not clear how the backslashes get in the file names. What could be going on? From kyagrd at gmail.com Mon Jun 16 08:47:40 2014 From: kyagrd at gmail.com (Ki Yung Ahn) Date: Mon, 16 Jun 2014 01:47:40 -0700 Subject: [Haskell-cafe] What are the problems with instances for polymorphic types? In-Reply-To: References: Message-ID: The only value that inhabits (forall a. [a]), except bottom, is the empty list []. You can actually experiment this with ghci. shell-prompt$ ghci -XRankNTypes GHCi, version 7.6.3: http://www.haskell.org/ghc/ :? for help Loading package ghc-prim ... linking ... done. Loading package integer-gmp ... linking ... done. Prelude> [] :: (forall a. [a]) [] Prelude> [True] :: (forall a. [a]) :7:2: Couldn't match expected type `a1' with actual type `Bool' `a1' is a rigid type variable bound by an expression type signature: [a1] at :7:1 In the expression: True In the expression: [True] :: forall a. [a] In an equation for `it': it = [True] :: forall a. [a] Prelude> ['a'] :: (forall a. [a]) :8:2: Couldn't match expected type `a1' with actual type `Char' `a1' is a rigid type variable bound by an expression type signature: [a1] at :8:1 In the expression: 'a' In the expression: ['a'] :: forall a. [a] In an equation for `it': it = ['a'] :: forall a. [a] Prelude> [\x -> x] :: (forall a. [a]) :9:2: Couldn't match expected type `a1' with actual type `t0 -> t0' `a1' is a rigid type variable bound by an expression type signature: [a1] at :9:1 The lambda expression `\ x -> x' has one argument, but its type `a1' has none In the expression: \ x -> x In the expression: [\ x -> x] :: forall a. [a] 2014? 06? 15? 12:47, G?bor Lehel ? ?: > In other words instances for forall-types, such as: > > instance Foo (forall a. [a]) where ... > > It feels obvious to me that there *would* be problems with this, but I'm > curious about what, exactly, they are. > > Could someone familiar with the matter either elaborate on them, or > refer me to an existing explanation, a previous discussion, or something > of the sort? > > I *don't* have any kind of use case in mind, I'm merely seeking a better > understanding of the type-system issues involved. > > (I attempted Google, but didn't have much success.) > > Thanks in advance. From hesselink at gmail.com Mon Jun 16 08:56:02 2014 From: hesselink at gmail.com (Erik Hesselink) Date: Mon, 16 Jun 2014 10:56:02 +0200 Subject: [Haskell-cafe] Uploading to hackage fails: bad file names in tarball In-Reply-To: <1853638.yjM1Shc7FX@u017021> References: <1853638.yjM1Shc7FX@u017021> Message-ID: I'm guessing this is because windows forbids you to name files 'aux.*' [1]. Erik [1] http://en.wikipedia.org/wiki/Filename On Mon, Jun 16, 2014 at 10:44 AM, Arie Peterson wrote: > Since some time, I have been unable to upload packages to Hackage, via either > the 'cabal upload' command, or using the web form. > > The error message it gives is this: > > ==== ? ==== > Hackage username: AriePeterson > Hackage password: > Uploading dist/np-linear-0.1.1.1.tar.gz... > Error: dist/np-linear-0.1.1.1.tar.gz: 400 Bad Request > Error: Invalid package > > Invalid windows file name in tar archive: "np-linear-0.1.1.1\\src\\Aux.hs". > For portability, hackage requires that file names be valid on both Unix and > Windows systems, and not refer outside of the tarball. > ==== ? ==== > > The tarball is created by 'cabal sdist': > cabal-install version 1.18.0.2 > using version 1.18.1.1 of the Cabal library. > > I also installed the newest cabal-install, on another machine, but this did > not help (same error). > > I also tried to create a tarball by hand, using 'tar --format=ustar', but this > again resulted in the same error message. > > By the way, I'm on linux, not Windows, so it is not clear how the backslashes > get in the file names. > > > What could be going on? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From ivanperezdominguez at gmail.com Mon Jun 16 08:58:48 2014 From: ivanperezdominguez at gmail.com (Ivan Perez) Date: Mon, 16 Jun 2014 10:58:48 +0200 Subject: [Haskell-cafe] Uploading to hackage fails: bad file names in tarball In-Reply-To: <1853638.yjM1Shc7FX@u017021> References: <1853638.yjM1Shc7FX@u017021> Message-ID: Hi, Aux is a bad file name on windows systems. It is reserved for OS stuff. If you create a file called Aux.txt, it will be damn hard to find it again. Anything that begins with Aux. should be avoided. In order to allow you package to be installed on other platforms, hackage checks that it does not include any Aux. file. Just name the file Auxiliary.hs Ivan On 16 June 2014 10:44, Arie Peterson wrote: > Since some time, I have been unable to upload packages to Hackage, via > either > the 'cabal upload' command, or using the web form. > > The error message it gives is this: > > ==== ? ==== > Hackage username: AriePeterson > Hackage password: > Uploading dist/np-linear-0.1.1.1.tar.gz... > Error: dist/np-linear-0.1.1.1.tar.gz: 400 Bad Request > Error: Invalid package > > Invalid windows file name in tar archive: "np-linear-0.1.1.1\\src\\Aux.hs". > For portability, hackage requires that file names be valid on both Unix and > Windows systems, and not refer outside of the tarball. > ==== ? ==== > > The tarball is created by 'cabal sdist': > cabal-install version 1.18.0.2 > using version 1.18.1.1 of the Cabal library. > > I also installed the newest cabal-install, on another machine, but this did > not help (same error). > > I also tried to create a tarball by hand, using 'tar --format=ustar', but > this > again resulted in the same error message. > > By the way, I'm on linux, not Windows, so it is not clear how the > backslashes > get in the file names. > > > What could be going on? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ariep at xs4all.nl Mon Jun 16 09:31:29 2014 From: ariep at xs4all.nl (Arie Peterson) Date: Mon, 16 Jun 2014 11:31:29 +0200 Subject: [Haskell-cafe] Uploading to hackage fails: bad file names in tarball In-Reply-To: References: <1853638.yjM1Shc7FX@u017021> Message-ID: <3950426.zV24Blnkq4@u017021> Thanks Eric and Ivan! Changing the name of the Aux module indeed fixed the problem. Maybe the error message could be a bit more specific. I guess I'm the first nor the last to name a module Aux... Regards, Arie From metaniklas at gmail.com Mon Jun 16 09:45:05 2014 From: metaniklas at gmail.com (Niklas Larsson) Date: Mon, 16 Jun 2014 11:45:05 +0200 Subject: [Haskell-cafe] Uploading to hackage fails: bad file names in tarball Message-ID: <539ebcaa.a883700a.7505.7705@mx.google.com> Hi! For extremely ancient and cludgy reasons AUX isn't a valid filename on windows, it's a DOS device. The other similarly reserved name are CON, PRN and NUL. Niklas ----- Ursprungligt meddelande ----- Fr?n: "Arie Peterson" Skickat: ?2014-?06-?16 10:45 Till: "haskell-cafe at haskell.org" ?mne: [Haskell-cafe] Uploading to hackage fails: bad file names in tarball Since some time, I have been unable to upload packages to Hackage, via either the 'cabal upload' command, or using the web form. The error message it gives is this: ==== ? ==== Hackage username: AriePeterson Hackage password: Uploading dist/np-linear-0.1.1.1.tar.gz... Error: dist/np-linear-0.1.1.1.tar.gz: 400 Bad Request Error: Invalid package Invalid windows file name in tar archive: "np-linear-0.1.1.1\\src\\Aux.hs". For portability, hackage requires that file names be valid on both Unix and Windows systems, and not refer outside of the tarball. ==== ? ==== The tarball is created by 'cabal sdist': cabal-install version 1.18.0.2 using version 1.18.1.1 of the Cabal library. I also installed the newest cabal-install, on another machine, but this did not help (same error). I also tried to create a tarball by hand, using 'tar --format=ustar', but this again resulted in the same error message. By the way, I'm on linux, not Windows, so it is not clear how the backslashes get in the file names. What could be going on? _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe at haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From haskell at nand.wakku.to Mon Jun 16 10:14:38 2014 From: haskell at nand.wakku.to (Niklas Haas) Date: Mon, 16 Jun 2014 12:14:38 +0200 Subject: [Haskell-cafe] What are the problems with instances for polymorphic types? In-Reply-To: References: Message-ID: <20140616121438.GB4704@nanodesu.localdomain> On Sun, 15 Jun 2014 21:47:52 +0200, G?bor Lehel wrote: > In other words instances for forall-types, such as: > > instance Foo (forall a. [a]) where ... > > It feels obvious to me that there *would* be problems with this, but I'm > curious about what, exactly, they are. > > Could someone familiar with the matter either elaborate on them, or refer > me to an existing explanation, a previous discussion, or something of the > sort? > > I *don't* have any kind of use case in mind, I'm merely seeking a better > understanding of the type-system issues involved. > > (I attempted Google, but didn't have much success.) > > Thanks in advance. It seems to me that it may be possible to get more information about this by searching for issues related to ImpredicativeTypes, which seem to be similar. (In fact, one could simulate instances like these by implementing type classes using ImplicitParams + ImpredicativeTypes + explicit instance records) From magnus at therning.org Mon Jun 16 11:08:26 2014 From: magnus at therning.org (Magnus Therning) Date: Mon, 16 Jun 2014 13:08:26 +0200 Subject: [Haskell-cafe] Uploading to hackage fails: bad file names in tarball In-Reply-To: <539ebcaa.a883700a.7505.7705@mx.google.com> References: <539ebcaa.a883700a.7505.7705@mx.google.com> Message-ID: <20140616110826.GB18678@mtcomp.evidente.local> On Mon, Jun 16, 2014 at 11:45:05AM +0200, Niklas Larsson wrote: > Hi! > > For extremely ancient and cludgy reasons AUX isn't a valid filename > on windows, it's a DOS device. The other similarly reserved name are > CON, PRN and NUL. Shouldn't COMn be added to that list too? :) /M -- Magnus Therning OpenPGP: 0xAB4DFBA4 email: magnus at therning.org jabber: magnus at therning.org twitter: magthe http://therning.org/magnus In a hierarchy, every employee tends to rise to his level of incompetence. -- The Peter Principle -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: not available URL: From raabe at froglogic.com Mon Jun 16 11:15:20 2014 From: raabe at froglogic.com (Frerich Raabe) Date: Mon, 16 Jun 2014 13:15:20 +0200 Subject: [Haskell-cafe] Uploading to hackage fails: bad file names in tarball In-Reply-To: <539ebcaa.a883700a.7505.7705@mx.google.com> References: <539ebcaa.a883700a.7505.7705@mx.google.com> Message-ID: Hi, There are a couple more special files, most (all?) of which are documented at http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#naming_conventions That page also says "Also avoid these names followed immediately by an extension; for example, NUL.txt is not recommended." and I suspect that it may be this recommendation based on which the error is raised. "NUL.txt" as well as "Aux.hs" are valid file names though. There is no file named 'AUX' though, and "Aux.hs" is a valid filename. On 2014-06-16 11:45, Niklas Larsson wrote: > Hi! > > For extremely ancient and cludgy reasons AUX isn't a valid filename on > windows, it's a DOS device. The other similarly reserved name are CON, > PRN and NUL. > > Niklas > > ----- Ursprungligt meddelande ----- > Fr?n: "Arie Peterson" > Skickat: ?2014-?06-?16 10:45 > Till: "haskell-cafe at haskell.org" > ?mne: [Haskell-cafe] Uploading to hackage fails: bad file names in tarball > > Since some time, I have been unable to upload packages to Hackage, via > either > the 'cabal upload' command, or using the web form. > > The error message it gives is this: > > ==== ? ==== > Hackage username: AriePeterson > Hackage password: > Uploading dist/np-linear-0.1.1.1.tar.gz... > Error: dist/np-linear-0.1.1.1.tar.gz: 400 Bad Request > Error: Invalid package > > Invalid windows file name in tar archive: > "np-linear-0.1.1.1\\src\\Aux.hs". > For portability, hackage requires that file names be valid on both Unix > and > Windows systems, and not refer outside of the tarball. > ==== ? ==== > > The tarball is created by 'cabal sdist': > cabal-install version 1.18.0.2 > using version 1.18.1.1 of the Cabal library. > > I also installed the newest cabal-install, on another machine, but this > did > not help (same error). > > I also tried to create a tarball by hand, using 'tar --format=ustar', but > this > again resulted in the same error message. > > By the way, I'm on linux, not Windows, so it is not clear how the > backslashes > get in the file names. > > > What could be going on? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Frerich Raabe - raabe at froglogic.com www.froglogic.com - Multi-Platform GUI Testing From german.zhivotnikov at gmail.com Mon Jun 16 11:17:04 2014 From: german.zhivotnikov at gmail.com (German Zhivotnikov) Date: Mon, 16 Jun 2014 14:17:04 +0300 Subject: [Haskell-cafe] Fwd: Problem with loading unix-compat in GHCi on Windows: is suggested solution acceptable? In-Reply-To: References: Message-ID: Hi all, There is a minor problem with unix-compat module on Windows: when one tries to load it (or the module that depends on it) into GHCi, i.e. in REPL mode, - GHCi refuses to load unix-compat with a message like that: ghc.exe: (skipped).cabal-sandbox\x86_64-windows-ghc-7.8.2\unix-compat-0.4.1.1\HSunix-compat-0.4.1.1.o: unknown symbol 'snprintf' ghc.exe: unable to load package 'unix-compat-0.4.1.1' Note that it only concerns REPL mode: when GHC is building a binary that uses unix-compat, - it produces correct executable that works fine. My hypothese is that this is because in typical Win32 build environment snprintf resides in libmingwex.a, which is static library, which GHCi is incapable of loading. Please correct me if I'm wrong. There is a solution - to make unix-compat depend on MSVCRT.DLL (instead of static mingwex.a) and replace 'snprintf' with Microsoft's '_snprintf' (and there's also stat/_stat to be replaced). However this introduces at least new dependency on MSVCRT.DLL, and maybe something else, which might be unexpected. Therefore, before accepting the solution into official codebase, it would be great to have an input - if anyone can foresee possible unintended side effects from suggested solution for code that depends on unix-compat module. Corresponding pull request resides at https://github.com/jystic/unix-compat/pull/12/files - could you possibly take a look if you've got something to say on that issue. Thank you in advance. -------------- next part -------------- An HTML attachment was scrubbed... URL: From metaniklas at gmail.com Mon Jun 16 12:25:35 2014 From: metaniklas at gmail.com (Niklas Larsson) Date: Mon, 16 Jun 2014 14:25:35 +0200 Subject: [Haskell-cafe] Uploading to hackage fails: bad file names intarball Message-ID: <539ee24a.2a7e700a.7779.7fb2@mx.google.com> The extension wasn't really part of the filename in those days. So aux.c and aux.hs is interpreted as aux. The funny thing is that Microsoft soon recognized how bad it was and added a flag to make it unix-like (\dev\nul etc) and free the names in dos 2.0, but the default stayed as it was. Niklas ----- Ursprungligt meddelande ----- Fr?n: "Frerich Raabe" Skickat: ?2014-?06-?16 13:15 Till: "haskell-cafe at haskell.org" ?mne: Re: [Haskell-cafe] Uploading to hackage fails: bad file names intarball Hi, There are a couple more special files, most (all?) of which are documented at http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247(v=vs.85).aspx#naming_conventions That page also says "Also avoid these names followed immediately by an extension; for example, NUL.txt is not recommended." and I suspect that it may be this recommendation based on which the error is raised. "NUL.txt" as well as "Aux.hs" are valid file names though. There is no file named 'AUX' though, and "Aux.hs" is a valid filename. On 2014-06-16 11:45, Niklas Larsson wrote: > Hi! > > For extremely ancient and cludgy reasons AUX isn't a valid filename on > windows, it's a DOS device. The other similarly reserved name are CON, > PRN and NUL. > > Niklas > > ----- Ursprungligt meddelande ----- > Fr?n: "Arie Peterson" > Skickat: ?2014-?06-?16 10:45 > Till: "haskell-cafe at haskell.org" > ?mne: [Haskell-cafe] Uploading to hackage fails: bad file names in tarball > > Since some time, I have been unable to upload packages to Hackage, via > either > the 'cabal upload' command, or using the web form. > > The error message it gives is this: > > ==== ? ==== > Hackage username: AriePeterson > Hackage password: > Uploading dist/np-linear-0.1.1.1.tar.gz... > Error: dist/np-linear-0.1.1.1.tar.gz: 400 Bad Request > Error: Invalid package > > Invalid windows file name in tar archive: > "np-linear-0.1.1.1\\src\\Aux.hs". > For portability, hackage requires that file names be valid on both Unix > and > Windows systems, and not refer outside of the tarball. > ==== ? ==== > > The tarball is created by 'cabal sdist': > cabal-install version 1.18.0.2 > using version 1.18.1.1 of the Cabal library. > > I also installed the newest cabal-install, on another machine, but this > did > not help (same error). > > I also tried to create a tarball by hand, using 'tar --format=ustar', but > this > again resulted in the same error message. > > By the way, I'm on linux, not Windows, so it is not clear how the > backslashes > get in the file names. > > > What could be going on? > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Frerich Raabe - raabe at froglogic.com www.froglogic.com - Multi-Platform GUI Testing _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe at haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From allbery.b at gmail.com Mon Jun 16 13:29:15 2014 From: allbery.b at gmail.com (Brandon Allbery) Date: Mon, 16 Jun 2014 09:29:15 -0400 Subject: [Haskell-cafe] Uploading to hackage fails: bad file names in tarball In-Reply-To: References: <539ebcaa.a883700a.7505.7705@mx.google.com> Message-ID: On Mon, Jun 16, 2014 at 7:15 AM, Frerich Raabe wrote: > There is no file named 'AUX' though, and "Aux.hs" is a valid filename. You do know that Windows filenames are not case sensitive? -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From raabe at froglogic.com Mon Jun 16 13:54:25 2014 From: raabe at froglogic.com (Frerich Raabe) Date: Mon, 16 Jun 2014 15:54:25 +0200 Subject: [Haskell-cafe] Uploading to hackage fails: bad file names in tarball In-Reply-To: References: <539ebcaa.a883700a.7505.7705@mx.google.com> Message-ID: <9734d4d80e1ab95c9e1ec27610735dad@roundcube.froglogic.com> On 2014-06-16 15:29, Brandon Allbery wrote: > On Mon, Jun 16, 2014 at 7:15 AM, Frerich Raabe > wrote: > >> There is no file named 'AUX' though, and "Aux.hs" is a valid filename. > > You do know that Windows filenames are not case sensitive? Sure, but I thought the extension distinguishes the file name. Note that "Aux.hs" is what's given in the original error message. However, according to Niklas Larsson, "The extension wasn't really part of the filename in those days." so I guess I stand corrected. -- Frerich Raabe - raabe at froglogic.com www.froglogic.com - Multi-Platform GUI Testing From dominic.p.mulligan at googlemail.com Mon Jun 16 13:54:58 2014 From: dominic.p.mulligan at googlemail.com (Dominic Mulligan) Date: Mon, 16 Jun 2014 14:54:58 +0100 Subject: [Haskell-cafe] What is GHC 7.8.2 doing here (typed holes, data+poly kinds, type families etc.) Message-ID: Hi, I've come across some behaviour in GHC 7.8.2 which seems strange, and may be a bug, but I wish to check before reporting it. Consider the minimum example pasted at the bottom of this message. At the line plusComm (SS m') n' = _ GHC tells me that I have a single hole in the file with type 'S (m1 :+: n) :~: (n :+: 'S m1) which is straightforward to provide, by rewriting with the inductive hypothesis (a recursive call of plusComm) and then some fiddling. However, replacing this line with the refinement plusComm (SS m') n' = substR (plusComm m' n') _ GHC tells me that the remaining hole now has type 'S (m1 :+: n) :~: (m1 :+: n) which seems completely incorrect to me. Shouldn't this hole have type 'S (n :+: m1) :~: (n :+: S m1) ? Can anybody give any clues as to what is happening? Thanks, Dominic {-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} module MinimumExample where data (:~:) (a :: k) (b :: k) where Refl :: a :~: a substR :: a :~: b -> f a -> f b substR Refl x = x substL :: a :~: b -> f b -> f a substL Refl x = x cong :: a :~: b -> f a :~: f b cong Refl = Refl data Nat where Z :: Nat S :: Nat -> Nat data NatS (m :: Nat) where ZS :: NatS Z SS :: NatS m -> NatS (S m) type family (:+:) (m :: Nat) (n :: Nat) :: Nat where Z :+: n = n (S m) :+: n = S (m :+: n) plusZRightNeutral :: NatS m -> (m :+: Z) :~: m plusZRightNeutral ZS = Refl plusZRightNeutral (SS m') = cong (plusZRightNeutral m') plusComm :: NatS m -> NatS n -> (m :+: n) :~: (n :+: m) plusComm ZS n' = substL (plusZRightNeutral n') Refl -- everything seems correct here plusComm (SS m') n = _ -- but things look completely incorrect, here -- plusComm (SS m') n' = substR (plusComm m' n') _ -------------- next part -------------- An HTML attachment was scrubbed... URL: From hesselink at gmail.com Mon Jun 16 14:26:19 2014 From: hesselink at gmail.com (Erik Hesselink) Date: Mon, 16 Jun 2014 16:26:19 +0200 Subject: [Haskell-cafe] What is GHC 7.8.2 doing here (typed holes, data+poly kinds, type families etc.) In-Reply-To: References: Message-ID: This seems right. The first argument you give to `substR` has type (m' + n) ~ (n + m'), so the rest is (f (m' + n) -> f (n + m')). The result type you have to provide is (S (m' + n) ~ n + S m'), so `f` is (S (m' + n) ~), which means your last argument should have type S (m' + n) ~ m' + n, which is what ghci gives as the type of the hole. Erik On Mon, Jun 16, 2014 at 3:54 PM, Dominic Mulligan wrote: > Hi, > > I've come across some behaviour in GHC 7.8.2 which seems strange, and may be > a bug, but I wish to check before reporting it. Consider the minimum > example pasted at the bottom of this message. At the line > > plusComm (SS m') n' = _ > > GHC tells me that I have a single hole in the file with type > > 'S (m1 :+: n) :~: (n :+: 'S m1) > > which is straightforward to provide, by rewriting with the inductive > hypothesis (a recursive call of plusComm) and then some fiddling. However, > replacing this line with the refinement > > plusComm (SS m') n' = substR (plusComm m' n') _ > > GHC tells me that the remaining hole now has type > > 'S (m1 :+: n) :~: (m1 :+: n) > > which seems completely incorrect to me. Shouldn't this hole have type > > 'S (n :+: m1) :~: (n :+: S m1) > > ? Can anybody give any clues as to what is happening? > > Thanks, > Dominic > > > > > > > {-# LANGUAGE DataKinds #-} > {-# LANGUAGE GADTs #-} > {-# LANGUAGE KindSignatures #-} > {-# LANGUAGE PolyKinds #-} > {-# LANGUAGE TypeFamilies #-} > {-# LANGUAGE TypeOperators #-} > > module MinimumExample where > > data (:~:) (a :: k) (b :: k) where > Refl :: a :~: a > > substR :: a :~: b -> f a -> f b > substR Refl x = x > > substL :: a :~: b -> f b -> f a > substL Refl x = x > > cong :: a :~: b -> f a :~: f b > cong Refl = Refl > > data Nat where > Z :: Nat > S :: Nat -> Nat > > data NatS (m :: Nat) where > ZS :: NatS Z > SS :: NatS m -> NatS (S m) > > type family (:+:) (m :: Nat) (n :: Nat) :: Nat where > Z :+: n = n > (S m) :+: n = S (m :+: n) > > plusZRightNeutral :: NatS m -> (m :+: Z) :~: m > plusZRightNeutral ZS = Refl > plusZRightNeutral (SS m') = cong (plusZRightNeutral m') > > plusComm :: NatS m -> NatS n -> (m :+: n) :~: (n :+: m) > plusComm ZS n' = substL (plusZRightNeutral n') Refl > -- everything seems correct here > plusComm (SS m') n = _ > -- but things look completely incorrect, here > -- plusComm (SS m') n' = substR (plusComm m' n') _ > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From dominic.p.mulligan at googlemail.com Mon Jun 16 14:32:52 2014 From: dominic.p.mulligan at googlemail.com (Dominic Mulligan) Date: Mon, 16 Jun 2014 15:32:52 +0100 Subject: [Haskell-cafe] What is GHC 7.8.2 doing here (typed holes, data+poly kinds, type families etc.) In-Reply-To: References: Message-ID: Hi Erik, Ahh, of course. Thanks for that! Dominic On 16 June 2014 15:26, Erik Hesselink wrote: > This seems right. The first argument you give to `substR` has type (m' > + n) ~ (n + m'), so the rest is (f (m' + n) -> f (n + m')). The result > type you have to provide is (S (m' + n) ~ n + S m'), so `f` is (S (m' > + n) ~), which means your last argument should have type S (m' + n) ~ > m' + n, which is what ghci gives as the type of the hole. > > Erik > > On Mon, Jun 16, 2014 at 3:54 PM, Dominic Mulligan > wrote: > > Hi, > > > > I've come across some behaviour in GHC 7.8.2 which seems strange, and > may be > > a bug, but I wish to check before reporting it. Consider the minimum > > example pasted at the bottom of this message. At the line > > > > plusComm (SS m') n' = _ > > > > GHC tells me that I have a single hole in the file with type > > > > 'S (m1 :+: n) :~: (n :+: 'S m1) > > > > which is straightforward to provide, by rewriting with the inductive > > hypothesis (a recursive call of plusComm) and then some fiddling. > However, > > replacing this line with the refinement > > > > plusComm (SS m') n' = substR (plusComm m' n') _ > > > > GHC tells me that the remaining hole now has type > > > > 'S (m1 :+: n) :~: (m1 :+: n) > > > > which seems completely incorrect to me. Shouldn't this hole have type > > > > 'S (n :+: m1) :~: (n :+: S m1) > > > > ? Can anybody give any clues as to what is happening? > > > > Thanks, > > Dominic > > > > > > > > > > > > > > {-# LANGUAGE DataKinds #-} > > {-# LANGUAGE GADTs #-} > > {-# LANGUAGE KindSignatures #-} > > {-# LANGUAGE PolyKinds #-} > > {-# LANGUAGE TypeFamilies #-} > > {-# LANGUAGE TypeOperators #-} > > > > module MinimumExample where > > > > data (:~:) (a :: k) (b :: k) where > > Refl :: a :~: a > > > > substR :: a :~: b -> f a -> f b > > substR Refl x = x > > > > substL :: a :~: b -> f b -> f a > > substL Refl x = x > > > > cong :: a :~: b -> f a :~: f b > > cong Refl = Refl > > > > data Nat where > > Z :: Nat > > S :: Nat -> Nat > > > > data NatS (m :: Nat) where > > ZS :: NatS Z > > SS :: NatS m -> NatS (S m) > > > > type family (:+:) (m :: Nat) (n :: Nat) :: Nat where > > Z :+: n = n > > (S m) :+: n = S (m :+: n) > > > > plusZRightNeutral :: NatS m -> (m :+: Z) :~: m > > plusZRightNeutral ZS = Refl > > plusZRightNeutral (SS m') = cong (plusZRightNeutral m') > > > > plusComm :: NatS m -> NatS n -> (m :+: n) :~: (n :+: m) > > plusComm ZS n' = substL (plusZRightNeutral n') Refl > > -- everything seems correct here > > plusComm (SS m') n = _ > > -- but things look completely incorrect, here > > -- plusComm (SS m') n' = substR (plusComm m' n') _ > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From allbery.b at gmail.com Mon Jun 16 14:49:28 2014 From: allbery.b at gmail.com (Brandon Allbery) Date: Mon, 16 Jun 2014 10:49:28 -0400 Subject: [Haskell-cafe] Uploading to hackage fails: bad file names in tarball In-Reply-To: <9734d4d80e1ab95c9e1ec27610735dad@roundcube.froglogic.com> References: <539ebcaa.a883700a.7505.7705@mx.google.com> <9734d4d80e1ab95c9e1ec27610735dad@roundcube.froglogic.com> Message-ID: On Mon, Jun 16, 2014 at 9:54 AM, Frerich Raabe wrote: > However, according to Niklas Larsson, "The extension wasn't really part of > the filename in those days." so I guess I stand corrected. Yes. It's a rather ugly bit of hackishness that Microsoft actually tried to clean up in MS-DOS 2 (with AVAILDEV), but that broke too many programs so we're stuck with it now. -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From nikoamia at gmail.com Mon Jun 16 15:19:48 2014 From: nikoamia at gmail.com (Nikolay Amiantov) Date: Mon, 16 Jun 2014 19:19:48 +0400 Subject: [Haskell-cafe] Warnings with OverloadedLists Message-ID: Hello, I've bumped into strange GHC behaviour with OverloadedLists and pattern matching. Consider this example: {-# LANGUAGE OverloadedLists #-} len :: [a] -> Int len [] = 0 len (_:t) = 1 + len t If I load this with "ghci -Wall", I get a warning: Test.hs:4:1: Warning: Pattern match(es) are non-exhaustive In an equation for ?len?: Patterns not matched: [] If I disable OverloadedLists extension, warning goes away. Can someone clear this behaviour out for me? It looks like a bug, but I'm not sure. Thanks for help, Nikolay. From martin.drautzburg at web.de Mon Jun 16 18:54:30 2014 From: martin.drautzburg at web.de (martin) Date: Mon, 16 Jun 2014 20:54:30 +0200 Subject: [Haskell-cafe] data/newtype vs. class Message-ID: <539F3D66.6050000@web.de> Hello all, I find myself trying to define a class, where a newtype would suffice. E.g. once I was pondering over "named" things and my initial thought was "well that's a class, which asks for a function 'getName'". But then here http://www.haskell.org/pipermail/haskell-cafe/2010-June/078803.html someone showed me a solution without any classes. Recently I was pondering over "timed things" (things which change at specific ponts in time) and again my initial thought was "that's a class, which asks for a method 'at'". Then I remembered things like State, i.e. data types which wrap around functions. State is not a class, which asks for a function 'nextState', it is all defined with data. Can someone give me some guidance, when to use classes and when to use data? Are the two concepts interchangeable in some scenarios? Martin From miguelimo38 at yandex.ru Mon Jun 16 19:28:54 2014 From: miguelimo38 at yandex.ru (Miguel Mitrofanov) Date: Mon, 16 Jun 2014 23:28:54 +0400 Subject: [Haskell-cafe] data/newtype vs. class In-Reply-To: <539F3D66.6050000@web.de> References: <539F3D66.6050000@web.de> Message-ID: <558261402946934@web29g.yandex.ru> Well, classes are datatypes. The only difference is that the compiler is able to derive the value of the class for you. Small example. Let's say we have a class > class AppendNumber a where > appendNumer :: a -> Integer -> a some instances > instance AppendNumber Integer where > appendNumber n d = n + d > instance AppendNumber String where > appendNumber s d = s ++ show d and some functions with it > increment :: AppendNumber a => a -> a > increment n = appendNumber n 1 that you can use with specific types > main = print $ increment 2048 Now, you can just as easy implement all that without classes: > data AppendNumber a = AppendNumber {appendNumber :: a -> Integer -> a} > appendNumberInteger :: AppendNumber Integer > appendNumberInteger = AppendNumber {appendNumber = \n d -> n + d} > appendNumberString :: AppendNumber String > appendNumberString = AppendNumber {appendNumber = \s d -> s ++ show d} > increment :: AppendNumber a -> a -> a > increment an n = appendNumber an n 1 > main = print $ increment appendNumberInteger 2048 The only two differences are that you have to 1) give names to the instances, and 2) manually insert the correct values in two last lines ('an' and 'appendNumberInteger' respectively). Classes simplify things, telling the compiler "I only care about one value of that type, and here it is; insert it whenever suitable". Now, I haven't seen your code, but it seems that you attempted to use something like > class Named a where > getName :: a -> String and then you were shown the better option, which is to just use String. Well, by the rules above, it translates to > data Named a = Named {getName :: a -> String} and in all your functions the value of type 'a' would be paired with, essentially, the function "a -> String". If that's the situation you find yourself in, it's only natural to unite both in one value like this: > data WithName = forall a. WithName a (a -> String) and use one value instead of two. But that calls for more refactoring; namely, the "WithName" data type above is isomorphic to "String", since you can't do anything else with it rather than apply it's second component to the first one. That's the reasoning behind removing classes in a nutshell. 16.06.2014, 22:58, "martin" : > Hello all, > > I find myself trying to define a class, where a newtype would suffice. > > E.g. once I was pondering over "named" things and my initial thought was "well that's a class, which asks for a function > 'getName'". But then here http://www.haskell.org/pipermail/haskell-cafe/2010-June/078803.html someone showed me a > solution without any classes. > > Recently I was pondering over "timed things" (things which change at specific ponts in time) and again my initial > thought was "that's a class, which asks for a method 'at'". > > Then I remembered things like State, i.e. data types which wrap around functions. State is not a class, which asks for a > function 'nextState', it is all defined with data. > > Can someone give me some guidance, when to use classes and when to use data? Are the two concepts interchangeable in > some scenarios? > > Martin > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From martin.drautzburg at web.de Mon Jun 16 21:03:06 2014 From: martin.drautzburg at web.de (martin) Date: Mon, 16 Jun 2014 23:03:06 +0200 Subject: [Haskell-cafe] data/newtype vs. class In-Reply-To: <558261402946934@web29g.yandex.ru> References: <539F3D66.6050000@web.de> <558261402946934@web29g.yandex.ru> Message-ID: <539F5B8A.60308@web.de> Am 06/16/2014 09:28 PM, schrieb Miguel Mitrofanov: > > Now, you can just as easy implement all that without classes: > >> data AppendNumber a = AppendNumber {appendNumber :: a -> Integer -> a} >> appendNumberInteger :: AppendNumber Integer >> appendNumberInteger = AppendNumber {appendNumber = \n d -> n + d} >> appendNumberString :: AppendNumber String >> appendNumberString = AppendNumber {appendNumber = \s d -> s ++ show d} >> increment :: AppendNumber a -> a -> a >> increment an n = appendNumber an n 1 >> main = print $ increment appendNumberInteger 2048 I just stumbled across some other things: When I use classes I can implement one function in terms of another function of the same class. When I use data/newtype I can't seem to do this. So I can replace a class by a data/newtype only when it wraps around a single function. Also I can use as many parameters as I like in data/newtype, but not in classes (if I stick to standard haskell) Is this correct? From miguelimo38 at yandex.ru Mon Jun 16 21:55:17 2014 From: miguelimo38 at yandex.ru (MigMit) Date: Tue, 17 Jun 2014 01:55:17 +0400 Subject: [Haskell-cafe] data/newtype vs. class In-Reply-To: <539F5B8A.60308@web.de> References: <539F3D66.6050000@web.de> <558261402946934@web29g.yandex.ru> <539F5B8A.60308@web.de> Message-ID: The bit about multiple parameters is, of course, correct. There is a MultiParamTypeClasses extension though. Also note that for some classes you'd need RankNTypes, like 'Monad' class: > class Monad m where > return :: a -> m a > ... is translated as > data Monad m = Monad {return :: forall a. a -> m a, ...} As for recursive definitions, well, that's the same issue I pointed before. Say you have a class > class Foo a where > bar :: a -> Bool > baz :: a -> Bool and you implement it as > instance Foo Integer where > bar n = n > 0 > baz n = not (bar n) Well, with datatypes you have > data Foo a = Foo {bar :: a -> Bool, baz :: a -> Bool} and of course this would never work: > fooInteger :: Foo Integer > fooInteger = Foo {bar = \n -> n > 0, baz = \n -> not (bar n)} However this one will: > fooInteger = Foo {bar = \n -> n > 0, baz = \n -> not (bar fooInteger n)} and it's the exact translation of the 'class' solution. ?????????? ? iPad > 17 ???? 2014 ?., ? 1:03, martin ???????(?): > > Am 06/16/2014 09:28 PM, schrieb Miguel Mitrofanov: > >> >> Now, you can just as easy implement all that without classes: >> >>> data AppendNumber a = AppendNumber {appendNumber :: a -> Integer -> a} >>> appendNumberInteger :: AppendNumber Integer >>> appendNumberInteger = AppendNumber {appendNumber = \n d -> n + d} >>> appendNumberString :: AppendNumber String >>> appendNumberString = AppendNumber {appendNumber = \s d -> s ++ show d} >>> increment :: AppendNumber a -> a -> a >>> increment an n = appendNumber an n 1 >>> main = print $ increment appendNumberInteger 2048 > > I just stumbled across some other things: > > When I use classes I can implement one function in terms of another function of the same class. When I use data/newtype > I can't seem to do this. So I can replace a class by a data/newtype only when it wraps around a single function. > > Also I can use as many parameters as I like in data/newtype, but not in classes (if I stick to standard haskell) > > Is this correct? > From tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Mon Jun 16 22:17:46 2014 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Mon, 16 Jun 2014 23:17:46 +0100 Subject: [Haskell-cafe] data/newtype vs. class In-Reply-To: <539F3D66.6050000@web.de> References: <539F3D66.6050000@web.de> Message-ID: <20140616221746.GA1461@henry> On Mon, Jun 16, 2014 at 08:54:30PM +0200, martin wrote: > Can someone give me some guidance, when to use classes and when to use > data? Are the two concepts interchangeable in some scenarios? The simplest way of answering this which is mostly correct is: use data From alexey.muranov at gmail.com Tue Jun 17 10:25:10 2014 From: alexey.muranov at gmail.com (Alexey Muranov) Date: Tue, 17 Jun 2014 03:25:10 -0700 (PDT) Subject: [Haskell-cafe] 1 = 0? Message-ID: <34cf024d-87bd-4c15-b6ff-6afa67f7c594@googlegroups.com> Is this the expected behavior that 1 = 0 does not raise any error? What does this mean? Thanks. Alexey. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jan.stolarek at p.lodz.pl Tue Jun 17 10:49:34 2014 From: jan.stolarek at p.lodz.pl (Jan Stolarek) Date: Tue, 17 Jun 2014 12:49:34 +0200 Subject: [Haskell-cafe] 1 = 0? In-Reply-To: <34cf024d-87bd-4c15-b6ff-6afa67f7c594@googlegroups.com> References: <34cf024d-87bd-4c15-b6ff-6afa67f7c594@googlegroups.com> Message-ID: <201406171249.35012.jan.stolarek@p.lodz.pl> Interesting. I just told GHC "let 5 = 3" and got no complaint. I'm curious to hear the rationale for this. Janek Dnia wtorek, 17 czerwca 2014, Alexey Muranov napisa?: > Is this the expected behavior that > > 1 = 0 > > does not raise any error? What does this mean? > > Thanks. > > Alexey. From roma at ro-che.info Tue Jun 17 10:51:19 2014 From: roma at ro-che.info (Roman Cheplyaka) Date: Tue, 17 Jun 2014 13:51:19 +0300 Subject: [Haskell-cafe] 1 = 0? In-Reply-To: <34cf024d-87bd-4c15-b6ff-6afa67f7c594@googlegroups.com> References: <34cf024d-87bd-4c15-b6ff-6afa67f7c594@googlegroups.com> Message-ID: <20140617105119.GA16999@sniper> * Alexey Muranov [2014-06-17 03:25:10-0700] > Is this the expected behavior that > > 1 = 0 > > does not raise any error? What does this mean? 1 is a valid (nullary) pattern, so yes. This pattern binding obviously fails. Prelude> let x at 1 = 0 Prelude> x *** Exception: :2:5-11: Irrefutable pattern failed for pattern x at 1 Roman From waldmann at imn.htwk-leipzig.de Tue Jun 17 10:53:45 2014 From: waldmann at imn.htwk-leipzig.de (J. Waldmann) Date: Tue, 17 Jun 2014 10:53:45 +0000 (UTC) Subject: [Haskell-cafe] 1 = 0? References: <34cf024d-87bd-4c15-b6ff-6afa67f7c594@googlegroups.com> <201406171249.35012.jan.stolarek@p.lodz.pl> Message-ID: > Interesting. I just told GHC "let 5 = 3" and got no complaint. lazy pattern matching semantics, see: ghci -XBangPatterns Prelude> let { 0 = 1 } in 0 0 Prelude> let { ! 0 = 1 } in 0 *** Exception: :3:7-13: Non-exhaustive patterns in pattern binding From tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Tue Jun 17 10:54:27 2014 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Tue, 17 Jun 2014 11:54:27 +0100 Subject: [Haskell-cafe] 1 = 0? In-Reply-To: <34cf024d-87bd-4c15-b6ff-6afa67f7c594@googlegroups.com> References: <34cf024d-87bd-4c15-b6ff-6afa67f7c594@googlegroups.com> Message-ID: <20140617105427.GJ1461@henry> On Tue, Jun 17, 2014 at 03:25:10AM -0700, Alexey Muranov wrote: > Is this the expected behavior that > > 1 = 0 > > does not raise any error? What does this mean? I guess it's an irrefutable pattern match that doesn't bind any variables, so you can never see it fair. Cf Prelude> let (x, 1) = (2,3) Prelude> x *** Exception: :7:5-18: Irrefutable pattern failed for pattern *** (x, 1) Prelude> let (x, 3) = (2,3) Prelude> x 2 I'll let someone more knowledgeable comment on why it's a good idea not to prevent this kind of thing. Tom From noteed at gmail.com Tue Jun 17 10:54:38 2014 From: noteed at gmail.com (Vo Minh Thu) Date: Tue, 17 Jun 2014 12:54:38 +0200 Subject: [Haskell-cafe] 1 = 0? In-Reply-To: <20140617105119.GA16999@sniper> References: <34cf024d-87bd-4c15-b6ff-6afa67f7c594@googlegroups.com> <20140617105119.GA16999@sniper> Message-ID: 2014-06-17 12:51 GMT+02:00 Roman Cheplyaka : > * Alexey Muranov [2014-06-17 03:25:10-0700] >> Is this the expected behavior that >> >> 1 = 0 >> >> does not raise any error? What does this mean? > > 1 is a valid (nullary) pattern, so yes. This pattern binding obviously fails. > > Prelude> let x at 1 = 0 > Prelude> x > *** Exception: :2:5-11: Irrefutable pattern failed for pattern x at 1 If it can make things clearer, you can do something similar with any constructor: > let Just x = Just 5 in x > let Just x = Nothing in x *** Exception: :19:5-20: Irrefutable pattern failed for pattern Data.Maybe.Just x From hesselink at gmail.com Tue Jun 17 11:05:12 2014 From: hesselink at gmail.com (Erik Hesselink) Date: Tue, 17 Jun 2014 13:05:12 +0200 Subject: [Haskell-cafe] 1 = 0? In-Reply-To: <20140617105119.GA16999@sniper> References: <34cf024d-87bd-4c15-b6ff-6afa67f7c594@googlegroups.com> <20140617105119.GA16999@sniper> Message-ID: On Tue, Jun 17, 2014 at 12:51 PM, Roman Cheplyaka wrote: > * Alexey Muranov [2014-06-17 03:25:10-0700] >> Is this the expected behavior that >> >> 1 = 0 >> >> does not raise any error? What does this mean? > > 1 is a valid (nullary) pattern, so yes. This pattern binding obviously fails. > > Prelude> let x at 1 = 0 > Prelude> x > *** Exception: :2:5-11: Irrefutable pattern failed for pattern x at 1 It doesn't even have to fail, since numeric literals are overloaded: instance Num () where fromInteger _ = () v :: () v = let x at 1 = 0 in x > v () Erik From byorgey at seas.upenn.edu Tue Jun 17 11:08:33 2014 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Tue, 17 Jun 2014 07:08:33 -0400 Subject: [Haskell-cafe] 1 = 0? In-Reply-To: <34cf024d-87bd-4c15-b6ff-6afa67f7c594@googlegroups.com> References: <34cf024d-87bd-4c15-b6ff-6afa67f7c594@googlegroups.com> Message-ID: <20140617110833.GA8838@seas.upenn.edu> On Tue, Jun 17, 2014 at 03:25:10AM -0700, Alexey Muranov wrote: > Is this the expected behavior that > > 1 = 0 > > does not raise any error? What does this mean? The general syntax of assignments is pattern = expression One most often uses a pattern consisting of a single variable, but any pattern will do. (For example, try writing [x,y,z] = [1,2,3] as a top-level declaration and see what happens!) 1 is a pattern which matches the number 1. 0 is obviously an expression. Of course, the pattern 1 does not match the expression 0. However, binding is lazy: for example, writing [x,y] = [1,2,3] does not in and of itself cause an error; it will only cause an error if you try to use x or y. However, since the pattern 1 contains no variables, there is no way to ever force the pattern-matching to actually take place. So 1 = 0 just sits there, sort of like an ugly, angry dog who wants to bite people except that it is locked in a cage with no door. Occasionally people walking by look at it pityingly, but mostly no one pays it any attention. -Brent From alexey.muranov at gmail.com Tue Jun 17 11:14:53 2014 From: alexey.muranov at gmail.com (Alexey Muranov) Date: Tue, 17 Jun 2014 04:14:53 -0700 (PDT) Subject: [Haskell-cafe] 1 = 0? In-Reply-To: <20140617110833.GA8838@seas.upenn.edu> References: <34cf024d-87bd-4c15-b6ff-6afa67f7c594@googlegroups.com> <20140617110833.GA8838@seas.upenn.edu> Message-ID: <1c5fd689-0aaa-4fb8-93d0-65507dbf98a3@googlegroups.com> On Tuesday, June 17, 2014 1:08:45 PM UTC+2, Brent Yorgey wrote: The general syntax of assignments is > > pattern = expression > > One most often uses a pattern consisting of a single variable, but any > pattern will do. (For example, try writing [x,y,z] = [1,2,3] as a > top-level declaration and see what happens!) 1 is a pattern which > matches the number 1. 0 is obviously an expression. Of course, the > pattern 1 does not match the expression 0. However, binding is lazy: > for example, writing [x,y] = [1,2,3] does not in and of itself cause > an error; it will only cause an error if you try to use x or y. > However, since the pattern 1 contains no variables, there is no way to > ever force the pattern-matching to actually take place. > > So 1 = 0 just sits there, sort of like an ugly, angry dog who wants to > bite people except that it is locked in a cage with no door. > Occasionally people walking by look at it pityingly, but mostly no one > pays it any attention. Thanks for the detailed explanation, i think i've understood. Alexey. -------------- next part -------------- An HTML attachment was scrubbed... URL: From r.wobben at home.nl Tue Jun 17 15:38:50 2014 From: r.wobben at home.nl (Roelof Wobben) Date: Tue, 17 Jun 2014 17:38:50 +0200 Subject: [Haskell-cafe] Fwd: testing platform In-Reply-To: <53A0609A.3040306@home.nl> References: <53A0609A.3040306@home.nl> Message-ID: <53A0610A.8050304@home.nl> Hello, IM learning Haskell by this book : Programming Haskell. Which test platform can I also learn the best or can I better first learn Haskell and later the test platforms ? Roelof From montezf at gmail.com Tue Jun 17 16:39:26 2014 From: montezf at gmail.com (Montez Fitzpatrick) Date: Tue, 17 Jun 2014 11:39:26 -0500 Subject: [Haskell-cafe] Package Maintenance: hfuse Message-ID: I would like to take over maintenance of the following package: "hfuse." I have attempted to e-mail the original package author and maintainer with no response. -------------- next part -------------- An HTML attachment was scrubbed... URL: From adam at well-typed.com Tue Jun 17 19:43:46 2014 From: adam at well-typed.com (Adam Gundry) Date: Tue, 17 Jun 2014 20:43:46 +0100 Subject: [Haskell-cafe] What are the problems with instances for polymorphic types? In-Reply-To: <20140616121438.GB4704@nanodesu.localdomain> References: <20140616121438.GB4704@nanodesu.localdomain> Message-ID: <53A09A72.3080608@well-typed.com> On 16/06/14 11:14, Niklas Haas wrote: > On Sun, 15 Jun 2014 21:47:52 +0200, G?bor Lehel wrote: >> In other words instances for forall-types, such as: >> >> instance Foo (forall a. [a]) where ... >> >> It feels obvious to me that there *would* be problems with this, but I'm >> curious about what, exactly, they are. >> >> Could someone familiar with the matter either elaborate on them, or refer >> me to an existing explanation, a previous discussion, or something of the >> sort? >> >> I *don't* have any kind of use case in mind, I'm merely seeking a better >> understanding of the type-system issues involved. >> >> (I attempted Google, but didn't have much success.) >> >> Thanks in advance. > > It seems to me that it may be possible to get more information about > this by searching for issues related to ImpredicativeTypes, which seem > to be similar. (In fact, one could simulate instances like these by > implementing type classes using ImplicitParams + ImpredicativeTypes + > explicit instance records) I don't think there has been much research on type inference for these kind of instances (though I'd be happy to be corrected). They are sort of like ImpredicativeTypes but worse, in that it is very hard to tell where the invisible type abstractions and applications go. For example, suppose we have these declarations: class Foo t where useFoo :: t -> Int instance Foo (forall a. [a]) where useFoo x = length (x :: [()]) f = useFoo [] The class and instance declarations make sense (the instance declaration ends up checking `useFoo` with a higher-rank type, but that's okay). But when inferring the type of `f`, we have useFoo :: forall t . Foo t => t -> Int and the typechecker needs to magically guess that t ~ forall a . [a] which is difficult. If there was some way of explicitly writing the type at which to instantiate `t`, for example f = useFoo @(forall a. [a]) [] then it might be possible to make progress. [1] All this would, however, make perfect sense in System FC, once type abstractions and applications have been made explicit, and typeclass constraints have been replaced with visible dictionaries. Hope this helps, Adam [1] https://ghc.haskell.org/trac/ghc/wiki/TypeApplication -- Adam Gundry, Haskell Consultant Well-Typed LLP, http://www.well-typed.com/ From tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Tue Jun 17 20:57:17 2014 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Tue, 17 Jun 2014 21:57:17 +0100 Subject: [Haskell-cafe] "Spinless Tagless G-Machine" erratum? Message-ID: <20140617205717.GI6633@henry> I am reading SPJ's seminal work "Implementing lazy functional languages on stock hardware: the Spinless Tagless G-machine" (1992) and I am confused by something which may be a minor notational error, or may be a key detail I am misunderstanding. The paper is available here http://citeseer.ist.psu.edu/viewdoc/summary?doi=10.1.1.53.3729 On page 26 we have aList = {} \n Cons {thing,nil} nil = {} \n Nil {} but I have not seen this use of the notation elsewhere in the paper. It strikes me that this should be aList = {} \n {} -> Cons {thing,nil} nil = {} \n {} -> Nil {} Is my intuition correct, or am I missing a key detail? Thanks, Tom From ozgurakgun at gmail.com Tue Jun 17 21:46:04 2014 From: ozgurakgun at gmail.com (Ozgur Akgun) Date: Wed, 18 Jun 2014 00:46:04 +0300 Subject: [Haskell-cafe] Warnings with OverloadedLists In-Reply-To: References: Message-ID: Hi Nikolay, On 16 June 2014 18:19, Nikolay Amiantov wrote: > If I disable OverloadedLists extension, warning goes away. Can someone > clear this behaviour out for me? It looks like a bug, but I'm not > sure. > I am not sure if this is a bug or not, but this page seems to explain the desugaring of patterns with OverloadedLists: https://ghc.haskell.org/trac/ghc/wiki/OverloadedLists As a workaround, you could try calling `toList` explicitly in a case statement to implement a `len` function for types with an IsList instance. Maybe something like the following. len :: IsList l => l -> Int len xs = case toList xs of [] -> ... Or even: len :: IsList l => l -> Int len = length . toList Hope this helps. -- Ozgur Akgun -------------- next part -------------- An HTML attachment was scrubbed... URL: From conal at conal.net Tue Jun 17 22:51:07 2014 From: conal at conal.net (Conal Elliott) Date: Tue, 17 Jun 2014 15:51:07 -0700 Subject: [Haskell-cafe] Hackage "500 Internal Server Error" Message-ID: Is hackage uploading broken? I'm trying to upload a new version of vector-space and am getting "500 Internal Server Error". -- Conal -------------- next part -------------- An HTML attachment was scrubbed... URL: From iricanaycan at gmail.com Tue Jun 17 23:08:57 2014 From: iricanaycan at gmail.com (Aycan iRiCAN) Date: Wed, 18 Jun 2014 02:08:57 +0300 Subject: [Haskell-cafe] Hackage "500 Internal Server Error" In-Reply-To: References: Message-ID: I remember Hackage upload doesn't support Safari. You may try Firefox (which works). On Wed, Jun 18, 2014 at 1:51 AM, Conal Elliott wrote: > Is hackage uploading broken? I'm trying to upload a new version of > vector-space and am getting "500 Internal Server Error". -- Conal > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- http://www.google.com/profiles/iricanaycan -------------- next part -------------- An HTML attachment was scrubbed... URL: From cma at bitemyapp.com Tue Jun 17 23:21:40 2014 From: cma at bitemyapp.com (Christopher Allen) Date: Tue, 17 Jun 2014 18:21:40 -0500 Subject: [Haskell-cafe] Hackage "500 Internal Server Error" In-Reply-To: References: Message-ID: You can upload from the terminal using `cabal upload` as well. On Tue, Jun 17, 2014 at 6:08 PM, Aycan iRiCAN wrote: > I remember Hackage upload doesn't support Safari. You may try Firefox > (which works). > > > On Wed, Jun 18, 2014 at 1:51 AM, Conal Elliott wrote: > >> Is hackage uploading broken? I'm trying to upload a new version of >> vector-space and am getting "500 Internal Server Error". -- Conal >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > > -- > http://www.google.com/profiles/iricanaycan > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From conal at conal.net Wed Jun 18 00:06:01 2014 From: conal at conal.net (Conal Elliott) Date: Tue, 17 Jun 2014 17:06:01 -0700 Subject: [Haskell-cafe] Hackage "500 Internal Server Error" In-Reply-To: References: Message-ID: Thanks for the suggestions. I'm getting this error with 'cabal upload' (my normal use) and with Firefox, Chrome, and Safari. Looks like it's been a few hours since any successful hackage uploads. Maybe uploads are broken. CC'ing admin at hackage.haskell.org. On Tue, Jun 17, 2014 at 4:21 PM, Christopher Allen wrote: > You can upload from the terminal using `cabal upload` as well. > > > On Tue, Jun 17, 2014 at 6:08 PM, Aycan iRiCAN > wrote: > >> I remember Hackage upload doesn't support Safari. You may try Firefox >> (which works). >> >> >> On Wed, Jun 18, 2014 at 1:51 AM, Conal Elliott wrote: >> >>> Is hackage uploading broken? I'm trying to upload a new version of >>> vector-space and am getting "500 Internal Server Error". -- Conal >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe at haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >>> >> >> >> -- >> http://www.google.com/profiles/iricanaycan >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From wangbj at gmail.com Wed Jun 18 00:50:18 2014 From: wangbj at gmail.com (Baojun Wang) Date: Tue, 17 Jun 2014 17:50:18 -0700 Subject: [Haskell-cafe] return with mutable object Message-ID: Hi List, Per my understanding, return x would make a new copy of the object. What if the returned object is mutable? Will this make a new (mutable) object? My concern is if I created a very large mutable object, does return mutable make a full copy of the original mutable data, or just copy a reference (pointer?)? Thanks baojun -------------- next part -------------- An HTML attachment was scrubbed... URL: From wangbj at gmail.com Wed Jun 18 00:53:24 2014 From: wangbj at gmail.com (Baojun Wang) Date: Tue, 17 Jun 2014 17:53:24 -0700 Subject: [Haskell-cafe] return with mutable object In-Reply-To: References: Message-ID: To make my question more clearer, will test1/test2 have noticeable performance difference? -- mutable1.hs import qualified Data.Vector.Mutable as MV import Control.Monad import Control.Monad.Primitive a1 :: (PrimMonad m) => MV.MVector (PrimState m) a -> m () a1 v = do -- do something return () a2 :: (PrimMonad m) => MV.MVector (PrimState m) a -> m () a2 v = do -- do something else return () b1 :: (PrimMonad m) => MV.MVector (PrimState m) a -> m (MV.MVector (PrimState m) a) b2 :: (PrimMonad m) => MV.MVector (PrimState m) a -> m (MV.MVector (PrimState m) a) b1 v = do -- do something different return v b2 v = do -- do something else different return v test1 :: IO () test1 = do v1 <- MV.replicate 1000 0 a1 v1 a2 v1 return () test2 :: IO () test2 = MV.replicate 1000 0 >>= b1 >>= b2 >> return () -- I'd prefer this way cause it's more haskell. On Tue, Jun 17, 2014 at 5:50 PM, Baojun Wang wrote: > Hi List, > > Per my understanding, return x would make a new copy of the object. What > if the returned object is mutable? Will this make a new (mutable) object? > > My concern is if I created a very large mutable object, does return > mutable make a full copy of the original mutable data, or just copy a > reference (pointer?)? > > Thanks > baojun > -------------- next part -------------- An HTML attachment was scrubbed... URL: From austin at well-typed.com Wed Jun 18 00:54:53 2014 From: austin at well-typed.com (Austin Seipp) Date: Tue, 17 Jun 2014 19:54:53 -0500 Subject: [Haskell-cafe] Hackage "500 Internal Server Error" In-Reply-To: References: Message-ID: This should hopefully now be fixed, and the Hackage server has been restarted. Do let me know if anything is wrong. On Tue, Jun 17, 2014 at 7:06 PM, Conal Elliott wrote: > Thanks for the suggestions. I'm getting this error with 'cabal upload' (my > normal use) and with Firefox, Chrome, and Safari. > > Looks like it's been a few hours since any successful hackage uploads. Maybe > uploads are broken. CC'ing admin at hackage.haskell.org. > > > > On Tue, Jun 17, 2014 at 4:21 PM, Christopher Allen > wrote: >> >> You can upload from the terminal using `cabal upload` as well. >> >> >> On Tue, Jun 17, 2014 at 6:08 PM, Aycan iRiCAN >> wrote: >>> >>> I remember Hackage upload doesn't support Safari. You may try Firefox >>> (which works). >>> >>> >>> On Wed, Jun 18, 2014 at 1:51 AM, Conal Elliott wrote: >>>> >>>> Is hackage uploading broken? I'm trying to upload a new version of >>>> vector-space and am getting "500 Internal Server Error". -- Conal >>>> >>>> _______________________________________________ >>>> Haskell-Cafe mailing list >>>> Haskell-Cafe at haskell.org >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>>> >>> >>> >>> >>> -- >>> http://www.google.com/profiles/iricanaycan >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe at haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >> > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Regards, Austin Seipp, Haskell Consultant Well-Typed LLP, http://www.well-typed.com/ From conal at conal.net Wed Jun 18 01:03:28 2014 From: conal at conal.net (Conal Elliott) Date: Tue, 17 Jun 2014 18:03:28 -0700 Subject: [Haskell-cafe] Hackage "500 Internal Server Error" In-Reply-To: References: Message-ID: Works now. Thanks! -- Conal On Tue, Jun 17, 2014 at 5:54 PM, Austin Seipp wrote: > This should hopefully now be fixed, and the Hackage server has been > restarted. > > Do let me know if anything is wrong. > > On Tue, Jun 17, 2014 at 7:06 PM, Conal Elliott wrote: > > Thanks for the suggestions. I'm getting this error with 'cabal upload' > (my > > normal use) and with Firefox, Chrome, and Safari. > > > > Looks like it's been a few hours since any successful hackage uploads. > Maybe > > uploads are broken. CC'ing admin at hackage.haskell.org. > > > > > > > > On Tue, Jun 17, 2014 at 4:21 PM, Christopher Allen > > wrote: > >> > >> You can upload from the terminal using `cabal upload` as well. > >> > >> > >> On Tue, Jun 17, 2014 at 6:08 PM, Aycan iRiCAN > >> wrote: > >>> > >>> I remember Hackage upload doesn't support Safari. You may try Firefox > >>> (which works). > >>> > >>> > >>> On Wed, Jun 18, 2014 at 1:51 AM, Conal Elliott > wrote: > >>>> > >>>> Is hackage uploading broken? I'm trying to upload a new version of > >>>> vector-space and am getting "500 Internal Server Error". -- Conal > >>>> > >>>> _______________________________________________ > >>>> Haskell-Cafe mailing list > >>>> Haskell-Cafe at haskell.org > >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe > >>>> > >>> > >>> > >>> > >>> -- > >>> http://www.google.com/profiles/iricanaycan > >>> > >>> _______________________________________________ > >>> Haskell-Cafe mailing list > >>> Haskell-Cafe at haskell.org > >>> http://www.haskell.org/mailman/listinfo/haskell-cafe > >>> > >> > > > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > -- > Regards, > > Austin Seipp, Haskell Consultant > Well-Typed LLP, http://www.well-typed.com/ > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob at redivi.com Wed Jun 18 01:15:45 2014 From: bob at redivi.com (Bob Ippolito) Date: Tue, 17 Jun 2014 20:15:45 -0500 Subject: [Haskell-cafe] return with mutable object In-Reply-To: References: Message-ID: Your understanding is not correct. The monad laws would be violated If return did make a new mutable object. http://www.haskell.org/haskellwiki/Monad_laws Side-effects typically have a `m ()` return type, so your "more Haskell" way is not idiomatic Haskell. On Tue, Jun 17, 2014 at 7:53 PM, Baojun Wang wrote: > To make my question more clearer, will test1/test2 have noticeable > performance difference? > > -- mutable1.hs > > import qualified Data.Vector.Mutable as MV > > import Control.Monad > > import Control.Monad.Primitive > > a1 :: (PrimMonad m) => MV.MVector (PrimState m) a -> m () > > a1 v = do > > -- do something > > return () > > a2 :: (PrimMonad m) => MV.MVector (PrimState m) a -> m () > > a2 v = do > > -- do something else > > return () > > b1 :: (PrimMonad m) => MV.MVector (PrimState m) a -> m (MV.MVector > (PrimState m) a) > > b2 :: (PrimMonad m) => MV.MVector (PrimState m) a -> m (MV.MVector > (PrimState m) a) > > b1 v = do > > -- do something different > > return v > > b2 v = do > > -- do something else different > > return v > > test1 :: IO () > > test1 = do > > v1 <- MV.replicate 1000 0 > > a1 v1 > > a2 v1 > > return () > > test2 :: IO () > > test2 = > > MV.replicate 1000 0 >>= b1 >>= b2 >> return () -- I'd prefer this way > cause it's more haskell. > > > > > On Tue, Jun 17, 2014 at 5:50 PM, Baojun Wang wrote: > >> Hi List, >> >> Per my understanding, return x would make a new copy of the object. What >> if the returned object is mutable? Will this make a new (mutable) object? >> >> My concern is if I created a very large mutable object, does return >> mutable make a full copy of the original mutable data, or just copy a >> reference (pointer?)? >> >> Thanks >> baojun >> > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From wangbj at gmail.com Wed Jun 18 05:28:43 2014 From: wangbj at gmail.com (Baojun Wang) Date: Tue, 17 Jun 2014 22:28:43 -0700 Subject: [Haskell-cafe] return with mutable object In-Reply-To: References: Message-ID: Thanks a lot for the correction, I guess the right identity law would be violated, right? I was think about the type constructor stuff, next time should definitely think about the laws first. On Tuesday, June 17, 2014, Bob Ippolito wrote: > Your understanding is not correct. The monad laws would be violated If > return did make a new mutable object. > http://www.haskell.org/haskellwiki/Monad_laws > > Side-effects typically have a `m ()` return type, so your "more Haskell" > way is not idiomatic Haskell. > > > > On Tue, Jun 17, 2014 at 7:53 PM, Baojun Wang > wrote: > >> To make my question more clearer, will test1/test2 have noticeable >> performance difference? >> >> -- mutable1.hs >> >> import qualified Data.Vector.Mutable as MV >> >> import Control.Monad >> >> import Control.Monad.Primitive >> >> a1 :: (PrimMonad m) => MV.MVector (PrimState m) a -> m () >> >> a1 v = do >> >> -- do something >> >> return () >> >> a2 :: (PrimMonad m) => MV.MVector (PrimState m) a -> m () >> >> a2 v = do >> >> -- do something else >> >> return () >> >> b1 :: (PrimMonad m) => MV.MVector (PrimState m) a -> m (MV.MVector >> (PrimState m) a) >> >> b2 :: (PrimMonad m) => MV.MVector (PrimState m) a -> m (MV.MVector >> (PrimState m) a) >> >> b1 v = do >> >> -- do something different >> >> return v >> >> b2 v = do >> >> -- do something else different >> >> return v >> >> test1 :: IO () >> >> test1 = do >> >> v1 <- MV.replicate 1000 0 >> >> a1 v1 >> >> a2 v1 >> >> return () >> >> test2 :: IO () >> >> test2 = >> >> MV.replicate 1000 0 >>= b1 >>= b2 >> return () -- I'd prefer this way >> cause it's more haskell. >> >> >> >> >> On Tue, Jun 17, 2014 at 5:50 PM, Baojun Wang > > wrote: >> >>> Hi List, >>> >>> Per my understanding, return x would make a new copy of the object. What >>> if the returned object is mutable? Will this make a new (mutable) object? >>> >>> My concern is if I created a very large mutable object, does return >>> mutable make a full copy of the original mutable data, or just copy a >>> reference (pointer?)? >>> >>> Thanks >>> baojun >>> >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg at gregorycollins.net Wed Jun 18 06:29:27 2014 From: greg at gregorycollins.net (Gregory Collins) Date: Wed, 18 Jun 2014 08:29:27 +0200 Subject: [Haskell-cafe] return with mutable object In-Reply-To: References: Message-ID: On Wed, Jun 18, 2014 at 2:53 AM, Baojun Wang wrote: > To make my question more clearer, will test1/test2 have noticeable > performance difference? No. The copy is by reference. -- Gregory Collins -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuuzetsu at fuuzetsu.co.uk Wed Jun 18 07:43:50 2014 From: fuuzetsu at fuuzetsu.co.uk (Mateusz Kowalczyk) Date: Wed, 18 Jun 2014 09:43:50 +0200 Subject: [Haskell-cafe] ANN: haddock-library 1.0.0 Message-ID: <53A14336.5050105@fuuzetsu.co.uk> Hi, haddock-library is a package aiming to provide bits of Haddock to the rest of the Haskell world without imposing the GHC dependency that we have on the ?haddock? package itself. Please note that this does not deprecate the ?haddock? package which aims to expose other bits of Haddock, including those talking with GHC. Specifically, 1.0.0 exposes the types used by the comment parser and the parser itself. This allows you to supply the Haddock parser with String and get a Haddock ADT back out to play with. This means that if in the past you were processing Haddock strings with your own solution (or copy + pasted Alex parser we had) then you should now switch to this package instead. The API is subject to change so upper version bound is advised. Tested on 7.6.3, 7.8.x and current HEAD. The parser exposed is what is used in Haddock itself which now internally depends on this package. There are plans to move more parts into this package, exposing as much useful functionality as possible without the GHC dependency. New releases are independent of the GHC release cycle, unlike Haddock itself. To file issues for this package, use the Haddock issue tracker that's now on GitHub. Thanks -- Mateusz K. From dominic at steinitz.org Wed Jun 18 08:14:45 2014 From: dominic at steinitz.org (Dominic Steinitz) Date: Wed, 18 Jun 2014 08:14:45 +0000 (UTC) Subject: [Haskell-cafe] Hackage References: Message-ID: Aycan iRiCAN gmail.com> writes: > I remember Hackage upload doesn't support Safari. You may try > Firefox (which works). On Wed, Jun 18, 2014 at 1:51 AM, Conal > Elliott conal.net> wrote: Or just use cabal upload From nikita.y.volkov at mail.ru Wed Jun 18 10:53:02 2014 From: nikita.y.volkov at mail.ru (Nikita Volkov) Date: Wed, 18 Jun 2014 14:53:02 +0400 Subject: [Haskell-cafe] Support of multi-constructor types by UNPACK pragma In-Reply-To: References: Message-ID: FWIW, I posted a ticket: https://ghc.haskell.org/trac/ghc/ticket/9214 Together with the following issues it would make a lot of data structures lighter in terms of memory footprint: https://ghc.haskell.org/trac/ghc/ticket/7647 https://ghc.haskell.org/trac/ghc/ticket/3990 -------------- next part -------------- An HTML attachment was scrubbed... URL: From nikoamia at gmail.com Wed Jun 18 11:55:24 2014 From: nikoamia at gmail.com (Nikolay Amiantov) Date: Wed, 18 Jun 2014 15:55:24 +0400 Subject: [Haskell-cafe] Warnings with OverloadedLists In-Reply-To: References: Message-ID: Hi Ozgur, On Wed, Jun 18, 2014 at 1:46 AM, Ozgur Akgun wrote: > I am not sure if this is a bug or not, but this page seems to explain the > desugaring of patterns with OverloadedLists: > https://ghc.haskell.org/trac/ghc/wiki/OverloadedLists Thanks for the link, I've experimented a bit with this: 1) GHC will alert me if I use VIewPatterns and don't match _: len (id -> []) = 0 len (id -> (_:xs)) = 1 + len xs Warning: Pattern match(es) are non-exhaustive In an equation for ?len?: Patterns not matched: _ I suppose this is because GHC cannot detect if "id" will yield bottom. 2) GHC, however, will alert me that I should also match [] if I use OverloadedLists, as shown before. If I have correctly understood this desugaring, it should warn me about matching _ as before. I can't quite understand behaviour (2) there. Any ideas? Nikolay. From nikoamia at gmail.com Wed Jun 18 12:01:13 2014 From: nikoamia at gmail.com (Nikolay Amiantov) Date: Wed, 18 Jun 2014 16:01:13 +0400 Subject: [Haskell-cafe] Building static libraries with -fPIC Message-ID: Hello all, I'm trying to build a shared (.so) library written in Haskell with "foreign export"s, which is statically linked with all needed dependencies. To do this, as far as I understood, I need to build all my dependencies (I use Cabal) with -fPIC flag, and also somehow get RTS static library built with -fPIC. Two questions regarding to this: 1) How can I add a build flag which will be added while building all my dependencies in Cabal. 2) How can I get needed RTS library. 3) How can I deal with "base"? Can I just build it with Cabal, so this question reduces to (1)? Thanks, Nikolay. From hesselink at gmail.com Wed Jun 18 13:39:55 2014 From: hesselink at gmail.com (Erik Hesselink) Date: Wed, 18 Jun 2014 15:39:55 +0200 Subject: [Haskell-cafe] Hackage "500 Internal Server Error" In-Reply-To: References: Message-ID: The Safari bug [1] should be fixed now, by the way. Erik [1] https://github.com/haskell/hackage-server/issues/132 On Wed, Jun 18, 2014 at 3:03 AM, Conal Elliott wrote: > Works now. Thanks! -- Conal > > > On Tue, Jun 17, 2014 at 5:54 PM, Austin Seipp wrote: >> >> This should hopefully now be fixed, and the Hackage server has been >> restarted. >> >> Do let me know if anything is wrong. >> >> On Tue, Jun 17, 2014 at 7:06 PM, Conal Elliott wrote: >> > Thanks for the suggestions. I'm getting this error with 'cabal upload' >> > (my >> > normal use) and with Firefox, Chrome, and Safari. >> > >> > Looks like it's been a few hours since any successful hackage uploads. >> > Maybe >> > uploads are broken. CC'ing admin at hackage.haskell.org. >> > >> > >> > >> > On Tue, Jun 17, 2014 at 4:21 PM, Christopher Allen >> > wrote: >> >> >> >> You can upload from the terminal using `cabal upload` as well. >> >> >> >> >> >> On Tue, Jun 17, 2014 at 6:08 PM, Aycan iRiCAN >> >> wrote: >> >>> >> >>> I remember Hackage upload doesn't support Safari. You may try Firefox >> >>> (which works). >> >>> >> >>> >> >>> On Wed, Jun 18, 2014 at 1:51 AM, Conal Elliott >> >>> wrote: >> >>>> >> >>>> Is hackage uploading broken? I'm trying to upload a new version of >> >>>> vector-space and am getting "500 Internal Server Error". -- Conal >> >>>> >> >>>> _______________________________________________ >> >>>> Haskell-Cafe mailing list >> >>>> Haskell-Cafe at haskell.org >> >>>> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >>>> >> >>> >> >>> >> >>> >> >>> -- >> >>> http://www.google.com/profiles/iricanaycan >> >>> >> >>> _______________________________________________ >> >>> Haskell-Cafe mailing list >> >>> Haskell-Cafe at haskell.org >> >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >>> >> >> >> > >> > >> > _______________________________________________ >> > Haskell-Cafe mailing list >> > Haskell-Cafe at haskell.org >> > http://www.haskell.org/mailman/listinfo/haskell-cafe >> > >> >> >> >> -- >> Regards, >> >> Austin Seipp, Haskell Consultant >> Well-Typed LLP, http://www.well-typed.com/ > > From agocorona at gmail.com Wed Jun 18 14:02:11 2014 From: agocorona at gmail.com (Alberto G. Corona ) Date: Wed, 18 Jun 2014 16:02:11 +0200 Subject: [Haskell-cafe] ANNOUNCE: haste-perch Message-ID: Hi, haste-perch defines builder elements (perchs) for Haste.DOM elements that are appendable, so that dynamic HTML can be created in the client in a natural way, like textual HTML, but programmatically and with the advantage of static type checking. It can be ported to other haskell-js compilers. http://hackage.haskell.org/package/haste-perch This program, when compiled with haste: main= do withElem "idelem" $ build $ do div $ do div $ do p "hello" p ! atr "style" "color:red" $ "world" return () Creates these element:
<-- was already in the HTML

hello

world

Since the creation is in the browser, that permit quite dynamic pages for data presentation, and interctive textual (a.k.a "serious") applications and, in general the development of client-side web frameworks using haskell with the haste compiler. See the README in the git repository: https://github.com/agocorona/haste-perch -- Alberto. -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrew.gibiansky at gmail.com Wed Jun 18 16:11:20 2014 From: andrew.gibiansky at gmail.com (Andrew Gibiansky) Date: Wed, 18 Jun 2014 09:11:20 -0700 Subject: [Haskell-cafe] [Haskell] ANNOUNCE: haste-perch In-Reply-To: References: Message-ID: Could you elaborate on how this is better/different from blaze-html? I'm a bit confused - is it just the same thing but works with Haste, while blaze-html doesn't? What's the main idea? Thanks! Andrew On Wed, Jun 18, 2014 at 7:02 AM, Alberto G. Corona wrote: > Hi, > > haste-perch defines builder elements (perchs) for Haste.DOM elements that > are appendable, so that dynamic HTML can be created in the client in a > natural way, like textual HTML, but programmatically and with the advantage > of static type checking. It can be ported to other haskell-js compilers. > > http://hackage.haskell.org/package/haste-perch > > This program, when compiled with haste: > > main= do > withElem "idelem" $ build $ do > div $ do > div $ do > p "hello" > p ! atr "style" "color:red" $ "world" > > return () > > Creates these element: > >
<-- was already in the HTML >
>
>

hello

>

world

>
>
>
> > Since the creation is in the browser, that permit quite dynamic pages for > data > presentation, and interctive textual (a.k.a "serious") applications and, > in general > the development of client-side web frameworks using haskell with the haste > compiler. > > > See the README in the git repository: > > https://github.com/agocorona/haste-perch > > -- > Alberto. > > _______________________________________________ > Haskell mailing list > Haskell at haskell.org > http://www.haskell.org/mailman/listinfo/haskell > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mats.rauhala at gmail.com Wed Jun 18 16:42:31 2014 From: mats.rauhala at gmail.com (Mats Rauhala) Date: Wed, 18 Jun 2014 19:42:31 +0300 Subject: [Haskell-cafe] [Haskell] ANNOUNCE: haste-perch In-Reply-To: References: Message-ID: <20140618164231.GA19712@peitto.info> I don't know the implementation, but as far as I know, creating html with javascript dom api is faster than creating textual html and then using that. And also if blaze-html uses text (or bytestring?), it is not compilable with haste On Wed, Jun 18, 2014 at 09:11:20AM -0700, Andrew Gibiansky wrote: > Could you elaborate on how this is better/different from blaze-html? > > I'm a bit confused - is it just the same thing but works with Haste, while > blaze-html doesn't? What's the main idea? > > Thanks! > Andrew > > > On Wed, Jun 18, 2014 at 7:02 AM, Alberto G. Corona > wrote: > > > Hi, > > > > haste-perch defines builder elements (perchs) for Haste.DOM elements that > > are appendable, so that dynamic HTML can be created in the client in a > > natural way, like textual HTML, but programmatically and with the advantage > > of static type checking. It can be ported to other haskell-js compilers. > > > > http://hackage.haskell.org/package/haste-perch > > > > This program, when compiled with haste: > > > > main= do > > withElem "idelem" $ build $ do > > div $ do > > div $ do > > p "hello" > > p ! atr "style" "color:red" $ "world" > > > > return () > > > > Creates these element: > > > >
<-- was already in the HTML > >
> >
> >

hello

> >

world

> >
> >
> >
> > > > Since the creation is in the browser, that permit quite dynamic pages for > > data > > presentation, and interctive textual (a.k.a "serious") applications and, > > in general > > the development of client-side web frameworks using haskell with the haste > > compiler. > > > > > > See the README in the git repository: > > > > https://github.com/agocorona/haste-perch > > > > -- > > Alberto. > > > > _______________________________________________ > > Haskell mailing list > > Haskell at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Mats Rauhala MasseR -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 198 bytes Desc: Digital signature URL: From glaebhoerl at gmail.com Wed Jun 18 17:06:00 2014 From: glaebhoerl at gmail.com (=?UTF-8?B?R8OhYm9yIExlaGVs?=) Date: Wed, 18 Jun 2014 19:06:00 +0200 Subject: [Haskell-cafe] What are the problems with instances for polymorphic types? In-Reply-To: <53A09A72.3080608@well-typed.com> References: <20140616121438.GB4704@nanodesu.localdomain> <53A09A72.3080608@well-typed.com> Message-ID: On Tue, Jun 17, 2014 at 9:43 PM, Adam Gundry wrote: > On 16/06/14 11:14, Niklas Haas wrote: > > On Sun, 15 Jun 2014 21:47:52 +0200, G?bor Lehel > wrote: > >> In other words instances for forall-types, such as: > >> > >> instance Foo (forall a. [a]) where ... > >> > >> It feels obvious to me that there *would* be problems with this, but I'm > >> curious about what, exactly, they are. > >> > >> Could someone familiar with the matter either elaborate on them, or > refer > >> me to an existing explanation, a previous discussion, or something of > the > >> sort? > >> > >> I *don't* have any kind of use case in mind, I'm merely seeking a better > >> understanding of the type-system issues involved. > >> > >> (I attempted Google, but didn't have much success.) > >> > >> Thanks in advance. > > > > It seems to me that it may be possible to get more information about > > this by searching for issues related to ImpredicativeTypes, which seem > > to be similar. (In fact, one could simulate instances like these by > > implementing type classes using ImplicitParams + ImpredicativeTypes + > > explicit instance records) > > I don't think there has been much research on type inference for these > kind of instances (though I'd be happy to be corrected). They are sort > of like ImpredicativeTypes but worse, in that it is very hard to tell > where the invisible type abstractions and applications go. > > For example, suppose we have these declarations: > > class Foo t where > useFoo :: t -> Int > > instance Foo (forall a. [a]) where > useFoo x = length (x :: [()]) > > f = useFoo [] > > The class and instance declarations make sense (the instance declaration > ends up checking `useFoo` with a higher-rank type, but that's okay). But > when inferring the type of `f`, we have > > useFoo :: forall t . Foo t => t -> Int > > and the typechecker needs to magically guess that > > t ~ forall a . [a] > > which is difficult. If there was some way of explicitly writing the > type at which to instantiate `t`, for example > > f = useFoo @(forall a. [a]) [] > > then it might be possible to make progress. [1] > > All this would, however, make perfect sense in System FC, once type > abstractions and applications have been made explicit, and typeclass > constraints have been replaced with visible dictionaries. > I see. Thanks a lot! So there wouldn't be any issues with coherence, or with typechecking itself: only with inference? Would the foralls in instances essentially be treated as another type constructor under this scenario? > > Hope this helps, > > Adam > > [1] https://ghc.haskell.org/trac/ghc/wiki/TypeApplication > > > -- > Adam Gundry, Haskell Consultant > Well-Typed LLP, http://www.well-typed.com/ > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From agocorona at gmail.com Wed Jun 18 17:20:09 2014 From: agocorona at gmail.com (Alberto G. Corona ) Date: Wed, 18 Jun 2014 19:20:09 +0200 Subject: [Haskell-cafe] [Haskell] ANNOUNCE: haste-perch In-Reply-To: References: Message-ID: The syntax is similar to blaze-html, but haste-perch uses the HTM-DOM in the browser to create DOM elements. blaze-html creates a html bytestring in the server that the browser must load. It uses Haste.DOM http://hackage.haskell.org/package/haste-compiler-0.2.99/docs/Haste-DOM.html Haste.DOM has primitives that invoke Javascript functions in browser like: For example newElem invoke "createElement" in javascript Perch assemble a sequence of DOM calls that create the HTML tree directly in the browser. so you can create an application that run fully in the browser The tree can change depeding on different actions done by the user by changing the HTML tree dynamically. It is possible to create dynamic applications. 2014-06-18 18:11 GMT+02:00 Andrew Gibiansky : > Could you elaborate on how this is better/different from blaze-html? > > I'm a bit confused - is it just the same thing but works with Haste, while > blaze-html doesn't? What's the main idea? > > Thanks! > Andrew > > > On Wed, Jun 18, 2014 at 7:02 AM, Alberto G. Corona > wrote: > >> Hi, >> >> haste-perch defines builder elements (perchs) for Haste.DOM elements that >> are appendable, so that dynamic HTML can be created in the client in a >> natural way, like textual HTML, but programmatically and with the advantage >> of static type checking. It can be ported to other haskell-js compilers. >> >> http://hackage.haskell.org/package/haste-perch >> >> This program, when compiled with haste: >> >> main= do >> withElem "idelem" $ build $ do >> div $ do >> div $ do >> p "hello" >> p ! atr "style" "color:red" $ "world" >> >> return () >> >> Creates these element: >> >>
<-- was already in the HTML >>
>>
>>

hello

>>

world

>>
>>
>>
>> >> Since the creation is in the browser, that permit quite dynamic pages for >> data >> presentation, and interctive textual (a.k.a "serious") applications and, >> in general >> the development of client-side web frameworks using haskell with the >> haste compiler. >> >> >> See the README in the git repository: >> >> https://github.com/agocorona/haste-perch >> >> -- >> Alberto. >> >> _______________________________________________ >> Haskell mailing list >> Haskell at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell >> >> > -- Alberto. -------------- next part -------------- An HTML attachment was scrubbed... URL: From agocorona at gmail.com Wed Jun 18 17:43:54 2014 From: agocorona at gmail.com (Alberto G. Corona ) Date: Wed, 18 Jun 2014 19:43:54 +0200 Subject: [Haskell-cafe] [Haskell] ANNOUNCE: haste-perch In-Reply-To: References: Message-ID: The readme in the Git repository tell more details https://github.com/agocorona/haste-perch/blob/master/README.md And also this blog post: http://haskell-web.blogspot.com.es/2014/06/taming-html-dom-with-monads-and-monoids.html 2014-06-18 19:20 GMT+02:00 Alberto G. Corona : > The syntax is similar to blaze-html, but haste-perch uses the HTM-DOM in > the browser to create DOM elements. blaze-html creates a html bytestring in > the server that the browser must load. > > It uses Haste.DOM > > > http://hackage.haskell.org/package/haste-compiler-0.2.99/docs/Haste-DOM.html > > Haste.DOM has primitives that invoke Javascript functions in browser like: > For example newElem invoke "createElement" in javascript > > Perch assemble a sequence of DOM calls that create the HTML tree directly > in the browser. so you can create an application that run fully in the > browser > > The tree can change depeding on different actions done by the user by > changing the HTML tree dynamically. It is possible to create dynamic > applications. > > > > > 2014-06-18 18:11 GMT+02:00 Andrew Gibiansky : > > Could you elaborate on how this is better/different from blaze-html? >> >> I'm a bit confused - is it just the same thing but works with Haste, >> while blaze-html doesn't? What's the main idea? >> >> Thanks! >> Andrew >> >> >> On Wed, Jun 18, 2014 at 7:02 AM, Alberto G. Corona >> wrote: >> >>> Hi, >>> >>> haste-perch defines builder elements (perchs) for Haste.DOM elements >>> that are appendable, so that dynamic HTML can be created in the client in a >>> natural way, like textual HTML, but programmatically and with the advantage >>> of static type checking. It can be ported to other haskell-js compilers. >>> >>> http://hackage.haskell.org/package/haste-perch >>> >>> This program, when compiled with haste: >>> >>> main= do >>> withElem "idelem" $ build $ do >>> div $ do >>> div $ do >>> p "hello" >>> p ! atr "style" "color:red" $ "world" >>> >>> return () >>> >>> Creates these element: >>> >>>
<-- was already in the HTML >>>
>>>
>>>

hello

>>>

world

>>>
>>>
>>>
>>> >>> Since the creation is in the browser, that permit quite dynamic pages >>> for data >>> presentation, and interctive textual (a.k.a "serious") applications and, >>> in general >>> the development of client-side web frameworks using haskell with the >>> haste compiler. >>> >>> >>> See the README in the git repository: >>> >>> https://github.com/agocorona/haste-perch >>> >>> -- >>> Alberto. >>> >>> _______________________________________________ >>> Haskell mailing list >>> Haskell at haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell >>> >>> >> > > > -- > Alberto. > -- Alberto. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at nh2.me Wed Jun 18 18:07:29 2014 From: mail at nh2.me (=?ISO-8859-1?Q?Niklas_Hamb=FCchen?=) Date: Wed, 18 Jun 2014 19:07:29 +0100 Subject: [Haskell-cafe] Hackage In-Reply-To: References: Message-ID: <53A1D561.5040105@nh2.me> On 18/06/14 09:14, Dominic Steinitz wrote: > Aycan iRiCAN gmail.com> writes: > >> I remember Hackage upload doesn't support Safari. You may try >> Firefox (which works). On Wed, Jun 18, 2014 at 1:51 AM, Conal >> Elliott conal.net> wrote: > > Or just use cabal upload cabal upload still happens unencrypted, doesn't it? From ynasser at oanda.com Wed Jun 18 19:40:58 2014 From: ynasser at oanda.com (Yomna Nasser) Date: Wed, 18 Jun 2014 15:40:58 -0400 Subject: [Haskell-cafe] dead links on mailing list page Message-ID: I was trying to look at some mailing list archives, and encountered several dead links in section 1.3 on this page: http://www.haskell.org/haskellwiki/Mailing_lists - 3rd paragraph, link to http://www.cse.unsw.edu.au/~dons/haskell-1990-2006/threads.html (a 403 is returned), where the link is under the text "hosted here" - 4th paragraph, link to the Google Coop Haskell Search Engine (a 404 is returned) I wasn't sure where else to report this. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dstcruz at gmail.com Thu Jun 19 01:08:33 2014 From: dstcruz at gmail.com (Daniel Santa Cruz) Date: Wed, 18 Jun 2014 21:08:33 -0400 Subject: [Haskell-cafe] Haskell Weekly News: Issue 297 Message-ID: Welcome to issue 297 of the HWN, an issue covering crowd-sourced bits of information about Haskell from around the web. This issue covers from June 8 to 14, 2014 Quotes of the Week * dpwright: this afternoon I've literally taken an entire (portrait) screen's worth of code and reduced it to about three lines and a few lens operators * tommd: Haskell is a great language. I needed to test a program under high CPU load, so to burn some cycles I cabal-installed lens. Is there anything Haskell can't do? * bernalex: I imagine hell as a place where spj & edwardk are holding talks at the same time and I have to choose. Top Reddit Stories * Haxl on Github Domain: github.com, Score: 124, Comments: 25 Original: [1] http://goo.gl/zw8Y8q On Reddit: [2] http://goo.gl/FoV1zw * www.dohaskell.com Domain: dohaskell.com, Score: 92, Comments: 23 Original: [3] http://goo.gl/uxmtUy On Reddit: [4] http://goo.gl/xkGJUb * cloud-haskell is on hackage now Domain: hackage.haskell.org, Score: 87, Comments: 7 Original: [5] http://goo.gl/eCHMgO On Reddit: [6] http://goo.gl/h9j7H1 * Facebook releases Haxl, a library for async data access Domain: code.facebook.com, Score: 65, Comments: 0 Original: [7] http://goo.gl/D6xEnM On Reddit: [8] http://goo.gl/GCqeEt * The problem with mtl Domain: ro-che.info, Score: 61, Comments: 58 Original: [9] http://goo.gl/hDncB8 On Reddit: [10] http://goo.gl/2uRfm2 * Why programmers can?t make any money: dimensionality and the Eternal Haskell Tax Domain: michaelochurch.wordpress.com, Score: 56, Comments: 37 Original: [11] http://goo.gl/Ums4cZ On Reddit: [12] http://goo.gl/ytLSN2 * A Year of Functional Programming Domain: japgolly.blogspot.com.au, Score: 52, Comments: 17 Original: [13] http://goo.gl/torrXD On Reddit: [14] http://goo.gl/XTSVed * Haskell for all: Spreadsheet-like programming in Haskell Domain: haskellforall.com, Score: 52, Comments: 26 Original: [15] http://goo.gl/eaaeHa On Reddit: [16] http://goo.gl/biUwQf * GHC bug squashing at ZuriHac 2014 Domain: joachim-breitner.de, Score: 50, Comments: 0 Original: [17] http://goo.gl/zgd6qV On Reddit: [18] http://goo.gl/HDp0Wt * There is no Fork?our ICFP 2014 paper about Haxl Domain: community.haskell.org, Score: 47, Comments: 4 Original: [19] http://goo.gl/yvbvAH On Reddit: [20] http://goo.gl/pwcBxO * EclipseFP 2.6.0 released Domain: jpmoresmau.blogspot.fr, Score: 46, Comments: 18 Original: [21] http://goo.gl/fohXYx On Reddit: [22] http://goo.gl/duJMir * Haskell Development Workflow Demo, first video I've made, wanted to see if any found it useful Domain: youtube.com, Score: 44, Comments: 11 Original: [23] http://goo.gl/O1REsS On Reddit: [24] http://goo.gl/KTK1kk * Announcement: Bang, a drum machine DSL for Haskell Domain: self.haskell, Score: 42, Comments: 17 Original: [25] http://goo.gl/QVlj3E On Reddit: [26] http://goo.gl/QVlj3E * How do you learn to write systems in Haskell? (and a story) Domain: self.haskell, Score: 42, Comments: 66 Original: [27] http://goo.gl/PXiZUD On Reddit: [28] http://goo.gl/PXiZUD * The Haskell Cast #7 - Chris Done on Compiling to JavaScript and SQL Domain: haskellcast.com, Score: 41, Comments: 15 Original: [29] http://goo.gl/747Kpj On Reddit: [30] http://goo.gl/n0nlLJ * ICFP 2014 accepted papers Domain: github.com, Score: 40, Comments: 3 Original: [31] http://goo.gl/XZ962N On Reddit: [32] http://goo.gl/VnuyDW * cabal - the simple guide Domain: katychuang.com, Score: 40, Comments: 16 Original: [33] http://goo.gl/svwYE1 On Reddit: [34] http://goo.gl/oGidxo * Two failed attempts at extensible effects Domain: ro-che.info, Score: 37, Comments: 12 Original: [35] http://goo.gl/DD7WX9 On Reddit: [36] http://goo.gl/wh8fWW * Follow up blog post: "Understanding the RealWorld": the Haskell heap, function calls, and primitive types. Domain: well-typed.com, Score: 34, Comments: 12 Original: [37] http://goo.gl/9OMjWu On Reddit: [38] http://goo.gl/N0B4cJ * "Why Haskell?" Elevator Pitch Domain: self.haskell, Score: 33, Comments: 70 Original: [39] http://goo.gl/xsIOqw On Reddit: [40] http://goo.gl/xsIOqw Top StackOverflow Questions * Why should Applicative be a superclass of Monad? votes: 21, answers: 3 Read on SO: [41] http://goo.gl/Z1Q6uo * What do you call the data wrapped inside a monad? votes: 15, answers: 2 Read on SO: [42] http://goo.gl/iNtQAX * What algorithm is used in Haskell (GHC) for deriving types of recursive expressions? votes: 14, answers: 1 Read on SO: [43] http://goo.gl/7QvfqM * What container really mimics std::vector in Haskell? votes: 14, answers: 4 Read on SO: [44] http://goo.gl/k0vk2n * Why the cycle function cannot work with empty list? votes: 14, answers: 2 Read on SO: [45] http://goo.gl/B5Na0a Until next time, [46]+Daniel Santa Cruz References 1. https://github.com/facebook/Haxl 2. http://www.reddit.com/r/haskell/comments/27sv88/haxl_on_github/ 3. http://www.dohaskell.com/ 4. http://www.reddit.com/r/haskell/comments/27wjwk/wwwdohaskellcom/ 5. http://hackage.haskell.org/package/cloud-haskell-0.0.1.0 6. http://www.reddit.com/r/haskell/comments/281sbp/cloudhaskell_is_on_hackage_now/ 7. https://code.facebook.com/projects/854888367872565/haxl/ 8. http://www.reddit.com/r/haskell/comments/27syj2/facebook_releases_haxl_a_library_for_async_data/ 9. http://ro-che.info/articles/2014-06-11-problem-with-mtl.html 10. http://www.reddit.com/r/haskell/comments/27vhd1/the_problem_with_mtl/ 11. http://michaelochurch.wordpress.com/2014/06/06/why-programmers-cant-make-any-money-dimensionality-and-the-eternal-haskell-tax/ 12. http://www.reddit.com/r/haskell/comments/27onwq/why_programmers_cant_make_any_money/ 13. http://japgolly.blogspot.com.au/2014/06/a-year-of-functional-programming.html 14. http://www.reddit.com/r/haskell/comments/27oxr4/a_year_of_functional_programming/ 15. http://www.haskellforall.com/2014/06/spreadsheet-like-programming-in-haskell.html 16. http://www.reddit.com/r/haskell/comments/284enc/haskell_for_all_spreadsheetlike_programming_in/ 17. http://www.joachim-breitner.de/blog/archives/651-ZuriHac-2014.html 18. http://www.reddit.com/r/haskell/comments/27p2nc/ghc_bug_squashing_at_zurihac_2014/ 19. http://community.haskell.org/~simonmar/papers/haxl-icfp14.pdf 20. http://www.reddit.com/r/haskell/comments/27tjpj/there_is_no_forkour_icfp_2014_paper_about_haxl/ 21. http://jpmoresmau.blogspot.fr/2014/06/eclipsefp-260-released.html 22. http://www.reddit.com/r/haskell/comments/27utrw/eclipsefp_260_released/ 23. https://www.youtube.com/watch?v=Li6oaO8x2VY 24. http://www.reddit.com/r/haskell/comments/27lcz3/haskell_development_workflow_demo_first_video_ive/ 25. http://www.reddit.com/r/haskell/comments/27s6py/announcement_bang_a_drum_machine_dsl_for_haskell/ 26. http://www.reddit.com/r/haskell/comments/27s6py/announcement_bang_a_drum_machine_dsl_for_haskell/ 27. http://www.reddit.com/r/haskell/comments/28575l/how_do_you_learn_to_write_systems_in_haskell_and/ 28. http://www.reddit.com/r/haskell/comments/28575l/how_do_you_learn_to_write_systems_in_haskell_and/ 29. http://www.haskellcast.com/episode/007-chris-done-on-compiling-to-javascript-and-sql/ 30. http://www.reddit.com/r/haskell/comments/27sh2d/the_haskell_cast_7_chris_done_on_compiling_to/ 31. https://github.com/yallop/icfp2014-papers/blob/master/README.md 32. http://www.reddit.com/r/haskell/comments/27p8xo/icfp_2014_accepted_papers/ 33. http://katychuang.com/cabal-guide/ 34. http://www.reddit.com/r/haskell/comments/280h9h/cabal_the_simple_guide/ 35. http://ro-che.info/articles/2014-06-14-extensible-effects-failed.html 36. http://www.reddit.com/r/haskell/comments/285prk/two_failed_attempts_at_extensible_effects/ 37. http://www.well-typed.com/blog/95/ 38. http://www.reddit.com/r/haskell/comments/27yg67/follow_up_blog_post_understanding_the_realworld/ 39. http://www.reddit.com/r/haskell/comments/282yky/why_haskell_elevator_pitch/ 40. http://www.reddit.com/r/haskell/comments/282yky/why_haskell_elevator_pitch/ 41. http://stackoverflow.com/questions/24112786/why-should-applicative-be-a-superclass-of-monad 42. http://stackoverflow.com/questions/24127190/what-do-you-call-the-data-wrapped-inside-a-monad 43. http://stackoverflow.com/questions/24105812/what-algorithm-is-used-in-haskell-ghc-for-deriving-types-of-recursive-expressi 44. http://stackoverflow.com/questions/24123967/what-container-really-mimics-stdvector-in-haskell 45. http://stackoverflow.com/questions/24223201/why-the-cycle-function-cannot-work-with-empty-list 46. https://plus.google.com/105107667630152149014/about -------------- next part -------------- An HTML attachment was scrubbed... URL: From dennis.raddle at gmail.com Thu Jun 19 03:31:19 2014 From: dennis.raddle at gmail.com (Dennis Raddle) Date: Wed, 18 Jun 2014 20:31:19 -0700 Subject: [Haskell-cafe] diagrams Message-ID: I'm a math tutor and I want to create videos to explain certain math concepts, and I'm wondering if the diagrams library would help me. There are two questions--first, whether it has the capability to do what I want, and second how hard it would to integrate the animations into YouTube videos with voice-over. To describe the capability, I'm looking first to typeset equations. Then, second, to represent manipulation of equations by having elements of equations move locations or cross-fade. Also "elements" could mean pictures or non-mathematical notation. I have no doubt that diagrams can make the diagrams themselves. What I wonder about is the animation capabilities---ability to have elements move or cross-fade (dissolve), in particular. As far as the ability to integrate these into YouTube videos, that is probably beyond the scope of this list, but maybe someone happens to have done this and knows the answer. Mike -------------- next part -------------- An HTML attachment was scrubbed... URL: From acowley at gmail.com Thu Jun 19 03:44:32 2014 From: acowley at gmail.com (Anthony Cowley) Date: Wed, 18 Jun 2014 23:44:32 -0400 Subject: [Haskell-cafe] diagrams In-Reply-To: References: Message-ID: <862F364A-317E-4BA6-AE00-233668E7B9AB@gmail.com> > On Jun 18, 2014, at 11:31 PM, Dennis Raddle wrote: > > I'm a math tutor and I want to create videos to explain certain math concepts, and I'm wondering if the diagrams library would help me. There are two questions--first, whether it has the capability to do what I want, and second how hard it would to integrate the animations into YouTube videos with voice-over. > > To describe the capability, I'm looking first to typeset equations. Then, second, to represent manipulation of equations by having elements of equations move locations or cross-fade. Also "elements" could mean pictures or non-mathematical notation. > > I have no doubt that diagrams can make the diagrams themselves. What I wonder about is the animation capabilities---ability to have elements move or cross-fade (dissolve), in particular. > > As far as the ability to integrate these into YouTube videos, that is probably beyond the scope of this list, but maybe someone happens to have done this and knows the answer. > > Mike I'll chime in on the last part: between diagrams, Rasterific (http://hackage.haskell.org/package/Rasterific), and ffmpeg-light (http://hackage.haskell.org/package/ffmpeg-light) you can certainly make animations ready for upload to YouTube. The ffmpeg-light repository has examples of saving out h264 video and Rasterific animations. Tying these pieces together with some transition effects would be a great project. Anthony -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuuzetsu at fuuzetsu.co.uk Thu Jun 19 04:40:47 2014 From: fuuzetsu at fuuzetsu.co.uk (Mateusz Kowalczyk) Date: Thu, 19 Jun 2014 06:40:47 +0200 Subject: [Haskell-cafe] dead links on mailing list page In-Reply-To: References: Message-ID: <53A269CF.2070100@fuuzetsu.co.uk> On 06/18/2014 09:40 PM, Yomna Nasser wrote: > I was trying to look at some mailing list archives, and encountered several > dead links in section 1.3 on this page: > http://www.haskell.org/haskellwiki/Mailing_lists > > - 3rd paragraph, link to > http://www.cse.unsw.edu.au/~dons/haskell-1990-2006/threads.html (a 403 is > returned), where the link is under the text "hosted here" > > - 4th paragraph, link to the Google Coop Haskell Search Engine (a 404 is > returned) > > I wasn't sure where else to report this. > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > You can register on the Wiki (I think it's still a manual-confirmation process though) and fix up the links yourself if you know what they should be pointing to now, if anything. -- Mateusz K. From gautier.difolco at gmail.com Thu Jun 19 07:36:56 2014 From: gautier.difolco at gmail.com (Gautier DI FOLCO) Date: Thu, 19 Jun 2014 09:36:56 +0200 Subject: [Haskell-cafe] Relations between Functor typeclass and kind Message-ID: Hi all, Some days ago, I was talking with someone about Kinds and GADTs. At some point he mention that types with this Kind: (* -> *) are called Functors. So, is there any relations between Functor typeclass and Functor kind? Is it considered as a "pattern"? if so, are there some other ones? If you have any link on this, I'll take them. Thanks in advance for your help. -------------- next part -------------- An HTML attachment was scrubbed... URL: From haskell at nand.wakku.to Thu Jun 19 07:45:48 2014 From: haskell at nand.wakku.to (Niklas Haas) Date: Thu, 19 Jun 2014 09:45:48 +0200 Subject: [Haskell-cafe] Relations between Functor typeclass and kind In-Reply-To: References: Message-ID: <20140619094548.GB15005@nanodesu.localdomain> On Thu, 19 Jun 2014 09:36:56 +0200, Gautier DI FOLCO wrote: > Hi all, > > Some days ago, I was talking with someone about Kinds and GADTs. > At some point he mention that types with this Kind: (* -> *) are called > Functors. > So, is there any relations between Functor typeclass and Functor kind? > Is it considered as a "pattern"? if so, are there some other ones? If you > have any link on this, I'll take them. > > Thanks in advance for your help. An argument could be made for all things of kind * -> * being (at least) functors (in the CT sense) from Hask to a discrete subcategory that contains only id :: F a -> F a but this is likely not what he meant. In general, things that are of kind * -> * are not necessarily Haskell Functors, for a simple counterexample see: newtype Auto a = Auto (a -> a) This type does not permit fmap, which would be equivalent to (a -> b) -> (a -> a) -> b -> b. The only general relationship between Functor and * -> * is that Functor's parameter must have that kind, for example in the instance Functor Maybe we have Maybe :: * -> *. From gautier.difolco at gmail.com Thu Jun 19 07:51:00 2014 From: gautier.difolco at gmail.com (Gautier DI FOLCO) Date: Thu, 19 Jun 2014 09:51:00 +0200 Subject: [Haskell-cafe] Relations between Functor typeclass and kind In-Reply-To: <20140619094548.GB15005@nanodesu.localdomain> References: <20140619094548.GB15005@nanodesu.localdomain> Message-ID: 2014-06-19 9:45 GMT+02:00 Niklas Haas : > On Thu, 19 Jun 2014 09:36:56 +0200, Gautier DI FOLCO < > gautier.difolco at gmail.com> wrote: > > Hi all, > > > > Some days ago, I was talking with someone about Kinds and GADTs. > > At some point he mention that types with this Kind: (* -> *) are called > > Functors. > > So, is there any relations between Functor typeclass and Functor kind? > > Is it considered as a "pattern"? if so, are there some other ones? If you > > have any link on this, I'll take them. > > > > Thanks in advance for your help. > > An argument could be made for all things of kind * -> * being (at least) > functors (in the CT sense) from Hask to a discrete subcategory that > contains only id :: F a -> F a but this is likely not what he meant. > > In general, things that are of kind * -> * are not necessarily Haskell > Functors, for a simple counterexample see: > > newtype Auto a = Auto (a -> a) > > This type does not permit fmap, which would be equivalent to (a -> b) -> > (a -> a) -> b -> b. > > The only general relationship between Functor and * -> * is that > Functor's parameter must have that kind, for example in the instance > Functor Maybe we have Maybe :: * -> *. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > ok, it's clear, thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From corentin.dupont at gmail.com Thu Jun 19 15:17:13 2014 From: corentin.dupont at gmail.com (Corentin Dupont) Date: Thu, 19 Jun 2014 17:17:13 +0200 Subject: [Haskell-cafe] Do you recognize this type? Message-ID: Hi guys, I am making a DSL for event composition (inspired from digestive-functor & reactive-banana) and I find myself wanting a primitive like that: -- given a list of events, evaluate the function on those that have already fired. -- returns an event yelding the result when ready. ListEvent :: [Event a] -> ([a] -> Maybe b) -> Event b Does this type tell you something? Is there a better abstraction that can encompass it? My DSL is like that: -- | Composable events data Event a where SumEvent :: Event a -> Event a -> Event a -- The first event to fire will be returned AppEvent :: Event (a -> b) -> Event a -> Event b -- Both events should fire, and then the result is returned PureEvent :: a -> Event a -- Create a fake event. The result is useable with no delay. EmptyEvent :: Event a -- An event that is never fired. BaseEvent :: (Typeable a) => Field a -> Event a -- Embed a base event It's easy to define instances for Applicative and Alternative. But then I have a use case that I cannot solve: In the case of votations (which use this DSL), sometime you can end prematuraly the voting, even if not everybody voted yet: for example if the majority is already reached. In this case no need to wait for everybody, we can end the vote. This does not seem to be possible with Applicative or Monad interfaces: things have to be sequenced in a monad, they cannot be evaluated in parralel. For example: do v1 <- getVote1 v2 <- getVote2 v3 <- getVote3 evalMajority(v1, v2, v3) In this example I have to wait for all 3 votes to be completed, but in fact only two would suffice to achieve majority. That's why I added "ListEvent" to the DSL above which allow to achieve that but I'm wondering if there is a better/bigger abstraction to put it in. Thanks!! Corentin -------------- next part -------------- An HTML attachment was scrubbed... URL: From corentin.dupont at gmail.com Fri Jun 20 12:59:41 2014 From: corentin.dupont at gmail.com (Corentin Dupont) Date: Fri, 20 Jun 2014 14:59:41 +0200 Subject: [Haskell-cafe] Do you recognize this type? In-Reply-To: References: Message-ID: Nobody on that? What I really want is: a computation that can be interrupted if enough result is already there. I would be surprise if that concept doesn't exist already somewhere :) On Thu, Jun 19, 2014 at 5:17 PM, Corentin Dupont wrote: > Hi guys, > I am making a DSL for event composition (inspired from digestive-functor & > reactive-banana) and I find myself wanting a primitive like that: > > -- given a list of events, evaluate the function on those that have > already fired. > -- returns an event yelding the result when ready. > ListEvent :: [Event a] -> ([a] -> Maybe b) -> Event b > > Does this type tell you something? Is there a better abstraction that can > encompass it? > My DSL is like that: > > -- | Composable events > data Event a where > SumEvent :: Event a -> Event a -> Event a -- The first event > to fire will be returned > AppEvent :: Event (a -> b) -> Event a -> Event b -- Both events > should fire, and then the result is returned > PureEvent :: a -> Event a -- Create a fake > event. The result is useable with no delay. > EmptyEvent :: Event a -- An event that is > never fired. > BaseEvent :: (Typeable a) => Field a -> Event a -- Embed a base event > > It's easy to define instances for Applicative and Alternative. > But then I have a use case that I cannot solve: > In the case of votations (which use this DSL), sometime you can end > prematuraly the voting, even if not everybody voted yet: for example if the > majority is already reached. > In this case no need to wait for everybody, we can end the vote. > > This does not seem to be possible with Applicative or Monad interfaces: > things have to be sequenced in a monad, they cannot be evaluated in > parralel. > For example: > > do > v1 <- getVote1 > v2 <- getVote2 > v3 <- getVote3 > evalMajority(v1, v2, v3) > > In this example I have to wait for all 3 votes to be completed, but in > fact only two would suffice to achieve majority. > That's why I added "ListEvent" to the DSL above which allow to achieve > that but I'm wondering if there is a better/bigger abstraction to put it in. > > Thanks!! > Corentin > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From chriswarbo at googlemail.com Fri Jun 20 14:55:17 2014 From: chriswarbo at googlemail.com (Chris Warburton) Date: Fri, 20 Jun 2014 15:55:17 +0100 Subject: [Haskell-cafe] Do you recognize this type? In-Reply-To: (Corentin Dupont's message of "Fri, 20 Jun 2014 14:59:41 +0200") References: Message-ID: <86egyjr5pm.fsf@gmail.com> Corentin Dupont writes: > Nobody on that? > What I really want is: a computation that can be interrupted if enough > result is already there. > I would be surprise if that concept doesn't exist already somewhere :) I'd be surprised if this can be done with Applicative without some hackery. Very roughly, we can think of Functors as one-shot actions. For example, the IO instance of Functor lets us perform exactly 1 side-effect; all we can do with the result is map pure functions over it. Applicatives are a static chain of actions. For example, the IO instance of Applicative lets us chain together any number of side-effecting actions, but those actions can't alter the chain itself. Monads are a dynamic chain of actions. They're like Applicatives, but each action can choose which action to perform next based on the previous results. >From this perspective, the "shortcut" you're looking for requires the ability to choose the next action (count another vote or finish prematurely) based on the previous results (the running total). That's what Monads are good for, but Applicatives can't do it by themselves. There's probably an unsafe* way to do this, which will in fact be safe due to your voting invariant ("if there aren't enough uncounted votes to change the outcome, the outcome cannot change"). Maybe someone who's performed similar optimisations can help. Good luck! Chris From corentin.dupont at gmail.com Fri Jun 20 15:09:30 2014 From: corentin.dupont at gmail.com (Corentin Dupont) Date: Fri, 20 Jun 2014 17:09:30 +0200 Subject: [Haskell-cafe] Fwd: Do you recognize this type? In-Reply-To: References: Message-ID: Yes it looks like, but I don't think it is: the argument function in ListEvent is taking a list itself, so that's not a fold. It's a sort of interruptible computation (since as soon as the argument function returns Just, we remove all remaining events). But I'm sure there is a better way to write it. ListEvent :: [Event a] -> ([a] -> Maybe b) -> Event b On Fri, Jun 20, 2014 at 4:31 PM, Kyle Marek-Spartz < kyle.marek.spartz at gmail.com> wrote: > Isn?t this a fold? > > ? > Kyle Marek-Spartz > > > > On Jun 20, 2014, 7:59:41 AM, Corentin Dupont > wrote: > ------------------------------ > Nobody on that? > What I really want is: a computation that can be interrupted if enough > result is already there. > I would be surprise if that concept doesn't exist already somewhere :) > > > On Thu, Jun 19, 2014 at 5:17 PM, Corentin Dupont < > corentin.dupont at gmail.com> wrote: > >> Hi guys, >> I am making a DSL for event composition (inspired from >> digestive-functor & reactive-banana) and I find myself wanting a primitive >> like that: >> >> -- given a list of events, evaluate the function on those that have >> already fired. >> -- returns an event yelding the result when ready. >> ListEvent :: [Event a] -> ([a] -> Maybe b) -> Event b >> >> Does this type tell you something? Is there a better abstraction that >> can encompass it? >> My DSL is like that: >> >> -- | Composable events >> data Event a where >> SumEvent :: Event a -> Event a -> Event a -- The first event >> to fire will be returned >> AppEvent :: Event (a -> b) -> Event a -> Event b -- Both events >> should fire, and then the result is returned >> PureEvent :: a -> Event a -- Create a fake >> event. The result is useable with no delay. >> EmptyEvent :: Event a -- An event that is >> never fired. >> BaseEvent :: (Typeable a) => Field a -> Event a -- Embed a base >> event >> >> It's easy to define instances for Applicative and Alternative. >> But then I have a use case that I cannot solve: >> In the case of votations (which use this DSL), sometime you can end >> prematuraly the voting, even if not everybody voted yet: for example if the >> majority is already reached. >> In this case no need to wait for everybody, we can end the vote. >> >> This does not seem to be possible with Applicative or Monad interfaces: >> things have to be sequenced in a monad, they cannot be evaluated in >> parralel. >> For example: >> >> do >> v1 <- getVote1 >> v2 <- getVote2 >> v3 <- getVote3 >> evalMajority(v1, v2, v3) >> >> In this example I have to wait for all 3 votes to be completed, but in >> fact only two would suffice to achieve majority. >> That's why I added "ListEvent" to the DSL above which allow to achieve >> that but I'm wondering if there is a better/bigger abstraction to put it >> in. >> >> Thanks!! >> Corentin >> >> > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From corentin.dupont at gmail.com Fri Jun 20 15:10:12 2014 From: corentin.dupont at gmail.com (Corentin Dupont) Date: Fri, 20 Jun 2014 17:10:12 +0200 Subject: [Haskell-cafe] Do you recognize this type? In-Reply-To: <86egyjr5pm.fsf@gmail.com> References: <86egyjr5pm.fsf@gmail.com> Message-ID: On Fri, Jun 20, 2014 at 4:55 PM, Chris Warburton wrote: > Corentin Dupont writes: > > > Nobody on that? > > What I really want is: a computation that can be interrupted if enough > > result is already there. > > I would be surprise if that concept doesn't exist already somewhere :) > > I'd be surprised if this can be done with Applicative without some > hackery. > > Very roughly, we can think of Functors as one-shot actions. For example, > the IO instance of Functor lets us perform exactly 1 side-effect; all we > can do with the result is map pure functions over it. > > Applicatives are a static chain of actions. For example, the IO instance > of Applicative lets us chain together any number of side-effecting > actions, but those actions can't alter the chain itself. > > Monads are a dynamic chain of actions. They're like Applicatives, but > each action can choose which action to perform next based on the > previous results. > wow, I *love* this summary! Thanks for that! > > From this perspective, the "shortcut" you're looking for requires the > ability to choose the next action (count another vote or finish > prematurely) based on the previous results (the running total). That's > what Monads are good for, but Applicatives can't do it by themselves. > Indeed I could make my DSL a monad instance with some changes, that would be easy to do. But even not a Monad cannot do the trick: imagine if in a country, you were asking the people to vote one by one, only to interrupt them when the result is known. In fact they have to vote altogether, in whatever order, and we count the votes as they arrive. So I think what I need is a sort of Applicative++: not a chain of actions but a set of actions, all independent from each other (so no monad) and with no particular order. > > There's probably an unsafe* way to do this, which will in fact be safe > due to your voting invariant ("if there aren't enough uncounted votes > to change the outcome, the outcome cannot change"). Maybe someone who's > performed similar optimisations can help. > > Good luck! > > Chris > -------------- next part -------------- An HTML attachment was scrubbed... URL: From almeidaraf at gmail.com Fri Jun 20 15:24:25 2014 From: almeidaraf at gmail.com (Rafael Almeida) Date: Fri, 20 Jun 2014 12:24:25 -0300 Subject: [Haskell-cafe] How to represent a board? Message-ID: Hello, There are many examples of games which use boards: chess, checkers, go, etc. Many people starting out at programming and/or game programming are very much tempted to code a board game. It looks like such a game would be easy to build at first sight. Even more sophisticated games sometimes use a grid system, which looks a lot like boards as well. In a grid system the movements of a given agent are bound do discrete positions. Although the user may not see the board underneath pretty graphics, it is a board game. Having in mind the sort of operations such games have to make on boards, I ask: what are the best representations for a board in Haskell? In many languages a NxN array seems like a good pick. In Haskell, most would translate that into lists of lists. I know I have. However, traversing those lists to get a position, calculate where a piece or agent could go, etc., feels awkward and unefficient. Beside the point already made, we have no type safe guarantee that our 64x64 won't become a 63x63 + 65x1 board due to some misbehaving function. It strikes me that list of lists is not a great board representation. I think STArrays are a better pick; from the perspective of translating an NxN array into Haskell, at least. However, maybe there is an even more elegant way to deal with a board in Haskell. I hope you can help me out figuring it out. []'s Rafael -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex at lagoa.com Fri Jun 20 15:33:25 2014 From: alex at lagoa.com (Alexander Vieth) Date: Fri, 20 Jun 2014 11:33:25 -0400 Subject: [Haskell-cafe] How to represent a board? In-Reply-To: References: Message-ID: > In many languages a NxN array seems like a good pick. In Haskell, most would translate that into lists of lists. I know I have. However, traversing those lists to get a position, calculate where a piece or agent could go, etc., feels awkward and unefficient. Beside the point already made, we have no type safe guarantee that our 64x64 won't become a 63x63 + 65x1 board due to some misbehaving function. Perhaps choosing a zipper-like representation, in which all adjacent places on your board can be found without any traversal, would make the usage less awkward and more efficient. As for the size, you can get a guarantee that it won't change, so long as you make a new type for your board and verify that no function on that type will produce a board of bogus size. Alex On 2014-06-20, at 11:24 AM, Rafael Almeida wrote: > Hello, > > There are many examples of games which use boards: chess, checkers, go, etc. Many people starting out at programming and/or game programming are very much tempted to code a board game. It looks like such a game would be easy to build at first sight. > > Even more sophisticated games sometimes use a grid system, which looks a lot like boards as well. In a grid system the movements of a given agent are bound do discrete positions. Although the user may not see the board underneath pretty graphics, it is a board game. > > Having in mind the sort of operations such games have to make on boards, I ask: what are the best representations for a board in Haskell? > > In many languages a NxN array seems like a good pick. In Haskell, most would translate that into lists of lists. I know I have. However, traversing those lists to get a position, calculate where a piece or agent could go, etc., feels awkward and unefficient. Beside the point already made, we have no type safe guarantee that our 64x64 won't become a 63x63 + 65x1 board due to some misbehaving function. > > It strikes me that list of lists is not a great board representation. I think STArrays are a better pick; from the perspective of translating an NxN array into Haskell, at least. However, maybe there is an even more elegant way to deal with a board in Haskell. I hope you can help me out figuring it out. > > []'s > Rafael > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From bob at redivi.com Fri Jun 20 15:33:54 2014 From: bob at redivi.com (Bob Ippolito) Date: Fri, 20 Jun 2014 08:33:54 -0700 Subject: [Haskell-cafe] How to represent a board? In-Reply-To: References: Message-ID: I've used Data.Array or Data.Vector when trying to solve these sorts of problems. The size of the board is not encoded in the type with either library, but that's not something that's easy to do or commonly implemented in Haskell. Data.Vector has better functionality, but the index is always an Int, so Array can be more convenient in many cases as it can be indexed by any instance of Ix. STArray, MVector, etc. are all options as well, but I prefer to write functional solutions when possible. On Fri, Jun 20, 2014 at 8:24 AM, Rafael Almeida wrote: > Hello, > > There are many examples of games which use boards: chess, checkers, go, > etc. Many people starting out at programming and/or game programming are > very much tempted to code a board game. It looks like such a game would be > easy to build at first sight. > > Even more sophisticated games sometimes use a grid system, which looks a > lot like boards as well. In a grid system the movements of a given agent > are bound do discrete positions. Although the user may not see the board > underneath pretty graphics, it is a board game. > > Having in mind the sort of operations such games have to make on boards, I > ask: what are the best representations for a board in Haskell? > > In many languages a NxN array seems like a good pick. In Haskell, most > would translate that into lists of lists. I know I have. However, > traversing those lists to get a position, calculate where a piece or agent > could go, etc., feels awkward and unefficient. Beside the point already > made, we have no type safe guarantee that our 64x64 won't become a 63x63 + > 65x1 board due to some misbehaving function. > > It strikes me that list of lists is not a great board representation. I > think STArrays are a better pick; from the perspective of translating an > NxN array into Haskell, at least. However, maybe there is an even more > elegant way to deal with a board in Haskell. I hope you can help me out > figuring it out. > > []'s > Rafael > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From corentin.dupont at gmail.com Fri Jun 20 15:38:32 2014 From: corentin.dupont at gmail.com (Corentin Dupont) Date: Fri, 20 Jun 2014 17:38:32 +0200 Subject: [Haskell-cafe] How to represent a board? In-Reply-To: References: Message-ID: Instead of encoding the board, I would encode the position of the pieces: there is usually much less pieces than squares. On Fri, Jun 20, 2014 at 5:33 PM, Bob Ippolito wrote: > I've used Data.Array or Data.Vector when trying to solve these sorts of > problems. The size of the board is not encoded in the type with either > library, but that's not something that's easy to do or commonly implemented > in Haskell. > > Data.Vector has better functionality, but the index is always an Int, so > Array can be more convenient in many cases as it can be indexed by any > instance of Ix. > > STArray, MVector, etc. are all options as well, but I prefer to write > functional solutions when possible. > > > On Fri, Jun 20, 2014 at 8:24 AM, Rafael Almeida > wrote: > >> Hello, >> >> There are many examples of games which use boards: chess, checkers, go, >> etc. Many people starting out at programming and/or game programming are >> very much tempted to code a board game. It looks like such a game would be >> easy to build at first sight. >> >> Even more sophisticated games sometimes use a grid system, which looks a >> lot like boards as well. In a grid system the movements of a given agent >> are bound do discrete positions. Although the user may not see the board >> underneath pretty graphics, it is a board game. >> >> Having in mind the sort of operations such games have to make on boards, >> I ask: what are the best representations for a board in Haskell? >> >> In many languages a NxN array seems like a good pick. In Haskell, most >> would translate that into lists of lists. I know I have. However, >> traversing those lists to get a position, calculate where a piece or agent >> could go, etc., feels awkward and unefficient. Beside the point already >> made, we have no type safe guarantee that our 64x64 won't become a 63x63 + >> 65x1 board due to some misbehaving function. >> >> It strikes me that list of lists is not a great board representation. I >> think STArrays are a better pick; from the perspective of translating an >> NxN array into Haskell, at least. However, maybe there is an even more >> elegant way to deal with a board in Haskell. I hope you can help me out >> figuring it out. >> >> []'s >> Rafael >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mystic.satvik at gmail.com Fri Jun 20 15:47:19 2014 From: mystic.satvik at gmail.com (satvik chauhan) Date: Fri, 20 Jun 2014 21:17:19 +0530 Subject: [Haskell-cafe] Do you recognize this type? In-Reply-To: References: <86egyjr5pm.fsf@gmail.com> Message-ID: I might be wrong but what is the problem in folding with the `SumEvent` over all the events? On Fri, Jun 20, 2014 at 8:40 PM, Corentin Dupont wrote: > > > > On Fri, Jun 20, 2014 at 4:55 PM, Chris Warburton < > chriswarbo at googlemail.com> wrote: > >> Corentin Dupont writes: >> >> > Nobody on that? >> > What I really want is: a computation that can be interrupted if enough >> > result is already there. >> > I would be surprise if that concept doesn't exist already somewhere :) >> >> I'd be surprised if this can be done with Applicative without some >> hackery. >> >> Very roughly, we can think of Functors as one-shot actions. For example, >> the IO instance of Functor lets us perform exactly 1 side-effect; all we >> can do with the result is map pure functions over it. >> >> Applicatives are a static chain of actions. For example, the IO instance >> of Applicative lets us chain together any number of side-effecting >> actions, but those actions can't alter the chain itself. >> >> Monads are a dynamic chain of actions. They're like Applicatives, but >> each action can choose which action to perform next based on the >> previous results. >> > > wow, I *love* this summary! Thanks for that! > > >> >> From this perspective, the "shortcut" you're looking for requires the >> ability to choose the next action (count another vote or finish >> prematurely) based on the previous results (the running total). That's >> what Monads are good for, but Applicatives can't do it by themselves. >> > > Indeed I could make my DSL a monad instance with some changes, that would > be easy to do. But even not a Monad cannot do the trick: imagine if in a > country, you were asking > the people to vote one by one, only to interrupt them when the result is > known. In fact they have to vote altogether, > in whatever order, and we count the votes as they arrive. > > So I think what I need is a sort of Applicative++: not a chain of actions > but a set of actions, all independent from each other (so no monad) and > with no particular order. > > > > >> >> There's probably an unsafe* way to do this, which will in fact be safe >> due to your voting invariant ("if there aren't enough uncounted votes >> to change the outcome, the outcome cannot change"). Maybe someone who's >> performed similar optimisations can help. >> >> Good luck! >> >> Chris >> > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From chriswarbo at googlemail.com Fri Jun 20 15:53:15 2014 From: chriswarbo at googlemail.com (Chris Warburton) Date: Fri, 20 Jun 2014 16:53:15 +0100 Subject: [Haskell-cafe] How to represent a board? In-Reply-To: (Alexander Vieth's message of "Fri, 20 Jun 2014 11:33:25 -0400") References: Message-ID: <8661jvr310.fsf@gmail.com> Alexander Vieth writes: >> In many languages a NxN array seems like a good pick. In Haskell, >> most would translate that into lists of lists. I know I >> have. However, traversing those lists to get a position, calculate >> where a piece or agent could go, etc., feels awkward and >> unefficient. Beside the point already made, we have no type safe >> guarantee that our 64x64 won't become a 63x63 + 65x1 board due to >> some misbehaving function. > > Perhaps choosing a zipper-like representation, in which all adjacent > places on your board can be found without any traversal, would make > the usage less awkward and more efficient. I thought of zippers too, although their simplicity suffers when moving from 1D lists to 2D lists-of-lists. Comonads are possibly related. They're certainly useful for cellular automata[1], which are effectively zero-player board games. [1] http://blog.sigfpe.com/2006/12/evaluating-cellular-automata-is.html Cheers, Chris From chriswarbo at googlemail.com Fri Jun 20 15:57:50 2014 From: chriswarbo at googlemail.com (Chris Warburton) Date: Fri, 20 Jun 2014 16:57:50 +0100 Subject: [Haskell-cafe] How to represent a board? In-Reply-To: (Corentin Dupont's message of "Fri, 20 Jun 2014 17:38:32 +0200") References: Message-ID: <861tujr2td.fsf@gmail.com> Corentin Dupont writes: > Instead of encoding the board, I would encode the position of the pieces: > there is usually much less pieces than squares. Possibly useful: http://en.wikipedia.org/wiki/Sparse_matrix Cheers, Chris From carter.schonwald at gmail.com Fri Jun 20 16:09:47 2014 From: carter.schonwald at gmail.com (Carter Schonwald) Date: Fri, 20 Jun 2014 12:09:47 -0400 Subject: [Haskell-cafe] How to represent a board? In-Reply-To: <861tujr2td.fsf@gmail.com> References: <861tujr2td.fsf@gmail.com> Message-ID: Unless you're dealing with a board with millions of positions or more, sparse matrices don't matter. The array package has support for 2d arrays. I've my own pretty fancy multi dim array tooling in the works, but for your use case just use array package On Friday, June 20, 2014, Chris Warburton wrote: > Corentin Dupont > writes: > > > Instead of encoding the board, I would encode the position of the pieces: > > there is usually much less pieces than squares. > > Possibly useful: http://en.wikipedia.org/wiki/Sparse_matrix > > Cheers, > Chris > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From corentin.dupont at gmail.com Fri Jun 20 16:11:28 2014 From: corentin.dupont at gmail.com (Corentin Dupont) Date: Fri, 20 Jun 2014 18:11:28 +0200 Subject: [Haskell-cafe] Do you recognize this type? In-Reply-To: References: <86egyjr5pm.fsf@gmail.com> Message-ID: I thinks that's the function asum: https://hackage.haskell.org/package/base-4.7.0.0/docs/src/Data-Foldable.html#asum What you obtain is an event that will yield the value of the first event to fire, effectively short-cutting the others! firstVote = asum [getVote1, getVote2, getVote3] I need something more or less similar but with a function that can tune exactly when the shortcut will happen. On Fri, Jun 20, 2014 at 5:47 PM, satvik chauhan wrote: > I might be wrong but what is the problem in folding with the `SumEvent` > over all the events? > > > On Fri, Jun 20, 2014 at 8:40 PM, Corentin Dupont < > corentin.dupont at gmail.com> wrote: > >> >> >> >> On Fri, Jun 20, 2014 at 4:55 PM, Chris Warburton < >> chriswarbo at googlemail.com> wrote: >> >>> Corentin Dupont writes: >>> >>> > Nobody on that? >>> > What I really want is: a computation that can be interrupted if enough >>> > result is already there. >>> > I would be surprise if that concept doesn't exist already somewhere :) >>> >>> I'd be surprised if this can be done with Applicative without some >>> hackery. >>> >>> Very roughly, we can think of Functors as one-shot actions. For example, >>> the IO instance of Functor lets us perform exactly 1 side-effect; all we >>> can do with the result is map pure functions over it. >>> >>> Applicatives are a static chain of actions. For example, the IO instance >>> of Applicative lets us chain together any number of side-effecting >>> actions, but those actions can't alter the chain itself. >>> >>> Monads are a dynamic chain of actions. They're like Applicatives, but >>> each action can choose which action to perform next based on the >>> previous results. >>> >> >> wow, I *love* this summary! Thanks for that! >> >> >>> >>> From this perspective, the "shortcut" you're looking for requires the >>> ability to choose the next action (count another vote or finish >>> prematurely) based on the previous results (the running total). That's >>> what Monads are good for, but Applicatives can't do it by themselves. >>> >> >> Indeed I could make my DSL a monad instance with some changes, that would >> be easy to do. But even not a Monad cannot do the trick: imagine if in a >> country, you were asking >> the people to vote one by one, only to interrupt them when the result is >> known. In fact they have to vote altogether, >> in whatever order, and we count the votes as they arrive. >> >> So I think what I need is a sort of Applicative++: not a chain of actions >> but a set of actions, all independent from each other (so no monad) and >> with no particular order. >> >> >> >> >>> >>> There's probably an unsafe* way to do this, which will in fact be safe >>> due to your voting invariant ("if there aren't enough uncounted votes >>> to change the outcome, the outcome cannot change"). Maybe someone who's >>> performed similar optimisations can help. >>> >>> Good luck! >>> >>> Chris >>> >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From daniel.trstenjak at gmail.com Fri Jun 20 16:12:10 2014 From: daniel.trstenjak at gmail.com (Daniel Trstenjak) Date: Fri, 20 Jun 2014 18:12:10 +0200 Subject: [Haskell-cafe] How to represent a board? In-Reply-To: References: Message-ID: <20140620161210.GA21419@machine> Hi Rafael, > Having in mind the sort of operations such games have to make on boards, I ask: > what are the best representations for a board in Haskell? What works pretty nicely is using a one dimensional Data.Vector[1] to represent your board, a tuple (x, y) to represent a position on the board and then using a lens[2] to transform the tuple (x, y) into an index of the one dimensional Data.Vector. You can then write code like: -- get board value at position (1, 2) board ^. atCoord (1, 2) -- set board value at position (1, 2) board & atCoord (1, 2) .~ newValue Having a one dimensional vector has the advantage, that's a lot nicer to e.g. map or fold over it. In the toy example hsbot[3] I used this kind of representation. Greetings, Daniel [1] https://hackage.haskell.org/package/vector [2] https://hackage.haskell.org/package/lens [3] https://github.com/dan-t/hsbot From edwards.benj at gmail.com Fri Jun 20 16:16:01 2014 From: edwards.benj at gmail.com (Benjamin Edwards) Date: Fri, 20 Jun 2014 09:16:01 -0700 (PDT) Subject: [Haskell-cafe] How to represent a board? In-Reply-To: <20140620161210.GA21419@machine> References: <20140620161210.GA21419@machine> Message-ID: <1403280961178.4600066f@Nodemailer> There is also the grid package on hackage that has support for a number of different grid shapes. Ben On Fri, Jun 20, 2014 at 5:12 PM, Daniel Trstenjak wrote: > Hi Rafael, >> Having in mind the sort of operations such games have to make on boards, I ask: >> what are the best representations for a board in Haskell? > What works pretty nicely is using a one dimensional Data.Vector[1] to represent > your board, a tuple (x, y) to represent a position on the board and then using > a lens[2] to transform the tuple (x, y) into an index of the one dimensional Data.Vector. > You can then write code like: > -- get board value at position (1, 2) > board ^. atCoord (1, 2) > -- set board value at position (1, 2) > board & atCoord (1, 2) .~ newValue > Having a one dimensional vector has the advantage, that's a lot nicer to e.g. map or fold over it. > In the toy example hsbot[3] I used this kind of representation. > Greetings, > Daniel > [1] https://hackage.haskell.org/package/vector > [2] https://hackage.haskell.org/package/lens > [3] https://github.com/dan-t/hsbot > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From aruiz at um.es Fri Jun 20 16:36:53 2014 From: aruiz at um.es (Alberto Ruiz) Date: Fri, 20 Jun 2014 18:36:53 +0200 Subject: [Haskell-cafe] ANN: hmatrix-0.16 Message-ID: <53A46325.7070709@um.es> Hi! I am happy to announce the release of hmatrix-0.16, a Haskell package for matrix computations and numeric linear algebra. New features: - BSD3 license. The modules depending on GSL have been moved to a new package hmatrix-gsl (GPL). Now hmatrix depends only on BLAS/LAPACK. - Simpler reexport modules with improved documentation and usage examples. There are a few API changes but the traditional modules are also exposed for backwards compatibility. - Alternative interface using type-level literals for static dimension checking and inference (work in progress). - Initial support for sparse linear systems. - Minor improvements and bug fixes (see the changelog for details). http://hackage.haskell.org/package/hmatrix https://github.com/albertoruiz/hmatrix Some examples: http://dis.um.es/~alberto/hmatrix/hmatrix.html Suggestions, contributions, and bug reports are welcome. Thanks! Alberto From david.sorokin at gmail.com Fri Jun 20 17:13:59 2014 From: david.sorokin at gmail.com (David Sorokin) Date: Fri, 20 Jun 2014 21:13:59 +0400 Subject: [Haskell-cafe] Do you recognize this type? In-Reply-To: References: Message-ID: <8306823C-82F5-4170-9B44-3192EF37E480@gmail.com> Hi Corentin, If I undestand your idea, then it is possible to do with help of continuations wrapped in a monad computation, at least with help of two continuations: (1) the main branch of computation; (2) the immediate cancellation if the result is already known. The approach is implemented in the F# async workflow (so called the asynchronous computation) and .. in my simulation library Aivika (to model the discontinuous process). Both are monads. Only like the F# developers, I use a plain cancellation without returning the meaningful result, but nothing prevents from returning some data. Also like F# my library supports the third continuation for handling exceptions, namely the IO exceptions in terms of Haskell. So, the keywords are: canceling the F# asynchronous computation. Best regards, David Sorokin 20 ???? 2014 ?., ? 16:59, Corentin Dupont ???????(?): > Nobody on that? > What I really want is: a computation that can be interrupted if enough result is already there. > I would be surprise if that concept doesn't exist already somewhere :) > > > On Thu, Jun 19, 2014 at 5:17 PM, Corentin Dupont wrote: > Hi guys, > I am making a DSL for event composition (inspired from digestive-functor & reactive-banana) and I find myself wanting a primitive like that: > > -- given a list of events, evaluate the function on those that have already fired. > -- returns an event yelding the result when ready. > ListEvent :: [Event a] -> ([a] -> Maybe b) -> Event b > > Does this type tell you something? Is there a better abstraction that can encompass it? > My DSL is like that: > > -- | Composable events > data Event a where > SumEvent :: Event a -> Event a -> Event a -- The first event to fire will be returned > AppEvent :: Event (a -> b) -> Event a -> Event b -- Both events should fire, and then the result is returned > PureEvent :: a -> Event a -- Create a fake event. The result is useable with no delay. > EmptyEvent :: Event a -- An event that is never fired. > BaseEvent :: (Typeable a) => Field a -> Event a -- Embed a base event > > It's easy to define instances for Applicative and Alternative. > But then I have a use case that I cannot solve: > In the case of votations (which use this DSL), sometime you can end prematuraly the voting, even if not everybody voted yet: for example if the majority is already reached. > In this case no need to wait for everybody, we can end the vote. > > This does not seem to be possible with Applicative or Monad interfaces: things have to be sequenced in a monad, they cannot be evaluated in parralel. > For example: > > do > v1 <- getVote1 > v2 <- getVote2 > v3 <- getVote3 > evalMajority(v1, v2, v3) > > In this example I have to wait for all 3 votes to be completed, but in fact only two would suffice to achieve majority. > That's why I added "ListEvent" to the DSL above which allow to achieve that but I'm wondering if there is a better/bigger abstraction to put it in. > > Thanks!! > Corentin > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From mail at joachim-breitner.de Fri Jun 20 20:30:29 2014 From: mail at joachim-breitner.de (Joachim Breitner) Date: Fri, 20 Jun 2014 13:30:29 -0700 Subject: [Haskell-cafe] diagrams In-Reply-To: <862F364A-317E-4BA6-AE00-233668E7B9AB@gmail.com> References: <862F364A-317E-4BA6-AE00-233668E7B9AB@gmail.com> Message-ID: <1403296229.16156.3.camel@kirk> Hi, Am Mittwoch, den 18.06.2014, 23:44 -0400 schrieb Anthony Cowley: > > I have no doubt that diagrams can make the diagrams themselves. What > > I wonder about is the animation capabilities---ability to have > > elements move or cross-fade (dissolve), in particular. I very recently created this animation with diagrams, which does move and fade stuff: http://joachim-breitner.de/publications/haskell_bytes_portland_2014-06-13.webm But the ride was not as smooth as it should have been. See https://gist.github.com/nomeata/cde96a2e693a23cca8ee for the code. The function positionSpec contains a ?script?, i.e. a sequence of animated modifications to the image, using lenses to position the change. I guess with the right combinators, this can be greatly simplified, but it is hard to come up with the right combinators. Especially as our code is one-dimensional, and we want to compose in three dimensions (x, y and time). Greetings, Joachim -- Joachim ?nomeata? Breitner mail at joachim-breitner.de ? http://www.joachim-breitner.de/ Jabber: nomeata at joachim-breitner.de ? GPG-Key: 0xF0FBF51F Debian Developer: nomeata at debian.org -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: This is a digitally signed message part URL: From dominic at steinitz.org Sun Jun 22 10:37:20 2014 From: dominic at steinitz.org (Dominic Steinitz) Date: Sun, 22 Jun 2014 10:37:20 +0000 (UTC) Subject: [Haskell-cafe] ANN: hmatrix-0.16 References: <53A46325.7070709@um.es> Message-ID: Alberto Ruiz um.es> writes: > > Hi! > > I am happy to announce the release of hmatrix-0.16, a Haskell package > for matrix computations and numeric linear algebra. > Very nice From dominic at steinitz.org Sun Jun 22 10:39:30 2014 From: dominic at steinitz.org (Dominic Steinitz) Date: Sun, 22 Jun 2014 11:39:30 +0100 Subject: [Haskell-cafe] =?utf-8?b?RndkOiDoh6rliqjlm57lpI3vvJpSZTogIEFOTjog?= =?utf-8?q?hmatrix-0=2E16?= References: <20140622103749.D289BCB0318@mda06.fmail.tg.sinanode.com> Message-ID: <6470E8F5-12A8-4774-BF92-BBEB209A336F@steinitz.org> Hello Cafe, Everytime I post something via gmane I get what I assume is spam - see below. Is this a gmane feature or a haskell-cafe feature? Dominic Steinitz dominic at steinitz.org http://idontgetoutmuch.wordpress.com Begin forwarded message: > From: > Subject: ?????Re: [Haskell-cafe] ANN: hmatrix-0.16 > Date: 22 June 2014 11:37:49 BST > To: > > ??????????????????? -------------- next part -------------- An HTML attachment was scrubbed... URL: From dominic at steinitz.org Sun Jun 22 10:47:30 2014 From: dominic at steinitz.org (Dominic Steinitz) Date: Sun, 22 Jun 2014 11:47:30 +0100 Subject: [Haskell-cafe] diagrams In-Reply-To: References: Message-ID: <66386D68-D9C5-4C97-9719-585D3CAED6F6@steinitz.org> > Message: 3 > Date: Fri, 20 Jun 2014 13:30:29 -0700 > From: Joachim Breitner > To: haskell-cafe at haskell.org > Subject: Re: [Haskell-cafe] diagrams > Message-ID: <1403296229.16156.3.camel at kirk> > Content-Type: text/plain; charset="utf-8" > > Hi, > > Am Mittwoch, den 18.06.2014, 23:44 -0400 schrieb Anthony Cowley: > >>> I have no doubt that diagrams can make the diagrams themselves. What >>> I wonder about is the animation capabilities---ability to have >>> elements move or cross-fade (dissolve), in particular. > > I very recently created this animation with diagrams, which does move > and fade stuff: > http://joachim-breitner.de/publications/haskell_bytes_portland_2014-06-13.webm > > But the ride was not as smooth as it should have been. See > https://gist.github.com/nomeata/cde96a2e693a23cca8ee for the code. The > function positionSpec contains a ?script?, i.e. a sequence of animated > modifications to the image, using lenses to position the change. > > I guess with the right combinators, this can be greatly simplified, but > it is hard to come up with the right combinators. Especially as our code > is one-dimensional, and we want to compose in three dimensions (x, y and > time). It?s still a nice example though - thanks for posting it. Dominic Steinitz dominic at steinitz.org http://idontgetoutmuch.wordpress.com From phil at cnphil.com Sun Jun 22 11:02:39 2014 From: phil at cnphil.com (Xiaojun "Phil" Hu) Date: Sun, 22 Jun 2014 19:02:39 +0800 Subject: [Haskell-cafe] =?utf-8?b?RndkOiDoh6rliqjlm57lpI3vvJpSZTogQU5OOiBo?= =?utf-8?q?matrix-0=2E16?= In-Reply-To: <6470E8F5-12A8-4774-BF92-BBEB209A336F@steinitz.org> References: <20140622103749.D289BCB0318@mda06.fmail.tg.sinanode.com> <6470E8F5-12A8-4774-BF92-BBEB209A336F@steinitz.org> Message-ID: It's an "auto-reply" feature popular among Chinese email providers. They just "auto-reply" any email they get. If wanna ignore this, you can just create a spam filter with "????" -- it means "auto-reply" in Mandarin. --- Phil On Sun, Jun 22, 2014 at 6:39 PM, Dominic Steinitz wrote: > Hello Cafe, > > Everytime I post something via gmane I get what I assume is spam - see > below. Is this a gmane feature or a haskell-cafe feature? > > Dominic Steinitz > dominic at steinitz.org > http://idontgetoutmuch.wordpress.com > > Begin forwarded message: > > *From: * > *Subject: **?????Re: [Haskell-cafe] ANN: hmatrix-0.16* > *Date: *22 June 2014 11:37:49 BST > *To: * > > ??????????????????? > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From muranushi at gmail.com Sun Jun 22 17:43:29 2014 From: muranushi at gmail.com (Takayuki Muranushi) Date: Mon, 23 Jun 2014 02:43:29 +0900 Subject: [Haskell-cafe] ANN: set-cover solves Sudoku, Soma cube, 8 Queens etc. In-Reply-To: <522C8795.3030004@imn.htwk-leipzig.de> References: <522C8795.3030004@imn.htwk-leipzig.de> Message-ID: Hi, I'm also one of the guys strongly attracted by this package. It seems to provide elegant interface for problems that requires elaborate solvers. I feel that set-cover will grow to one of a swiss-army-knife tool like SMT solver DSLs. I have several application problems in my idea list that can be reduced to set cover problems. I've been testing this set-cover for a while, however, me too am finding it hard to understand the library. Although the coherent choices of names and types makes great clues, additional documentation in natural language might help in better understanding. I wish to see some articles of set-cover API and examples, when your time allows. Best regards, Takayuki. 2013-09-08 23:20 GMT+09:00 Johannes Waldmann : > Henning Thielemann henning-thielemann.de> writes: > >> .. package set-cover for solving exact set cover problems. >> http://hackage.haskell.org/package/set-cover > > It's hard to evaluate whether one could use the library > because there's essentially no visible documentation. > > E.g., what does Math.SetCover.Exact.search do? > Its type refers to "State" which seems implementation-dependent, > and hides the connection to the specification of the set cover problem. > > Putting some text and examples into the haddocks might help. > But of course putting the specification there would be even better. > > Also, care to explain what algorithm your solver uses, > and give some performance data (e.g., N-queens for N=10,20,40,..)? > > - J.W. > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From leilmyxwz at gmail.com Sun Jun 22 20:49:26 2014 From: leilmyxwz at gmail.com (bruce li) Date: Sun, 22 Jun 2014 16:49:26 -0400 Subject: [Haskell-cafe] Problems with Parallel N Queens using Control.Parallel.Strategy Message-ID: Hello, Cafe, I'm currently reading Parallel and Concurrent Programming in Haskell. I tried to implement an n-queens problem as an exercise, but a little bit overwhelmed by the strategy mystery. The code is listed at http://pastebin.com/ySgc3VSR. I implemented the higher order skeleton of search and try to add parallelism. My original idea was spawning a few threads while the search tree was small and each thread handles the following expansion of the tree. Hence, I gave a "maxDepth" variable to restrict the parallelism. But this did not go very well if I set the maxDepth to very small value, say, 2, 3, 4 etc. The speed up was very small. Viewing in threadscope, it seems there was very small amount of parallelism. Then I tried to let it go, which means I set the tree depth to a value larger than the maximum possible depth, say 20. Then it speeds up about 1.4 times on 2-cores. Viewing in threadscope, it seems the 2 cores are fully utilized. But the report is a bit annoying: SPARKS: 4686728 (100456 converted, 3461 overflowed, 0 dud, 4540817 GC'd, 41994 fizzled) with no restrictions on the parallelism, a lot of sparks are not converted and are GC'd. I wonder if there is some way to further improve the results, reducing un-convereted sparks and achieving better speed-up ratio. Thanks. From erantapaa at gmail.com Mon Jun 23 03:24:35 2014 From: erantapaa at gmail.com (Erik Rantapaa) Date: Sun, 22 Jun 2014 20:24:35 -0700 (PDT) Subject: [Haskell-cafe] hayoo doesn't find the Kleisli arrow? Message-ID: <4c59c17a-4fea-4f4b-a52f-41dd46ba6b13@googlegroups.com> I just happen to notice that this query comes back empty in Hayoo: (a -> m b) -> (b -> m c) -> (a -> m c) Hoogle is able to find (>=>), and I'm wondering if its a bug or...? -------------- next part -------------- An HTML attachment was scrubbed... URL: From magicloud.magiclouds at gmail.com Mon Jun 23 03:34:22 2014 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Mon, 23 Jun 2014 11:34:22 +0800 Subject: [Haskell-cafe] cabal-install failure Message-ID: Hi, This is a box that used to work well. But today, I found that I could not install anything by cabal. I removed ~/.ghc and ~/.cabal to start all userspace thing from the beginning. I used Setup.hs to install Cabal, and bootstrap.sh to install cabal-install. All succeeded. Then I tried to install data-default-class, I got following. Notice the ld fail near the end. Versions: OS: Ubuntu Precise; ghc 7.8.2; Cabal/cabal-install: latest from github. % cabal install -v3 data-default-class Searching for ghc in path. Found ghc at /usr/local/bin/ghc ("/usr/local/bin/ghc",["--numeric-version"]) /usr/local/bin/ghc is version 7.8.2 looking for tool ghc-pkg near compiler in /usr/local/bin found ghc-pkg in /usr/local/bin/ghc-pkg ("/usr/local/bin/ghc-pkg",["--version"]) /usr/local/bin/ghc-pkg is version 7.8.2 ("/usr/local/bin/ghc",["--supported-languages"]) ("/usr/local/bin/ghc",["--info"]) Reading installed packages... ("/usr/local/bin/ghc-pkg",["dump","--global","-v0"]) ("/usr/local/bin/ghc-pkg",["dump","--user","-v0"]) ("/usr/local/bin/ghc",["--print-libdir"]) Reading available packages... Warning: The package list for the local repo '/home/local/ANT/shida/.cabal/packages/cabal-src/' is missing. The repo is invalid. Resolving dependencies... targets: data-default-class constraints: base installed ghc-prim installed integer-gmp installed stanzas data-default-class preferences: strategy: PreferAllLatest [__0] trying: data-default-class-0.0.1 (user goal) [__1] trying: base-4.7.0.0/installed-018... (dependency of data-default-class-0.0.1) [__2] trying: rts-1.0/installedbuil... (dependency of base-4.7.0.0/installed-018...) [__3] trying: integer-gmp-0.5.1.0/installed-dc4... (dependency of base-4.7.0.0/installed-018...) [__4] next goal: ghc-prim (dependency of base-4.7.0.0/installed-018...) [__4] trying: ghc-prim-0.3.1.0/installed-948... [__5] done Ready to install data-default-class-0.0.1 Waiting for install task to finish... Extracting /home/local/ANT/shida/.cabal/packages/ hackage.haskell.org/data-default-class/0.0.1/data-default-class-0.0.1.tar.gz to /tmp/data-default-class-0.0.1-19534... Updating data-default-class.cabal with the latest revision from the index. Using internal setup method with build-type Simple and args: ["configure","--verbose=3","--ghc","--prefix=/home/local/ANT/shida/.cabal","--bindir=/home/local/ANT/shida/.cabal/bin","--libdir=/home/local/ANT/shida/.cabal/lib","--libsubdir=x86_64-linux-ghc-7.8.2/data-default-class-0.0.1","--libexecdir=/home/local/ANT/shida/.cabal/libexec","--datadir=/home/local/ANT/shida/.cabal/share","--datasubdir=x86_64-linux-ghc-7.8.2/data-default-class-0.0.1","--docdir=/home/local/ANT/shida/.cabal/share/doc/x86_64-linux-ghc-7.8.2/data-default-class-0.0.1","--htmldir=/home/local/ANT/shida/.cabal/share/doc/x86_64-linux-ghc-7.8.2/data-default-class-0.0.1/html","--haddockdir=/home/local/ANT/shida/.cabal/share/doc/x86_64-linux-ghc-7.8.2/data-default-class-0.0.1/html","--sysconfdir=/home/local/ANT/shida/.cabal/etc","--enable-split-objs","--user","--dependency=base=base-4.7.0.0-018311399e3b6350d5be3a16b144df9b","--disable-tests","--exact-configuration","--disable-benchmarks"] Configuring data-default-class-0.0.1... creating dist Searching for ghc in path. Found ghc at /usr/local/bin/ghc ("/usr/local/bin/ghc",["--numeric-version"]) /usr/local/bin/ghc is version 7.8.2 looking for tool ghc-pkg near compiler in /usr/local/bin found ghc-pkg in /usr/local/bin/ghc-pkg ("/usr/local/bin/ghc-pkg",["--version"]) /usr/local/bin/ghc-pkg is version 7.8.2 ("/usr/local/bin/ghc",["--supported-languages"]) ("/usr/local/bin/ghc",["--info"]) Reading installed packages... ("/usr/local/bin/ghc-pkg",["dump","--global","-v0"]) ("/usr/local/bin/ghc-pkg",["dump","--user","-v0"]) ("/usr/local/bin/ghc",["--print-libdir"]) Dependency base ==4.7.0.0: using base-4.7.0.0 Searching for alex in path. Cannot find alex on the path Searching for ar in path. Found ar at /usr/bin/ar Searching for c2hs in path. Cannot find c2hs on the path Searching for cpphs in path. Cannot find cpphs on the path Searching for ffihugs in path. Cannot find ffihugs on the path Searching for gcc in path. Found gcc at /usr/bin/gcc ("/usr/bin/gcc",["-dumpversion"]) /usr/bin/gcc is version 4.6 Searching for greencard in path. Cannot find greencard on the path Searching for haddock in path. Found haddock at /usr/local/bin/haddock ("/usr/local/bin/haddock",["--version"]) /usr/local/bin/haddock is version 2.14.2 Searching for happy in path. Cannot find happy on the path Searching for hmake in path. Cannot find hmake on the path Searching for hpc in path. Found hpc at /usr/local/bin/hpc ("/usr/local/bin/hpc",["version"]) /usr/local/bin/hpc is version 0.67 looking for tool hsc2hs near compiler in /usr/local/bin found hsc2hs in /usr/local/bin/hsc2hs ("/usr/local/bin/hsc2hs",["--version"]) /usr/local/bin/hsc2hs is version 0.67 Searching for HsColour in path. Cannot find HsColour on the path Searching for hugs in path. Cannot find hugs on the path Searching for jhc in path. Cannot find jhc on the path Searching for ld in path. Found ld at /usr/bin/ld Environment: [("COLORFGBG","12;default;8"),("COLORTERM","rxvt-xpm"),("DBUS_SESSION_BUS_ADDRESS","unix:abstract=/tmp/dbus-5El0U8sCi8,guid=09290436e309789f9814dffc00000406"),("DEFAULTS_PATH","/usr/share/gconf/xmonad.default.path"),("DESKTOP_SESSION","xmonad"),("DISPLAY"," 10.69.208.185:0"),("EDITOR","vim"),("GDMSESSION","xmonad"),("GPG_AGENT_INFO","/tmp/gpg-KKH3WT/S.gpg-agent:5467:1"),("GREP_COLOR","1;32"),("GREP_OPTIONS","--color=auto --exclude-dir=.cvs --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn"),("GTK_IM_MODULE","xim"),("HOME","/home/local/ANT/shida"),("LANG","C.UTF-8"),("LC_ALL","C.UTF-8"),("LC_CTYPE","C.UTF-8"),("LESS","-R"),("LOGNAME","shida"),("LSCOLORS","Gxfxcxdxbxegedabagacad"),("MANDATORY_PATH","/usr/share/gconf/xmonad.mandatory.path"),("NODE_PATH","/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript"),("OLDPWD","/home/local/ANT/shida/src/git/cabal/cabal-install"),("PAGER","less"),("PATH","/usr/local/heroku/bin:.:/home/local/ANT/shida/.cabal/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/lightdm/lightdm:/usr/local/bin:/usr/bin:/bin"),("PULSE_SERVER","10.69.208.185"),("PWD","/home/local/ANT/shida"),("QT_IM_MODULE","xim"),("SHELL","/usr/bin/zsh"),("SHLVL","1"),("SSH_AGENT_PID","14748"),("SSH_AUTH_SOCK","/tmp/ssh-NeRVrYb14746/agent.14746"),("TERM","rxvt-unicode-256color"),("UBUNTU_MENUPROXY","libappmenu.so"),("USER","shida"),("VISUAL","vim"),("WINDOWID","14683293"),("XAUTHORITY","/home/local/ANT/shida/.Xauthority"),("XDG_CONFIG_DIRS","/etc/xdg/xdg-xmonad:/etc/xdg"),("XDG_DATA_DIRS","/usr/share/xmonad:/usr/local/share/:/usr/share/"),("XDG_SEAT_PATH","/org/freedesktop/DisplayManager/Seat1"),("XDG_SESSION_COOKIE","05ca21f0ee7e6a10e18260ac00001d83-1402975930.974487-843139146"),("XDG_SESSION_PATH","/org/freedesktop/DisplayManager/Session0"),("XMODIFIERS","@im=ibus"),("ZSH","/home/local/ANT/shida/.oh-my-zsh"),("_","/home/local/ANT/shida/.cabal/bin/cabal")] ("/usr/local/bin/ghc",["-c","/tmp/19534.c","-o","/tmp/19534.o"]) ("/usr/bin/ld",["-x","-r","/tmp/19534.o","-o","/tmp/19535.o"]) Searching for lhc in path. Cannot find lhc on the path Searching for lhc-pkg in path. Cannot find lhc-pkg on the path Searching for nhc98 in path. Cannot find nhc98 on the path Searching for pkg-config in path. Found pkg-config at /usr/bin/pkg-config ("/usr/bin/pkg-config",["--version"]) /usr/bin/pkg-config is version 0.26 Searching for strip in path. Found strip at /usr/bin/strip Searching for tar in path. Found tar at /bin/tar Searching for uhc in path. Cannot find uhc on the path Using Cabal-1.21.0.0 compiled by ghc-7.8 Using compiler: ghc-7.8.2 Using install prefix: /home/local/ANT/shida/.cabal Binaries installed in: /home/local/ANT/shida/.cabal/bin Libraries installed in: /home/local/ANT/shida/.cabal/lib/x86_64-linux-ghc-7.8.2/data-default-class-0.0.1 Private binaries installed in: /home/local/ANT/shida/.cabal/libexec Data files installed in: /home/local/ANT/shida/.cabal/share/x86_64-linux-ghc-7.8.2/data-default-class-0.0.1 Documentation installed in: /home/local/ANT/shida/.cabal/share/doc/x86_64-linux-ghc-7.8.2/data-default-class-0.0.1 Configuration files installed in: /home/local/ANT/shida/.cabal/etc No alex found Using ar found on system at: /usr/bin/ar No c2hs found No cpphs found No ffihugs found Using gcc version 4.6 found on system at: /usr/bin/gcc Using ghc version 7.8.2 found on system at: /usr/local/bin/ghc Using ghc-pkg version 7.8.2 found on system at: /usr/local/bin/ghc-pkg No greencard found Using haddock version 2.14.2 found on system at: /usr/local/bin/haddock No happy found Using haskell-suite found on system at: haskell-suite-dummy-location Using haskell-suite-pkg found on system at: haskell-suite-pkg-dummy-location No hmake found Using hpc version 0.67 found on system at: /usr/local/bin/hpc Using hsc2hs version 0.67 found on system at: /usr/local/bin/hsc2hs No hscolour found No hugs found No jhc found Using ld found on system at: /usr/bin/ld No lhc found No lhc-pkg found No nhc98 found Using pkg-config version 0.26 found on system at: /usr/bin/pkg-config Using strip found on system at: /usr/bin/strip Using tar found on system at: /bin/tar No uhc found ("/usr/bin/gcc",["/tmp/19534.c","-o","/tmp/19534","-D__GLASGOW_HASKELL__=708","-Dlinux_BUILD_OS=1","-Dx86_64_BUILD_ARCH=1","-Dlinux_HOST_OS=1","-Dx86_64_HOST_ARCH=1","-Idist/build/autogen","-I.","-I/usr/local/lib/ghc-7.8.2/base-4.7.0.0/include","-I/usr/local/lib/ghc-7.8.2/integer-gmp-0.5.1.0/include","-I/usr/local/lib/ghc-7.8.2/include","-L/usr/local/lib/ghc-7.8.2/base-4.7.0.0","-L/usr/local/lib/ghc-7.8.2/integer-gmp-0.5.1.0","-L/usr/local/lib/ghc-7.8.2/ghc-prim-0.3.1.0","-L/usr/local/lib/ghc-7.8.2/rts-1.0"]) Using internal setup method with build-type Simple and args: ["build","--verbose=3"] Component build order: library creating dist/build creating dist/build/autogen Building data-default-class-0.0.1... Preprocessing library data-default-class-0.0.1... Building library... creating dist/build Environment: [("COLORFGBG","12;default;8"),("COLORTERM","rxvt-xpm"),("DBUS_SESSION_BUS_ADDRESS","unix:abstract=/tmp/dbus-5El0U8sCi8,guid=09290436e309789f9814dffc00000406"),("DEFAULTS_PATH","/usr/share/gconf/xmonad.default.path"),("DESKTOP_SESSION","xmonad"),("DISPLAY"," 10.69.208.185:0"),("EDITOR","vim"),("GDMSESSION","xmonad"),("GPG_AGENT_INFO","/tmp/gpg-KKH3WT/S.gpg-agent:5467:1"),("GREP_COLOR","1;32"),("GREP_OPTIONS","--color=auto --exclude-dir=.cvs --exclude-dir=.git --exclude-dir=.hg --exclude-dir=.svn"),("GTK_IM_MODULE","xim"),("HOME","/home/local/ANT/shida"),("LANG","C.UTF-8"),("LC_ALL","C.UTF-8"),("LC_CTYPE","C.UTF-8"),("LESS","-R"),("LOGNAME","shida"),("LSCOLORS","Gxfxcxdxbxegedabagacad"),("MANDATORY_PATH","/usr/share/gconf/xmonad.mandatory.path"),("NODE_PATH","/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript"),("OLDPWD","/home/local/ANT/shida/src/git/cabal/cabal-install"),("PAGER","less"),("PATH","/usr/local/heroku/bin:.:/home/local/ANT/shida/.cabal/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/lightdm/lightdm:/usr/local/bin:/usr/bin:/bin"),("PULSE_SERVER","10.69.208.185"),("PWD","/home/local/ANT/shida"),("QT_IM_MODULE","xim"),("SHELL","/usr/bin/zsh"),("SHLVL","1"),("SSH_AGENT_PID","14748"),("SSH_AUTH_SOCK","/tmp/ssh-NeRVrYb14746/agent.14746"),("TERM","rxvt-unicode-256color"),("UBUNTU_MENUPROXY","libappmenu.so"),("USER","shida"),("VISUAL","vim"),("WINDOWID","14683293"),("XAUTHORITY","/home/local/ANT/shida/.Xauthority"),("XDG_CONFIG_DIRS","/etc/xdg/xdg-xmonad:/etc/xdg"),("XDG_DATA_DIRS","/usr/share/xmonad:/usr/local/share/:/usr/share/"),("XDG_SEAT_PATH","/org/freedesktop/DisplayManager/Seat1"),("XDG_SESSION_COOKIE","05ca21f0ee7e6a10e18260ac00001d83-1402975930.974487-843139146"),("XDG_SESSION_PATH","/org/freedesktop/DisplayManager/Session0"),("XMODIFIERS","@im=ibus"),("ZSH","/home/local/ANT/shida/.oh-my-zsh"),("_","/home/local/ANT/shida/.cabal/bin/cabal")] ("/usr/local/bin/ghc",["--make","-v","-fbuilding-cabal-package","-O","-split-objs","-static","-dynamic-too","-dynosuf","dyn_o","-dynhisuf","dyn_hi","-outputdir","dist/build","-odir","dist/build","-hidir","dist/build","-stubdir","dist/build","-i","-idist/build","-i.","-idist/build/autogen","-Idist/build/autogen","-Idist/build","-optP-include","-optPdist/build/autogen/cabal_macros.h","-package-name","data-default-class-0.0.1","-hide-all-packages","-package-db","dist/package.conf.inplace","-package-id","base-4.7.0.0-018311399e3b6350d5be3a16b144df9b","-XHaskell98","Data.Default.Class"]) Glasgow Haskell Compiler, Version 7.8.2, stage 2 booted by GHC version 7.8.1 Using binary package database: /usr/local/lib/ghc-7.8.2/package.conf.d/package.cache Using binary package database: /home/local/ANT/shida/.ghc/x86_64-linux-7.8.2/package.conf.d/package.cache Using package config file: dist/package.conf.inplace wired-in package ghc-prim mapped to ghc-prim-0.3.1.0-948744e1f99cc8bcc7c7d3ba60c7c2d8 wired-in package integer-gmp mapped to integer-gmp-0.5.1.0-dc47f6b546fc171f67a7f7d311684a99 wired-in package base mapped to base-4.7.0.0-018311399e3b6350d5be3a16b144df9b wired-in package rts mapped to builtin_rts wired-in package template-haskell mapped to template-haskell-2.9.0.0-dcc8c210fb02937e104bc1784d7b0f06 wired-in package dph-seq not found. wired-in package dph-par not found. Hsc static flags: wired-in package ghc-prim mapped to ghc-prim-0.3.1.0-948744e1f99cc8bcc7c7d3ba60c7c2d8 wired-in package integer-gmp mapped to integer-gmp-0.5.1.0-dc47f6b546fc171f67a7f7d311684a99 wired-in package base mapped to base-4.7.0.0-018311399e3b6350d5be3a16b144df9b wired-in package rts mapped to builtin_rts wired-in package template-haskell mapped to template-haskell-2.9.0.0-dcc8c210fb02937e104bc1784d7b0f06 wired-in package dph-seq not found. wired-in package dph-par not found. *** Chasing dependencies: Chasing modules from: *Data.Default.Class Stable obj: [] Stable BCO: [] Ready for upsweep [NONREC ModSummary { ms_hs_date = 2014-06-23 03:29:30.794067064 UTC ms_mod = data-default-class-0.0.1:Data.Default.Class, ms_textual_imps = [import (implicit) Prelude] ms_srcimps = [] }] *** Deleting temp files: Deleting: compile: input file ./Data/Default/Class.hs Created temporary directory: /tmp/ghc19596_0 *** Checking old interface for data-default-class-0.0.1:Data.Default.Class: [1 of 1] Compiling Data.Default.Class ( Data/Default/Class.hs, dist/build/Data/Default/Class.o ) *** Parser: *** Renamer/typechecker: *** Desugar: Result size of Desugar (after optimization) = {terms: 0, types: 0, coercions: 0} *** Simplifier: Result size of Simplifier = {terms: 0, types: 0, coercions: 0} *** Specialise: Result size of Specialise = {terms: 0, types: 0, coercions: 0} *** Float out(FOS {Lam = Just 0, Consts = True, PAPs = False}): Result size of Float out(FOS {Lam = Just 0, Consts = True, PAPs = False}) = {terms: 0, types: 0, coercions: 0} *** Float inwards: Result size of Float inwards = {terms: 0, types: 0, coercions: 0} *** Simplifier: Result size of Simplifier = {terms: 0, types: 0, coercions: 0} *** Simplifier: Result size of Simplifier = {terms: 0, types: 0, coercions: 0} *** Simplifier: Result size of Simplifier = {terms: 0, types: 0, coercions: 0} *** Demand analysis: Result size of Demand analysis = {terms: 0, types: 0, coercions: 0} *** Worker Wrapper binds: Result size of Worker Wrapper binds = {terms: 0, types: 0, coercions: 0} *** Simplifier: Result size of Simplifier = {terms: 0, types: 0, coercions: 0} *** Float out(FOS {Lam = Just 0, Consts = True, PAPs = True}): Result size of Float out(FOS {Lam = Just 0, Consts = True, PAPs = True}) = {terms: 0, types: 0, coercions: 0} *** Common sub-expression: Result size of Common sub-expression = {terms: 0, types: 0, coercions: 0} *** Float inwards: Result size of Float inwards = {terms: 0, types: 0, coercions: 0} *** Simplifier: Result size of Simplifier = {terms: 0, types: 0, coercions: 0} *** Tidy Core: Result size of Tidy Core = {terms: 4, types: 7, coercions: 2} writeBinIface: 2 Names writeBinIface: 16 dict entries writeBinIface: 2 Names writeBinIface: 16 dict entries *** CorePrep: Result size of CorePrep = {terms: 4, types: 7, coercions: 2} *** Stg2Stg: *** CodeOutput: *** New CodeGen: *** CPSZ: *** CPSZ: *** Splitter: /usr/local/lib/ghc-7.8.2/ghc-split /tmp/ghc19596_0/ghc19596_2.split_s /tmp/ghc19596_0/ghc19596_4.split /tmp/ghc19596_0/ghc19596_4.split *** Assembler: /usr/bin/gcc -fno-stack-protector -DTABLES_NEXT_TO_CODE -c -o dist/build/Data/Default/Class_o_split/Class__1.o /tmp/ghc19596_0/ghc19596_4.split__1.s *** Assembler: /usr/bin/gcc -fno-stack-protector -DTABLES_NEXT_TO_CODE -c -o dist/build/Data/Default/Class_o_split/Class__2.o /tmp/ghc19596_0/ghc19596_4.split__2.s *** Linker: /usr/bin/gcc -fno-stack-protector -DTABLES_NEXT_TO_CODE -nostdlib -Wl,-r -nodefaultlibs '-Wl,--build-id=none' -o dist/build/Data/Default/Class.o /tmp/ghc19596_0/ghc19596_5.ldscript /usr/bin/ld: error: cannot find dist/build/Data/Default/Class_o_split/Class__1.o /usr/bin/ld: error: cannot find dist/build/Data/Default/Class_o_split/.o::Class(void) collect2: ld returned 1 exit status *** Deleting temp files: Deleting: /tmp/ghc19596_0/ghc19596_5.ldscript /tmp/ghc19596_0/ghc19596_4.split__1.s /tmp/ghc19596_0/ghc19596_4.split__2.s /tmp/ghc19596_0/ghc19596_4.split /tmp/ghc19596_0/ghc19596_3.c /tmp/ghc19596_0/ghc19596_2.split_s /tmp/ghc19596_0/ghc19596_1.split_s Warning: deleting non-existent /tmp/ghc19596_0/ghc19596_3.c Warning: deleting non-existent /tmp/ghc19596_0/ghc19596_1.split_s *** Deleting temp dirs: Deleting: /tmp/ghc19596_0 /usr/local/bin/ghc returned ExitFailure 1 Failed to install data-default-class-0.0.1 Updating world file... cabal: Error: some packages failed to install: data-default-class-0.0.1 failed during the building phase. The exception was: ExitFailure 1 -- ??????? ??????? And for G+, please use magiclouds#gmail.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: From magicloud.magiclouds at gmail.com Mon Jun 23 04:11:36 2014 From: magicloud.magiclouds at gmail.com (Magicloud Magiclouds) Date: Mon, 23 Jun 2014 12:11:36 +0800 Subject: [Haskell-cafe] cabal-install failure In-Reply-To: References: Message-ID: I see. GNU tools upgrading used ld.gold to replace ld, which broke ghc, thus cabal. On Mon, Jun 23, 2014 at 11:34 AM, Magicloud Magiclouds < magicloud.magiclouds at gmail.com> wrote: > Hi, > > This is a box that used to work well. But today, I found that I could > not install anything by cabal. > > I removed ~/.ghc and ~/.cabal to start all userspace thing from the > beginning. > > I used Setup.hs to install Cabal, and bootstrap.sh to install > cabal-install. All succeeded. > > Then I tried to install data-default-class, I got following. Notice the > ld fail near the end. > > Versions: OS: Ubuntu Precise; ghc 7.8.2; Cabal/cabal-install: latest > from github. > > % cabal install -v3 data-default-class > Searching for ghc in path. > Found ghc at /usr/local/bin/ghc > ("/usr/local/bin/ghc",["--numeric-version"]) > /usr/local/bin/ghc is version 7.8.2 > looking for tool ghc-pkg near compiler in /usr/local/bin > found ghc-pkg in /usr/local/bin/ghc-pkg > ("/usr/local/bin/ghc-pkg",["--version"]) > /usr/local/bin/ghc-pkg is version 7.8.2 > ("/usr/local/bin/ghc",["--supported-languages"]) > ("/usr/local/bin/ghc",["--info"]) > Reading installed packages... > ("/usr/local/bin/ghc-pkg",["dump","--global","-v0"]) > ("/usr/local/bin/ghc-pkg",["dump","--user","-v0"]) > ("/usr/local/bin/ghc",["--print-libdir"]) > Reading available packages... > Warning: The package list for the local repo > '/home/local/ANT/shida/.cabal/packages/cabal-src/' is missing. The repo is > invalid. > Resolving dependencies... > targets: data-default-class > constraints: > base installed > ghc-prim installed > integer-gmp installed > stanzas data-default-class > preferences: > strategy: PreferAllLatest > [__0] trying: data-default-class-0.0.1 (user goal) > [__1] trying: base-4.7.0.0/installed-018... (dependency of > data-default-class-0.0.1) > [__2] trying: rts-1.0/installedbuil... (dependency of > base-4.7.0.0/installed-018...) > [__3] trying: integer-gmp-0.5.1.0/installed-dc4... (dependency of > base-4.7.0.0/installed-018...) > [__4] next goal: ghc-prim (dependency of base-4.7.0.0/installed-018...) > [__4] trying: ghc-prim-0.3.1.0/installed-948... > [__5] done > Ready to install data-default-class-0.0.1 > Waiting for install task to finish... > Extracting > /home/local/ANT/shida/.cabal/packages/ > hackage.haskell.org/data-default-class/0.0.1/data-default-class-0.0.1.tar.gz > to /tmp/data-default-class-0.0.1-19534... > Updating data-default-class.cabal with the latest revision from the index. > Using internal setup method with build-type Simple and args: > > ["configure","--verbose=3","--ghc","--prefix=/home/local/ANT/shida/.cabal","--bindir=/home/local/ANT/shida/.cabal/bin","--libdir=/home/local/ANT/shida/.cabal/lib","--libsubdir=x86_64-linux-ghc-7.8.2/data-default-class-0.0.1","--libexecdir=/home/local/ANT/shida/.cabal/libexec","--datadir=/home/local/ANT/shida/.cabal/share","--datasubdir=x86_64-linux-ghc-7.8.2/data-default-class-0.0.1","--docdir=/home/local/ANT/shida/.cabal/share/doc/x86_64-linux-ghc-7.8.2/data-default-class-0.0.1","--htmldir=/home/local/ANT/shida/.cabal/share/doc/x86_64-linux-ghc-7.8.2/data-default-class-0.0.1/html","--haddockdir=/home/local/ANT/shida/.cabal/share/doc/x86_64-linux-ghc-7.8.2/data-default-class-0.0.1/html","--sysconfdir=/home/local/ANT/shida/.cabal/etc","--enable-split-objs","--user","--dependency=base=base-4.7.0.0-018311399e3b6350d5be3a16b144df9b","--disable-tests","--exact-configuration","--disable-benchmarks"] > Configuring data-default-class-0.0.1... > creating dist > Searching for ghc in path. > Found ghc at /usr/local/bin/ghc > ("/usr/local/bin/ghc",["--numeric-version"]) > /usr/local/bin/ghc is version 7.8.2 > looking for tool ghc-pkg near compiler in /usr/local/bin > found ghc-pkg in /usr/local/bin/ghc-pkg > ("/usr/local/bin/ghc-pkg",["--version"]) > /usr/local/bin/ghc-pkg is version 7.8.2 > ("/usr/local/bin/ghc",["--supported-languages"]) > ("/usr/local/bin/ghc",["--info"]) > Reading installed packages... > ("/usr/local/bin/ghc-pkg",["dump","--global","-v0"]) > ("/usr/local/bin/ghc-pkg",["dump","--user","-v0"]) > ("/usr/local/bin/ghc",["--print-libdir"]) > Dependency base ==4.7.0.0: using base-4.7.0.0 > Searching for alex in path. > Cannot find alex on the path > Searching for ar in path. > Found ar at /usr/bin/ar > Searching for c2hs in path. > Cannot find c2hs on the path > Searching for cpphs in path. > Cannot find cpphs on the path > Searching for ffihugs in path. > Cannot find ffihugs on the path > Searching for gcc in path. > Found gcc at /usr/bin/gcc > ("/usr/bin/gcc",["-dumpversion"]) > /usr/bin/gcc is version 4.6 > Searching for greencard in path. > Cannot find greencard on the path > Searching for haddock in path. > Found haddock at /usr/local/bin/haddock > ("/usr/local/bin/haddock",["--version"]) > /usr/local/bin/haddock is version 2.14.2 > Searching for happy in path. > Cannot find happy on the path > Searching for hmake in path. > Cannot find hmake on the path > Searching for hpc in path. > Found hpc at /usr/local/bin/hpc > ("/usr/local/bin/hpc",["version"]) > /usr/local/bin/hpc is version 0.67 > looking for tool hsc2hs near compiler in /usr/local/bin > found hsc2hs in /usr/local/bin/hsc2hs > ("/usr/local/bin/hsc2hs",["--version"]) > /usr/local/bin/hsc2hs is version 0.67 > Searching for HsColour in path. > Cannot find HsColour on the path > Searching for hugs in path. > Cannot find hugs on the path > Searching for jhc in path. > Cannot find jhc on the path > Searching for ld in path. > Found ld at /usr/bin/ld > Environment: > [("COLORFGBG","12;default;8"),("COLORTERM","rxvt-xpm"),("DBUS_SESSION_BUS_ADDRESS","unix:abstract=/tmp/dbus-5El0U8sCi8,guid=09290436e309789f9814dffc00000406"),("DEFAULTS_PATH","/usr/share/gconf/xmonad.default.path"),("DESKTOP_SESSION","xmonad"),("DISPLAY"," > 10.69.208.185:0"),("EDITOR","vim"),("GDMSESSION","xmonad"),("GPG_AGENT_INFO","/tmp/gpg-KKH3WT/S.gpg-agent:5467:1"),("GREP_COLOR","1;32"),("GREP_OPTIONS","--color=auto > --exclude-dir=.cvs --exclude-dir=.git --exclude-dir=.hg > --exclude-dir=.svn"),("GTK_IM_MODULE","xim"),("HOME","/home/local/ANT/shida"),("LANG","C.UTF-8"),("LC_ALL","C.UTF-8"),("LC_CTYPE","C.UTF-8"),("LESS","-R"),("LOGNAME","shida"),("LSCOLORS","Gxfxcxdxbxegedabagacad"),("MANDATORY_PATH","/usr/share/gconf/xmonad.mandatory.path"),("NODE_PATH","/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript"),("OLDPWD","/home/local/ANT/shida/src/git/cabal/cabal-install"),("PAGER","less"),("PATH","/usr/local/heroku/bin:.:/home/local/ANT/shida/.cabal/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/lightdm/lightdm:/usr/local/bin:/usr/bin:/bin"),("PULSE_SERVER","10.69.208.185"),("PWD","/home/local/ANT/shida"),("QT_IM_MODULE","xim"),("SHELL","/usr/bin/zsh"),("SHLVL","1"),("SSH_AGENT_PID","14748"),("SSH_AUTH_SOCK","/tmp/ssh-NeRVrYb14746/agent.14746"),("TERM","rxvt-unicode-256color"),("UBUNTU_MENUPROXY","libappmenu.so"),("USER","shida"),("VISUAL","vim"),("WINDOWID","14683293"),("XAUTHORITY","/home/local/ANT/shida/.Xauthority"),("XDG_CONFIG_DIRS","/etc/xdg/xdg-xmonad:/etc/xdg"),("XDG_DATA_DIRS","/usr/share/xmonad:/usr/local/share/:/usr/share/"),("XDG_SEAT_PATH","/org/freedesktop/DisplayManager/Seat1"),("XDG_SESSION_COOKIE","05ca21f0ee7e6a10e18260ac00001d83-1402975930.974487-843139146"),("XDG_SESSION_PATH","/org/freedesktop/DisplayManager/Session0"),("XMODIFIERS","@im=ibus"),("ZSH","/home/local/ANT/shida/.oh-my-zsh"),("_","/home/local/ANT/shida/.cabal/bin/cabal")] > ("/usr/local/bin/ghc",["-c","/tmp/19534.c","-o","/tmp/19534.o"]) > ("/usr/bin/ld",["-x","-r","/tmp/19534.o","-o","/tmp/19535.o"]) > Searching for lhc in path. > Cannot find lhc on the path > Searching for lhc-pkg in path. > Cannot find lhc-pkg on the path > Searching for nhc98 in path. > Cannot find nhc98 on the path > Searching for pkg-config in path. > Found pkg-config at /usr/bin/pkg-config > ("/usr/bin/pkg-config",["--version"]) > /usr/bin/pkg-config is version 0.26 > Searching for strip in path. > Found strip at /usr/bin/strip > Searching for tar in path. > Found tar at /bin/tar > Searching for uhc in path. > Cannot find uhc on the path > Using Cabal-1.21.0.0 compiled by ghc-7.8 > Using compiler: ghc-7.8.2 > Using install prefix: /home/local/ANT/shida/.cabal > Binaries installed in: /home/local/ANT/shida/.cabal/bin > Libraries installed in: > > /home/local/ANT/shida/.cabal/lib/x86_64-linux-ghc-7.8.2/data-default-class-0.0.1 > Private binaries installed in: /home/local/ANT/shida/.cabal/libexec > Data files installed in: > > /home/local/ANT/shida/.cabal/share/x86_64-linux-ghc-7.8.2/data-default-class-0.0.1 > Documentation installed in: > > /home/local/ANT/shida/.cabal/share/doc/x86_64-linux-ghc-7.8.2/data-default-class-0.0.1 > Configuration files installed in: /home/local/ANT/shida/.cabal/etc > No alex found > Using ar found on system at: /usr/bin/ar > No c2hs found > No cpphs found > No ffihugs found > Using gcc version 4.6 found on system at: /usr/bin/gcc > Using ghc version 7.8.2 found on system at: /usr/local/bin/ghc > Using ghc-pkg version 7.8.2 found on system at: /usr/local/bin/ghc-pkg > No greencard found > Using haddock version 2.14.2 found on system at: /usr/local/bin/haddock > No happy found > Using haskell-suite found on system at: haskell-suite-dummy-location > Using haskell-suite-pkg found on system at: > haskell-suite-pkg-dummy-location > No hmake found > Using hpc version 0.67 found on system at: /usr/local/bin/hpc > Using hsc2hs version 0.67 found on system at: /usr/local/bin/hsc2hs > No hscolour found > No hugs found > No jhc found > Using ld found on system at: /usr/bin/ld > No lhc found > No lhc-pkg found > No nhc98 found > Using pkg-config version 0.26 found on system at: /usr/bin/pkg-config > Using strip found on system at: /usr/bin/strip > Using tar found on system at: /bin/tar > No uhc found > > ("/usr/bin/gcc",["/tmp/19534.c","-o","/tmp/19534","-D__GLASGOW_HASKELL__=708","-Dlinux_BUILD_OS=1","-Dx86_64_BUILD_ARCH=1","-Dlinux_HOST_OS=1","-Dx86_64_HOST_ARCH=1","-Idist/build/autogen","-I.","-I/usr/local/lib/ghc-7.8.2/base-4.7.0.0/include","-I/usr/local/lib/ghc-7.8.2/integer-gmp-0.5.1.0/include","-I/usr/local/lib/ghc-7.8.2/include","-L/usr/local/lib/ghc-7.8.2/base-4.7.0.0","-L/usr/local/lib/ghc-7.8.2/integer-gmp-0.5.1.0","-L/usr/local/lib/ghc-7.8.2/ghc-prim-0.3.1.0","-L/usr/local/lib/ghc-7.8.2/rts-1.0"]) > Using internal setup method with build-type Simple and args: > ["build","--verbose=3"] > Component build order: library > creating dist/build > creating dist/build/autogen > Building data-default-class-0.0.1... > Preprocessing library data-default-class-0.0.1... > Building library... > creating dist/build > Environment: > [("COLORFGBG","12;default;8"),("COLORTERM","rxvt-xpm"),("DBUS_SESSION_BUS_ADDRESS","unix:abstract=/tmp/dbus-5El0U8sCi8,guid=09290436e309789f9814dffc00000406"),("DEFAULTS_PATH","/usr/share/gconf/xmonad.default.path"),("DESKTOP_SESSION","xmonad"),("DISPLAY"," > 10.69.208.185:0"),("EDITOR","vim"),("GDMSESSION","xmonad"),("GPG_AGENT_INFO","/tmp/gpg-KKH3WT/S.gpg-agent:5467:1"),("GREP_COLOR","1;32"),("GREP_OPTIONS","--color=auto > --exclude-dir=.cvs --exclude-dir=.git --exclude-dir=.hg > --exclude-dir=.svn"),("GTK_IM_MODULE","xim"),("HOME","/home/local/ANT/shida"),("LANG","C.UTF-8"),("LC_ALL","C.UTF-8"),("LC_CTYPE","C.UTF-8"),("LESS","-R"),("LOGNAME","shida"),("LSCOLORS","Gxfxcxdxbxegedabagacad"),("MANDATORY_PATH","/usr/share/gconf/xmonad.mandatory.path"),("NODE_PATH","/usr/lib/nodejs:/usr/lib/node_modules:/usr/share/javascript"),("OLDPWD","/home/local/ANT/shida/src/git/cabal/cabal-install"),("PAGER","less"),("PATH","/usr/local/heroku/bin:.:/home/local/ANT/shida/.cabal/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/lightdm/lightdm:/usr/local/bin:/usr/bin:/bin"),("PULSE_SERVER","10.69.208.185"),("PWD","/home/local/ANT/shida"),("QT_IM_MODULE","xim"),("SHELL","/usr/bin/zsh"),("SHLVL","1"),("SSH_AGENT_PID","14748"),("SSH_AUTH_SOCK","/tmp/ssh-NeRVrYb14746/agent.14746"),("TERM","rxvt-unicode-256color"),("UBUNTU_MENUPROXY","libappmenu.so"),("USER","shida"),("VISUAL","vim"),("WINDOWID","14683293"),("XAUTHORITY","/home/local/ANT/shida/.Xauthority"),("XDG_CONFIG_DIRS","/etc/xdg/xdg-xmonad:/etc/xdg"),("XDG_DATA_DIRS","/usr/share/xmonad:/usr/local/share/:/usr/share/"),("XDG_SEAT_PATH","/org/freedesktop/DisplayManager/Seat1"),("XDG_SESSION_COOKIE","05ca21f0ee7e6a10e18260ac00001d83-1402975930.974487-843139146"),("XDG_SESSION_PATH","/org/freedesktop/DisplayManager/Session0"),("XMODIFIERS","@im=ibus"),("ZSH","/home/local/ANT/shida/.oh-my-zsh"),("_","/home/local/ANT/shida/.cabal/bin/cabal")] > > ("/usr/local/bin/ghc",["--make","-v","-fbuilding-cabal-package","-O","-split-objs","-static","-dynamic-too","-dynosuf","dyn_o","-dynhisuf","dyn_hi","-outputdir","dist/build","-odir","dist/build","-hidir","dist/build","-stubdir","dist/build","-i","-idist/build","-i.","-idist/build/autogen","-Idist/build/autogen","-Idist/build","-optP-include","-optPdist/build/autogen/cabal_macros.h","-package-name","data-default-class-0.0.1","-hide-all-packages","-package-db","dist/package.conf.inplace","-package-id","base-4.7.0.0-018311399e3b6350d5be3a16b144df9b","-XHaskell98","Data.Default.Class"]) > Glasgow Haskell Compiler, Version 7.8.2, stage 2 booted by GHC version > 7.8.1 > Using binary package database: > /usr/local/lib/ghc-7.8.2/package.conf.d/package.cache > Using binary package database: > /home/local/ANT/shida/.ghc/x86_64-linux-7.8.2/package.conf.d/package.cache > Using package config file: dist/package.conf.inplace > wired-in package ghc-prim mapped to > ghc-prim-0.3.1.0-948744e1f99cc8bcc7c7d3ba60c7c2d8 > wired-in package integer-gmp mapped to > integer-gmp-0.5.1.0-dc47f6b546fc171f67a7f7d311684a99 > wired-in package base mapped to > base-4.7.0.0-018311399e3b6350d5be3a16b144df9b > wired-in package rts mapped to builtin_rts > wired-in package template-haskell mapped to > template-haskell-2.9.0.0-dcc8c210fb02937e104bc1784d7b0f06 > wired-in package dph-seq not found. > wired-in package dph-par not found. > Hsc static flags: > wired-in package ghc-prim mapped to > ghc-prim-0.3.1.0-948744e1f99cc8bcc7c7d3ba60c7c2d8 > wired-in package integer-gmp mapped to > integer-gmp-0.5.1.0-dc47f6b546fc171f67a7f7d311684a99 > wired-in package base mapped to > base-4.7.0.0-018311399e3b6350d5be3a16b144df9b > wired-in package rts mapped to builtin_rts > wired-in package template-haskell mapped to > template-haskell-2.9.0.0-dcc8c210fb02937e104bc1784d7b0f06 > wired-in package dph-seq not found. > wired-in package dph-par not found. > *** Chasing dependencies: > Chasing modules from: *Data.Default.Class > Stable obj: [] > Stable BCO: [] > Ready for upsweep > [NONREC > ModSummary { > ms_hs_date = 2014-06-23 03:29:30.794067064 UTC > ms_mod = data-default-class-0.0.1:Data.Default.Class, > ms_textual_imps = [import (implicit) Prelude] > ms_srcimps = [] > }] > *** Deleting temp files: > Deleting: > compile: input file ./Data/Default/Class.hs > Created temporary directory: /tmp/ghc19596_0 > *** Checking old interface for data-default-class-0.0.1:Data.Default.Class: > [1 of 1] Compiling Data.Default.Class ( Data/Default/Class.hs, > dist/build/Data/Default/Class.o ) > *** Parser: > *** Renamer/typechecker: > *** Desugar: > Result size of Desugar (after optimization) > = {terms: 0, types: 0, coercions: 0} > *** Simplifier: > Result size of Simplifier = {terms: 0, types: 0, coercions: 0} > *** Specialise: > Result size of Specialise = {terms: 0, types: 0, coercions: 0} > *** Float out(FOS {Lam = Just 0, Consts = True, PAPs = False}): > Result size of Float out(FOS {Lam = Just 0, > Consts = True, > PAPs = False}) > = {terms: 0, types: 0, coercions: 0} > *** Float inwards: > Result size of Float inwards = {terms: 0, types: 0, coercions: 0} > *** Simplifier: > Result size of Simplifier = {terms: 0, types: 0, coercions: 0} > *** Simplifier: > Result size of Simplifier = {terms: 0, types: 0, coercions: 0} > *** Simplifier: > Result size of Simplifier = {terms: 0, types: 0, coercions: 0} > *** Demand analysis: > Result size of Demand analysis = {terms: 0, types: 0, coercions: 0} > *** Worker Wrapper binds: > Result size of Worker Wrapper binds > = {terms: 0, types: 0, coercions: 0} > *** Simplifier: > Result size of Simplifier = {terms: 0, types: 0, coercions: 0} > *** Float out(FOS {Lam = Just 0, Consts = True, PAPs = True}): > Result size of Float out(FOS {Lam = Just 0, > Consts = True, > PAPs = True}) > = {terms: 0, types: 0, coercions: 0} > *** Common sub-expression: > Result size of Common sub-expression > = {terms: 0, types: 0, coercions: 0} > *** Float inwards: > Result size of Float inwards = {terms: 0, types: 0, coercions: 0} > *** Simplifier: > Result size of Simplifier = {terms: 0, types: 0, coercions: 0} > *** Tidy Core: > Result size of Tidy Core = {terms: 4, types: 7, coercions: 2} > writeBinIface: 2 Names > writeBinIface: 16 dict entries > writeBinIface: 2 Names > writeBinIface: 16 dict entries > *** CorePrep: > Result size of CorePrep = {terms: 4, types: 7, coercions: 2} > *** Stg2Stg: > *** CodeOutput: > *** New CodeGen: > *** CPSZ: > *** CPSZ: > *** Splitter: > /usr/local/lib/ghc-7.8.2/ghc-split /tmp/ghc19596_0/ghc19596_2.split_s > /tmp/ghc19596_0/ghc19596_4.split /tmp/ghc19596_0/ghc19596_4.split > *** Assembler: > /usr/bin/gcc -fno-stack-protector -DTABLES_NEXT_TO_CODE -c -o > dist/build/Data/Default/Class_o_split/Class__1.o > /tmp/ghc19596_0/ghc19596_4.split__1.s > *** Assembler: > /usr/bin/gcc -fno-stack-protector -DTABLES_NEXT_TO_CODE -c -o > dist/build/Data/Default/Class_o_split/Class__2.o > /tmp/ghc19596_0/ghc19596_4.split__2.s > *** Linker: > /usr/bin/gcc -fno-stack-protector -DTABLES_NEXT_TO_CODE -nostdlib -Wl,-r > -nodefaultlibs '-Wl,--build-id=none' -o dist/build/Data/Default/Class.o > /tmp/ghc19596_0/ghc19596_5.ldscript > /usr/bin/ld: error: cannot find > dist/build/Data/Default/Class_o_split/Class__1.o > /usr/bin/ld: error: cannot find > dist/build/Data/Default/Class_o_split/.o::Class(void) > collect2: ld returned 1 exit status > *** Deleting temp files: > Deleting: /tmp/ghc19596_0/ghc19596_5.ldscript > /tmp/ghc19596_0/ghc19596_4.split__1.s /tmp/ghc19596_0/ghc19596_4.split__2.s > /tmp/ghc19596_0/ghc19596_4.split /tmp/ghc19596_0/ghc19596_3.c > /tmp/ghc19596_0/ghc19596_2.split_s /tmp/ghc19596_0/ghc19596_1.split_s > Warning: deleting non-existent /tmp/ghc19596_0/ghc19596_3.c > Warning: deleting non-existent /tmp/ghc19596_0/ghc19596_1.split_s > *** Deleting temp dirs: > Deleting: /tmp/ghc19596_0 > /usr/local/bin/ghc returned ExitFailure 1 > Failed to install data-default-class-0.0.1 > Updating world file... > cabal: Error: some packages failed to install: > data-default-class-0.0.1 failed during the building phase. The exception > was: > ExitFailure 1 > > -- > ??????? > ??????? > > And for G+, please use magiclouds#gmail.com. > -- ??????? ??????? And for G+, please use magiclouds#gmail.com. -------------- next part -------------- An HTML attachment was scrubbed... URL: From simonyarde at me.com Mon Jun 23 07:46:22 2014 From: simonyarde at me.com (Simon Yarde) Date: Mon, 23 Jun 2014 08:46:22 +0100 Subject: [Haskell-cafe] Pathological overloaded function Message-ID: <8B9FCBDC-C2B6-43F0-A2B1-C62F4DD45BAF@me.com> Could anyone chip in with examples of a pathological overloaded functions in relation to the GHC Guide 6.2: > Overloaded functions are not your friend: > Haskell's overloading (using type classes) is elegant, neat, etc., etc., but it is death to performance if left to linger in an inner loop. How can you squash it? > > Give explicit type signatures: > Signatures are the basic trick; putting them on exported, top-level functions is good software-engineering practice, anyway. (Tip: using -fwarn-missing-signatures can help enforce good signature-practice). http://lambda.haskell.org/platform/doc/current/ghc-doc/users_guide/faster.html Best Regards, Simon From byorgey at seas.upenn.edu Mon Jun 23 12:04:40 2014 From: byorgey at seas.upenn.edu (Brent Yorgey) Date: Mon, 23 Jun 2014 08:04:40 -0400 Subject: [Haskell-cafe] hayoo doesn't find the Kleisli arrow? In-Reply-To: <4c59c17a-4fea-4f4b-a52f-41dd46ba6b13@googlegroups.com> References: <4c59c17a-4fea-4f4b-a52f-41dd46ba6b13@googlegroups.com> Message-ID: <20140623120440.GA32149@seas.upenn.edu> On Sun, Jun 22, 2014 at 08:24:35PM -0700, Erik Rantapaa wrote: > > I just happen to notice that this query comes back empty in Hayoo: > > (a -> m b) -> (b -> m c) -> (a -> m c) > > Hoogle is able to find (>=>), and I'm wondering if its a bug or...? Hayoo does text-based search only; it does not do true type searches. If you remove the parentheses from the final arrow, i.e. (a -> m b) -> (b -> m c) -> a -> m c then you will see that it does find (>=>). The reason is that it does not really know about types, it is just doing a textual matching so it does not know that the parentheses are unimportant. (Actually, it seems Hayoo may have a bit of smarts beyond just plain text matching when it comes to types; for example, searching for [b] -> b instead of [a] -> a will still find 'head'. I am not really familiar with the details.) Hoogle, on the other hand, truly understands the syntax and semantics of types, so it is able to do things like find related, simplified, or reordered versions of the search type, deal with alpha-equivalence, etc. -Brent From Graham.Hutton at nottingham.ac.uk Mon Jun 23 13:02:52 2014 From: Graham.Hutton at nottingham.ac.uk (Graham Hutton) Date: Mon, 23 Jun 2014 14:02:52 +0100 Subject: [Haskell-cafe] New Assistant Professorship in Nottingham Message-ID: <0854F8CD-3E4B-4B9A-86D2-A852787873CC@exmail.nottingham.ac.uk> Dear all, The School of Computer Science at the University of Nottingham in the UK is seeking to appoint a new Assistant Professor: http://www.nottingham.ac.uk/jobs/currentvacancies/ref/SCI181514 Applications in the area of the Functional Programming (FP) lab would be most welcome. The FP lab is keen to receive applications from candidates with an excellent publication record, experience in combining theory with practice, and the ability to secure external funding to support their research. Further information about the FP lab is available from: http://fp.cs.nott.ac.uk The deadline for applications is Friday 22nd August 2014. The advert mentions computer vision, but the position is open to applicants from any area of Computer Science. Best wishes, Graham Hutton -- Prof Graham Hutton Functional Programming Lab School of Computer Science University of Nottingham, UK http://www.cs.nott.ac.uk/~gmh This message and any attachment are intended solely for the addressee and may contain confidential information. If you have received this message in error, please send it back to me, and immediately delete it. Please do not use, copy or disclose the information contained in this message or in any attachment. Any views or opinions expressed by the author of this email do not necessarily reflect the views of the University of Nottingham. This message has been checked for viruses but the contents of an attachment may still contain software viruses which could damage your computer system, you are advised to perform your own checks. Email communications with the University of Nottingham may be monitored as permitted by UK legislation. From m at jaspervdj.be Mon Jun 23 14:07:49 2014 From: m at jaspervdj.be (Jasper Van der Jeugt) Date: Mon, 23 Jun 2014 16:07:49 +0200 Subject: [Haskell-cafe] ANN: psqueues Message-ID: <20140623140749.GD417@jasper.local> Here at Better, we have just a released a package which implements faster priority search queues for Haskell. We hope it proves to be useful to the community! More information can be found in this blogpost: http://medium.com/@bttr/announcing-psqueues-8a0fe9fe939 Grab it from Hackage or GitHub: http://hackage.haskell.org/package/psqueues https://github.com/bttr/psqueues On behalf of the engineering team at Better, Jasper Van der Jeugt From sean at functionaljobs.com Mon Jun 23 16:00:01 2014 From: sean at functionaljobs.com (Functional Jobs) Date: Mon, 23 Jun 2014 12:00:01 -0400 Subject: [Haskell-cafe] New Functional Programming Job Opportunities Message-ID: <53a84f04e23be@functionaljobs.com> Here are some functional programming job opportunities that were posted recently: Developer / DevOps Engineer at Klarna http://functionaljobs.com/jobs/8721-developer-devops-engineer-at-klarna Cheers, Sean Murphy FunctionalJobs.com From tobias.pflug at gmx.net Mon Jun 23 20:36:46 2014 From: tobias.pflug at gmx.net (Tobias Pflug) Date: Mon, 23 Jun 2014 22:36:46 +0200 Subject: [Haskell-cafe] determine hoolge database directory Message-ID: <53A88FDE.4010601@gmx.net> Hi haskellers, i'm new to haskell and am currently working on some tool that is supposed to fiddle with hoogle database files. Now I'm looking for a sane way to determine the directory where hoogle stores its database directories (when you perform `hoogle data`). In my case this is: .cabal/share/x86_64-linux-ghc-7.8.2/hoogle-4.2.33/databases So this is [home directory]/.cabal/[ghc-version]/[hoogle-version]/databases Could someone suggest me a sane way how I can determine this path at runtime ? Maybe there is a way to extract this from somewhere ? I'm out of ideas on this. I could of course take the easy way out and let users declare the path as config parameter but it would be nice if there was a way ... thanks in advance. regards, Tobi From johan.g.larson at gmail.com Mon Jun 23 21:48:26 2014 From: johan.g.larson at gmail.com (Johan Larson) Date: Mon, 23 Jun 2014 17:48:26 -0400 Subject: [Haskell-cafe] how to upgrade to a new version of Haskell? Message-ID: I am currently running an old installation of the Haskell environment from 2012, and I would like to upgrade. Can I just grab the installer from https://www.haskell.org/platform/windows.html and run it? This is on Windows. -- Johan Larson -- Toronto, Canada -------------- next part -------------- An HTML attachment was scrubbed... URL: From hjgtuyl at chello.nl Mon Jun 23 22:46:16 2014 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Tue, 24 Jun 2014 00:46:16 +0200 Subject: [Haskell-cafe] how to upgrade to a new version of Haskell? In-Reply-To: References: Message-ID: On Mon, 23 Jun 2014 23:48:26 +0200, Johan Larson wrote: > I am currently running an old installation of the Haskell environment > from > 2012, and I would like to upgrade. Can I just grab the installer from > https://www.haskell.org/platform/windows.html and run it? > > This is on Windows. > Yes, you can keep the old compiler and packages, so that you can test new software with an old configuration if you like. The old things are not in the way for the new software. Regards, Henk-Jan van Tuyl -- Folding at home What if you could share your unused computer power to help find a cure? In just 5 minutes you can join the world's biggest networked computer and get us closer sooner. Watch the video. http://folding.stanford.edu/ http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming -- From kc1956 at gmail.com Mon Jun 23 22:55:49 2014 From: kc1956 at gmail.com (KC) Date: Mon, 23 Jun 2014 15:55:49 -0700 Subject: [Haskell-cafe] how to upgrade to a new version of Haskell? In-Reply-To: References: Message-ID: Better to install it to a different folder than Program Files since Windows has special protections on that folder and many others. :) -- -- Sent from an expensive device which will be obsolete in a few months! :D Casey On Jun 23, 2014 2:48 PM, "Johan Larson" wrote: > I am currently running an old installation of the Haskell environment from > 2012, and I would like to upgrade. Can I just grab the installer from > https://www.haskell.org/platform/windows.html and run it? > > This is on Windows. > > -- > Johan Larson -- Toronto, Canada > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From johan.g.larson at gmail.com Tue Jun 24 00:01:11 2014 From: johan.g.larson at gmail.com (Johan Larson) Date: Mon, 23 Jun 2014 20:01:11 -0400 Subject: [Haskell-cafe] how to upgrade to a new version of Haskell? In-Reply-To: References: Message-ID: I found a bit of an odd problem. In my configuration, which I haven't modified, the installed copy of cabal appears in the path earlier than the directory into which executables built by cabal are installed, meaning that when cabal installs a new version of itself, that version is not used by default. That doesn't seem right. The installed location of cabal: C:\Program Files (x86)\Haskell Platform\2013.2.0.0\lib\extralibs\bin Where cabal puts executables: C:\Users\Johan\AppData\Roaming\cabal\bin I can work around it, sure, but is this a deliberate choice or a blindspot in the installer? On Mon, Jun 23, 2014 at 6:55 PM, KC wrote: > Better to install it to a different folder than Program Files since > Windows has special protections on that folder and many others. :) > > -- > -- > > Sent from an expensive device which will be obsolete in a few months! :D > > Casey > > On Jun 23, 2014 2:48 PM, "Johan Larson" wrote: > >> I am currently running an old installation of the Haskell environment >> from 2012, and I would like to upgrade. Can I just grab the installer >> from https://www.haskell.org/platform/windows.html and run it? >> >> This is on Windows. >> >> -- >> Johan Larson -- Toronto, Canada >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> -- Johan Larson -- Toronto, Canada -------------- next part -------------- An HTML attachment was scrubbed... URL: From saulzar at gmail.com Tue Jun 24 01:07:19 2014 From: saulzar at gmail.com (Oliver Batchelor) Date: Tue, 24 Jun 2014 13:07:19 +1200 Subject: [Haskell-cafe] ANN: psqueues In-Reply-To: <20140623140749.GD417@jasper.local> References: <20140623140749.GD417@jasper.local> Message-ID: Great! Your benchmark closely matches my experience with using fingertree-psqueue and PSQueue for use in an A* search algorithm. Hopefully when people go to find a ps queue implementation they'll notice your benchmark, it would have saved me some time. Cheers, Oliver Batchelor On Tue, Jun 24, 2014 at 2:07 AM, Jasper Van der Jeugt wrote: > Here at Better, we have just a released a package which implements > faster priority search queues for Haskell. We hope it proves to be > useful to the community! > > More information can be found in this blogpost: > > http://medium.com/@bttr/announcing-psqueues-8a0fe9fe939 > > Grab it from Hackage or GitHub: > > http://hackage.haskell.org/package/psqueues > https://github.com/bttr/psqueues > > On behalf of the engineering team at Better, > Jasper Van der Jeugt > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From shumovichy at gmail.com Tue Jun 24 09:55:58 2014 From: shumovichy at gmail.com (Yuras Shumovich) Date: Tue, 24 Jun 2014 12:55:58 +0300 Subject: [Haskell-cafe] how to upgrade to a new version of Haskell? In-Reply-To: References: Message-ID: It is an old bug in HP, see https://github.com/haskell/haskell-platform/issues/51 (it is imported from trac, see http://trac.haskell.org/haskell-platform/ticket/146 ) 24.06.2014 3:01 ???????????? "Johan Larson" ???????: > I found a bit of an odd problem. > > In my configuration, which I haven't modified, the installed copy of cabal > appears in the path earlier than the directory into which executables built > by cabal are installed, meaning that when cabal installs a new version of > itself, that version is not used by default. > > That doesn't seem right. > > The installed location of cabal: C:\Program Files (x86)\Haskell > Platform\2013.2.0.0\lib\extralibs\bin > Where cabal puts executables: C:\Users\Johan\AppData\Roaming\cabal\bin > > I can work around it, sure, but is this a deliberate choice or a blindspot > in the installer? > > > On Mon, Jun 23, 2014 at 6:55 PM, KC wrote: > >> Better to install it to a different folder than Program Files since >> Windows has special protections on that folder and many others. :) >> >> -- >> -- >> >> Sent from an expensive device which will be obsolete in a few months! :D >> >> Casey >> >> On Jun 23, 2014 2:48 PM, "Johan Larson" wrote: >> >>> I am currently running an old installation of the Haskell environment >>> from 2012, and I would like to upgrade. Can I just grab the installer >>> from https://www.haskell.org/platform/windows.html and run it? >>> >>> This is on Windows. >>> >>> -- >>> Johan Larson -- Toronto, Canada >>> >>> _______________________________________________ >>> Haskell-Cafe mailing list >>> Haskell-Cafe at haskell.org >>> http://www.haskell.org/mailman/listinfo/haskell-cafe >>> >>> > > > -- > Johan Larson -- Toronto, Canada > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alpmestan at gmail.com Tue Jun 24 12:10:49 2014 From: alpmestan at gmail.com (Alp Mestanogullari) Date: Tue, 24 Jun 2014 14:10:49 +0200 Subject: [Haskell-cafe] ANN: hmatrix-0.16 In-Reply-To: <53A46325.7070709@um.es> References: <53A46325.7070709@um.es> Message-ID: Thanks a lot for the work on moving the gsl bits out, hnn 0.2 released :-) On Fri, Jun 20, 2014 at 6:36 PM, Alberto Ruiz wrote: > Hi! > > I am happy to announce the release of hmatrix-0.16, a Haskell package for > matrix computations and numeric linear algebra. > > New features: > > - BSD3 license. The modules depending on GSL have been moved to a new > package hmatrix-gsl (GPL). Now hmatrix depends only on BLAS/LAPACK. > > - Simpler reexport modules with improved documentation and usage examples. > There are a few API changes but the traditional modules are also exposed > for backwards compatibility. > > - Alternative interface using type-level literals for static dimension > checking and inference (work in progress). > > - Initial support for sparse linear systems. > > - Minor improvements and bug fixes (see the changelog for details). > > http://hackage.haskell.org/package/hmatrix > > https://github.com/albertoruiz/hmatrix > > Some examples: http://dis.um.es/~alberto/hmatrix/hmatrix.html > > Suggestions, contributions, and bug reports are welcome. > > Thanks! > Alberto > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Alp Mestanogullari -------------- next part -------------- An HTML attachment was scrubbed... URL: From mwm at mired.org Tue Jun 24 12:14:32 2014 From: mwm at mired.org (Mike Meyer) Date: Tue, 24 Jun 2014 07:14:32 -0500 Subject: [Haskell-cafe] ANN: Graphics.OpenSCAD Message-ID: Graphics.OpenSCAD provides an algebraic data type for creating OpenSCAD 3d models, as well a a function to generate an OpenSCAD program from a data structure. OpenSCAD is a "programmers" CAD tool. It provides a declarative language for 3d models with a primitive functional language for doing computation. The Graphics.OpenSCAD module tries to preserve the declarative parts by providing tools for building data structures that match the OpenSCAD declarative models, then embedding that in a powerful, modern functional language. The critical problem with OpenSCAD is the error handling. At it's best, it will say "syntax error" and provide sufficient location information to easily find the error. At times, the location information points outside the file. Errors in dealing with variables may have no error messages, or messages that are easy to overlook, resulting in models that are radically different from what was expected with no way to determine the problem except searching the complete program text. Graphics.OpenSCAD attempts to solve that by leveraging Haskell's type system as far as possible. While not every run-time OpenSCAD error can be detected in Haskell, as many as possible are. Hackage page with pointers to source and documentation: http://hackage.haskell.org/package/OpenSCAD -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuuzetsu at fuuzetsu.co.uk Tue Jun 24 12:28:37 2014 From: fuuzetsu at fuuzetsu.co.uk (Mateusz Kowalczyk) Date: Tue, 24 Jun 2014 14:28:37 +0200 Subject: [Haskell-cafe] ANN: hmatrix-0.16 In-Reply-To: <53A46325.7070709@um.es> References: <53A46325.7070709@um.es> Message-ID: <53A96EF5.8050902@fuuzetsu.co.uk> On 06/20/2014 06:36 PM, Alberto Ruiz wrote: > Hi! > > I am happy to announce the release of hmatrix-0.16, a Haskell package > for matrix computations and numeric linear algebra. > > New features: > > - BSD3 license. The modules depending on GSL have been moved to a new > package hmatrix-gsl (GPL). Now hmatrix depends only on BLAS/LAPACK. > > - Simpler reexport modules with improved documentation and usage > examples. There are a few API changes but the traditional modules are > also exposed for backwards compatibility. > > - Alternative interface using type-level literals for static dimension > checking and inference (work in progress). > > - Initial support for sparse linear systems. > > - Minor improvements and bug fixes (see the changelog for details). > > http://hackage.haskell.org/package/hmatrix > > https://github.com/albertoruiz/hmatrix > > Some examples: http://dis.um.es/~alberto/hmatrix/hmatrix.html > > Suggestions, contributions, and bug reports are welcome. > > Thanks! > Alberto > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > It is great to see an example page: I have tried to use hmatrix in the past for what should have been simple matrix/vector multiplication/addition but quickly became frustrated unable to figure out how to use it so I ended up writing my own (only needed few operations to try something out). I suggest that you put the link to that page in the description of the package so it shows on Hackage, on this[1] page. Secondly, I note that some modules (not all) such as Numeric.Container[2] give the missing documentation page when clicked on. Is this intentional? If I click back to something like version 0.14.x and click on Numeric.Container, I get documentation as I would expect. [1]: http://hackage.haskell.org/package/hmatrix [2]: http://hackage.haskell.org/package/hmatrix-0.16.0.3/docs/Numeric-Container.html -- Mateusz K. From ckkashyap at gmail.com Tue Jun 24 16:08:45 2014 From: ckkashyap at gmail.com (C K Kashyap) Date: Tue, 24 Jun 2014 21:38:45 +0530 Subject: [Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation Message-ID: Dear cafe, I have created a reproducible app here - https://github.com/ckkashyap/haskell-perf-repro Essentially I am trying to open a number of files and printing out their sized by reading them in and computing it's length. I have the equivalent perl program also there. I'd appreciate it very much if someone could take a look at my Haskell implementation and point out what I am doing wrong. Since it's over 50 times slower than the perl code, I assume I am doing something obviously incorrect. Regards, Kashyap -------------- next part -------------- An HTML attachment was scrubbed... URL: From bos at serpentine.com Tue Jun 24 16:19:22 2014 From: bos at serpentine.com (Bryan O'Sullivan) Date: Tue, 24 Jun 2014 09:19:22 -0700 Subject: [Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation In-Reply-To: References: Message-ID: On Tue, Jun 24, 2014 at 9:08 AM, C K Kashyap wrote: > Essentially I am trying to open a number of files and printing out their > sized by reading them in and computing it's length. > Don't use String, and don't use unsafeInterleaveIO unless you know what you're doing. -------------- next part -------------- An HTML attachment was scrubbed... URL: From carter.schonwald at gmail.com Tue Jun 24 16:19:08 2014 From: carter.schonwald at gmail.com (Carter Schonwald) Date: Tue, 24 Jun 2014 12:19:08 -0400 Subject: [Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation In-Reply-To: References: Message-ID: use mapM you've got mapMI :: (a -> IO b) -> [a] -> IO [b] mapMI _ [] = return [] mapMI f (x:xs) = do y <- SIU.unsafeInterleaveIO (f x) ; ys <- SIU.unsafeInterleaveIO (mapMI f xs) ; return (y:ys) in your code, and thats going to make you sad On Tue, Jun 24, 2014 at 12:08 PM, C K Kashyap wrote: > Dear cafe, > > I have created a reproducible app here - > https://github.com/ckkashyap/haskell-perf-repro > > Essentially I am trying to open a number of files and printing out their > sized by reading them in and computing it's length. > > I have the equivalent perl program also there. I'd appreciate it very much > if someone could take a look at my Haskell implementation and point out > what I am doing wrong. Since it's over 50 times slower than the perl code, > I assume I am doing something obviously incorrect. > > Regards, > Kashyap > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ckkashyap at gmail.com Tue Jun 24 16:25:21 2014 From: ckkashyap at gmail.com (C K Kashyap) Date: Tue, 24 Jun 2014 21:55:21 +0530 Subject: [Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation In-Reply-To: References: Message-ID: Thanks Bryan, I used unsafeInterleaveIO after I ran into "too many open file handles" error. Again, I doubt about String since even if I change the number of files to 12000 - the perl program finishes in less than a second. Regards, Kashyap On Tue, Jun 24, 2014 at 9:49 PM, Bryan O'Sullivan wrote: > > On Tue, Jun 24, 2014 at 9:08 AM, C K Kashyap wrote: > >> Essentially I am trying to open a number of files and printing out their >> sized by reading them in and computing it's length. >> > > Don't use String, and don't use unsafeInterleaveIO unless you know what > you're doing. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From allbery.b at gmail.com Tue Jun 24 16:29:38 2014 From: allbery.b at gmail.com (Brandon Allbery) Date: Tue, 24 Jun 2014 12:29:38 -0400 Subject: [Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation In-Reply-To: References: Message-ID: On Tue, Jun 24, 2014 at 12:25 PM, C K Kashyap wrote: > I used unsafeInterleaveIO after I ran into "too many open file handles" > error. That all by itself makes me think your problem is elsewhere and unsafeInterleaveIO is just covering it up. -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Tue Jun 24 16:32:14 2014 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Tue, 24 Jun 2014 17:32:14 +0100 Subject: [Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation In-Reply-To: References: Message-ID: <20140624163214.GK1418@henry> On Tue, Jun 24, 2014 at 09:55:21PM +0530, C K Kashyap wrote: > I used unsafeInterleaveIO after I ran into "too many open file handles" > error. > Again, I doubt about String since even if I change the number of files to > 12000 - the perl program finishes in less than a second. This pull request switching to ByteString brings performance in line with the Perl on my system: https://github.com/ckkashyap/haskell-perf-repro/pull/1 Tom From tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Tue Jun 24 16:33:17 2014 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Tue, 24 Jun 2014 17:33:17 +0100 Subject: [Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation In-Reply-To: References: Message-ID: <20140624163317.GL1418@henry> On Tue, Jun 24, 2014 at 12:29:38PM -0400, Brandon Allbery wrote: > On Tue, Jun 24, 2014 at 12:25 PM, C K Kashyap wrote: > > I used unsafeInterleaveIO after I ran into "too many open file handles" > > error. > > That all by itself makes me think your problem is elsewhere and > unsafeInterleaveIO is just covering it up. Yes, it's doing lazy IO. From ckkashyap at gmail.com Tue Jun 24 16:32:58 2014 From: ckkashyap at gmail.com (C K Kashyap) Date: Tue, 24 Jun 2014 22:02:58 +0530 Subject: [Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation In-Reply-To: References: Message-ID: That is what is particularly frustrating...its a tiny program and somewhat trivial thing that I am trying to achieve. If I use mapM as suggested by others, I quickly run into - openFile: resource exhausted (Too many open files) Regards, Kashyap Regards, Kashyap On Tue, Jun 24, 2014 at 9:59 PM, Brandon Allbery wrote: > On Tue, Jun 24, 2014 at 12:25 PM, C K Kashyap wrote: > >> I used unsafeInterleaveIO after I ran into "too many open file handles" >> error. > > > That all by itself makes me think your problem is elsewhere and > unsafeInterleaveIO is just covering it up. > > -- > brandon s allbery kf8nh sine nomine > associates > allbery.b at gmail.com > ballbery at sinenomine.net > unix, openafs, kerberos, infrastructure, xmonad > http://sinenomine.net > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Tue Jun 24 16:35:00 2014 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Tue, 24 Jun 2014 17:35:00 +0100 Subject: [Haskell-cafe] =?utf-8?b?RndkOiDoh6rliqjlm57lpI3vvJpSZTogQU5OOiBo?= =?utf-8?q?matrix-0=2E16?= In-Reply-To: References: <20140622103749.D289BCB0318@mda06.fmail.tg.sinanode.com> <6470E8F5-12A8-4774-BF92-BBEB209A336F@steinitz.org> Message-ID: <20140624163500.GM1418@henry> On Sun, Jun 22, 2014 at 07:02:39PM +0800, Xiaojun "Phil" Hu wrote: > It's an "auto-reply" feature popular among Chinese email providers. They > just "auto-reply" any email they get. > > If wanna ignore this, you can just create a spam filter with "????" -- it > means "auto-reply" in Mandarin. Really I think it would be best if the admins would unsubscribe such users. It's basically antisocial, costing every poster a little bit of annoyance. Altogether it adds up to a lot. Tom From ckkashyap at gmail.com Tue Jun 24 16:37:32 2014 From: ckkashyap at gmail.com (C K Kashyap) Date: Tue, 24 Jun 2014 22:07:32 +0530 Subject: [Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation In-Reply-To: <20140624163214.GK1418@henry> References: <20140624163214.GK1418@henry> Message-ID: Indeed it works. Thank you so much Tom. Sorry about the false alarm. Regards, Kashyap On Tue, Jun 24, 2014 at 10:02 PM, Tom Ellis < tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk> wrote: > On Tue, Jun 24, 2014 at 09:55:21PM +0530, C K Kashyap wrote: > > I used unsafeInterleaveIO after I ran into "too many open file handles" > > error. > > Again, I doubt about String since even if I change the number of files to > > 12000 - the perl program finishes in less than a second. > > This pull request switching to ByteString brings performance in line with > the Perl on my system: > > https://github.com/ckkashyap/haskell-perf-repro/pull/1 > > Tom > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From nicolas at incubaid.com Tue Jun 24 16:38:50 2014 From: nicolas at incubaid.com (Nicolas Trangez) Date: Tue, 24 Jun 2014 18:38:50 +0200 Subject: [Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation In-Reply-To: References: Message-ID: <1403627930.3587.13.camel@chi.nicolast.be> On Tue, 2014-06-24 at 21:38 +0530, C K Kashyap wrote: > Dear cafe, > > I have created a reproducible app here - > https://github.com/ckkashyap/haskell-perf-repro > > Essentially I am trying to open a number of files and printing out their > sized by reading them in and computing it's length. > > I have the equivalent perl program also there. I'd appreciate it very much > if someone could take a look at my Haskell implementation and point out > what I am doing wrong. Since it's over 50 times slower than the perl code, > I assume I am doing something obviously incorrect. That's simply because your Haskell program is doing something completely different than your Perl code. Using `String` is the biggest offense. You're creating huge lists of `Char`s instead of working on arrays of bytes, like your Perl code does. I made some trivial changes to bring the Haskell code on par with your Perl code speed-wise at https://github.com/NicolasT/haskell-perf-repro/compare/ckkashyap:master...master Check it out! Nicolas From tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Tue Jun 24 16:41:28 2014 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Tue, 24 Jun 2014 17:41:28 +0100 Subject: [Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation In-Reply-To: References: <20140624163214.GK1418@henry> Message-ID: <20140624164128.GN1418@henry> On Tue, Jun 24, 2014 at 10:07:32PM +0530, C K Kashyap wrote: > Indeed it works. Thank you so much Tom. > Sorry about the false alarm. Interestingly with `mapMI` it is twice as fast as with `mapM`. I haven't dug futher into that but at least you're getting reasonable speeds yet so you can decide how important that is to you. Tom From ckkashyap at gmail.com Tue Jun 24 16:45:22 2014 From: ckkashyap at gmail.com (C K Kashyap) Date: Tue, 24 Jun 2014 22:15:22 +0530 Subject: [Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation In-Reply-To: <1403627930.3587.13.camel@chi.nicolast.be> References: <1403627930.3587.13.camel@chi.nicolast.be> Message-ID: Thanks Nicholas ... you've gotten rid of unsafeInterleaveIO ... It feels much better :) Regards, Kashyap On Tue, Jun 24, 2014 at 10:08 PM, Nicolas Trangez wrote: > On Tue, 2014-06-24 at 21:38 +0530, C K Kashyap wrote: > > Dear cafe, > > > > I have created a reproducible app here - > > https://github.com/ckkashyap/haskell-perf-repro > > > > Essentially I am trying to open a number of files and printing out their > > sized by reading them in and computing it's length. > > > > I have the equivalent perl program also there. I'd appreciate it very > much > > if someone could take a look at my Haskell implementation and point out > > what I am doing wrong. Since it's over 50 times slower than the perl > code, > > I assume I am doing something obviously incorrect. > > That's simply because your Haskell program is doing something completely > different than your Perl code. > > Using `String` is the biggest offense. You're creating huge lists of > `Char`s instead of working on arrays of bytes, like your Perl code does. > > I made some trivial changes to bring the Haskell code on par with your > Perl code speed-wise at > > https://github.com/NicolasT/haskell-perf-repro/compare/ckkashyap:master...master > Check it out! > > Nicolas > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dedgrant at gmail.com Tue Jun 24 16:46:06 2014 From: dedgrant at gmail.com (Darren Grant) Date: Tue, 24 Jun 2014 09:46:06 -0700 Subject: [Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation In-Reply-To: References: Message-ID: It's one of those quirks arising from historical decisions that makes Haskell's non-strict idioms pathological where resources are limited. (A very real and common case.) You need very strict, possibly explicit, file handle management here. Look to APIs that deal with this problem in a way that suits your situation better: System.IO.Strict may be an option. Cheers, Darren On Jun 24, 2014 9:33 AM, "C K Kashyap" wrote: > That is what is particularly frustrating...its a tiny program and somewhat > trivial thing that I am trying to achieve. > > If I use mapM as suggested by others, I quickly run into - > > openFile: resource exhausted (Too many open files) > > Regards, > > Kashyap > > Regards, > Kashyap > > > On Tue, Jun 24, 2014 at 9:59 PM, Brandon Allbery > wrote: > >> On Tue, Jun 24, 2014 at 12:25 PM, C K Kashyap >> wrote: >> >>> I used unsafeInterleaveIO after I ran into "too many open file handles" >>> error. >> >> >> That all by itself makes me think your problem is elsewhere and >> unsafeInterleaveIO is just covering it up. >> >> -- >> brandon s allbery kf8nh sine nomine >> associates >> allbery.b at gmail.com >> ballbery at sinenomine.net >> unix, openafs, kerberos, infrastructure, xmonad >> http://sinenomine.net >> > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ckkashyap at gmail.com Tue Jun 24 16:46:03 2014 From: ckkashyap at gmail.com (C K Kashyap) Date: Tue, 24 Jun 2014 22:16:03 +0530 Subject: [Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation In-Reply-To: <20140624164128.GN1418@henry> References: <20140624163214.GK1418@henry> <20140624164128.GN1418@henry> Message-ID: Does mapM work for you? Don't you run into too many files open error? Regards, Kashyap On Tue, Jun 24, 2014 at 10:11 PM, Tom Ellis < tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk> wrote: > On Tue, Jun 24, 2014 at 10:07:32PM +0530, C K Kashyap wrote: > > Indeed it works. Thank you so much Tom. > > Sorry about the false alarm. > > Interestingly with `mapMI` it is twice as fast as with `mapM`. I haven't > dug futher into that but at least you're getting reasonable speeds yet so > you can decide how important that is to you. > > Tom > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Tue Jun 24 16:53:29 2014 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Tue, 24 Jun 2014 17:53:29 +0100 Subject: [Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation In-Reply-To: References: <20140624163214.GK1418@henry> <20140624164128.GN1418@henry> Message-ID: <20140624165329.GO1418@henry> On Tue, Jun 24, 2014 at 10:16:03PM +0530, C K Kashyap wrote: > Does mapM work for you? Don't you run into too many files open error? It works. No error. But is slower that your mapMI. Undoubtedly there is a method that is better than `unsafeInterleaveIO` and `mapMI` in terms of both performance and conceptual coherence. From nicolas at incubaid.com Tue Jun 24 17:05:22 2014 From: nicolas at incubaid.com (Nicolas Trangez) Date: Tue, 24 Jun 2014 19:05:22 +0200 Subject: [Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation In-Reply-To: References: Message-ID: <1403629522.3587.18.camel@chi.nicolast.be> On Tue, 2014-06-24 at 22:02 +0530, C K Kashyap wrote: > If I use mapM as suggested by others, I quickly run into - > > openFile: resource exhausted (Too many open files) You should `seq` the calculated length before returning the value, otherwise the file descriptor needs to be kept open until the processing result is used (when printing the result list), and you exhaust your resources. Anyway, for giggles I added concurrency support using `async` and IO handling using `pipes`/`pipes-bytestring` to my fork in https://github.com/NicolasT/haskell-perf-repro/commit/86639daa3b577487e75d385ea825aa58e3c8713b Using the sample dataset created by your Makefile, this version is somewhat slower than the previous (and your Perl script), but in case the dataset is huge (and depending on the block-device you're using, the layout of the files on it,... the lot) it might help (or might not). Nicolas From tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Tue Jun 24 17:07:32 2014 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Tue, 24 Jun 2014 18:07:32 +0100 Subject: [Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation In-Reply-To: <20140624165329.GO1418@henry> References: <20140624163214.GK1418@henry> <20140624164128.GN1418@henry> <20140624165329.GO1418@henry> Message-ID: <20140624170732.GP1418@henry> On Tue, Jun 24, 2014 at 05:53:29PM +0100, Tom Ellis wrote: > On Tue, Jun 24, 2014 at 10:16:03PM +0530, C K Kashyap wrote: > > Does mapM work for you? Don't you run into too many files open error? > > It works. No error. [...] Oh by the way, you should compile with `-O2` so that strictness analysis kicks in. Nicolas Trangez approaches this issue with an explicit `seq` instead. Tom From ckkashyap at gmail.com Tue Jun 24 17:07:35 2014 From: ckkashyap at gmail.com (C K Kashyap) Date: Tue, 24 Jun 2014 22:37:35 +0530 Subject: [Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation In-Reply-To: <1403629522.3587.18.camel@chi.nicolast.be> References: <1403629522.3587.18.camel@chi.nicolast.be> Message-ID: Thanks Nicholas :) ... and if I understand right doing `seq` would be equivalent to Strict IO that Darren mentioned. right? Regards, Kashyap On Tue, Jun 24, 2014 at 10:35 PM, Nicolas Trangez wrote: > On Tue, 2014-06-24 at 22:02 +0530, C K Kashyap wrote: > > If I use mapM as suggested by others, I quickly run into - > > > > openFile: resource exhausted (Too many open files) > > You should `seq` the calculated length before returning the value, > otherwise the file descriptor needs to be kept open until the processing > result is used (when printing the result list), and you exhaust your > resources. > > Anyway, for giggles I added concurrency support using `async` and IO > handling using `pipes`/`pipes-bytestring` to my fork in > > https://github.com/NicolasT/haskell-perf-repro/commit/86639daa3b577487e75d385ea825aa58e3c8713b > Using the sample dataset created by your Makefile, this version is > somewhat slower than the previous (and your Perl script), but in case > the dataset is huge (and depending on the block-device you're using, the > layout of the files on it,... the lot) it might help (or might not). > > Nicolas > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From stuart at cs.uchicago.edu Tue Jun 24 17:08:46 2014 From: stuart at cs.uchicago.edu (Stuart A. Kurtz) Date: Tue, 24 Jun 2014 12:08:46 -0500 Subject: [Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation In-Reply-To: References: <20140624163214.GK1418@henry> <20140624164128.GN1418@henry> Message-ID: Might it be more efficient to bypass counting altogether, and just use the Haskell version of stat? getFileSize :: FilePath -> IO Int64 getFileSize path = do stat <- getFileStatus path let COff fs = fileSize stat return fs Peace, Stu From nicolas at incubaid.com Tue Jun 24 17:10:43 2014 From: nicolas at incubaid.com (Nicolas Trangez) Date: Tue, 24 Jun 2014 19:10:43 +0200 Subject: [Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation In-Reply-To: References: <20140624163214.GK1418@henry> <20140624164128.GN1418@henry> Message-ID: <1403629843.3587.19.camel@chi.nicolast.be> On Tue, 2014-06-24 at 12:08 -0500, Stuart A. Kurtz wrote: > Might it be more efficient to bypass counting altogether, and just use the Haskell version of stat? > > getFileSize :: FilePath -> IO Int64 > getFileSize path = do > stat <- getFileStatus path > let COff fs = fileSize stat > return fs Obviously. I assumed the original author would do something else while processing the file, not just count bytes... Nicolas From haskell at nand.wakku.to Tue Jun 24 17:13:07 2014 From: haskell at nand.wakku.to (Niklas Haas) Date: Tue, 24 Jun 2014 19:13:07 +0200 Subject: [Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation In-Reply-To: References: Message-ID: <20140624191307.GC6801@nanodesu.localdomain> On Tue, 24 Jun 2014 21:55:21 +0530, C K Kashyap wrote: > Again, I doubt about String since even if I change the number of files to > 12000 - the perl program finishes in less than a second. There are just so many things wrong with String and the String API, these are all colliding: 1. String is based on Char, which is a horribly inefficient representation of characters (a tagged machine word, possibly 64 bit, representing the UCS code point) 2. String is based on [], which are lazy linked lists - For each single character, you have a heap-allocated pointed to a heap-allocated Char and the heap-allocated rest of the list; traversing the String to compute its length involves going through the entire heap, dereferencing after every single step, and pattern matching on the (:) constructors (which also requires a branch), garbage collecting the unused intermediate structures along the way. 3. readFile is based on lazy IO, which means it opens the Handle and leaves it dangling, then returns some values that, when forced, will dynamically cause it to read some more bytes from the disk, allocate heap objects for them, write them in there, and leave the Handle dangling again. Only when you reach the end of the file does the Handle eventually automatically get garbage collected and the file therefore closed. (In theory; no practical guarantees on when it actually gets closed) 4. All the while, your program is churning through the files like mad, creating more and more dangling pointers that are just precariously hanging around all over the place. Contrast this to what the simple change to B.readFile and B.length does: ByteString is basically a pointer to some array of bytes in memory, together with its length. all B.readFile has to do is read in the bytes 1:1 without allocating anything other than a single fixed sized buffer to hold them all, the size of which is given by the file size. All B.length has to do is return the already-known size of the buffer. After the handle is opened and the contents read in, it's immediately closed. No garbage collection necessary other than eventually freeing up the buffer used to store its contents - a single operation. (In addition to the pointer itself, which is stored in the heap) As you can see, there is a complete world of difference between the two approaches on many levels - runtimes differing by one or even many orders of magnitude are no surprise. Some would go as far as to say that the String based file I/O APIs should be removed completely. Either way, you could make your operation even more efficient by not opening the files at all and just consulting their length through filesystem APIs. From tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Tue Jun 24 17:14:26 2014 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Tue, 24 Jun 2014 18:14:26 +0100 Subject: [Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation In-Reply-To: References: <1403629522.3587.18.camel@chi.nicolast.be> Message-ID: <20140624171426.GQ1418@henry> On Tue, Jun 24, 2014 at 10:37:35PM +0530, C K Kashyap wrote: > Thanks Nicholas :) ... and if I understand right doing `seq` would be > equivalent to Strict IO that Darren mentioned. right? It's probably best to think of them as distinct. Strict IO roughly means the whole file will be read at once so the file handle can be released. On the other hand `seq`ing the `length` forces the calculation of the length so the file is read completely and the file handle can be released. They have similar outcomes but the means of achieving them is different. Tom From aruiz at um.es Tue Jun 24 17:51:18 2014 From: aruiz at um.es (Alberto Ruiz) Date: Tue, 24 Jun 2014 19:51:18 +0200 Subject: [Haskell-cafe] ANN: hmatrix-0.16 In-Reply-To: <53A96EF5.8050902@fuuzetsu.co.uk> References: <53A46325.7070709@um.es> <53A96EF5.8050902@fuuzetsu.co.uk> Message-ID: <53A9BA96.9020000@um.es> On 06/24/2014 02:28 PM, Mateusz Kowalczyk wrote: > On 06/20/2014 06:36 PM, Alberto Ruiz wrote: >> Hi! >> >> I am happy to announce the release of hmatrix-0.16, a Haskell package >> for matrix computations and numeric linear algebra. >> >> New features: >> >> - BSD3 license. The modules depending on GSL have been moved to a new >> package hmatrix-gsl (GPL). Now hmatrix depends only on BLAS/LAPACK. >> >> - Simpler reexport modules with improved documentation and usage >> examples. There are a few API changes but the traditional modules are >> also exposed for backwards compatibility. >> >> - Alternative interface using type-level literals for static dimension >> checking and inference (work in progress). >> >> - Initial support for sparse linear systems. >> >> - Minor improvements and bug fixes (see the changelog for details). >> >> http://hackage.haskell.org/package/hmatrix >> >> https://github.com/albertoruiz/hmatrix >> >> Some examples: http://dis.um.es/~alberto/hmatrix/hmatrix.html >> >> Suggestions, contributions, and bug reports are welcome. >> >> Thanks! >> Alberto >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > It is great to see an example page: I have tried to use hmatrix in the > past for what should have been simple matrix/vector > multiplication/addition but quickly became frustrated unable to figure > out how to use it so I ended up writing my own (only needed few > operations to try something out). > > I suggest that you put the link to that page in the description of the > package so it shows on Hackage, on this[1] page. Thanks! > Secondly, I note that some modules (not all) such as > Numeric.Container[2] give the missing documentation page when clicked > on. Is this intentional? If I click back to something like version > 0.14.x and click on Numeric.Container, I get documentation as I would > expect. > > [1]: http://hackage.haskell.org/package/hmatrix > [2]: > http://hackage.haskell.org/package/hmatrix-0.16.0.3/docs/Numeric-Container.html > Those modules are exposed for backwards compatibility but don't provide a good documentation structure. Their haddock pages are now hidden in the documentation locally generated by cabal install. We should only see four better organized reexport modules. For some reason the {-# OPTIONS_HADDOCK hide #-} pragma works in a different way in the Hackage server and all exposed modules are shown, making the online documentation even more confusing than before :( From gautier.difolco at gmail.com Tue Jun 24 20:55:30 2014 From: gautier.difolco at gmail.com (Gautier DI FOLCO) Date: Tue, 24 Jun 2014 22:55:30 +0200 Subject: [Haskell-cafe] HSpec vs Doctest for TDD Message-ID: Hi all, I'm a huge fan of TDD (Test-Driven Development) et I used to use tools such as RSpec (Ruby). So naturally, I looked to HSpec, but it seems not idiomatic in Haskell. I have a bunch of questions: - Do you do TDD? - Which tools do you use? - Is doctest "better" (in some senses) than HSpec? Why? - Are HSpec and Doctest complementary? If so, in which case do you use one or another? - Is there some Haskell-specific good practices do to TDD? Thanks in advance for your lights. -------------- next part -------------- An HTML attachment was scrubbed... URL: From miguelimo38 at yandex.ru Tue Jun 24 21:18:11 2014 From: miguelimo38 at yandex.ru (MigMit) Date: Tue, 24 Jun 2014 23:18:11 +0200 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: References: Message-ID: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> Well, for me TDD seems to be a poor substitute for type safety. And I specifically mean the level of type safety Haskell provides. In other languages TDD could be a good thing (although I value explorative programming too much), but in Haskell I think it's a waste of time. ?????????? ? iPad > 24 ???? 2014 ?., ? 22:55, Gautier DI FOLCO ???????(?): > > Hi all, > > I'm a huge fan of TDD (Test-Driven Development) et I used to use tools such as RSpec (Ruby). So naturally, I looked to HSpec, but it seems not idiomatic in Haskell. > I have a bunch of questions: > - Do you do TDD? > - Which tools do you use? > - Is doctest "better" (in some senses) than HSpec? Why? > - Are HSpec and Doctest complementary? If so, in which case do you use one or another? > - Is there some Haskell-specific good practices do to TDD? > > Thanks in advance for your lights. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From michael at orlitzky.com Tue Jun 24 21:20:41 2014 From: michael at orlitzky.com (Michael Orlitzky) Date: Tue, 24 Jun 2014 17:20:41 -0400 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: References: Message-ID: <53A9EBA9.4030909@orlitzky.com> On 06/24/2014 04:55 PM, Gautier DI FOLCO wrote: > Hi all, > > I'm a huge fan of TDD (Test-Driven Development) et I used to use tools > such as RSpec (Ruby). So naturally, I looked to HSpec, but it seems not > idiomatic in Haskell. > I have a bunch of questions: > - Do you do TDD? > - Which tools do you use? > - Is doctest "better" (in some senses) than HSpec? Why? > - Are HSpec and Doctest complementary? If so, in which case do you use > one or another? > - Is there some Haskell-specific good practices do to TDD? > > Thanks in advance for your lights. I like to use doctests for examples because they double as documentation. So if you have a function that's supposed to lowercase a string, you might show, -- Caps get lowercased: -- -- >>> lowercase_it "HELLO" -- "hello" -- -- And lowercase letters are left alone: -- -- >>> lowercase_it "hello" -- "hello" -- -- Numbers are unaffected: -- -- >>> lowercase_it "123" -- "123" -- -- It doesn't crash on the empty string: -- -- >>> lowercase_it "" -- "" -- If you think it would be useful to the reader, make it a doctest. For tests with a big setup/teardown -- like 20 lines of inserting junk into the database -- I use HUnit instead. For properties like idempotence, there's QuickCheck. I usually start out with doctest, because everything needs an example. Then if complicated tests or properties arise, I'll create a tasty[1] suite with HUnit[2]/QuickCheck[3] tests. Tasty basically groups all of your HUnit, QuickCheck, SmallCheck, etc. tests into one big suite with nicely-formatted output. HSpec is redundant once you have all of that in place, so I personally haven't found a niche for it yet. [1] http://hackage.haskell.org/package/tasty [2] http://hackage.haskell.org/package/tasty-hunit [3] http://hackage.haskell.org/package/tasty-quickcheck From cma at bitemyapp.com Tue Jun 24 21:24:24 2014 From: cma at bitemyapp.com (Christopher Allen) Date: Tue, 24 Jun 2014 16:24:24 -0500 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: References: Message-ID: I don't have a problem with using TDD *and* type-safety to the full extent of usefulness, but the lifecycle/process isn't what TDD experts would call proper TDD. I do use HSpec, very happily. The author has done a truly excellent job with it. Process is something like: write types, validate types -> fill holes, validate terms against types -> compose functions to see if results are sane, go back to 1st or 2nd step if not. -> Are there useful invariants QuickCheck can express? Write those first. Repeat cycle as needed. -> Decide on meaningful but compact functional/integration tests, repeat cycle as needed. Example HSpec tests (just functional/integration): http://github.com/bitemyapp/bloodhound/ On Tue, Jun 24, 2014 at 3:55 PM, Gautier DI FOLCO wrote: > Hi all, > > I'm a huge fan of TDD (Test-Driven Development) et I used to use tools > such as RSpec (Ruby). So naturally, I looked to HSpec, but it seems not > idiomatic in Haskell. > I have a bunch of questions: > - Do you do TDD? > - Which tools do you use? > - Is doctest "better" (in some senses) than HSpec? Why? > - Are HSpec and Doctest complementary? If so, in which case do you use one > or another? > - Is there some Haskell-specific good practices do to TDD? > > Thanks in advance for your lights. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From johnw at newartisans.com Tue Jun 24 23:36:39 2014 From: johnw at newartisans.com (John Wiegley) Date: Tue, 24 Jun 2014 16:36:39 -0700 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: (Gautier DI FOLCO's message of "Tue, 24 Jun 2014 22:55:30 +0200") References: Message-ID: >>>>> Gautier DI FOLCO writes: > I'm a huge fan of TDD (Test-Driven Development) et I used to use tools such > as RSpec (Ruby). So naturally, I looked to HSpec, but it seems not idiomatic > in Haskell. > I have a bunch of questions: > - Do you do TDD? Not as such, no, although there are times when I write what I want to say first, and then implement how to say it. This isn't my primary mode of development, however. > - Which tools do you use? Doctest, hspec+hunit, quickcheck, fuzzcheck. > - Is doctest "better" (in some senses) than HSpec? Why? I think they address different needs, actually. > - Are HSpec and Doctest complementary? If so, in which case do you use one > or another? I use doctest as much as possible, not only to create a test, but to demonstrate and motivate use of a function for anyone reading the docs. Hspec can handle more complicated tests that would be too heavyweight in that scenario. > - Is there some Haskell-specific good practices do to TDD? First of all, invest in your types. As much as you can, avoid naked tuples, Strings or Ints. Use newtype and create type wrappers. Build new ADTs. Encode your invariants so that many of your "tests" become unnecessary. Then, when you have effects whose interplay cannot be encoded in types, focus on testing the possible runtime combinations. But even then, think about how you could encode that invariant in a type. John From ckkashyap at gmail.com Wed Jun 25 01:56:43 2014 From: ckkashyap at gmail.com (C K Kashyap) Date: Wed, 25 Jun 2014 07:26:43 +0530 Subject: [Haskell-cafe] Need help - my haskell code is over 50 times slower than equivalent perl implementation In-Reply-To: <20140624171426.GQ1418@henry> References: <1403629522.3587.18.camel@chi.nicolast.be> <20140624171426.GQ1418@henry> Message-ID: Thank you Tom, Niklas, Nicolas and Stuart, Calculating the length was just an illustration - what I really need to do is parse the file. Anyway, it is clear that String for IO is a bad idea - I wonder if examples of String based readFile etc for beginners is a good idea or not. Regards, Kashyap On Tue, Jun 24, 2014 at 10:44 PM, Tom Ellis < tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk> wrote: > On Tue, Jun 24, 2014 at 10:37:35PM +0530, C K Kashyap wrote: > > Thanks Nicholas :) ... and if I understand right doing `seq` would be > > equivalent to Strict IO that Darren mentioned. right? > > It's probably best to think of them as distinct. > > Strict IO roughly means the whole file will be read at once so the file > handle can be released. On the other hand `seq`ing the `length` forces the > calculation of the length so the file is read completely and the file > handle > can be released. They have similar outcomes but the means of achieving > them > is different. > > Tom > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From almeidaraf at gmail.com Wed Jun 25 03:54:03 2014 From: almeidaraf at gmail.com (Rafael Almeida) Date: Wed, 25 Jun 2014 00:54:03 -0300 Subject: [Haskell-cafe] Monad laws Message-ID: Hello, You guys have been great taking my questions. Thank you. Now I have another one :) What can go wrong if I make an Monad instance but don't follow Monad rules (identity and associativity)? Sure it would be misleading for someone using the non-conforming class. They may make code that assume those laws, although they don't hold. However, could it make the compiler generate bad code or some standard functions to behave badly or even break? []'s Rafael -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuuzetsu at fuuzetsu.co.uk Wed Jun 25 04:33:43 2014 From: fuuzetsu at fuuzetsu.co.uk (Mateusz Kowalczyk) Date: Wed, 25 Jun 2014 06:33:43 +0200 Subject: [Haskell-cafe] Monad laws In-Reply-To: References: Message-ID: <53AA5127.8010900@fuuzetsu.co.uk> On 06/25/2014 05:54 AM, Rafael Almeida wrote: > Hello, > > You guys have been great taking my questions. Thank you. Now I have another > one :) > > What can go wrong if I make an Monad instance but don't follow Monad rules > (identity and associativity)? Sure it would be misleading for someone using > the non-conforming class. They may make code that assume those laws, > although they don't hold. However, could it make the compiler generate bad > code The compiler makes no assumption (at least that I know of) that laws are followed. It should never generate ?bad? code (whatever that might mean) anyway. > or some standard functions to behave badly or even break? Yes, namely they wouldn't do ?the expected thing? if they rely on the laws. Also someone might be overeager and use RULES based on just type-class laws. > []'s > Rafael > > Basically, if you don't have a monad, don't make it an instance of Monad, it defeats the whole point of having a typeclass expecting some laws to be satisfied to begin with. -- Mateusz K. From jwlato at gmail.com Wed Jun 25 04:52:34 2014 From: jwlato at gmail.com (John Lato) Date: Wed, 25 Jun 2014 12:52:34 +0800 Subject: [Haskell-cafe] Monad laws In-Reply-To: <53AA5127.8010900@fuuzetsu.co.uk> References: <53AA5127.8010900@fuuzetsu.co.uk> Message-ID: On Wed, Jun 25, 2014 at 12:33 PM, Mateusz Kowalczyk wrote: > On 06/25/2014 05:54 AM, Rafael Almeida wrote: > > Hello, > > > > You guys have been great taking my questions. Thank you. Now I have > another > > one :) > > > > What can go wrong if I make an Monad instance but don't follow Monad > rules > > (identity and associativity)? Sure it would be misleading for someone > using > > the non-conforming class. They may make code that assume those laws, > > although they don't hold. However, could it make the compiler generate > bad > > code > > The compiler makes no assumption (at least that I know of) that laws are > followed. It should never generate ?bad? code (whatever that might mean) > anyway. > The compiler makes assumptions about associativity when de-sugaring do-notation. If the monad laws aren't followed, it's possible for these two blocks to show different behavior (given that a,b,c are all values of the misbehaved Monad instance): > do { a; b; c } > a >> b >> c I think everyone can agree that this is surprising, at the very least. Although it's not the compiler that's generating bad code here. John L. -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuuzetsu at fuuzetsu.co.uk Wed Jun 25 09:36:11 2014 From: fuuzetsu at fuuzetsu.co.uk (Mateusz Kowalczyk) Date: Wed, 25 Jun 2014 11:36:11 +0200 Subject: [Haskell-cafe] =?utf-8?b?RndkOiDoh6rliqjlm57lpI3vvJpSZTogQU5OOiBo?= =?utf-8?q?matrix-0=2E16?= In-Reply-To: <20140624163500.GM1418@henry> References: <20140622103749.D289BCB0318@mda06.fmail.tg.sinanode.com> <6470E8F5-12A8-4774-BF92-BBEB209A336F@steinitz.org> <20140624163500.GM1418@henry> Message-ID: <53AA980B.4050903@fuuzetsu.co.uk> On 06/24/2014 06:35 PM, Tom Ellis wrote: > On Sun, Jun 22, 2014 at 07:02:39PM +0800, Xiaojun "Phil" Hu wrote: >> It's an "auto-reply" feature popular among Chinese email providers. They >> just "auto-reply" any email they get. >> >> If wanna ignore this, you can just create a spam filter with "????" -- it >> means "auto-reply" in Mandarin. > > Really I think it would be best if the admins would unsubscribe such users. > It's basically antisocial, costing every poster a little bit of annoyance. > Altogether it adds up to a lot. > > Tom > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > I have sought help in #haskell before but wasn't able to find anyone in charge. I will post to infrastructure. -- Mateusz K. From jkarni at gmail.com Wed Jun 25 09:46:45 2014 From: jkarni at gmail.com (Julian K. Arni) Date: Wed, 25 Jun 2014 11:46:45 +0200 Subject: [Haskell-cafe] Quantification in Instance Contexts Message-ID: <20140625094617.GB17417@jkarni.celeraone.com> Hi Cafe, I'm playing around with simple logic-programming at the type level. For instance, encoding trees: >> {-# LANGUAGE MultiParamTypeClasses >> , FunctionalDependencies >> , FlexibleInstances >> , UndecidableInstances >> , FlexibleContexts >> , OverlappingInstances #-} >> {-# OPTIONS_GHC -fcontext-stack=100 #-} >> >> >> -- *A >> -- / \ >> -- B* *C >> -- | >> -- D* >> >> >> data A >> data B >> data C >> data D >> class Child a b bool | a b -> bool >> instance Child A B TrueT >> instance Child B D TrueT >> instance Child B C TrueT >> class Path a b bool | a b -> bool Now the following obviously doesn't work (never mind for now that 'Path' needs a recursive definition, and that this is really just 'Grandchild'): >> instance (Child a b TrueT, Child b c TrueT) => Path a c TrueT Because 'b' is ambiguous. Fair enough. But I can't directly use a fundep, because 'b' *is* in fact ambiguous. What I want to tell the compiler is that it's really okay, since the RHS side (and any possible 'where' expressions) doesn't depend on what is instantiated for 'b'. I know I could switch to a class 'Children a bs bool' and encode all children of as a type-level list, and then have a fundep between 'a' and 'bs'. That's not a *bad* solution: it does give a good sense of the intention. But it's not very extensible; really I'd rather be using something like 'forall' - something, I would guess, along the lines of: >> instance forall a c. (forall b. (Child a b TrueT, Child b c TrueT)) => Path >> a c TrueT That, however, fails with: Malformed instance head: (forall b. (Child a b TrueT, Child b c TrueT)) -> Path a c TrueT In the instance declaration for ?Path a c TrueT? So: is there a way (presumably with 'forall') of telling the compiler that the ambiguous type 'b' actually won't "leak through" to the RHS, so stop bugging me about ambiguity? Thanks, Julian From klao at nilcons.com Wed Jun 25 10:58:53 2014 From: klao at nilcons.com (Mihaly Barasz) Date: Wed, 25 Jun 2014 12:58:53 +0200 Subject: [Haskell-cafe] accessing a ByteArray from FFI Message-ID: <20140625105853.GA25084@cs.elte.hu> Hello, I want to access the contents of a Data.Vector.Primitive from FFI. I came up with the following so far: {-# LANGUAGE ForeignFunctionInterface #-} module FFIExample (exampleFn) where import Control.Monad.Primitive (touch) import Control.Monad.ST (runST) import Data.Primitive.Addr (Addr(..)) import Data.Primitive.ByteArray (mutableByteArrayContents) import qualified Data.Vector.Primitive as P import qualified Data.Vector.Primitive.Mutable as PM import GHC.Ptr (Ptr(..), plusPtr) import Data.Word (Word64) foreign import ccall unsafe "my_external_fn" myExternalFn :: Ptr Word64 -> Int -> Int exampleFn :: P.Vector Word64 -> Int exampleFn v = runST $ do ? PM.MVector off len mba <- P.unsafeThaw v ? let ptr = case mutableByteArrayContents mba of ? ? ? ? Addr addr -> Ptr addr `plusPtr` off ? ? ? result = myExternalFn ptr len ? result `seq` touch mba ? return result This seems to work, but I have questions that I haven't been able to find the answers to on my own: 1. Is this actually OK to do? I guess that this wouldn't be OK if the foreign import were "safe", as then the GC could move the contents of the byte array while the foreign function is running. But is it safe like this? 2. If the answer to the previous question is no, then is there a way to do it properly? Or there is just no way to pass an unpinned byte array to a foreign call? What about foreign import prim? 3. If the answer to Q1 is no, then would it be OK if the underlying byte array were pinned? 4. Any other simplifications? Pointers to resources on these topics would be more than welcome! But, I haven't been able to find any. Thanks, Mihaly From hjgtuyl at chello.nl Wed Jun 25 11:56:10 2014 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Wed, 25 Jun 2014 13:56:10 +0200 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> References: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> Message-ID: On Tue, 24 Jun 2014 23:18:11 +0200, MigMit wrote: > Well, for me TDD seems to be a poor substitute for type safety. > > And I specifically mean the level of type safety Haskell provides. In > other languages TDD could be a good thing (although I value explorative > programming too much), but in Haskell I think it's a waste of time. Type safety does not cover everything; nearly an infinite number of functions could be made with the type: f :: Int -> Int To paraphrase prof. Edsger W. Dijkstra: No amount of type checking will prove a program correct Regards, Henk-Jan van Tuyl -- Folding at home What if you could share your unused computer power to help find a cure? In just 5 minutes you can join the world's biggest networked computer and get us closer sooner. Watch the video. http://folding.stanford.edu/ http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming -- From johan.tibell at gmail.com Wed Jun 25 12:11:44 2014 From: johan.tibell at gmail.com (Johan Tibell) Date: Wed, 25 Jun 2014 14:11:44 +0200 Subject: [Haskell-cafe] accessing a ByteArray from FFI In-Reply-To: <20140625105853.GA25084@cs.elte.hu> References: <20140625105853.GA25084@cs.elte.hu> Message-ID: Hi, On Wed, Jun 25, 2014 at 12:58 PM, Mihaly Barasz wrote: > 1. Is this actually OK to do? I guess that this wouldn't be OK if the > foreign import were "safe", as then the GC could move the contents of > the byte array while the foreign function is running. But is it safe > like this? > Whether the foreign import is marked as safe or not doesn't matter. The GC might move the array just after you make your address computation but before the call is made. This is only safe if the Primitive array is guaranteed to be pinned. I checked the docs for that module and couldn't see any such promise. > 2. If the answer to the previous question is no, then is there a way to > do it properly? Or there is just no way to pass an unpinned byte array > to a foreign call? What about foreign import prim? > There is a way to pass an unpinned ByteArray# (or MutableByteArray#, but the former seems right in your case) to a foreign call, using the UnliftedFFITypes language extension. The ByteArray# is guaranteed to not to be moved for the duration of the call. The code should treat the ByteArray# argument as if it was a pointer to bytes. You will need to do any address offset computations on the C side (i.e. pass any offsets you need as extra argument to your C function). > 3. If the answer to Q1 is no, then would it be OK if the underlying byte > array were pinned? > Yes, but I don't know if you can have the API give you any such guarantees, unless you use the Storable vector version. > 4. Any other simplifications? > The unsafeThat bothers me. Doesn't vector give you any other way to get to the underlying ByteArray#? -- Johan -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuuzetsu at fuuzetsu.co.uk Wed Jun 25 12:45:37 2014 From: fuuzetsu at fuuzetsu.co.uk (Mateusz Kowalczyk) Date: Wed, 25 Jun 2014 14:45:37 +0200 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: References: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> Message-ID: <53AAC471.7050505@fuuzetsu.co.uk> On 06/25/2014 01:56 PM, Henk-Jan van Tuyl wrote: > On Tue, 24 Jun 2014 23:18:11 +0200, MigMit wrote: > >> Well, for me TDD seems to be a poor substitute for type safety. >> >> And I specifically mean the level of type safety Haskell provides. In >> other languages TDD could be a good thing (although I value explorative >> programming too much), but in Haskell I think it's a waste of time. > > Type safety does not cover everything; nearly an infinite number of > functions could be made with the type: > f :: Int -> Int > > To paraphrase prof. Edsger W. Dijkstra: > No amount of type checking will prove a program correct > > Regards, > Henk-Jan van Tuyl > > While I disagree with initial view that testing is useless, I certainly disagree with this approach too. There are plenty proof-assistants using type-checking to prove programs correct. That's not to say Haskell itself is suited for such task. If you have a type system strong enough, classical tests are no longer required because you can encode all the properties you need in types proving at compile time that your program is in fact correct. -- Mateusz K. From klao at nilcons.com Wed Jun 25 12:54:24 2014 From: klao at nilcons.com (Mihaly Barasz) Date: Wed, 25 Jun 2014 14:54:24 +0200 Subject: [Haskell-cafe] accessing a ByteArray from FFI In-Reply-To: References: <20140625105853.GA25084@cs.elte.hu> Message-ID: On Wed, Jun 25, 2014 at 2:11 PM, Johan Tibell wrote: > Hi, > > On Wed, Jun 25, 2014 at 12:58 PM, Mihaly Barasz wrote: >> >> 1. Is this actually OK to do? I guess that this wouldn't be OK if the >> foreign import were "safe", as then the GC could move the contents of >> the byte array while the foreign function is running. But is it safe >> like this? > > > Whether the foreign import is marked as safe or not doesn't matter. The GC > might move the array just after you make your address computation but before > the call is made. This is only safe if the Primitive array is guaranteed to > be pinned. I checked the docs for that module and couldn't see any such > promise. Well, I don't know enough about how GC is specified in GHC, but _in practice_ calls to GC could happen only on entry to the exampleFn closure. Not between the address computation and the foreign call. (I simply looked at the generated code, I don't know if there is any guarantee for that.) >> >> 2. If the answer to the previous question is no, then is there a way to >> do it properly? Or there is just no way to pass an unpinned byte array >> to a foreign call? What about foreign import prim? > > > There is a way to pass an unpinned ByteArray# (or MutableByteArray#, but the > former seems right in your case) to a foreign call, using the > UnliftedFFITypes language extension. The ByteArray# is guaranteed to not to > be moved for the duration of the call. The code should treat the ByteArray# > argument as if it was a pointer to bytes. You will need to do any address > offset computations on the C side (i.e. pass any offsets you need as extra > argument to your C function). Thanks, I'll look into that. Are there any pointers/examples? >> >> 3. If the answer to Q1 is no, then would it be OK if the underlying byte >> array were pinned? > > > Yes, but I don't know if you can have the API give you any such guarantees, > unless you use the Storable vector version. > >> >> 4. Any other simplifications? > > > The unsafeThat bothers me. Doesn't vector give you any other way to get to > the underlying ByteArray#? I don't know why, but the constructor for Vector is not exported, only for the MVector. But, this use of unsafeThaw is completely benign. (Actually, it fully disappears in the generated code. :)) > -- Johan > From tobias.pflug at gmx.net Wed Jun 25 12:58:21 2014 From: tobias.pflug at gmx.net (Tobias Pflug) Date: Wed, 25 Jun 2014 14:58:21 +0200 Subject: [Haskell-cafe] =?utf-8?b?RndkOiDoh6rliqjlm57lpI3vvJpSZTogQU5OOiBo?= =?utf-8?q?matrix-0=2E16?= In-Reply-To: <20140624163500.GM1418@henry> References: <20140622103749.D289BCB0318@mda06.fmail.tg.sinanode.com> <6470E8F5-12A8-4774-BF92-BBEB209A336F@steinitz.org> <20140624163500.GM1418@henry> Message-ID: <824E54C0-8CBF-4E55-A5D9-62B0C3987861@gmx.net> Yes, please.. those messages are annoying SPAM in my book. > On 24.06.2014, at 18:35, Tom Ellis wrote: > >> On Sun, Jun 22, 2014 at 07:02:39PM +0800, Xiaojun "Phil" Hu wrote: >> It's an "auto-reply" feature popular among Chinese email providers. They >> just "auto-reply" any email they get. >> >> If wanna ignore this, you can just create a spam filter with "????" -- it >> means "auto-reply" in Mandarin. > > Really I think it would be best if the admins would unsubscribe such users. > It's basically antisocial, costing every poster a little bit of annoyance. > Altogether it adds up to a lot. > > Tom > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From johan.tibell at gmail.com Wed Jun 25 13:02:34 2014 From: johan.tibell at gmail.com (Johan Tibell) Date: Wed, 25 Jun 2014 15:02:34 +0200 Subject: [Haskell-cafe] accessing a ByteArray from FFI In-Reply-To: References: <20140625105853.GA25084@cs.elte.hu> Message-ID: On Wed, Jun 25, 2014 at 2:54 PM, Mihaly Barasz wrote: > Well, I don't know enough about how GC is specified in GHC, but _in > practice_ calls to GC could happen only on entry to the exampleFn > closure. Not between the address computation and the foreign call. (I > simply looked at the generated code, I don't know if there is any > guarantee for that.) > There can be additional heap checks at the start of any basic block in the generated assembly for the function. Right, in practice there's probably not an issue. > Thanks, I'll look into that. Are there any pointers/examples? > There's some code out there on the web that uses the extension. Here's an example: https://github.com/tibbe/hashable/blob/master/Data/Hashable/Class.hs#L470 > I don't know why, but the constructor for Vector is not exported, only > for the MVector. But, this use of unsafeThaw is completely benign. > (Actually, it fully disappears in the generated code. :)) > Probably because it's a ByteArray#, not an Array#. For the latter unsafe thawing results in the object being put on the GC mutable list (in practice that means that the info table ptr changes). -------------- next part -------------- An HTML attachment was scrubbed... URL: From vogt.adam at gmail.com Wed Jun 25 13:06:39 2014 From: vogt.adam at gmail.com (adam vogt) Date: Wed, 25 Jun 2014 09:06:39 -0400 Subject: [Haskell-cafe] Quantification in Instance Contexts In-Reply-To: <20140625094617.GB17417@jkarni.celeraone.com> References: <20140625094617.GB17417@jkarni.celeraone.com> Message-ID: Hi Julian, Does each child have only one parent? In other words, is a larger "tree" still accepted if you use: class Child1 a b bool | a b -> bool, b -> a instead of your Child. Regards, Adam On Wed, Jun 25, 2014 at 5:46 AM, Julian K. Arni wrote: > Hi Cafe, > > I'm playing around with simple logic-programming at the type level. For > instance, encoding trees: > >>> {-# LANGUAGE MultiParamTypeClasses >>> , FunctionalDependencies >>> , FlexibleInstances >>> , UndecidableInstances >>> , FlexibleContexts >>> , OverlappingInstances #-} >>> {-# OPTIONS_GHC -fcontext-stack=100 #-} >>> >>> >>> -- *A >>> -- / \ >>> -- B* *C >>> -- | >>> -- D* >>> >>> >>> data A >>> data B >>> data C >>> data D >>> class Child a b bool | a b -> bool >>> instance Child A B TrueT >>> instance Child B D TrueT >>> instance Child B C TrueT >>> class Path a b bool | a b -> bool > > Now the following obviously doesn't work (never mind for now that 'Path' needs > a recursive definition, and that this is really just 'Grandchild'): > >>> instance (Child a b TrueT, Child b c TrueT) => Path a c TrueT > > Because 'b' is ambiguous. Fair enough. But I can't directly use a fundep, > because 'b' *is* in fact ambiguous. What I want to tell the compiler is that > it's really okay, since the RHS side (and any possible 'where' expressions) > doesn't depend on what is instantiated for 'b'. > > I know I could switch to a class 'Children a bs bool' and encode all children > of as a type-level list, and then have a fundep between 'a' and 'bs'. That's > not a *bad* solution: it does give a good sense of the intention. But it's not > very extensible; really I'd rather be using something like 'forall' > - something, I would guess, along the lines of: > >>> instance forall a c. (forall b. (Child a b TrueT, Child b c TrueT)) => Path >>> a c TrueT > > That, however, fails with: > > Malformed instance head: (forall b. > (Child a b TrueT, Child b c TrueT)) > -> Path a c TrueT > In the instance declaration for ?Path a c TrueT? > > > So: is there a way (presumably with 'forall') of telling the compiler that the > ambiguous type 'b' actually won't "leak through" to the RHS, so stop bugging me > about ambiguity? > > Thanks, > Julian > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From klao at nilcons.com Wed Jun 25 13:48:48 2014 From: klao at nilcons.com (Mihaly Barasz) Date: Wed, 25 Jun 2014 15:48:48 +0200 Subject: [Haskell-cafe] accessing a ByteArray from FFI In-Reply-To: References: <20140625105853.GA25084@cs.elte.hu> Message-ID: <20140625134848.GA26861@cs.elte.hu> On Wed, Jun 25, 2014 at 15:02 +0200, Johan Tibell wrote: > On Wed, Jun 25, 2014 at 2:54 PM, Mihaly Barasz wrote: > > > Well, I don't know enough about how GC is specified in GHC, but _in > > practice_ calls to GC could happen only on entry to the exampleFn > > closure. Not between the address computation and the foreign call. (I > > simply looked at the generated code, I don't know if there is any > > guarantee for that.) > > > > There can be additional heap checks at the start of any basic block in the > generated assembly for the function. Right, in practice there's probably > not an issue. > > > > Thanks, I'll look into that. Are there any pointers/examples? > > > > There's some code out there on the web that uses the extension. Here's an > example: > https://github.com/tibbe/hashable/blob/master/Data/Hashable/Class.hs#L470 Thanks, this works wonderfully. The code is much simplified: {-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE MagicHash, UnliftedFFITypes #-} module FFIExample (exampleFn) where import Control.Monad.ST (runST) import Data.Primitive.ByteArray (ByteArray(..), ByteArray#, unsafeFreezeByteArray) import qualified Data.Vector.Primitive as P import qualified Data.Vector.Primitive.Mutable as PM import Data.Word (Word64) foreign import ccall unsafe "my_external_fn" myExternalFn :: ByteArray# -> Int -> Int -> Int exampleFn :: P.Vector Word64 -> Int exampleFn v = runST $ do PM.MVector off len mba <- P.unsafeThaw v ByteArray ba <- unsafeFreezeByteArray mba return $! myExternalFn ba off len And yeah, now the unsafeThaw followed immediately by the unsafeFreezeByteArray looks even sillier. (But again, it completely disappears in the generated code.) Mihaly > > > I don't know why, but the constructor for Vector is not exported, only > > for the MVector. But, this use of unsafeThaw is completely benign. > > (Actually, it fully disappears in the generated code. :)) > > > > Probably because it's a ByteArray#, not an Array#. For the latter unsafe > thawing results in the object being put on the GC mutable list (in practice > that means that the info table ptr changes). From jkarni at gmail.com Wed Jun 25 14:00:47 2014 From: jkarni at gmail.com (Julian Arni) Date: Wed, 25 Jun 2014 16:00:47 +0200 Subject: [Haskell-cafe] Quantification in Instance Contexts In-Reply-To: References: <20140625094617.GB17417@jkarni.celeraone.com> Message-ID: Alas, no. I tried to simplify the use case, but in fact the structure is a DAG, and each node may have multiple parents. So neither "a -> b" nor "b -> a" hold. On Wed, Jun 25, 2014 at 3:06 PM, adam vogt wrote: > Hi Julian, > > Does each child have only one parent? In other words, is a larger > "tree" still accepted if you use: > > class Child1 a b bool | a b -> bool, b -> a > > instead of your Child. > > Regards, > Adam > > > On Wed, Jun 25, 2014 at 5:46 AM, Julian K. Arni wrote: > > Hi Cafe, > > > > I'm playing around with simple logic-programming at the type level. For > > instance, encoding trees: > > > >>> {-# LANGUAGE MultiParamTypeClasses > >>> , FunctionalDependencies > >>> , FlexibleInstances > >>> , UndecidableInstances > >>> , FlexibleContexts > >>> , OverlappingInstances #-} > >>> {-# OPTIONS_GHC -fcontext-stack=100 #-} > >>> > >>> > >>> -- *A > >>> -- / \ > >>> -- B* *C > >>> -- | > >>> -- D* > >>> > >>> > >>> data A > >>> data B > >>> data C > >>> data D > >>> class Child a b bool | a b -> bool > >>> instance Child A B TrueT > >>> instance Child B D TrueT > >>> instance Child B C TrueT > >>> class Path a b bool | a b -> bool > > > > Now the following obviously doesn't work (never mind for now that 'Path' > needs > > a recursive definition, and that this is really just 'Grandchild'): > > > >>> instance (Child a b TrueT, Child b c TrueT) => Path a c TrueT > > > > Because 'b' is ambiguous. Fair enough. But I can't directly use a fundep, > > because 'b' *is* in fact ambiguous. What I want to tell the compiler is > that > > it's really okay, since the RHS side (and any possible 'where' > expressions) > > doesn't depend on what is instantiated for 'b'. > > > > I know I could switch to a class 'Children a bs bool' and encode all > children > > of as a type-level list, and then have a fundep between 'a' and 'bs'. > That's > > not a *bad* solution: it does give a good sense of the intention. But > it's not > > very extensible; really I'd rather be using something like 'forall' > > - something, I would guess, along the lines of: > > > >>> instance forall a c. (forall b. (Child a b TrueT, Child b c TrueT)) => > Path > >>> a c TrueT > > > > That, however, fails with: > > > > Malformed instance head: (forall b. > > (Child a b TrueT, Child b c TrueT)) > > -> Path a c TrueT > > In the instance declaration for ?Path a c TrueT? > > > > > > So: is there a way (presumably with 'forall') of telling the compiler > that the > > ambiguous type 'b' actually won't "leak through" to the RHS, so stop > bugging me > > about ambiguity? > > > > Thanks, > > Julian > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From gdweber at iue.edu Wed Jun 25 14:07:27 2014 From: gdweber at iue.edu (Gregory Dean Weber) Date: Wed, 25 Jun 2014 10:07:27 -0400 Subject: [Haskell-cafe] determine hoolge database directory In-Reply-To: <53A88FDE.4010601@gmx.net> References: <53A88FDE.4010601@gmx.net> Message-ID: <20140625140726.GE2165@lady> Hi, Tobi, and welcome to Haskell. Maybe this would help: http://neilmitchell.blogspot.com/2008/02/adding-data-files-using-cabal.html See also the Cabal User's Guide -- in particular, the section on "Accessing data files from package code" -- http://www.haskell.org/cabal/users-guide/ http://www.haskell.org/cabal/users-guide/developing-packages.html#accessing-data-files-from-package-code Gregory On 2014-Jun-23, Tobias Pflug and/or a Mail User Agent wrote: > Hi haskellers, > > i'm new to haskell and am currently working on some tool that is > supposed to fiddle with hoogle database files. Now I'm looking > for a sane way to determine the directory where hoogle stores its > database directories (when you perform `hoogle data`). > In my case this is: > .cabal/share/x86_64-linux-ghc-7.8.2/hoogle-4.2.33/databases > > So this is [home directory]/.cabal/[ghc-version]/[hoogle-version]/databases > > Could someone suggest me a sane way how I can determine this path at > runtime ? Maybe there is a way to extract this > from somewhere ? I'm out of ideas on this. I could of course take > the easy way out and let users declare the path > as config parameter but it would be nice if there was a way ... > > thanks in advance. > > regards, > Tobi > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- Gregory D. Weber, Ph. D. http://mypage.iu.edu/~gdweber/ Associate Professor of Informatics Tel (765) 973-8420 Indiana University East FAX (765) 973-8550 From miguelimo38 at yandex.ru Wed Jun 25 14:46:39 2014 From: miguelimo38 at yandex.ru (MigMit) Date: Wed, 25 Jun 2014 16:46:39 +0200 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: References: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> Message-ID: That's true. I'm not stating tests aren't necessary; I'm stating TDD isn't necessary. You write tests, but you don't START with writing tests. ?????????? ? iPad > 25 ???? 2014 ?., ? 13:56, "Henk-Jan van Tuyl" ???????(?): > >> On Tue, 24 Jun 2014 23:18:11 +0200, MigMit wrote: >> >> Well, for me TDD seems to be a poor substitute for type safety. >> >> And I specifically mean the level of type safety Haskell provides. In other languages TDD could be a good thing (although I value explorative programming too much), but in Haskell I think it's a waste of time. > > Type safety does not cover everything; nearly an infinite number of functions could be made with the type: > f :: Int -> Int > > To paraphrase prof. Edsger W. Dijkstra: > No amount of type checking will prove a program correct > > Regards, > Henk-Jan van Tuyl > > > -- > Folding at home > What if you could share your unused computer power to help find a cure? In just 5 minutes you can join the world's biggest networked computer and get us closer sooner. Watch the video. > http://folding.stanford.edu/ > > > http://Van.Tuyl.eu/ > http://members.chello.nl/hjgtuyl/tourdemonad.html > Haskell programming > -- From alois.cochard at gmail.com Wed Jun 25 14:51:58 2014 From: alois.cochard at gmail.com (Alois Cochard) Date: Wed, 25 Jun 2014 15:51:58 +0100 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: References: Message-ID: For me TDD is highly overrated, and is abused as a buzz word by recruiter... In the context of writing a DSL, how one can start by the test? It's just impossible... TDD is okay if you fix a regression... sure I always fix bug that way, I start by creating a test that reproduce it... but I never ever do TDD when designing something new... >From my experience, usually people advocating TDD, are kind of person to focus more the methodology than the actual technical challenge... it might be what you are looking for... I don't. On 24 June 2014 21:55, Gautier DI FOLCO wrote: > Hi all, > > I'm a huge fan of TDD (Test-Driven Development) et I used to use tools > such as RSpec (Ruby). So naturally, I looked to HSpec, but it seems not > idiomatic in Haskell. > I have a bunch of questions: > - Do you do TDD? > - Which tools do you use? > - Is doctest "better" (in some senses) than HSpec? Why? > - Are HSpec and Doctest complementary? If so, in which case do you use one > or another? > - Is there some Haskell-specific good practices do to TDD? > > Thanks in advance for your lights. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- *A\ois* http://twitter.com/aloiscochard http://github.com/aloiscochard -------------- next part -------------- An HTML attachment was scrubbed... URL: From fa-ml at ariis.it Wed Jun 25 15:24:31 2014 From: fa-ml at ariis.it (Francesco Ariis) Date: Wed, 25 Jun 2014 17:24:31 +0200 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: <53AAC471.7050505@fuuzetsu.co.uk> References: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> <53AAC471.7050505@fuuzetsu.co.uk> Message-ID: <20140625152431.GA25045@x60s.casa> On Wed, Jun 25, 2014 at 02:45:37PM +0200, Mateusz Kowalczyk wrote: > While I disagree with initial view that testing is useless, I certainly > disagree with this approach too. There are plenty proof-assistants using > type-checking to prove programs correct. That's not to say Haskell > itself is suited for such task. If you have a type system strong enough, > classical tests are no longer required because you can encode all the > properties you need in types proving at compile time that your program > is in fact correct. > For non-believers, here is a blog post that opened my eyes on the matter [1]. [1] http://lambda.jstolarek.com/2013/12/data-is-evidence/ From michael at orlitzky.com Wed Jun 25 15:47:23 2014 From: michael at orlitzky.com (Michael Orlitzky) Date: Wed, 25 Jun 2014 11:47:23 -0400 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: <20140625152431.GA25045@x60s.casa> References: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> <53AAC471.7050505@fuuzetsu.co.uk> <20140625152431.GA25045@x60s.casa> Message-ID: <53AAEF0B.1000407@orlitzky.com> On 06/25/2014 11:24 AM, Francesco Ariis wrote: > On Wed, Jun 25, 2014 at 02:45:37PM +0200, Mateusz Kowalczyk wrote: >> While I disagree with initial view that testing is useless, I certainly >> disagree with this approach too. There are plenty proof-assistants using >> type-checking to prove programs correct. That's not to say Haskell >> itself is suited for such task. If you have a type system strong enough, >> classical tests are no longer required because you can encode all the >> properties you need in types proving at compile time that your program >> is in fact correct. >> > > For non-believers, here is a blog post that opened my eyes on the matter [1]. > > [1] http://lambda.jstolarek.com/2013/12/data-is-evidence/ None of that helps if you write the wrong program. Your program may typecheck, but if you're expecting "42" as output and your program hums the Star Trek theme instead, the fact that it correctly does the wrong thing won't be much consolation. From miguelimo38 at yandex.ru Wed Jun 25 16:05:18 2014 From: miguelimo38 at yandex.ru (MigMit) Date: Wed, 25 Jun 2014 18:05:18 +0200 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: <53AAEF0B.1000407@orlitzky.com> References: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> <53AAC471.7050505@fuuzetsu.co.uk> <20140625152431.GA25045@x60s.casa> <53AAEF0B.1000407@orlitzky.com> Message-ID: <2E2EBEC1-6D69-49DA-BBE2-78AB2ABC0A29@yandex.ru> Again, nobody here suggests that tests aren't necessary. ?????????? ? iPad > 25 ???? 2014 ?., ? 17:47, Michael Orlitzky ???????(?): > >> On 06/25/2014 11:24 AM, Francesco Ariis wrote: >>> On Wed, Jun 25, 2014 at 02:45:37PM +0200, Mateusz Kowalczyk wrote: >>> While I disagree with initial view that testing is useless, I certainly >>> disagree with this approach too. There are plenty proof-assistants using >>> type-checking to prove programs correct. That's not to say Haskell >>> itself is suited for such task. If you have a type system strong enough, >>> classical tests are no longer required because you can encode all the >>> properties you need in types proving at compile time that your program >>> is in fact correct. >> >> For non-believers, here is a blog post that opened my eyes on the matter [1]. >> >> [1] http://lambda.jstolarek.com/2013/12/data-is-evidence/ > > None of that helps if you write the wrong program. Your program may > typecheck, but if you're expecting "42" as output and your program hums > the Star Trek theme instead, the fact that it correctly does the wrong > thing won't be much consolation. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From mwm at mired.org Wed Jun 25 16:10:09 2014 From: mwm at mired.org (Mike Meyer) Date: Wed, 25 Jun 2014 11:10:09 -0500 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: <2E2EBEC1-6D69-49DA-BBE2-78AB2ABC0A29@yandex.ru> References: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> <53AAC471.7050505@fuuzetsu.co.uk> <20140625152431.GA25045@x60s.casa> <53AAEF0B.1000407@orlitzky.com> <2E2EBEC1-6D69-49DA-BBE2-78AB2ABC0A29@yandex.ru> Message-ID: On Wed, Jun 25, 2014 at 11:05 AM, MigMit wrote: > Again, nobody here suggests that tests aren't necessary. > Doing so would make them a PETS member (People for the Ethical Treatment of Software): http://humor.mcf.com/microsloth/pets.html -------------- next part -------------- An HTML attachment was scrubbed... URL: From fa-ml at ariis.it Wed Jun 25 16:26:06 2014 From: fa-ml at ariis.it (Francesco Ariis) Date: Wed, 25 Jun 2014 18:26:06 +0200 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: <53AAEF0B.1000407@orlitzky.com> References: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> <53AAC471.7050505@fuuzetsu.co.uk> <20140625152431.GA25045@x60s.casa> <53AAEF0B.1000407@orlitzky.com> Message-ID: <20140625162606.GA3211@x60s.casa> On Wed, Jun 25, 2014 at 11:47:23AM -0400, Michael Orlitzky wrote: > On 06/25/2014 11:24 AM, Francesco Ariis wrote: > > > > For non-believers, here is a blog post that opened my eyes on the matter [1]. > > > > [1] http://lambda.jstolarek.com/2013/12/data-is-evidence/ > > None of that helps if you write the wrong program. Your program may > typecheck, but if you're expecting "42" as output and your program hums > the Star Trek theme instead, the fact that it correctly does the wrong > thing won't be much consolation. data Hum = HumStarTrekTheme | CountrySong data UltimateAnswerToEverything = FourtyTwo {- assorted datatypes and functions -} program :: a -> UltimateAnswerToEverything Getting serious again, the author of the post states: " A type system can be regarded as calculating a kind of static approximation to the run-time behaviours of the terms in a program. and then delivers (i.e. |order zero (suc b) = ge ge0| won't typecheck). I cannot but feel 90%+ of tests are just an "ad hoc, bug ridden, informally specified" type system. From spam at scientician.net Wed Jun 25 16:28:27 2014 From: spam at scientician.net (Bardur Arantsson) Date: Wed, 25 Jun 2014 18:28:27 +0200 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: References: Message-ID: On 2014-06-24 22:55, Gautier DI FOLCO wrote: > Hi all, > > I'm a huge fan of TDD (Test-Driven Development) et I used to use tools such > as RSpec (Ruby). So naturally, I looked to HSpec, but it seems not > idiomatic in Haskell. > I have a bunch of questions: > - Do you do TDD? > - Which tools do you use? > - Is doctest "better" (in some senses) than HSpec? Why? > - Are HSpec and Doctest complementary? If so, in which case do you use one > or another? > - Is there some Haskell-specific good practices do to TDD? > > Thanks in advance for your lights. > I suspect most people practice "the other TDD", namely *Type*-Directed Development. At its most basic you just start by writing out all the type signatures (and type classes and whatnot) that you expect everything to have with "undefined" as the body of the functions. Then you just fill in the "undefined"s. Regards, From dedgrant at gmail.com Wed Jun 25 16:37:12 2014 From: dedgrant at gmail.com (Darren Grant) Date: Wed, 25 Jun 2014 09:37:12 -0700 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: <20140625152431.GA25045@x60s.casa> References: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> <53AAC471.7050505@fuuzetsu.co.uk> <20140625152431.GA25045@x60s.casa> Message-ID: Great share thank you! There is incredible motivation for typed calculus here: Where there are formal properties a proof may be pursued to build reliable abstractions. Where and how such methods are applied must still remain the purview of thoughtful design. Cheers, Darren On Jun 25, 2014 8:25 AM, "Francesco Ariis" wrote: > On Wed, Jun 25, 2014 at 02:45:37PM +0200, Mateusz Kowalczyk wrote: > > While I disagree with initial view that testing is useless, I certainly > > disagree with this approach too. There are plenty proof-assistants using > > type-checking to prove programs correct. That's not to say Haskell > > itself is suited for such task. If you have a type system strong enough, > > classical tests are no longer required because you can encode all the > > properties you need in types proving at compile time that your program > > is in fact correct. > > > > For non-believers, here is a blog post that opened my eyes on the matter > [1]. > > [1] http://lambda.jstolarek.com/2013/12/data-is-evidence/ > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From spam at scientician.net Wed Jun 25 17:01:24 2014 From: spam at scientician.net (Bardur Arantsson) Date: Wed, 25 Jun 2014 19:01:24 +0200 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: References: Message-ID: On 2014-06-25 18:28, Bardur Arantsson wrote: > On 2014-06-24 22:55, Gautier DI FOLCO wrote: >> Hi all, >> >> I'm a huge fan of TDD (Test-Driven Development) et I used to use tools such >> as RSpec (Ruby). So naturally, I looked to HSpec, but it seems not >> idiomatic in Haskell. >> I have a bunch of questions: >> - Do you do TDD? >> - Which tools do you use? >> - Is doctest "better" (in some senses) than HSpec? Why? >> - Are HSpec and Doctest complementary? If so, in which case do you use one >> or another? >> - Is there some Haskell-specific good practices do to TDD? >> >> Thanks in advance for your lights. >> > > I suspect most people practice "the other TDD", namely *Type*-Directed > Development. *"most people around here practice" From gautier.difolco at gmail.com Wed Jun 25 18:00:57 2014 From: gautier.difolco at gmail.com (Gautier DI FOLCO) Date: Wed, 25 Jun 2014 20:00:57 +0200 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: References: Message-ID: Hi all, Thanks for all your answers, I didn't expect to create a debate but I think it's the best place to make my own point of view (or at least the best place to decide where to start deeper investigations/experiments). So, thank you all. -------------- next part -------------- An HTML attachment was scrubbed... URL: From eir at cis.upenn.edu Wed Jun 25 18:14:04 2014 From: eir at cis.upenn.edu (Richard Eisenberg) Date: Wed, 25 Jun 2014 14:14:04 -0400 Subject: [Haskell-cafe] Monad laws In-Reply-To: References: <53AA5127.8010900@fuuzetsu.co.uk> Message-ID: <35C3CFD5-339E-43E2-88F4-60B896922058@cis.upenn.edu> On Jun 25, 2014, at 12:52 AM, John Lato wrote: > > The compiler makes assumptions about associativity when de-sugaring do-notation. If the monad laws aren't followed, it's possible for these two blocks to show different behavior (given that a,b,c are all values of the misbehaved Monad instance): > > > do { a; b; c } > > > a >> b >> c > > I think everyone can agree that this is surprising, at the very least. Although it's not the compiler that's generating bad code here. As far as I know, GHC makes no assumptions about associativity, or any class-based laws. The effect John observes above is accurate, but it is a direct consequence of the design of Haskell in the Haskell 2010 Report, not any assumptions in the compiler. Specifically, Section 3.14 (https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-470003.14) says that `do { e; stmts }` desugars to `e >> do {stmts}`. In the case of `do { a; b; c }`, that means we get `a >> (b >> c)`. However, in Table 4.1 in Section 4.4.2 (under https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-800004.4), we see that (>>) is *left*-associative, meaning that `a >> b >> c` means `(a >> b) >> c`. Are the different meanings here an "assumption" of associativity? I suppose one could construe it that way, but I just see `do { a; b; c}` and `a >> b >> c` as different chunks of code with different meanings. If the monad in question upholds the associativity law, then the chunks evaluate to the same result, but they're still distinct. Richard -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex.solla at gmail.com Wed Jun 25 19:31:54 2014 From: alex.solla at gmail.com (Alexander Solla) Date: Wed, 25 Jun 2014 12:31:54 -0700 Subject: [Haskell-cafe] Monad laws In-Reply-To: <35C3CFD5-339E-43E2-88F4-60B896922058@cis.upenn.edu> References: <53AA5127.8010900@fuuzetsu.co.uk> <35C3CFD5-339E-43E2-88F4-60B896922058@cis.upenn.edu> Message-ID: > If the monad in question upholds the associativity law, then the chunks evaluate to the same result, but they're still distinct. Distinct with respect to what equivalence relation? Also, an object isn't a monad if it isn't associative. On Wed, Jun 25, 2014 at 11:14 AM, Richard Eisenberg wrote: > On Jun 25, 2014, at 12:52 AM, John Lato wrote: > > > The compiler makes assumptions about associativity when de-sugaring > do-notation. If the monad laws aren't followed, it's possible for these > two blocks to show different behavior (given that a,b,c are all values of > the misbehaved Monad instance): > > > do { a; b; c } > > > a >> b >> c > > I think everyone can agree that this is surprising, at the very least. > Although it's not the compiler that's generating bad code here. > > > As far as I know, GHC makes no assumptions about associativity, or any > class-based laws. The effect John observes above is accurate, but it is a > direct consequence of the design of Haskell in the Haskell 2010 Report, not > any assumptions in the compiler. > > Specifically, Section 3.14 ( > https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-470003.14) > says that `do { e; stmts }` desugars to `e >> do {stmts}`. In the case of > `do { a; b; c }`, that means we get `a >> (b >> c)`. However, in Table 4.1 > in Section 4.4.2 (under > https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-800004.4), > we see that (>>) is *left*-associative, meaning that `a >> b >> c` means > `(a >> b) >> c`. > > Are the different meanings here an "assumption" of associativity? I > suppose one could construe it that way, but I just see `do { a; b; c}` and > `a >> b >> c` as different chunks of code with different meanings. If the > monad in question upholds the associativity law, then the chunks evaluate > to the same result, but they're still distinct. > > Richard > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok at cs.otago.ac.nz Wed Jun 25 21:44:18 2014 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Thu, 26 Jun 2014 09:44:18 +1200 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: References: Message-ID: On 26/06/2014, at 2:51 AM, Alois Cochard wrote: > For me TDD is highly overrated, and is abused as a buzz word by recruiter... > > In the context of writing a DSL, how one can start by the test? It's just impossible... I'm puzzled by this. You have some sort of fuzzy idea for a DSL. You're not sure exactly what it's going to look like, but you have a fair idea of what you want to be able to do with it. So you write some code in your DSL, making it up as you go. As you do this. you keep changing your mind about what's a nice way to say things, and you go back and revise earlier sketches. After a few hours to a few days, you now have some examples of things you'd like to be able to handle, and can start mining them for a a grammar and you can write some code to support them. And guess what, you have written your DSL tests first, because the examples you needed to do the *design* work are precisely test cases that your code should handle. My understanding of the history is that this is pretty much what happened when Erlang was designed. From raabe at froglogic.com Wed Jun 25 22:21:53 2014 From: raabe at froglogic.com (Frerich Raabe) Date: Thu, 26 Jun 2014 00:21:53 +0200 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: <2E2EBEC1-6D69-49DA-BBE2-78AB2ABC0A29@yandex.ru> References: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> <53AAC471.7050505@fuuzetsu.co.uk> <20140625152431.GA25045@x60s.casa> <53AAEF0B.1000407@orlitzky.com> <2E2EBEC1-6D69-49DA-BBE2-78AB2ABC0A29@yandex.ru> Message-ID: <744e51319a617358c652787960b33d94@roundcube.froglogic.com> On 2014-06-25 18:05, MigMit wrote: > Again, nobody here suggests that tests aren't necessary. And rightfully so! TDD is not "a poor substitute for type safety" (as you put it in your earlier mail) at all. In fact, strong type systems complement test-driven development very nicely. An expressive type system greatly simplifies testing because the compiler can catch a larger classes of mistakes and because - in the case of pure functions - the function signatures very clearly communicate the required input and output. There are no hidden dependencies and there's no setup or tear-down work required. So I'd argue that test-driven development is relevant *because* of Haskell's type system, not *in spite of* it. -- Frerich Raabe - raabe at froglogic.com www.froglogic.com - Multi-Platform GUI Testing From miguelimo38 at yandex.ru Wed Jun 25 22:26:42 2014 From: miguelimo38 at yandex.ru (MigMit) Date: Thu, 26 Jun 2014 00:26:42 +0200 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: <744e51319a617358c652787960b33d94@roundcube.froglogic.com> References: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> <53AAC471.7050505@fuuzetsu.co.uk> <20140625152431.GA25045@x60s.casa> <53AAEF0B.1000407@orlitzky.com> <2E2EBEC1-6D69-49DA-BBE2-78AB2ABC0A29@yandex.ru> <744e51319a617358c652787960b33d94@roundcube.froglogic.com> Message-ID: <0A9B6429-A90A-4A2F-BDC7-8216BC9A4058@yandex.ru> And TDD is not the same as having tests, so please stop arguing for the second while pretending to be arguing for the first. ?????????? ? iPhone > 26 ???? 2014 ?., ? 0:21, Frerich Raabe ???????(?): > >> On 2014-06-25 18:05, MigMit wrote: >> Again, nobody here suggests that tests aren't necessary. > > And rightfully so! TDD is not "a poor substitute for type safety" (as you put it in your earlier mail) at all. > > In fact, strong type systems complement test-driven development very nicely. An expressive type system greatly simplifies testing because the compiler can catch a larger classes of mistakes and because - in the case of pure functions - the function signatures very clearly communicate the required input and output. There are no hidden dependencies and there's no setup or tear-down work required. > > So I'd argue that test-driven development is relevant *because* of Haskell's type system, not *in spite of* it. > > -- > Frerich Raabe - raabe at froglogic.com > www.froglogic.com - Multi-Platform GUI Testing > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From johan.g.larson at gmail.com Wed Jun 25 22:53:37 2014 From: johan.g.larson at gmail.com (Johan Larson) Date: Wed, 25 Jun 2014 18:53:37 -0400 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: <0A9B6429-A90A-4A2F-BDC7-8216BC9A4058@yandex.ru> References: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> <53AAC471.7050505@fuuzetsu.co.uk> <20140625152431.GA25045@x60s.casa> <53AAEF0B.1000407@orlitzky.com> <2E2EBEC1-6D69-49DA-BBE2-78AB2ABC0A29@yandex.ru> <744e51319a617358c652787960b33d94@roundcube.froglogic.com> <0A9B6429-A90A-4A2F-BDC7-8216BC9A4058@yandex.ru> Message-ID: Has anyone here actually done strict TDD? I would expect strict TDD-based development (with no substantial design up front) to gradually build up a system from fuzzy ideas. This would grow increasingly unwieldy until the designer got fed up trying to keep it all together and redesigned it from scratch. And for a large system there could be several such redesign-completely episodes. On Wed, Jun 25, 2014 at 6:26 PM, MigMit wrote: > And TDD is not the same as having tests, so please stop arguing for the > second while pretending to be arguing for the first. > > ?????????? ? iPhone > > > 26 ???? 2014 ?., ? 0:21, Frerich Raabe ???????(?): > > > >> On 2014-06-25 18:05, MigMit wrote: > >> Again, nobody here suggests that tests aren't necessary. > > > > And rightfully so! TDD is not "a poor substitute for type safety" (as > you put it in your earlier mail) at all. > > > > In fact, strong type systems complement test-driven development very > nicely. An expressive type system greatly simplifies testing because the > compiler can catch a larger classes of mistakes and because - in the case > of pure functions - the function signatures very clearly communicate the > required input and output. There are no hidden dependencies and there's no > setup or tear-down work required. > > > > So I'd argue that test-driven development is relevant *because* of > Haskell's type system, not *in spite of* it. > > > > -- > > Frerich Raabe - raabe at froglogic.com > > www.froglogic.com - Multi-Platform GUI Testing > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Johan Larson -- Toronto, Canada -------------- next part -------------- An HTML attachment was scrubbed... URL: From knardi at gmail.com Wed Jun 25 22:55:51 2014 From: knardi at gmail.com (Kevin Nardi) Date: Wed, 25 Jun 2014 15:55:51 -0700 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: References: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> <53AAC471.7050505@fuuzetsu.co.uk> <20140625152431.GA25045@x60s.casa> <53AAEF0B.1000407@orlitzky.com> <2E2EBEC1-6D69-49DA-BBE2-78AB2ABC0A29@yandex.ru> <744e51319a617358c652787960b33d94@roundcube.froglogic.com> <0A9B6429-A90A-4A2F-BDC7-8216BC9A4058@yandex.ru> Message-ID: <2FB0009D-5CD7-475D-8E65-5987186837C8@gmail.com> On Jun 25, 2014, at 3:53 PM, Johan Larson wrote: > Has anyone here actually done strict TDD? > > I would expect strict TDD-based development (with no substantial design up front) to gradually build up a system from fuzzy ideas. This would grow increasingly unwieldy until the designer got fed up trying to keep it all together and redesigned it from scratch. And for a large system there could be several such redesign-completely episodes. I?ve done it a few times. What you?re missing is that good test coverage makes it incredibly easy to refactor, so you never have to redesign completely. Just refactor as necessary, when problems arise. TDD has a long history of being paired with agile design processes for this reason. -Kevin > On Wed, Jun 25, 2014 at 6:26 PM, MigMit wrote: > And TDD is not the same as having tests, so please stop arguing for the second while pretending to be arguing for the first. > > ?????????? ? iPhone > > > 26 ???? 2014 ?., ? 0:21, Frerich Raabe ???????(?): > > > >> On 2014-06-25 18:05, MigMit wrote: > >> Again, nobody here suggests that tests aren't necessary. > > > > And rightfully so! TDD is not "a poor substitute for type safety" (as you put it in your earlier mail) at all. > > > > In fact, strong type systems complement test-driven development very nicely. An expressive type system greatly simplifies testing because the compiler can catch a larger classes of mistakes and because - in the case of pure functions - the function signatures very clearly communicate the required input and output. There are no hidden dependencies and there's no setup or tear-down work required. > > > > So I'd argue that test-driven development is relevant *because* of Haskell's type system, not *in spite of* it. > > > > -- > > Frerich Raabe - raabe at froglogic.com > > www.froglogic.com - Multi-Platform GUI Testing > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > -- > Johan Larson -- Toronto, Canada > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From eir at cis.upenn.edu Wed Jun 25 23:30:37 2014 From: eir at cis.upenn.edu (Richard Eisenberg) Date: Wed, 25 Jun 2014 19:30:37 -0400 Subject: [Haskell-cafe] Monad laws In-Reply-To: References: <53AA5127.8010900@fuuzetsu.co.uk> <35C3CFD5-339E-43E2-88F4-60B896922058@cis.upenn.edu> Message-ID: <77486DAB-E5BD-43FC-83E3-6AD6F52078CC@cis.upenn.edu> On Jun 25, 2014, at 3:31 PM, Alexander Solla wrote: > > If the monad in question upholds the associativity law, then the chunks evaluate to the same result, but they're still distinct. > > Distinct with respect to what equivalence relation? I was thinking of syntactic equality (modulo renaming) on desugared programs. Another way of witnessing that the chunks are distinct is that the sequence of memory states they induce will be different -- even an associative member of the Monad class may have efficiency differences depending on the precise association. > > Also, an object isn't a monad if it isn't associative. You're right, of course. I meant a member of Haskell's Monad class, which may or may not be a monad. Richard From 0slemi0 at gmail.com Wed Jun 25 23:58:49 2014 From: 0slemi0 at gmail.com (Andras Slemmer) Date: Wed, 25 Jun 2014 16:58:49 -0700 Subject: [Haskell-cafe] Quantification in Instance Contexts In-Reply-To: References: <20140625094617.GB17417@jkarni.celeraone.com> Message-ID: Think about what you're asking from the compiler. If it sees a (Path a c) constraint it would have to magically guess whether there is an intermediate type b for which (Path a b) and (Path b c), which is impossible. Logic programming relies on the closed world assumption, meaning that if a statement cannot be proven within the closed world we are working in then it is false. Haskell typeclasses don't work like this; there is no closed world of types, so the compiler cannot "refute" a constraint. In prolog you'd have something like this: path(A,C) :- path(A,B), path(B,C). (havent used prolog for a while so syntax might be off) If you translate this to first order logic you'd have: \forall A,C.(path(A,C) <- \exists B.(path(A,B)^path(B,C))) It is the existential that is emulated with the cwa and cannot be emulated in haskell's typesystem. On 25 June 2014 07:00, Julian Arni wrote: > Alas, no. I tried to simplify the use case, but in fact the structure is a > DAG, and each node may have multiple parents. So neither "a -> b" nor "b -> > a" hold. > > > On Wed, Jun 25, 2014 at 3:06 PM, adam vogt wrote: > >> Hi Julian, >> >> Does each child have only one parent? In other words, is a larger >> "tree" still accepted if you use: >> >> class Child1 a b bool | a b -> bool, b -> a >> >> instead of your Child. >> >> Regards, >> Adam >> >> >> On Wed, Jun 25, 2014 at 5:46 AM, Julian K. Arni wrote: >> > Hi Cafe, >> > >> > I'm playing around with simple logic-programming at the type level. For >> > instance, encoding trees: >> > >> >>> {-# LANGUAGE MultiParamTypeClasses >> >>> , FunctionalDependencies >> >>> , FlexibleInstances >> >>> , UndecidableInstances >> >>> , FlexibleContexts >> >>> , OverlappingInstances #-} >> >>> {-# OPTIONS_GHC -fcontext-stack=100 #-} >> >>> >> >>> >> >>> -- *A >> >>> -- / \ >> >>> -- B* *C >> >>> -- | >> >>> -- D* >> >>> >> >>> >> >>> data A >> >>> data B >> >>> data C >> >>> data D >> >>> class Child a b bool | a b -> bool >> >>> instance Child A B TrueT >> >>> instance Child B D TrueT >> >>> instance Child B C TrueT >> >>> class Path a b bool | a b -> bool >> > >> > Now the following obviously doesn't work (never mind for now that >> 'Path' needs >> > a recursive definition, and that this is really just 'Grandchild'): >> > >> >>> instance (Child a b TrueT, Child b c TrueT) => Path a c TrueT >> > >> > Because 'b' is ambiguous. Fair enough. But I can't directly use a >> fundep, >> > because 'b' *is* in fact ambiguous. What I want to tell the compiler is >> that >> > it's really okay, since the RHS side (and any possible 'where' >> expressions) >> > doesn't depend on what is instantiated for 'b'. >> > >> > I know I could switch to a class 'Children a bs bool' and encode all >> children >> > of as a type-level list, and then have a fundep between 'a' and 'bs'. >> That's >> > not a *bad* solution: it does give a good sense of the intention. But >> it's not >> > very extensible; really I'd rather be using something like 'forall' >> > - something, I would guess, along the lines of: >> > >> >>> instance forall a c. (forall b. (Child a b TrueT, Child b c TrueT)) >> => Path >> >>> a c TrueT >> > >> > That, however, fails with: >> > >> > Malformed instance head: (forall b. >> > (Child a b TrueT, Child b c TrueT)) >> > -> Path a c TrueT >> > In the instance declaration for ?Path a c TrueT? >> > >> > >> > So: is there a way (presumably with 'forall') of telling the compiler >> that the >> > ambiguous type 'b' actually won't "leak through" to the RHS, so stop >> bugging me >> > about ambiguity? >> > >> > Thanks, >> > Julian >> > _______________________________________________ >> > Haskell-Cafe mailing list >> > Haskell-Cafe at haskell.org >> > http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuuzetsu at fuuzetsu.co.uk Thu Jun 26 01:29:09 2014 From: fuuzetsu at fuuzetsu.co.uk (Mateusz Kowalczyk) Date: Thu, 26 Jun 2014 03:29:09 +0200 Subject: [Haskell-cafe] BNFC-meta being maintained? Is there public src repo? In-Reply-To: <539E7391.6040300@gmail.com> References: <539E7391.6040300@gmail.com> Message-ID: <53AB7765.5060505@fuuzetsu.co.uk> On 06/16/2014 06:33 AM, Ki Yung Ahn wrote: > Dear BNFC-meta developers and users, > > I've been using BNFC-meta for the parser of my experimental language Nax > language implementation ( https://github.com/kyagrd/mininax ). It's very > cool 'cause you don't need to write makefile or cabal entries to call > the command line tools (bnfc, alex, happy), and you get quasiquoters for > free, which really makes the early development pleasant. > > But due to the bug fixed in recent versions of BNFC, probably after > latest BNFC-meta release, I'll have to switch back to using plain BNFC > at some point. (FYI,the bug is that block comments arn't working). > > If there is a source repository that has ported more recent versions of > BNFC into BNFC-meta, it'll be helpful for people like me. Or, if the > source repository has open access and easy to participate (e.g., putting > on github or something like that), we can draw community support > maintaining BNFC-meta to keep up with the recent BNFC (and also happy > and alex) versions. > > -- > Ki Yung Ahn > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > You should probably e-mail the maintainer directly, their e-mail is on the Hackage page for the package. -- Mateusz K. From jkarni at gmail.com Thu Jun 26 06:06:37 2014 From: jkarni at gmail.com (Julian Arni) Date: Thu, 26 Jun 2014 08:06:37 +0200 Subject: [Haskell-cafe] Quantification in Instance Contexts In-Reply-To: References: <20140625094617.GB17417@jkarni.celeraone.com> Message-ID: Thanks for the reply. I don't quite understand why guessing whether there is an intermediate type would be so magical, though. Let's simplify: data A data B class IsNotFirst a class IsAfter b a instance (IsAfter b a) => IsNotFirst a instance IsAfter B A Here we've separated out the ambiguous type issue from the unification. Note that *already*, if I query with undefined::(IsNotFirst A => a), I get: No instance for (IsAfter b A) arising from a use of ?t? The type variable ?b? is ambiguous Note: there is a potential instance available: instance [overlap ok] IsAfter B A Generally, GHC is doing the work that I wanted it to *in the error message*. In what sense, then, is this impossible? And why is there some inexcusable use of CWA here? Instances already have (if you squint) a negation-as-failure semantics. "instance (IsAfter b a) => IsNotFirst a" doesn't *in that sense* look that different to me than "instance (IsSecond a) => IsNotFirst a": adding extra instance declarations can 'change the truth-value' of the right-hand side. Thanks again, Julian On Thu, Jun 26, 2014 at 1:58 AM, Andras Slemmer <0slemi0 at gmail.com> wrote: > Think about what you're asking from the compiler. If it sees a (Path a c) > constraint it would have to magically guess whether there is an > intermediate type b for which (Path a b) and (Path b c), which is > impossible. > > Logic programming relies on the closed world assumption, meaning that if a > statement cannot be proven within the closed world we are working in then > it is false. Haskell typeclasses don't work like this; there is no closed > world of types, so the compiler cannot "refute" a constraint. > > In prolog you'd have something like this: > path(A,C) :- path(A,B), path(B,C). > (havent used prolog for a while so syntax might be off) > > If you translate this to first order logic you'd have: > \forall A,C.(path(A,C) <- \exists B.(path(A,B)^path(B,C))) > > It is the existential that is emulated with the cwa and cannot be emulated > in haskell's typesystem. > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hesselink at gmail.com Thu Jun 26 07:10:22 2014 From: hesselink at gmail.com (Erik Hesselink) Date: Thu, 26 Jun 2014 09:10:22 +0200 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: <53AAEF0B.1000407@orlitzky.com> References: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> <53AAC471.7050505@fuuzetsu.co.uk> <20140625152431.GA25045@x60s.casa> <53AAEF0B.1000407@orlitzky.com> Message-ID: On Wed, Jun 25, 2014 at 5:47 PM, Michael Orlitzky wrote: > On 06/25/2014 11:24 AM, Francesco Ariis wrote: >> On Wed, Jun 25, 2014 at 02:45:37PM +0200, Mateusz Kowalczyk wrote: >>> While I disagree with initial view that testing is useless, I certainly >>> disagree with this approach too. There are plenty proof-assistants using >>> type-checking to prove programs correct. That's not to say Haskell >>> itself is suited for such task. If you have a type system strong enough, >>> classical tests are no longer required because you can encode all the >>> properties you need in types proving at compile time that your program >>> is in fact correct. >>> >> >> For non-believers, here is a blog post that opened my eyes on the matter [1]. >> >> [1] http://lambda.jstolarek.com/2013/12/data-is-evidence/ > > None of that helps if you write the wrong program. Your program may > typecheck, but if you're expecting "42" as output and your program hums > the Star Trek theme instead, the fact that it correctly does the wrong > thing won't be much consolation. The same goes for any kind of testing, though. All these (writing the program, giving types for the program and testing the program) are different ways of specifying the same thing. The benefit from doing it twice in different ways, is that it's unlikely that you'll do it wrong twice *in the same way*. Erik From haskell at dshevchenko.biz Thu Jun 26 07:19:35 2014 From: haskell at dshevchenko.biz (Denis Shevchenko) Date: Thu, 26 Jun 2014 11:19:35 +0400 Subject: [Haskell-cafe] direct-fastcgi and logging Message-ID: <19B11BB5-9AC9-47F2-B3D2-EF18F9C1F872@dshevchenko.biz> Hi all! I write a FastCGI-server based on excellent package 'direct-fastcgi' (http://hackage.haskell.org/package/direct-fastcgi). It works perfectly, but I want to inject a logging facility into a handler of requests. For example: import Control.Concurrent (forkIO) import Network.FastCGI main :: IO () main = acceptLoop forkIO handleRequest handleRequest :: FastCGI () handleRequest = do -- >>> In this place I want to log a message <<< setResponseStatus 400 setResponseHeader HttpContentType "application/json" fPutStr "{ "my": "problem_description" }" Yes, I know about this function in 'Network.FastCGI': fLog :: MonadFastCGI m => String -> m () but it "logs a message using the web server's logging facility", and I want to log into _my_own_ file. So which solution I can use here? I'd be very grateful for any help. ---------- Sincerely, Denis Shevchenko haskell at dshevchenko.biz From hesselink at gmail.com Thu Jun 26 07:42:27 2014 From: hesselink at gmail.com (Erik Hesselink) Date: Thu, 26 Jun 2014 09:42:27 +0200 Subject: [Haskell-cafe] direct-fastcgi and logging In-Reply-To: <19B11BB5-9AC9-47F2-B3D2-EF18F9C1F872@dshevchenko.biz> References: <19B11BB5-9AC9-47F2-B3D2-EF18F9C1F872@dshevchenko.biz> Message-ID: FastCGI seems to be just a ReaderT over IO, so you can just use liftIO to perform arbitrary IO, like writing to a file. If you want something more full-featured, you could use something like hslogger. Regards, Erik On Thu, Jun 26, 2014 at 9:19 AM, Denis Shevchenko wrote: > Hi all! > > I write a FastCGI-server based on excellent package 'direct-fastcgi' (http://hackage.haskell.org/package/direct-fastcgi). It works perfectly, but I want to inject a logging facility into a handler of requests. For example: > > import Control.Concurrent (forkIO) > import Network.FastCGI > > main :: IO () > main = acceptLoop forkIO handleRequest > > handleRequest :: FastCGI () > handleRequest = do > -- >>> In this place I want to log a message <<< > setResponseStatus 400 > setResponseHeader HttpContentType "application/json" > fPutStr "{ "my": "problem_description" }" > > Yes, I know about this function in 'Network.FastCGI': > > fLog :: MonadFastCGI m => String -> m () > > but it "logs a message using the web server's logging facility", and I want to log into _my_own_ file. So which solution I can use here? I'd be very grateful for any help. > > ---------- > Sincerely, Denis Shevchenko > haskell at dshevchenko.biz > > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From 0slemi0 at gmail.com Thu Jun 26 09:08:24 2014 From: 0slemi0 at gmail.com (Andras Slemmer) Date: Thu, 26 Jun 2014 02:08:24 -0700 Subject: [Haskell-cafe] Quantification in Instance Contexts In-Reply-To: References: <20140625094617.GB17417@jkarni.celeraone.com> Message-ID: Your second example shouldn't (and doesn't) compile, as the IsNotFirst instance has an ambiguous variable 'b'. What you want is this 'b' to be existentially quantified and have the compiler provide a witness for it. Again, Haskell doesn't have a closed world of types. Even if the compiler doesn't find a 'b' in say the current module it cannot refute an IsNotFirst constraint, as an IsAfter instance may be defined in another module. module A where weirdId :: IsNotFirst a => a -> a weirdId = id Should this compile if we don't have an IsAfter instance in the current module? What if we define one in module B which imports module A? What if we have two IsAfter instances? Which instance should it use? > adding extra instance declarations can 'change the truth-value' of the right-hand side. No, they cannot. instance (IsSecond a) => IsNotFirst a translates to (\forall a. IsSecond(a) -> IsNotFirst(a)), which will always hold. (Unless you switch on overlappinginstances which you shouldnt) On 25 June 2014 23:06, Julian Arni wrote: > Thanks for the reply. I don't quite understand why guessing whether there > is an intermediate type would be so magical, though. Let's simplify: > > data A > data B > class IsNotFirst a > class IsAfter b a > instance (IsAfter b a) => IsNotFirst a > instance IsAfter B A > > > Here we've separated out the ambiguous type issue from the unification. > Note that *already*, if I query with undefined::(IsNotFirst A => a), I get: > > No instance for (IsAfter b A) arising from a use of ?t? > The type variable ?b? is ambiguous > Note: there is a potential instance available: > instance [overlap ok] IsAfter B A > > Generally, GHC is doing the work that I wanted it to *in the error > message*. In what sense, then, is this impossible? > And why is there some inexcusable use of CWA here? Instances already > have (if you squint) a negation-as-failure semantics. "instance (IsAfter b > a) => IsNotFirst a" doesn't *in that sense* look that different to me than > "instance (IsSecond a) => IsNotFirst a": adding extra instance declarations > can 'change the truth-value' of the right-hand side. > > > Thanks again, > Julian > > > On Thu, Jun 26, 2014 at 1:58 AM, Andras Slemmer <0slemi0 at gmail.com> wrote: > >> Think about what you're asking from the compiler. If it sees a (Path a c) >> constraint it would have to magically guess whether there is an >> intermediate type b for which (Path a b) and (Path b c), which is >> impossible. >> >> Logic programming relies on the closed world assumption, meaning that if >> a statement cannot be proven within the closed world we are working in then >> it is false. Haskell typeclasses don't work like this; there is no closed >> world of types, so the compiler cannot "refute" a constraint. >> >> In prolog you'd have something like this: >> path(A,C) :- path(A,B), path(B,C). >> (havent used prolog for a while so syntax might be off) >> >> If you translate this to first order logic you'd have: >> \forall A,C.(path(A,C) <- \exists B.(path(A,B)^path(B,C))) >> >> It is the existential that is emulated with the cwa and cannot be >> emulated in haskell's typesystem. >> >> >> >> -------------- next part -------------- An HTML attachment was scrubbed... URL: From hutch-lists at recursive.ca Thu Jun 26 12:18:06 2014 From: hutch-lists at recursive.ca (Bob Hutchison) Date: Thu, 26 Jun 2014 08:18:06 -0400 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: References: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> <53AAC471.7050505@fuuzetsu.co.uk> <20140625152431.GA25045@x60s.casa> <53AAEF0B.1000407@orlitzky.com> <2E2EBEC1-6D69-49DA-BBE2-78AB2ABC0A29@yandex.ru> <744e51319a617358c652787960b33d94@roundcube.froglogic.com> <0A9B6429-A90A-4A2F-BDC7-8216BC9A4058@yandex.ru> Message-ID: <9955EA11-CD82-41D9-943D-3152DDCEEE19@recursive.ca> On Jun 25, 2014, at 6:53 PM, Johan Larson wrote: > Has anyone here actually done strict TDD? Yes. Routinely. For many years. With many programming languages, including Haskell. > > I would expect strict TDD-based development (with no substantial design up front) to gradually build up a system from fuzzy ideas. Why? Read Richard O?Keefe?s post from yesterday. Testing at the DSL level that he?s talking about is precisely where the tests in TDD exist. If it?s not a DSL it?ll be an API. In TDD, you do not test anywhere else. This includes regression test suites. There are constraints on an application?s architecture implied by TDD ? you need an interface of some kind. If you feel testing at a more detailed level would be helpful when you write some part of the system, go ahead but delete those tests when you?re done. A recent talk about what TDD is, and isn?t, is at: http://www.infoq.com/presentations/tdd-original > This would grow increasingly unwieldy until the designer got fed up trying to keep it all together and redesigned it from scratch. And for a large system there could be several such redesign-completely episodes. > > > On Wed, Jun 25, 2014 at 6:26 PM, MigMit wrote: > And TDD is not the same as having tests, so please stop arguing for the second while pretending to be arguing for the first. > > ?????????? ? iPhone > > > 26 ???? 2014 ?., ? 0:21, Frerich Raabe ???????(?): > > > >> On 2014-06-25 18:05, MigMit wrote: > >> Again, nobody here suggests that tests aren't necessary. > > > > And rightfully so! TDD is not "a poor substitute for type safety" (as you put it in your earlier mail) at all. > > > > In fact, strong type systems complement test-driven development very nicely. An expressive type system greatly simplifies testing because the compiler can catch a larger classes of mistakes and because - in the case of pure functions - the function signatures very clearly communicate the required input and output. There are no hidden dependencies and there's no setup or tear-down work required. > > > > So I'd argue that test-driven development is relevant *because* of Haskell's type system, not *in spite of* it. > > > > -- > > Frerich Raabe - raabe at froglogic.com > > www.froglogic.com - Multi-Platform GUI Testing > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > -- > Johan Larson -- Toronto, Canada > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From hutch-lists at recursive.ca Thu Jun 26 12:24:09 2014 From: hutch-lists at recursive.ca (Bob Hutchison) Date: Thu, 26 Jun 2014 08:24:09 -0400 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: References: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> <53AAC471.7050505@fuuzetsu.co.uk> <20140625152431.GA25045@x60s.casa> <53AAEF0B.1000407@orlitzky.com> Message-ID: <8EE57728-1AD4-4680-A9C3-015C8555A3FF@recursive.ca> On Jun 26, 2014, at 3:10 AM, Erik Hesselink wrote: > On Wed, Jun 25, 2014 at 5:47 PM, Michael Orlitzky wrote: >> On 06/25/2014 11:24 AM, Francesco Ariis wrote: >>> On Wed, Jun 25, 2014 at 02:45:37PM +0200, Mateusz Kowalczyk wrote: >>>> While I disagree with initial view that testing is useless, I certainly >>>> disagree with this approach too. There are plenty proof-assistants using >>>> type-checking to prove programs correct. That's not to say Haskell >>>> itself is suited for such task. If you have a type system strong enough, >>>> classical tests are no longer required because you can encode all the >>>> properties you need in types proving at compile time that your program >>>> is in fact correct. >>>> >>> >>> For non-believers, here is a blog post that opened my eyes on the matter [1]. >>> >>> [1] http://lambda.jstolarek.com/2013/12/data-is-evidence/ >> >> None of that helps if you write the wrong program. Your program may >> typecheck, but if you're expecting "42" as output and your program hums >> the Star Trek theme instead, the fact that it correctly does the wrong >> thing won't be much consolation. > > The same goes for any kind of testing, though. All these (writing the > program, giving types for the program and testing the program) are > different ways of specifying the same thing. The benefit from doing it > twice in different ways, is that it's unlikely that you'll do it wrong > twice *in the same way*. So, tell me about QuickCheck? why is this thing thought so highly of? (this is a rhetorical question, I don?t need an answer :-) The problem isn?t really the unexpected humming of a song. It?s answering 43 when you?re expecting 42. Cheers, Bob > > Erik > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From hutch-lists at recursive.ca Thu Jun 26 12:24:41 2014 From: hutch-lists at recursive.ca (Bob Hutchison) Date: Thu, 26 Jun 2014 08:24:41 -0400 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: References: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> <53AAC471.7050505@fuuzetsu.co.uk> <20140625152431.GA25045@x60s.casa> <53AAEF0B.1000407@orlitzky.com> <2E2EBEC1-6D69-49DA-BBE2-78AB2ABC0A29@yandex.ru> <744e51319a617358c652787960b33d94@roundcube.froglogic.com> <0A9B6429-A90A-4A2F-BDC7-8216BC9A4058@yandex.ru> Message-ID: <63EAFA58-B3A5-4EC9-A66B-31E9D3E943EF@recursive.ca> On Jun 25, 2014, at 6:53 PM, Johan Larson wrote: > Has anyone here actually done strict TDD? Yes. Routinely. For many years. With many programming languages, including Haskell. > > I would expect strict TDD-based development (with no substantial design up front) to gradually build up a system from fuzzy ideas. Why? Read Richard O?Keefe?s post from yesterday. Testing at the DSL level that he?s talking about is precisely where the tests in TDD exist. If it?s not a DSL it?ll be an API. In TDD, you do not test anywhere else. This includes regression test suites. There are constraints on an application?s architecture implied by TDD ? you need an interface of some kind. If you feel testing at a more detailed level would be helpful when you write some part of the system, go ahead but delete those tests when you?re done. A recent talk about what TDD is, and isn?t, is at: http://www.infoq.com/presentations/tdd-original > This would grow increasingly unwieldy until the designer got fed up trying to keep it all together and redesigned it from scratch. And for a large system there could be several such redesign-completely episodes. > > > On Wed, Jun 25, 2014 at 6:26 PM, MigMit wrote: > And TDD is not the same as having tests, so please stop arguing for the second while pretending to be arguing for the first. > > ?????????? ? iPhone > > > 26 ???? 2014 ?., ? 0:21, Frerich Raabe ???????(?): > > > >> On 2014-06-25 18:05, MigMit wrote: > >> Again, nobody here suggests that tests aren't necessary. > > > > And rightfully so! TDD is not "a poor substitute for type safety" (as you put it in your earlier mail) at all. > > > > In fact, strong type systems complement test-driven development very nicely. An expressive type system greatly simplifies testing because the compiler can catch a larger classes of mistakes and because - in the case of pure functions - the function signatures very clearly communicate the required input and output. There are no hidden dependencies and there's no setup or tear-down work required. > > > > So I'd argue that test-driven development is relevant *because* of Haskell's type system, not *in spite of* it. > > > > -- > > Frerich Raabe - raabe at froglogic.com > > www.froglogic.com - Multi-Platform GUI Testing > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > -- > Johan Larson -- Toronto, Canada > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -------------- next part -------------- An HTML attachment was scrubbed... URL: From alois.cochard at gmail.com Thu Jun 26 12:37:11 2014 From: alois.cochard at gmail.com (Alois Cochard) Date: Thu, 26 Jun 2014 13:37:11 +0100 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: References: Message-ID: Interesting, It's sounds like your definition of `TDD` is what is my definition of `solving problem`. My point was that I don't want to write test for a grammar that I might realize during further design that is wrong, this would be just complete wasted effort... Instead I just test as a way to tryout my DSL... but really to me it does *not* relate to TDD... because I can do the same with just a REPL and the history of it... I wish that definition you use was the same understood by the industry, but it is not the way it was presented to me when I discussed with TDD enthusiast in the past... maybe things changed. Cheers On 25 June 2014 22:44, Richard A. O'Keefe wrote: > > On 26/06/2014, at 2:51 AM, Alois Cochard wrote: > > > For me TDD is highly overrated, and is abused as a buzz word by > recruiter... > > > > In the context of writing a DSL, how one can start by the test? It's > just impossible... > > I'm puzzled by this. > > You have some sort of fuzzy idea for a DSL. > You're not sure exactly what it's going to look like, > but you have a fair idea of what you want to be able > to do with it. > > So you write some code in your DSL, making it up as > you go. As you do this. you keep changing your mind > about what's a nice way to say things, and you go back > and revise earlier sketches. > > After a few hours to a few days, you now have some > examples of things you'd like to be able to handle, > and can start mining them for a a grammar and you > can write some code to support them. > > And guess what, you have written your DSL tests first, > because the examples you needed to do the *design* > work are precisely test cases that your code should > handle. > > My understanding of the history is that this is > pretty much what happened when Erlang was designed. > > > -- *A\ois* http://twitter.com/aloiscochard http://github.com/aloiscochard -------------- next part -------------- An HTML attachment was scrubbed... URL: From hesselink at gmail.com Thu Jun 26 12:44:06 2014 From: hesselink at gmail.com (Erik Hesselink) Date: Thu, 26 Jun 2014 14:44:06 +0200 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: <8EE57728-1AD4-4680-A9C3-015C8555A3FF@recursive.ca> References: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> <53AAC471.7050505@fuuzetsu.co.uk> <20140625152431.GA25045@x60s.casa> <53AAEF0B.1000407@orlitzky.com> <8EE57728-1AD4-4680-A9C3-015C8555A3FF@recursive.ca> Message-ID: On Thu, Jun 26, 2014 at 2:24 PM, Bob Hutchison wrote: > > On Jun 26, 2014, at 3:10 AM, Erik Hesselink wrote: > >> On Wed, Jun 25, 2014 at 5:47 PM, Michael Orlitzky wrote: >>> On 06/25/2014 11:24 AM, Francesco Ariis wrote: >>>> On Wed, Jun 25, 2014 at 02:45:37PM +0200, Mateusz Kowalczyk wrote: >>>>> While I disagree with initial view that testing is useless, I certainly >>>>> disagree with this approach too. There are plenty proof-assistants using >>>>> type-checking to prove programs correct. That's not to say Haskell >>>>> itself is suited for such task. If you have a type system strong enough, >>>>> classical tests are no longer required because you can encode all the >>>>> properties you need in types proving at compile time that your program >>>>> is in fact correct. >>>>> >>>> >>>> For non-believers, here is a blog post that opened my eyes on the matter [1]. >>>> >>>> [1] http://lambda.jstolarek.com/2013/12/data-is-evidence/ >>> >>> None of that helps if you write the wrong program. Your program may >>> typecheck, but if you're expecting "42" as output and your program hums >>> the Star Trek theme instead, the fact that it correctly does the wrong >>> thing won't be much consolation. >> >> The same goes for any kind of testing, though. All these (writing the >> program, giving types for the program and testing the program) are >> different ways of specifying the same thing. The benefit from doing it >> twice in different ways, is that it's unlikely that you'll do it wrong >> twice *in the same way*. > > So, tell me about QuickCheck? why is this thing thought so highly of? (this is a rhetorical question, I don?t need an answer :-) > > The problem isn?t really the unexpected humming of a song. It?s answering 43 when you?re expecting 42. Are you replying to me, or Michael Orlitzky? Because I'm not sure what point you're making. I'm not arguing against the use of tests *or* types. I'm just saying neither is going to give you complete guarantees, but using either one is already much better than using none. Erik From alois.cochard at gmail.com Thu Jun 26 12:50:18 2014 From: alois.cochard at gmail.com (Alois Cochard) Date: Thu, 26 Jun 2014 13:50:18 +0100 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: References: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> <53AAC471.7050505@fuuzetsu.co.uk> <20140625152431.GA25045@x60s.casa> <53AAEF0B.1000407@orlitzky.com> <8EE57728-1AD4-4680-A9C3-015C8555A3FF@recursive.ca> Message-ID: I'm not replying to you nor Michael Orlitzky. I'm replying to Richard A. O'Keefe. You can see that by looking at which message was quoted below my actual response. I hope it will make things clearer, because I'm actually not arguing at all against what you are saying :-) On 26 June 2014 13:44, Erik Hesselink wrote: > On Thu, Jun 26, 2014 at 2:24 PM, Bob Hutchison > wrote: > > > > On Jun 26, 2014, at 3:10 AM, Erik Hesselink wrote: > > > >> On Wed, Jun 25, 2014 at 5:47 PM, Michael Orlitzky > wrote: > >>> On 06/25/2014 11:24 AM, Francesco Ariis wrote: > >>>> On Wed, Jun 25, 2014 at 02:45:37PM +0200, Mateusz Kowalczyk wrote: > >>>>> While I disagree with initial view that testing is useless, I > certainly > >>>>> disagree with this approach too. There are plenty proof-assistants > using > >>>>> type-checking to prove programs correct. That's not to say Haskell > >>>>> itself is suited for such task. If you have a type system strong > enough, > >>>>> classical tests are no longer required because you can encode all the > >>>>> properties you need in types proving at compile time that your > program > >>>>> is in fact correct. > >>>>> > >>>> > >>>> For non-believers, here is a blog post that opened my eyes on the > matter [1]. > >>>> > >>>> [1] http://lambda.jstolarek.com/2013/12/data-is-evidence/ > >>> > >>> None of that helps if you write the wrong program. Your program may > >>> typecheck, but if you're expecting "42" as output and your program hums > >>> the Star Trek theme instead, the fact that it correctly does the wrong > >>> thing won't be much consolation. > >> > >> The same goes for any kind of testing, though. All these (writing the > >> program, giving types for the program and testing the program) are > >> different ways of specifying the same thing. The benefit from doing it > >> twice in different ways, is that it's unlikely that you'll do it wrong > >> twice *in the same way*. > > > > So, tell me about QuickCheck? why is this thing thought so highly of? > (this is a rhetorical question, I don?t need an answer :-) > > > > The problem isn?t really the unexpected humming of a song. It?s > answering 43 when you?re expecting 42. > > Are you replying to me, or Michael Orlitzky? Because I'm not sure what > point you're making. I'm not arguing against the use of tests *or* > types. I'm just saying neither is going to give you complete > guarantees, but using either one is already much better than using > none. > > Erik > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- *A\ois* http://twitter.com/aloiscochard http://github.com/aloiscochard -------------- next part -------------- An HTML attachment was scrubbed... URL: From tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Thu Jun 26 12:59:31 2014 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Thu, 26 Jun 2014 13:59:31 +0100 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: References: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> <53AAC471.7050505@fuuzetsu.co.uk> <20140625152431.GA25045@x60s.casa> <53AAEF0B.1000407@orlitzky.com> <8EE57728-1AD4-4680-A9C3-015C8555A3FF@recursive.ca> Message-ID: <20140626125930.GP1765@henry> I feel like I'm reading a Monty Python sketch. On Thu, Jun 26, 2014 at 01:50:18PM +0100, Alois Cochard wrote: > I'm not replying to you nor Michael Orlitzky. > I'm replying to Richard A. O'Keefe. > > You can see that by looking at which message was quoted below my actual > response. > I hope it will make things clearer, because I'm actually not arguing at all > against what you are saying :-) > > > On 26 June 2014 13:44, Erik Hesselink wrote: > > > On Thu, Jun 26, 2014 at 2:24 PM, Bob Hutchison > > wrote: > > > > > > On Jun 26, 2014, at 3:10 AM, Erik Hesselink wrote: > > > > > >> On Wed, Jun 25, 2014 at 5:47 PM, Michael Orlitzky > > wrote: > > >>> On 06/25/2014 11:24 AM, Francesco Ariis wrote: > > >>>> On Wed, Jun 25, 2014 at 02:45:37PM +0200, Mateusz Kowalczyk wrote: > > >>>>> While I disagree with initial view that testing is useless, I > > certainly > > >>>>> disagree with this approach too. There are plenty proof-assistants > > using > > >>>>> type-checking to prove programs correct. That's not to say Haskell > > >>>>> itself is suited for such task. If you have a type system strong > > enough, > > >>>>> classical tests are no longer required because you can encode all the > > >>>>> properties you need in types proving at compile time that your > > program > > >>>>> is in fact correct. > > >>>>> > > >>>> > > >>>> For non-believers, here is a blog post that opened my eyes on the > > matter [1]. > > >>>> > > >>>> [1] http://lambda.jstolarek.com/2013/12/data-is-evidence/ > > >>> > > >>> None of that helps if you write the wrong program. Your program may > > >>> typecheck, but if you're expecting "42" as output and your program hums > > >>> the Star Trek theme instead, the fact that it correctly does the wrong > > >>> thing won't be much consolation. > > >> > > >> The same goes for any kind of testing, though. All these (writing the > > >> program, giving types for the program and testing the program) are > > >> different ways of specifying the same thing. The benefit from doing it > > >> twice in different ways, is that it's unlikely that you'll do it wrong > > >> twice *in the same way*. > > > > > > So, tell me about QuickCheck? why is this thing thought so highly of? > > (this is a rhetorical question, I don?t need an answer :-) > > > > > > The problem isn?t really the unexpected humming of a song. It?s > > answering 43 when you?re expecting 42. > > > > Are you replying to me, or Michael Orlitzky? Because I'm not sure what > > point you're making. I'm not arguing against the use of tests *or* > > types. I'm just saying neither is going to give you complete > > guarantees, but using either one is already much better than using > > none. > > > > Erik > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > -- > *A\ois* > http://twitter.com/aloiscochard > http://github.com/aloiscochard > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From hesselink at gmail.com Thu Jun 26 13:01:05 2014 From: hesselink at gmail.com (Erik Hesselink) Date: Thu, 26 Jun 2014 15:01:05 +0200 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: <20140626125930.GP1765@henry> References: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> <53AAC471.7050505@fuuzetsu.co.uk> <20140625152431.GA25045@x60s.casa> <53AAEF0B.1000407@orlitzky.com> <8EE57728-1AD4-4680-A9C3-015C8555A3FF@recursive.ca> <20140626125930.GP1765@henry> Message-ID: That is a good description of my feeling right now as well :) Erik On Thu, Jun 26, 2014 at 2:59 PM, Tom Ellis wrote: > I feel like I'm reading a Monty Python sketch. > > On Thu, Jun 26, 2014 at 01:50:18PM +0100, Alois Cochard wrote: >> I'm not replying to you nor Michael Orlitzky. >> I'm replying to Richard A. O'Keefe. >> >> You can see that by looking at which message was quoted below my actual >> response. >> I hope it will make things clearer, because I'm actually not arguing at all >> against what you are saying :-) >> >> >> On 26 June 2014 13:44, Erik Hesselink wrote: >> >> > On Thu, Jun 26, 2014 at 2:24 PM, Bob Hutchison >> > wrote: >> > > >> > > On Jun 26, 2014, at 3:10 AM, Erik Hesselink wrote: >> > > >> > >> On Wed, Jun 25, 2014 at 5:47 PM, Michael Orlitzky >> > wrote: >> > >>> On 06/25/2014 11:24 AM, Francesco Ariis wrote: >> > >>>> On Wed, Jun 25, 2014 at 02:45:37PM +0200, Mateusz Kowalczyk wrote: >> > >>>>> While I disagree with initial view that testing is useless, I >> > certainly >> > >>>>> disagree with this approach too. There are plenty proof-assistants >> > using >> > >>>>> type-checking to prove programs correct. That's not to say Haskell >> > >>>>> itself is suited for such task. If you have a type system strong >> > enough, >> > >>>>> classical tests are no longer required because you can encode all the >> > >>>>> properties you need in types proving at compile time that your >> > program >> > >>>>> is in fact correct. >> > >>>>> >> > >>>> >> > >>>> For non-believers, here is a blog post that opened my eyes on the >> > matter [1]. >> > >>>> >> > >>>> [1] http://lambda.jstolarek.com/2013/12/data-is-evidence/ >> > >>> >> > >>> None of that helps if you write the wrong program. Your program may >> > >>> typecheck, but if you're expecting "42" as output and your program hums >> > >>> the Star Trek theme instead, the fact that it correctly does the wrong >> > >>> thing won't be much consolation. >> > >> >> > >> The same goes for any kind of testing, though. All these (writing the >> > >> program, giving types for the program and testing the program) are >> > >> different ways of specifying the same thing. The benefit from doing it >> > >> twice in different ways, is that it's unlikely that you'll do it wrong >> > >> twice *in the same way*. >> > > >> > > So, tell me about QuickCheck? why is this thing thought so highly of? >> > (this is a rhetorical question, I don?t need an answer :-) >> > > >> > > The problem isn?t really the unexpected humming of a song. It?s >> > answering 43 when you?re expecting 42. >> > >> > Are you replying to me, or Michael Orlitzky? Because I'm not sure what >> > point you're making. I'm not arguing against the use of tests *or* >> > types. I'm just saying neither is going to give you complete >> > guarantees, but using either one is already much better than using >> > none. >> > >> > Erik >> > _______________________________________________ >> > Haskell-Cafe mailing list >> > Haskell-Cafe at haskell.org >> > http://www.haskell.org/mailman/listinfo/haskell-cafe >> > >> >> >> >> -- >> *A\ois* >> http://twitter.com/aloiscochard >> http://github.com/aloiscochard > >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe From michael at orlitzky.com Thu Jun 26 13:27:09 2014 From: michael at orlitzky.com (Michael Orlitzky) Date: Thu, 26 Jun 2014 09:27:09 -0400 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: References: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> <53AAC471.7050505@fuuzetsu.co.uk> <20140625152431.GA25045@x60s.casa> <53AAEF0B.1000407@orlitzky.com> Message-ID: <53AC1FAD.1050200@orlitzky.com> On 06/26/2014 03:10 AM, Erik Hesselink wrote: >> >> None of that helps if you write the wrong program. Your program may >> typecheck, but if you're expecting "42" as output and your program hums >> the Star Trek theme instead, the fact that it correctly does the wrong >> thing won't be much consolation. > > The same goes for any kind of testing, though. All these (writing the > program, giving types for the program and testing the program) are > different ways of specifying the same thing. The benefit from doing it > twice in different ways, is that it's unlikely that you'll do it wrong > twice *in the same way*. > > Erik > It guarantees that you've made an even number of mistakes =) From jkarni at gmail.com Thu Jun 26 13:59:38 2014 From: jkarni at gmail.com (Julian K. Arni) Date: Thu, 26 Jun 2014 15:59:38 +0200 Subject: [Haskell-cafe] Quantification in Instance Contexts In-Reply-To: References: <20140625094617.GB17417@jkarni.celeraone.com> Message-ID: <20140626135938.GA1836@jkarni.celeraone.com> On Thu, Jun 26, 2014 at 02:08:24AM -0700, Andras Slemmer wrote: > Your second example shouldn't (and doesn't) compile, as the IsNotFirst > instance has an ambiguous variable 'b'. What you want is this 'b' to be > existentially quantified and have the compiler provide a witness for it. That's exactly what I want! Well, modulo actually caring that the witness be provided (of course *that* would raise the 'which one' question). Sorry if that wasn't clear. > Should this compile if we don't have an IsAfter instance in the current > module? What if we define one in module B which imports module A? What if > we have two IsAfter instances? Which instance should it use? I understand the general problem of ambiguous types, but my point was that sometimes which instance is picked doesn't matter, and my question was whether there was a way of expressing that - e.g., with a quantifier whose scope doesn't extend to the RHS, so the RHS wouldn't even have access to it. As to the "Should this compile" question, I guess I still don't see how the situation is different from: >> v = (undefined::A) >> t = show v Which should only compile if there is an instance for Show A. In both cases you need to check whether an instance exists; but in one it's *any* instance, and with the other it's an instance with the right instance head. I concede the former is probably tricky, but I've seen people achieve really tricky things with Haskell types, and have decided to ask even when something looks impossible. > > > adding extra instance declarations can 'change the truth-value' of the > right-hand side. > > No, they cannot. instance (IsSecond a) => IsNotFirst a translates to > (\forall a. IsSecond(a) -> IsNotFirst(a)), which will always hold. (Unless > you switch on overlappinginstances which you shouldnt) What I meant was that IsNotFirst A, for some concrete A, will hold depending on whether there is an instance declaration - for example, IsNotFirst A. But you're right: without OverlappingInstances, this is a stretch of the imagination, whereas with it, you can have type-level boolean witnesses to this 'change'. From jkarni at gmail.com Thu Jun 26 14:28:43 2014 From: jkarni at gmail.com (Julian K. Arni) Date: Thu, 26 Jun 2014 16:28:43 +0200 Subject: [Haskell-cafe] Quantification in Instance Contexts In-Reply-To: References: <20140625094617.GB17417@jkarni.celeraone.com> Message-ID: <20140626142843.GB1836@jkarni.celeraone.com> Ah, but yes, now I see what you mean by CWA. I was thinking in terms of instance declarations, but you mean 'types'. That makes sense. Pity, it would have been fun! On Thu, Jun 26, 2014 at 02:08:24AM -0700, Andras Slemmer wrote: > Your second example shouldn't (and doesn't) compile, as the IsNotFirst > instance has an ambiguous variable 'b'. What you want is this 'b' to be > existentially quantified and have the compiler provide a witness for it. > > Again, Haskell doesn't have a closed world of types. Even if the compiler > doesn't find a 'b' in say the current module it cannot refute an IsNotFirst > constraint, as an IsAfter instance may be defined in another module. > > module A where > weirdId :: IsNotFirst a => a -> a > weirdId = id > > Should this compile if we don't have an IsAfter instance in the current > module? What if we define one in module B which imports module A? What if > we have two IsAfter instances? Which instance should it use? > > > adding extra instance declarations can 'change the truth-value' of the > right-hand side. > > No, they cannot. instance (IsSecond a) => IsNotFirst a translates to > (\forall a. IsSecond(a) -> IsNotFirst(a)), which will always hold. (Unless > you switch on overlappinginstances which you shouldnt) > > > On 25 June 2014 23:06, Julian Arni wrote: > > > Thanks for the reply. I don't quite understand why guessing whether there > > is an intermediate type would be so magical, though. Let's simplify: > > > > data A > > data B > > class IsNotFirst a > > class IsAfter b a > > instance (IsAfter b a) => IsNotFirst a > > instance IsAfter B A > > > > > > Here we've separated out the ambiguous type issue from the unification. > > Note that *already*, if I query with undefined::(IsNotFirst A => a), I get: > > > > No instance for (IsAfter b A) arising from a use of ?t? > > The type variable ?b? is ambiguous > > Note: there is a potential instance available: > > instance [overlap ok] IsAfter B A > > > > Generally, GHC is doing the work that I wanted it to *in the error > > message*. In what sense, then, is this impossible? > > And why is there some inexcusable use of CWA here? Instances already > > have (if you squint) a negation-as-failure semantics. "instance (IsAfter b > > a) => IsNotFirst a" doesn't *in that sense* look that different to me than > > "instance (IsSecond a) => IsNotFirst a": adding extra instance declarations > > can 'change the truth-value' of the right-hand side. > > > > > > Thanks again, > > Julian > > > > > > On Thu, Jun 26, 2014 at 1:58 AM, Andras Slemmer <0slemi0 at gmail.com> wrote: > > > >> Think about what you're asking from the compiler. If it sees a (Path a c) > >> constraint it would have to magically guess whether there is an > >> intermediate type b for which (Path a b) and (Path b c), which is > >> impossible. > >> > >> Logic programming relies on the closed world assumption, meaning that if > >> a statement cannot be proven within the closed world we are working in then > >> it is false. Haskell typeclasses don't work like this; there is no closed > >> world of types, so the compiler cannot "refute" a constraint. > >> > >> In prolog you'd have something like this: > >> path(A,C) :- path(A,B), path(B,C). > >> (havent used prolog for a while so syntax might be off) > >> > >> If you translate this to first order logic you'd have: > >> \forall A,C.(path(A,C) <- \exists B.(path(A,B)^path(B,C))) > >> > >> It is the existential that is emulated with the cwa and cannot be > >> emulated in haskell's typesystem. > >> > >> > >> > >> From trebla at vex.net Thu Jun 26 18:14:51 2014 From: trebla at vex.net (Albert Y. C. Lai) Date: Thu, 26 Jun 2014 14:14:51 -0400 Subject: [Haskell-cafe] ANN: psqueues In-Reply-To: <20140623140749.GD417@jasper.local> References: <20140623140749.GD417@jasper.local> Message-ID: <53AC631B.9020109@vex.net> On 14-06-23 10:07 AM, Jasper Van der Jeugt wrote: > Here at Better, we have just a released a package which implements > faster priority search queues for Haskell. We hope it proves to be > useful to the community! [...] > http://hackage.haskell.org/package/psqueues Nice, it does priority-key-value too, not just priority-key. I need the value part there. Previously, I took PSQueue source code and added a value field for myself. From icfp.publicity at googlemail.com Thu Jun 26 18:55:14 2014 From: icfp.publicity at googlemail.com (David Van Horn) Date: Thu, 26 Jun 2014 14:55:14 -0400 Subject: [Haskell-cafe] ICFP 2014 Call for Participation Message-ID: [ Please note that much of the block reservation of hotel rooms currently being held for ICFP participants will be released next week. The beginning of September is a very busy conference week in G?teborg, so there is high pressure on hotel rooms in that period. If you plan to attend ICFP 2014, it would be best to make your hotel reservations now before the block reservation expires. ] ===================================================================== Call for Participation ICFP 2014 19th ACM SIGPLAN International Conference on Functional Programming and affiliated events August 31 - September 6, 2013 Gothenburg, Sweden http://icfpconference.org/icfp2014/ ===================================================================== ICFP provides a forum for researchers and developers to hear about the latest work on the design, implementations, principles, and uses of functional programming. The conference covers the entire spectrum of work, from practice to theory, including its peripheries. A full week dedicated to functional programming: 1 conference, 1 symposium, 10 workshops, tutorials, programming contest results, student research competition * Accepted Papers: http://www.icfpconference.org/icfp2014/accepted.html * Local arrangements (including travel and accommodation): http://icfpconference.org/icfp2014/local.html * Registration is available via: https://regmaster4.com/2014conf/ICFP14/register.php Early registration is due 3 August, 2014. * Programming contest, 25-28 July, 2014: http://icfpcontest.org/ * Follow @icfp_conference on twitter for the latest news: http://twitter.com/#!/icfp_conference There are several events affiliated with ICFP: Sunday, August 31 ACM SIGPLAN Workshop on Generic Programming ACM SIGPLAN Workshop on Higher-order Programming with Effects Monday, September 1 ? Wednesday, September 3 ICFP Thursday, September 4 ACM SIGPLAN Commercial Users of Functional Programming: Day 1, Tutorials ACM SIGPLAN Haskell Symposium: Day 1 ACM SIGPLAN Workshop on Functional High-Performance Computing ACM SIGPLAN ML Family Workshop Friday, September 5 ACM SIGPLAN Commercial Users of Functional Programming: Day 2, Tutorials ACM SIGPLAN Haskell Symposium: Day 2 ACM SIGPLAN OCaml Workshop ACM SIGPLAN Erlang Workshop ACM SIGPLAN Workshop on Haskell and Rewriting Techniques Saturday, September 6 ACM SIGPLAN Commercial Users of Functional Programming: Day 3, Talks ACM SIGPLAN Haskell Implementors Workshop ACM SIGPLAN Workshop on Functional Art, Music, Modeling and Design Conference Organizers General Chair: Johan Jeuring, Utrecht University Program Chair: Manuel Chakravarty, University of New South Wales Local Arrangements Chair: Bj?rn von Sydow, Chalmers University Industrial Relations Chair: Anil Madhavapeddy, University of Cambridge Workshop Co-Chairs: Tom Schrijvers, Ghent University Sam Tobin-Hochstadt, Indiana University Programming Contest Co-Chairs: Duncan Coutts, Well Typed LLP Nicolas Wu, University of Oxford Student Research Competition Chair: Meng Wang, Chalmers University Publicity Chair: David Van Horn, University of Maryland Video Chair: Iavor Diatchki, Galois Malcolm Wallace, Standard Chartered Bank Industrial partners: Platinum partners Jane Street Capital Gold partners Google Microsoft Research Mozilla Oracle Labs Standard Chartered Bank Silver partners Bloomberg Credit Suisse CyberPoint Erlang Solutions Facebook Galois Klarna Lexifi Twitter Bronze partners IntelliFactory Opera Software QuviQ ===================================================================== From ok at cs.otago.ac.nz Thu Jun 26 23:22:34 2014 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Fri, 27 Jun 2014 11:22:34 +1200 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: References: Message-ID: <9326C827-727F-4C5F-A96B-7879A8CEB6C3@cs.otago.ac.nz> On 27/06/2014, at 12:37 AM, Alois Cochard wrote: > Interesting, It's sounds like your definition of `TDD` is what is my definition of `solving problem`. Not exactly. It's problem solving/design activity PLUS recording aspects of your decisions as machine-readable tests. > > My point was that I don't want to write test for a grammar that I might realize during further design that is wrong, this would be just complete wasted effort... For one thing, tests can be automatically generated from a grammar. The first time I demonstrated this to a class of students, I said "now, here I've got this program that I wrote a few years ago and I know it works, this is just demonstrating how you can generate tests from a grammar." And then the very first generated test revealed a bug. At that point I was Enlightened. But the most important thing here is that a grammar and an API are not that different. The whole *point* of writing your tests first is that the interfaces we design are just another of the things we get wrong. It's way too easy to design an interface, code it up, start testing, and discover that something that should be easy is somewhere between difficult and impossible, and fixing it requires a redesign. (I would say that the original Document Object Model looks very much like something that was frozen before being checked this way. Certainly everything *I* wanted to do with it was unspeakably clumsy. Hooray for Haskell and document *value* models!) Writing test cases is one way in which "further design" happens; if a test that should be straightforward isn't, *that* is when you "release .. that is wrong". None of this is new. Back in the 1960s when people like Dijkstra were talking about top down design, they were talking about writing a program *as if* some helpful genie provided all the library support you needed, *playing* around and getting the design right, and only *then* implementing the library. (And when doing that, you do the same thing all over again.) > Instead I just test as a way to tryout my DSL... but really to me it does *not* relate to TDD... because I can do the same with just a REPL and the history of it... Using a REPL (provided your system saves a transcript so that you can replay tests later) has two main problems: (1) you can't do it until the code and its interface *exist*, whereas writing tests earlier can save you time wasted on implementing the wrong interface (2) using a REPL is apt to be a bit haphazard; thinking about your tests off-line you can get more coverage with less work. Don't mistake me. I am *not* good at testing yet. The only reason I'm defending TDD is that I have after too many years finally learned that "if it isn't tested it doesn't work" is true of *MY* code, so the earlier I test something the less horribly embarrassed I'm going to be. > > I wish that definition you use was the same understood by the industry, but it is not the way it was presented to me when I discussed with TDD enthusiast in the past... maybe things changed. We are not called to be right. We are called to improve. Learn from many masters but obey none. From ok at cs.otago.ac.nz Thu Jun 26 23:25:30 2014 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Fri, 27 Jun 2014 11:25:30 +1200 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: References: <09DA657C-13A3-4CD4-9DCB-5D509C6FE2DA@yandex.ru> <53AAC471.7050505@fuuzetsu.co.uk> <20140625152431.GA25045@x60s.casa> <53AAEF0B.1000407@orlitzky.com> <8EE57728-1AD4-4680-A9C3-015C8555A3FF@recursive.ca> Message-ID: <5AF44404-2D67-43BC-BA77-28A82D1C0AE0@cs.otago.ac.nz> On 27/06/2014, at 12:50 AM, Alois Cochard wrote: > I'm not replying to you nor Michael Orlitzky. > I'm replying to Richard A. O'Keefe. What is this thing called QuickCheck? A *fantastic* tool from a great source which has been imitated more or less successfully for several other languages. The results tend to show just how amazing the Haskell type system is. (Yes, types AND tests!) Whenever I use it, it helps me. From vigalchin at gmail.com Thu Jun 26 23:31:29 2014 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Thu, 26 Jun 2014 18:31:29 -0500 Subject: [Haskell-cafe] POSIX capabilities support Message-ID: Hello Haskellers, I have looked through the various POSIX hack age modules to see if there is capabilities support. ??? Regards, Vasya -------------- next part -------------- An HTML attachment was scrubbed... URL: From kazu at iij.ad.jp Fri Jun 27 00:23:32 2014 From: kazu at iij.ad.jp (Kazu Yamamoto (=?iso-2022-jp?B?GyRCOzNLXE9CSScbKEI=?=)) Date: Fri, 27 Jun 2014 09:23:32 +0900 (JST) Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: References: Message-ID: <20140627.092332.1386383478000412215.kazu@iij.ad.jp> > I'm a huge fan of TDD (Test-Driven Development) et I used to use tools such > as RSpec (Ruby). So naturally, I looked to HSpec, but it seems not > idiomatic in Haskell. > I have a bunch of questions: > - Do you do TDD? > - Which tools do you use? > - Is doctest "better" (in some senses) than HSpec? Why? > - Are HSpec and Doctest complementary? If so, in which case do you use one > or another? > - Is there some Haskell-specific good practices do to TDD? Both doctest and HSpec are implemented by Simon (the same author). His intention is described here: https://github.com/kazu-yamamoto/unit-test-example/blob/master/markdown/en/tutorial.md Probably Haskell specific feature is QuickCheck integration. Now GHC 7.8 is out, we can use the "prop>" keyword in doctest cases, too. Enjoy. --Kazu From vigalchin at gmail.com Fri Jun 27 06:31:35 2014 From: vigalchin at gmail.com (Vasili I. Galchin) Date: Fri, 27 Jun 2014 01:31:35 -0500 Subject: [Haskell-cafe] POSIX capabilities support In-Reply-To: References: Message-ID: Hello, Now I realize (I think) that my question was not correct .. in that I should focus on where in a given POSIX kernel capability calls are made and for what capability attribute/property, yes? Regards, Vasya On Thu, Jun 26, 2014 at 6:31 PM, Vasili I. Galchin wrote: > Hello Haskellers, > > I have looked through the various POSIX hack age modules to see if > there is capabilities support. ??? > > Regards, > > Vasya > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alois.cochard at gmail.com Fri Jun 27 08:55:33 2014 From: alois.cochard at gmail.com (Alois Cochard) Date: Fri, 27 Jun 2014 09:55:33 +0100 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: <9326C827-727F-4C5F-A96B-7879A8CEB6C3@cs.otago.ac.nz> References: <9326C827-727F-4C5F-A96B-7879A8CEB6C3@cs.otago.ac.nz> Message-ID: On 27 June 2014 00:22, Richard A. O'Keefe wrote: > > For one thing, tests can be automatically generated from a grammar. > The first time I demonstrated this to a class of students, I said > "now, here I've got this program that I wrote a few years ago and > I know it works, this is just demonstrating how you can generate > tests from a grammar." And then the very first generated test > revealed a bug. At that point I was Enlightened. > > Sure that is awesome, same kind of thing as using QuickCheck in a way... but do you consider this as TDD? I always seen TDD as "writing test first", where here you generate them once you have the grammar... that feel different to me, but as said before I'm realizing my definition was wrong. > But the most important thing here is that a grammar and an API > are not that different. Yeah I completely agree, the fact that I was trying to make a point specific to DSL design is wrong... it's should be the same really. > The whole *point* of writing your tests > first is that the interfaces we design are just another of the > things we get wrong. > But don't you think this particular step can be achieved in your head? Maybe not for complex thing, but at least it work for me for simple case... I test the interface in my head or on paper before actually coding them (I'm not saying *implementing* them!) > Don't mistake me. I am *not* good at testing yet. The only > reason I'm defending TDD is that I have after too many years > finally learned that "if it isn't tested it doesn't work" is > true of *MY* code, so the earlier I test something the less > horribly embarrassed I'm going to be. > > That's for sure, but that point is imo about testing in general and not TDD in particular. Once you deliver a piece of work, it should be proven it work... Maybe doing it earlier help, but that's more about fighting procrastination than anything else, because I'm sure you hate as much as me writing tests ;-) > We are not called to be right. > We are called to improve. > Learn from many masters but obey none. > > Nice, a wise advice that I'll surely remember. -- *A\ois* http://twitter.com/aloiscochard http://github.com/aloiscochard -------------- next part -------------- An HTML attachment was scrubbed... URL: From frantisek at farka.eu Fri Jun 27 16:18:59 2014 From: frantisek at farka.eu (Frantisek Farka) Date: Fri, 27 Jun 2014 18:18:59 +0200 Subject: [Haskell-cafe] Empty case alternative Message-ID: <20140627181859.1ebabee3@farka.eu> Hello cafe, I was looking into Haskell Report 2010 and notice something in the definition of case statement: https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-460003.13 Apparently an empty alternative within case statement is a plausible production. ('alt' production rule, third option). If I get it correctly, following example shows the empty alternative: > > cStmt e = case e of { 'a' -> True ; {-- empty here --} ; 'b' -> False } > What I miss is any ratio behind this. What is the empty alternative good for? Any idea? Franta From chriswarbo at googlemail.com Fri Jun 27 16:00:33 2014 From: chriswarbo at googlemail.com (Chris Warburton) Date: Fri, 27 Jun 2014 17:00:33 +0100 Subject: [Haskell-cafe] Empty case alternative In-Reply-To: <20140627181859.1ebabee3@farka.eu> (Frantisek Farka's message of "Fri, 27 Jun 2014 18:18:59 +0200") References: <20140627181859.1ebabee3@farka.eu> Message-ID: <86ionmmjfi.fsf@gmail.com> Frantisek Farka writes: > Hello cafe, > > I was looking into Haskell Report 2010 and notice something in the > definition of case statement: > > https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-460003.13 > > Apparently an empty alternative within case statement is a plausible > production. ('alt' production rule, third option). > > If I get it correctly, following example shows the empty alternative: > >> >> cStmt e = case e of { 'a' -> True ; {-- empty here --} ; 'b' -> False } >> > > What I miss is any ratio behind this. What is the empty alternative > good for? Any idea? Looks like it's to allow "case e of {}". Notice that "lexp" requires an "alts" and "alts" requires at least 1 "alt", so for empty braces to be acceptable there must be an empty alt for them to 'contain'. Cheers, Chris From tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Fri Jun 27 16:52:39 2014 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Fri, 27 Jun 2014 17:52:39 +0100 Subject: [Haskell-cafe] "Generating" type synonyms without Template Haskell Message-ID: <20140627165239.GD2983@henry> I'd like to know how to conveniently generate specialisations of a product type without resorting to Template Haskell. Concretely, I have a type like data MyProduct a b c = MyProduct { foo :: a , bar :: b , baz :: c } and I use it in type signatures in various different specialisations. Generally the "base" type of each component stays fixed but it is wrapped in zero or more type constructors. For example a. MyProduct Int Bool String b. MyProduct (Maybe Int) (Maybe Bool) (Maybe String) c. MyProduct [IO Int] [IO Bool] [IO String] d. MyProduct (P Int) (P Bool) (P String) for various P that are not always functors in my uses. I thought I might be able to reduce this duplication by parametrisation, that is data MyProduct f a b c = MyProduct { foo :: f a , bar :: f b , baz :: f c } However, I can't always substitute a type constructor for `f` because that doesn't work for cases a. or c.. I thought a type family might work but it seems they have to be fully applied, like type synonyms. Is there an approach to this problem that will allow me to avoid Template Haskell here? Thanks, Tom From vogt.adam at gmail.com Fri Jun 27 17:41:49 2014 From: vogt.adam at gmail.com (adam vogt) Date: Fri, 27 Jun 2014 13:41:49 -0400 Subject: [Haskell-cafe] "Generating" type synonyms without Template Haskell In-Reply-To: <20140627165239.GD2983@henry> References: <20140627165239.GD2983@henry> Message-ID: Hi Tom, You could push the use of that type family into the definition of MyProduct so that the type family can be fully applied: > {-# LANGUAGE DataKinds, PolyKinds, TypeFamilies, TypeOperators #-} > > data MyProduct f a b c = MyProduct > { foo :: MkF f a > , bar :: MkF f b > , baz :: MkF f c } > > > type family MkF (f :: k) (x :: *) :: * > > type instance MkF () x = x > type instance MkF (f ': fs) x = f (MkF fs x) > type instance MkF '[] x = x > type instance MkF f x = f x Then your example signatures can be written as > type MP f = MyProduct f Int Bool String > > type A = MP () > type B = MP Maybe > type C = MP [[], IO] > type D = MP P I'm not sure this approach gains you much over just writing out the type signatures has you had them. Adam From haskell at nand.wakku.to Fri Jun 27 20:30:45 2014 From: haskell at nand.wakku.to (Niklas Haas) Date: Fri, 27 Jun 2014 22:30:45 +0200 Subject: [Haskell-cafe] "Generating" type synonyms without Template Haskell In-Reply-To: <20140627165239.GD2983@henry> References: <20140627165239.GD2983@henry> Message-ID: <20140627223045.GB28135@nanodesu.localdomain> On Fri, 27 Jun 2014 17:52:39 +0100, Tom Ellis wrote: > I'd like to know how to conveniently generate specialisations of a > product type without resorting to Template Haskell. > > Concretely, I have a type like > > data MyProduct a b c = MyProduct { foo :: a > , bar :: b > , baz :: c } > > and I use it in type signatures in various different specialisations. > Generally the "base" type of each component stays fixed but it is > wrapped in zero or more type constructors. For example > > a. MyProduct Int Bool String > > b. MyProduct (Maybe Int) (Maybe Bool) (Maybe String) > > c. MyProduct [IO Int] [IO Bool] [IO String] > > d. MyProduct (P Int) (P Bool) (P String) Using LiberalTypeSynonyms and your original MyProduct, we can define type Example f = MyProduct (f Int) (f Bool) (f String) type Id x = x type ListIO x = [IO x] type A = Example Id type B = Example Maybe type C = Example ListIO type D = Example P From nikita.y.volkov at mail.ru Fri Jun 27 22:54:56 2014 From: nikita.y.volkov at mail.ru (Nikita Volkov) Date: Sat, 28 Jun 2014 02:54:56 +0400 Subject: [Haskell-cafe] ANNOUNCE: stm-containers Message-ID: A post with introduction to the library, motivation behind it and its performance analysis: http://nikita-volkov.github.io/stm-containers/ Hackage: http://hackage.haskell.org/package/stm-containers GitHub: https://github.com/nikita-volkov/stm-containers -------------- next part -------------- An HTML attachment was scrubbed... URL: From tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk Fri Jun 27 22:55:42 2014 From: tom-lists-haskell-cafe-2013 at jaguarpaw.co.uk (Tom Ellis) Date: Fri, 27 Jun 2014 23:55:42 +0100 Subject: [Haskell-cafe] "Generating" type synonyms without Template Haskell In-Reply-To: <20140627223045.GB28135@nanodesu.localdomain> References: <20140627165239.GD2983@henry> <20140627223045.GB28135@nanodesu.localdomain> Message-ID: <20140627225542.GF2983@henry> On Fri, Jun 27, 2014 at 10:30:45PM +0200, Niklas Haas wrote: > On Fri, 27 Jun 2014 17:52:39 +0100, Tom Ellis wrote: > > I'd like to know how to conveniently generate specialisations of a > > product type without resorting to Template Haskell. > > > > Concretely, I have a type like > > > > data MyProduct a b c = MyProduct { foo :: a > > , bar :: b > > , baz :: c } > > > > and I use it in type signatures in various different specialisations. > > Generally the "base" type of each component stays fixed but it is > > wrapped in zero or more type constructors. For example > > > > a. MyProduct Int Bool String > > > > b. MyProduct (Maybe Int) (Maybe Bool) (Maybe String) > > > > c. MyProduct [IO Int] [IO Bool] [IO String] > > > > d. MyProduct (P Int) (P Bool) (P String) > > Using LiberalTypeSynonyms and your original MyProduct, we can define > > type Example f = MyProduct (f Int) (f Bool) (f String) > > type Id x = x > type ListIO x = [IO x] > > type A = Example Id > type B = Example Maybe > type C = Example ListIO > type D = Example P Oh, that looks like exactly what I wanted! I didn't know about LiberalTypeSynonyms. Thanks a lot, Tom From mle+hs at mega-nerd.com Sat Jun 28 09:14:47 2014 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Sat, 28 Jun 2014 19:14:47 +1000 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: References: Message-ID: <20140628191447.e1f4a395e11b23568d0e0c71@mega-nerd.com> Gautier DI FOLCO wrote: > Hi all, > > I'm a huge fan of TDD (Test-Driven Development) et I used to use tools such > as RSpec (Ruby). So naturally, I looked to HSpec, but it seems not > idiomatic in Haskell. > I have a bunch of questions: > - Do you do TDD? > - Which tools do you use? > - Is doctest "better" (in some senses) than HSpec? Why? > - Are HSpec and Doctest complementary? If so, in which case do you use one > or another? > - Is there some Haskell-specific good practices do to TDD? In languages other than Haskell I do sometimes write tests first and practive real TDD. I Haskell writing test first seems a little ridculous. What I tend to do is: * Write the types. * Make sure the types interact together. * Fill in the functions. * For stuff that cannot be enforced by types, write tests. For tests I use Hspec (both canned example test and QuickCheck style property tests) but intend to start suplementing it with doctest so that example code in the docstring comments is tested for correctness. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From fuuzetsu at fuuzetsu.co.uk Sat Jun 28 13:02:04 2014 From: fuuzetsu at fuuzetsu.co.uk (Mateusz Kowalczyk) Date: Sat, 28 Jun 2014 15:02:04 +0200 Subject: [Haskell-cafe] Testing web-interfacing applications Message-ID: <53AEBCCC.7010304@fuuzetsu.co.uk> Hi, Whenever I write a program which has to interface with the web (scraping, POSTing, whatever), I never know how to properly test it. What I have been doing up to date is fetching some pages ahead of time, saving locally and running my parsers or whatever it is I'm coding at the moment against that. The problem with this approach is that we can't test a whole lot: if we have a crawler, how do we test it it goes to the next page properly? Testing things like logging in and such seems close to impossible, we can only test if we are making a good POST. Let's stick to a crawler example. How would you test that it follows links? Do people set up local webservers with few dummy pages they download? Do you just inspect that GET and POST ?look? correct? Assume that we don't own the sites so we can't let the program run tests in the wild: page content might change (parser tests fail), APIs might change (unexpected stuff back), our account might be locked (guess they didn't like us logging in 20 times in last hour during tests) &c. Of course there is nothing which can prevent upstream changes but I'm wondering how we can test the more-or-less static stuff without calling out into the world. -- Mateusz K. From qdunkan at gmail.com Sat Jun 28 17:03:31 2014 From: qdunkan at gmail.com (Evan Laforge) Date: Sat, 28 Jun 2014 10:03:31 -0700 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: <20140628191447.e1f4a395e11b23568d0e0c71@mega-nerd.com> References: <20140628191447.e1f4a395e11b23568d0e0c71@mega-nerd.com> Message-ID: I often write tests first, as a way of testing my understanding. I figure out in my head what I think a certain function should return, and write that down first. That way I have a "second implementation" (the one in my head) that hasn't been compromised by seeing the actual results. Otherwise I'd be tempted to copy and paste actual output into the test and inspect it to make sure it makes sense. I think what kind of tests are relevant depends more strongly on what kind of program you are writing, than what language you are writing in. My program has a lot of complexity that's hard to put in types, and is also not amenable to QuickCheck, so I wind up with lots of 'equal (f x y z) [expected, result, ...]' type tests, and those can work well if you write them first. It's somewhat similar to compiler, so it's analogous to ghc's "expected output" and "should fail" tests. Another style of program could be totally different. From johan.g.larson at gmail.com Sat Jun 28 19:28:15 2014 From: johan.g.larson at gmail.com (Johan Larson) Date: Sat, 28 Jun 2014 15:28:15 -0400 Subject: [Haskell-cafe] handling non-string command line arguments Message-ID: I've been looking at choices for parsing command line arguments, including getOpt. The examples I can find focus on string arguments, whereas I am interested in numbers. In the application at hand, it is particularly important to issue clear error messages when arguments don't parse as numbers or are out of range. I could use getOpt as a first pass with string arguments and then turn the strings into validated numbers in a second pass, but that's a bit awkward. Alternately I could use the options records with Options -> IO Options functions. But both of these solutions treat type mismatches differently from other options errors. Has anyone found a cleaner solution? -- Johan Larson -- Toronto, Canada -------------- next part -------------- An HTML attachment was scrubbed... URL: From nukasu.kanaka at gmail.com Sat Jun 28 20:02:01 2014 From: nukasu.kanaka at gmail.com (Nikita Volkov) Date: Sun, 29 Jun 2014 00:02:01 +0400 Subject: [Haskell-cafe] handling non-string command line arguments In-Reply-To: References: Message-ID: I?d recommend taking a look at *optparse-applicative* . The library is very flexible and designed well. ? -------------- next part -------------- An HTML attachment was scrubbed... URL: From nikita.y.volkov at gmail.com Sat Jun 28 20:14:16 2014 From: nikita.y.volkov at gmail.com (Nikita Volkov) Date: Sun, 29 Jun 2014 00:14:16 +0400 Subject: [Haskell-cafe] Moderators, please block zhangliu529@sina.com Message-ID: Every time I send a message to Cafe I get an autoreply from this user with the following text: ??????????????????? It's extremely annoying. Please, exclude this user from the mailing list. -------------- next part -------------- An HTML attachment was scrubbed... URL: From hesselink at gmail.com Sat Jun 28 20:34:16 2014 From: hesselink at gmail.com (Erik Hesselink) Date: Sat, 28 Jun 2014 22:34:16 +0200 Subject: [Haskell-cafe] handling non-string command line arguments In-Reply-To: References: Message-ID: If you want to use getOpt, you could produce options of type 'OptDescr (Either String (Options -> Options))', that is, for a command line argument, either produce an error, or some modification of your options. It is my experience that sometimes you will need a second pass even if you do this, because there are some errors that require the value of multiple options to check. Erik On Sat, Jun 28, 2014 at 9:28 PM, Johan Larson wrote: > I've been looking at choices for parsing command line arguments, including > getOpt. The examples I can find focus on string arguments, whereas I am > interested in numbers. In the application at hand, it is particularly > important to issue clear error messages when arguments don't parse as > numbers or are out of range. > > I could use getOpt as a first pass with string arguments and then turn the > strings into validated numbers in a second pass, but that's a bit awkward. > Alternately I could use the options records with Options -> IO Options > functions. But both of these solutions treat type mismatches differently > from other options errors. > > Has anyone found a cleaner solution? > > -- > Johan Larson -- Toronto, Canada > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From john at repetae.net Sat Jun 28 21:16:30 2014 From: john at repetae.net (John Meacham) Date: Sat, 28 Jun 2014 14:16:30 -0700 Subject: [Haskell-cafe] Empty case alternative In-Reply-To: <86ionmmjfi.fsf@gmail.com> References: <20140627181859.1ebabee3@farka.eu> <86ionmmjfi.fsf@gmail.com> Message-ID: It is due to being able to mix layout with explicit semicolons. case x of a -> b; c -> d; e -> f ; g -> h; will add an additional semicolon before the e due to the layout rule. So in general, semis can always be repeated by allowing empty expressions in the Haskell grammar when layout is relevant. John On Fri, Jun 27, 2014 at 9:00 AM, Chris Warburton wrote: > Frantisek Farka writes: > >> Hello cafe, >> >> I was looking into Haskell Report 2010 and notice something in the >> definition of case statement: >> >> https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-460003.13 >> >> Apparently an empty alternative within case statement is a plausible >> production. ('alt' production rule, third option). >> >> If I get it correctly, following example shows the empty alternative: >> >>> >>> cStmt e = case e of { 'a' -> True ; {-- empty here --} ; 'b' -> False } >>> >> >> What I miss is any ratio behind this. What is the empty alternative >> good for? Any idea? > > Looks like it's to allow "case e of {}". Notice that "lexp" requires an > "alts" and "alts" requires at least 1 "alt", so for empty braces to be > acceptable there must be an empty alt for them to 'contain'. > > Cheers, > Chris > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe -- John Meacham - http://notanumber.net/ From john at repetae.net Sat Jun 28 21:30:31 2014 From: john at repetae.net (John Meacham) Date: Sat, 28 Jun 2014 14:30:31 -0700 Subject: [Haskell-cafe] handling non-string command line arguments In-Reply-To: References: Message-ID: What is the issue with other option errors and type matches being treated differently? I mean, you can print the same error message. A handy trick is to define a helper for building your options list that passes the option names into your monadic option builder function so it can print the name of the option that was given the wrong type in a generic and pretty way. I generally use a Writer monad to collect errors rather than an Error monad that cuts out early so all option errors can be accumulated and printed together. John On Sat, Jun 28, 2014 at 12:28 PM, Johan Larson wrote: > I've been looking at choices for parsing command line arguments, including > getOpt. The examples I can find focus on string arguments, whereas I am > interested in numbers. In the application at hand, it is particularly > important to issue clear error messages when arguments don't parse as > numbers or are out of range. > > I could use getOpt as a first pass with string arguments and then turn the > strings into validated numbers in a second pass, but that's a bit awkward. > Alternately I could use the options records with Options -> IO Options > functions. But both of these solutions treat type mismatches differently > from other options errors. > > Has anyone found a cleaner solution? > > -- > Johan Larson -- Toronto, Canada > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- John Meacham - http://notanumber.net/ From johan.g.larson at gmail.com Sat Jun 28 21:56:55 2014 From: johan.g.larson at gmail.com (Johan Larson) Date: Sat, 28 Jun 2014 17:56:55 -0400 Subject: [Haskell-cafe] handling non-string command line arguments In-Reply-To: References: Message-ID: I mean getOpt has its own way of keeping track of errors and whatever construction I use to collect typechecking errors will need another. If only there were a way for the typechecking errors messages to be picked up by getOpt itself, and returned with its own native error messages. On Sat, Jun 28, 2014 at 5:30 PM, John Meacham wrote: > What is the issue with other option errors and type matches being > treated differently? I mean, you can print the same error message. A > handy trick is to define a helper for building your options list that > passes the option names into your monadic option builder function so > it can print the name of the option that was given the wrong type in a > generic and pretty way. I generally use a Writer monad to collect > errors rather than an Error monad that cuts out early so all option > errors can be accumulated and printed together. > > John > > On Sat, Jun 28, 2014 at 12:28 PM, Johan Larson > wrote: > > I've been looking at choices for parsing command line arguments, > including > > getOpt. The examples I can find focus on string arguments, whereas I am > > interested in numbers. In the application at hand, it is particularly > > important to issue clear error messages when arguments don't parse as > > numbers or are out of range. > > > > I could use getOpt as a first pass with string arguments and then turn > the > > strings into validated numbers in a second pass, but that's a bit > awkward. > > Alternately I could use the options records with Options -> IO Options > > functions. But both of these solutions treat type mismatches differently > > from other options errors. > > > > Has anyone found a cleaner solution? > > > > -- > > Johan Larson -- Toronto, Canada > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > > > -- > John Meacham - http://notanumber.net/ > -- Johan Larson -- Toronto, Canada -------------- next part -------------- An HTML attachment was scrubbed... URL: From ydl at ydl.cm Sun Jun 29 00:37:34 2014 From: ydl at ydl.cm (Yuri Lensky) Date: Sat, 28 Jun 2014 20:37:34 -0400 Subject: [Haskell-cafe] Conceptualizing Functor vs Performance Message-ID: I am having trouble consolidating a performance-based data representation decision I would like to make against the concept of a "functor". The question can be reduced to the following: Conceptually I think that Data.Vector /should/ be a functor. More specifically, I see no CONCEPTUAL reason that it shouldn't be possible to define some "efficient" container-like object (for example for fast Matrix operations for unboxable numbers, but something that still works for a symbolic variable type) that chooses to represent its data as a Data.Vector.Unboxed if possible, but chooses some more generic structure (perhaps a strict list or a generic Data.Vector) if that is not the case. I haven't found such a functor, and can't seem to implement it on my own. The point is that in theory there is no true constraint on the type of the object being contained so it SHOULD be a Functor/Traversable/etc., the representation simply changes to something more efficient only if possible, and decays to a more generic type gracefully if necessary. Perhaps there is some type hackery that can be done with TypeFamilies? I.E. define some container type "data C a = (ListType a) a", but I haven't found a generic way to do this. Finally, I understand that "efficient" data structure can be problem-dependent, but I have no problem defining many different such "generic" types for different applications. The simplest example would be something like (invalid Haskell): (Data.Vector.Unboxed.Vector v a) => data instance (ListType a) = v (Data.Vector.Generic.Vector v a) => data instance (ListType a) = v data instance (ListType a) = ([]) Of course implementing fmap is a whole separate issue. The point is I do not think this is the right way/possible, but am wondering what the "true" solution is. Thanks. -------------- next part -------------- An HTML attachment was scrubbed... URL: From almeidaraf at gmail.com Sun Jun 29 02:16:31 2014 From: almeidaraf at gmail.com (Rafael Almeida) Date: Sat, 28 Jun 2014 23:16:31 -0300 Subject: [Haskell-cafe] Implementing parental using blood type Message-ID: Hello, I'm trying to practice my Haskell. So I had the idea of making a program which, given a mother's and a child blood type, it can determine whether a certain father is possible or not. Please take a look on this gist with my implementation: https://gist.github.com/aflag/14429dfb2e89791a44e2#file-parentaltesting Would you care to comment on it? It looks a bit cumbersome to my eyes. I'm trying to find the most intuitive and elegant way of do it. I'm not so much worried with performance. []'s Rafael -------------- next part -------------- An HTML attachment was scrubbed... URL: From almeidaraf at gmail.com Sun Jun 29 02:59:48 2014 From: almeidaraf at gmail.com (Rafael Almeida) Date: Sat, 28 Jun 2014 23:59:48 -0300 Subject: [Haskell-cafe] Monad laws In-Reply-To: <35C3CFD5-339E-43E2-88F4-60B896922058@cis.upenn.edu> References: <53AA5127.8010900@fuuzetsu.co.uk> <35C3CFD5-339E-43E2-88F4-60B896922058@cis.upenn.edu> Message-ID: On Wed, Jun 25, 2014 at 3:14 PM, Richard Eisenberg wrote: > On Jun 25, 2014, at 12:52 AM, John Lato wrote: > > > The compiler makes assumptions about associativity when de-sugaring > do-notation. If the monad laws aren't followed, it's possible for these > two blocks to show different behavior (given that a,b,c are all values of > the misbehaved Monad instance): > > > do { a; b; c } > > > a >> b >> c > > I think everyone can agree that this is surprising, at the very least. > Although it's not the compiler that's generating bad code here. > > > As far as I know, GHC makes no assumptions about associativity, or any > class-based laws. The effect John observes above is accurate, but it is a > direct consequence of the design of Haskell in the Haskell 2010 Report, not > any assumptions in the compiler. > > Specifically, Section 3.14 ( > https://www.haskell.org/onlinereport/haskell2010/haskellch3.html#x8-470003.14) > says that `do { e; stmts }` desugars to `e >> do {stmts}`. In the case of > `do { a; b; c }`, that means we get `a >> (b >> c)`. However, in Table 4.1 > in Section 4.4.2 (under > https://www.haskell.org/onlinereport/haskell2010/haskellch4.html#x10-800004.4), > we see that (>>) is *left*-associative, meaning that `a >> b >> c` means > `(a >> b) >> c`. > > Are the different meanings here an "assumption" of associativity? I > suppose one could construe it that way, but I just see `do { a; b; c}` and > `a >> b >> c` as different chunks of code with different meanings. If the > monad in question upholds the associativity law, then the chunks evaluate > to the same result, but they're still distinct. > > Great explanation! Would you say that the main reason for implementing monads so >> is associative is to make sure the do notation does the "right thing"? Monad is a notion from math which was imported into Haskell. As far as I know, the reason behind it was to give Haskell the possibility of doing IO while keeping itself pure. If there was a data type just like Moand, with >>=, >>, return and all. It behaved exactly the same, but no one cared about identity or associativity, then it wouldn't be a monad, but it would solve the computation with side-effects thing just the same. Why was associativity and identity brought to the language as well? What is there to be gained by such a law which can't be enforced by the compiler? -------------- next part -------------- An HTML attachment was scrubbed... URL: From allbery.b at gmail.com Sun Jun 29 03:11:44 2014 From: allbery.b at gmail.com (Brandon Allbery) Date: Sat, 28 Jun 2014 23:11:44 -0400 Subject: [Haskell-cafe] Monad laws In-Reply-To: References: <53AA5127.8010900@fuuzetsu.co.uk> <35C3CFD5-339E-43E2-88F4-60B896922058@cis.upenn.edu> Message-ID: On Sat, Jun 28, 2014 at 10:59 PM, Rafael Almeida wrote: > What is there to be gained by such a law which can't be enforced by the > compiler? There are lots of things that can't be enforced by the compiler; for example, it can't force you to write an Ord instance that implements a correct total ordering. Does this make Ord less useful to you? Or pointless? -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From almeidaraf at gmail.com Sun Jun 29 03:38:44 2014 From: almeidaraf at gmail.com (Rafael Almeida) Date: Sun, 29 Jun 2014 00:38:44 -0300 Subject: [Haskell-cafe] Monad laws In-Reply-To: References: <53AA5127.8010900@fuuzetsu.co.uk> <35C3CFD5-339E-43E2-88F4-60B896922058@cis.upenn.edu> Message-ID: On Sun, Jun 29, 2014 at 12:11 AM, Brandon Allbery wrote: > On Sat, Jun 28, 2014 at 10:59 PM, Rafael Almeida > wrote: > >> What is there to be gained by such a law which can't be enforced by the >> compiler? > > > There are lots of things that can't be enforced by the compiler; for > example, it can't force you to write an Ord instance that implements a > correct total ordering. Does this make Ord less useful to you? Or pointless? > No. I'm not trying to say Monad laws are useless or pointless. Rather, I am looking to understand the usefulness of those laws. People are indeed going to expect that the < operator is transitive. Even though the compiler can do nothing about it. I'm not sure how to explain why we need < to be transitive. If you do so, please explain that to me as well. I always took it for granted that such law must be obeyed. -------------- next part -------------- An HTML attachment was scrubbed... URL: From allbery.b at gmail.com Sun Jun 29 03:52:01 2014 From: allbery.b at gmail.com (Brandon Allbery) Date: Sat, 28 Jun 2014 23:52:01 -0400 Subject: [Haskell-cafe] Monad laws In-Reply-To: References: <53AA5127.8010900@fuuzetsu.co.uk> <35C3CFD5-339E-43E2-88F4-60B896922058@cis.upenn.edu> Message-ID: On Sat, Jun 28, 2014 at 11:38 PM, Rafael Almeida wrote: > No. I'm not trying to say Monad laws are useless or pointless. Rather, I > am looking to understand the usefulness of those laws. > My point was more that Ord could *also* be different; it could support partial ordering, for example, or could support non-mathematical ordering which would e.g. enable Data.Map to be used with things that don't have mathematical total ordering, like Complex Double, or possibly to fix its behavior with Double whose Ord instance is actually not a proper total ordering; what matters is not that there is a mathematical total ordering, but that there is *some* kind of reliable ordering that can be used to build a tree. I imagine that, like Ord, a decision was made to implement the proper mathematical abstraction and not merely a convenient one. This seems to be the "Haskell way". (I'm not sure how it explains Double, though the numeric hierarchy has a lot of compromises in the name of convenience or expected behavior. Possibly Monad was in some sense a reaction to this, even: "we got that one wrong, let's do this one correctly".) -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From mwm at mired.org Sun Jun 29 04:15:06 2014 From: mwm at mired.org (Mike Meyer) Date: Sat, 28 Jun 2014 23:15:06 -0500 Subject: [Haskell-cafe] Monad laws In-Reply-To: References: <53AA5127.8010900@fuuzetsu.co.uk> <35C3CFD5-339E-43E2-88F4-60B896922058@cis.upenn.edu> Message-ID: On Sat, Jun 28, 2014 at 10:52 PM, Brandon Allbery wrote: > I imagine that, like Ord, a decision was made to implement the proper > mathematical abstraction and not merely a convenient one. This seems to be > the "Haskell way". (I'm not sure how it explains Double, though the numeric > hierarchy has a lot of compromises in the name of convenience or expected > behavior. Possibly Monad was in some sense a reaction to this, even: "we > got that one wrong, let's do this one correctly".) > Double, like Int, is a computer construct, not a mathematical one. They both map to hardware types that act like mathematical ones until you look closely, but have better performance than the software constructs that have better behavior. -------------- next part -------------- An HTML attachment was scrubbed... URL: From allbery.b at gmail.com Sun Jun 29 04:16:34 2014 From: allbery.b at gmail.com (Brandon Allbery) Date: Sun, 29 Jun 2014 00:16:34 -0400 Subject: [Haskell-cafe] Monad laws In-Reply-To: References: <53AA5127.8010900@fuuzetsu.co.uk> <35C3CFD5-339E-43E2-88F4-60B896922058@cis.upenn.edu> Message-ID: On Sun, Jun 29, 2014 at 12:15 AM, Mike Meyer wrote: > On Sat, Jun 28, 2014 at 10:52 PM, Brandon Allbery > wrote: > >> I imagine that, like Ord, a decision was made to implement the proper >> mathematical abstraction and not merely a convenient one. This seems to be >> the "Haskell way". (I'm not sure how it explains Double, though the numeric >> hierarchy has a lot of compromises in the name of convenience or expected >> behavior. Possibly Monad was in some sense a reaction to this, even: "we >> got that one wrong, let's do this one correctly".) >> > > Double, like Int, is a computer construct, not a mathematical one. They > both map to hardware types that act like mathematical ones until you look > closely, but have better performance than the software constructs that have > better behavior. > Sure, but that doesn't change the fact that IEEE754 NaN in particular means there is no total ordering. -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From fa-ml at ariis.it Sun Jun 29 05:05:20 2014 From: fa-ml at ariis.it (Francesco Ariis) Date: Sun, 29 Jun 2014 07:05:20 +0200 Subject: [Haskell-cafe] Implementing parental using blood type In-Reply-To: References: Message-ID: <20140629050520.GA22615@x60s.casa> On Sat, Jun 28, 2014 at 11:16:31PM -0300, Rafael Almeida wrote: > I'm trying to practice my Haskell. So I had the idea of making a program > which, given a mother's and a child blood type, it can determine whether a > certain father is possible or not. > > Please take a look on this gist with my implementation: > > https://gist.github.com/aflag/14429dfb2e89791a44e2#file-parentaltesting > > Would you care to comment on it? It looks a bit cumbersome to my eyes. I'm > trying to find the most intuitive and elegant way of do it. I'm not so much > worried with performance. Since your 'main' function returns a Bool (possible/impossible), a simpler way to approach the problem is to calculate the potential blood-type of child C given parents A and B and then check the actual blood-type passed against this list (I attach a .hs with such solution). The 'cumbersome' part is the |Genes -> BloodType| conversion (and vice-versa); you can calculate the inverse instead of typing it out, but it will still be cumbersome. -------------- next part -------------- A non-text attachment was scrubbed... Name: parentaltesting.hs Type: text/x-haskell Size: 889 bytes Desc: not available URL: From almeidaraf at gmail.com Sun Jun 29 07:15:02 2014 From: almeidaraf at gmail.com (Rafael Almeida) Date: Sun, 29 Jun 2014 04:15:02 -0300 Subject: [Haskell-cafe] Implementing parental using blood type In-Reply-To: <20140629050520.GA22615@x60s.casa> References: <20140629050520.GA22615@x60s.casa> Message-ID: Good idea. Attached is the best solution I could think of. I think it reads quite elegantly :) On Sun, Jun 29, 2014 at 2:05 AM, Francesco Ariis wrote: > On Sat, Jun 28, 2014 at 11:16:31PM -0300, Rafael Almeida wrote: > > I'm trying to practice my Haskell. So I had the idea of making a program > > which, given a mother's and a child blood type, it can determine whether > a > > certain father is possible or not. > > > > Please take a look on this gist with my implementation: > > > > > https://gist.github.com/aflag/14429dfb2e89791a44e2#file-parentaltesting > > > > Would you care to comment on it? It looks a bit cumbersome to my eyes. > I'm > > trying to find the most intuitive and elegant way of do it. I'm not so > much > > worried with performance. > > Since your 'main' function returns a Bool (possible/impossible), a simpler > way to approach the problem is to calculate the potential blood-type of > child > C given parents A and B and then check the actual blood-type passed against > this list (I attach a .hs with such solution). > > The 'cumbersome' part is the |Genes -> BloodType| conversion (and > vice-versa); > you can calculate the inverse instead of typing it out, but it will still > be > cumbersome. > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: blood.hs Type: application/octet-stream Size: 1256 bytes Desc: not available URL: From alex.solla at gmail.com Sun Jun 29 07:45:18 2014 From: alex.solla at gmail.com (Alexander Solla) Date: Sun, 29 Jun 2014 00:45:18 -0700 Subject: [Haskell-cafe] Implementing parental using blood type In-Reply-To: References: <20140629050520.GA22615@x60s.casa> Message-ID: One thing I would suggest, as far as "Haskell style", is to make even short programs like these into libraries. You don't need to write a main function to test or even run such a simple program, and if you write it as a library, you can re-use it. On Sun, Jun 29, 2014 at 12:15 AM, Rafael Almeida wrote: > Good idea. Attached is the best solution I could think of. I think it > reads quite elegantly :) > > > On Sun, Jun 29, 2014 at 2:05 AM, Francesco Ariis wrote: > >> On Sat, Jun 28, 2014 at 11:16:31PM -0300, Rafael Almeida wrote: >> > I'm trying to practice my Haskell. So I had the idea of making a program >> > which, given a mother's and a child blood type, it can determine >> whether a >> > certain father is possible or not. >> > >> > Please take a look on this gist with my implementation: >> > >> > >> https://gist.github.com/aflag/14429dfb2e89791a44e2#file-parentaltesting >> > >> > Would you care to comment on it? It looks a bit cumbersome to my eyes. >> I'm >> > trying to find the most intuitive and elegant way of do it. I'm not so >> much >> > worried with performance. >> >> Since your 'main' function returns a Bool (possible/impossible), a simpler >> way to approach the problem is to calculate the potential blood-type of >> child >> C given parents A and B and then check the actual blood-type passed >> against >> this list (I attach a .hs with such solution). >> >> The 'cumbersome' part is the |Genes -> BloodType| conversion (and >> vice-versa); >> you can calculate the inverse instead of typing it out, but it will still >> be >> cumbersome. >> >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From jwlato at gmail.com Sun Jun 29 08:08:03 2014 From: jwlato at gmail.com (John Lato) Date: Sun, 29 Jun 2014 01:08:03 -0700 Subject: [Haskell-cafe] Conceptualizing Functor vs Performance In-Reply-To: References: Message-ID: First of all, in your use case are you sure that using Data.Vector is much less efficient than one of the specialized types? It's possible that all the allocations are fused away entirely after all. Secondly, the module Data.Vector.Generic allows you to write functions that will work on all types of vectors, including unboxed and Storable-based vectors. Would it be possible to use this module to write the desired code? You'd then need to include a type annotation only once at the top level. Finally, I supposed you could get something like this by creating a class similar to Data.Vector.Generic but using closed type families. I haven't worked out the details but I think it would work. The vector would only be available for a pre-defined list of available types though. On Sat, Jun 28, 2014 at 5:37 PM, Yuri Lensky wrote: > I am having trouble consolidating a performance-based data representation > decision I would like to make against the concept of a "functor". The > question can be reduced to the following: > > Conceptually I think that Data.Vector /should/ be a functor. More > specifically, I see no CONCEPTUAL reason that it shouldn't be possible to > define some "efficient" container-like object (for example for fast Matrix > operations for unboxable numbers, but something that still works for a > symbolic variable type) that chooses to represent its data as a > Data.Vector.Unboxed if possible, but chooses some more generic structure > (perhaps a strict list or a generic Data.Vector) if that is not the case. I > haven't found such a functor, and can't seem to implement it on my own. The > point is that in theory there is no true constraint on the type of the > object being contained so it SHOULD be a Functor/Traversable/etc., the > representation simply changes to something more efficient only if possible, > and decays to a more generic type gracefully if necessary. > > Perhaps there is some type hackery that can be done with TypeFamilies? > I.E. define some container type "data C a = (ListType a) a", but I haven't > found a generic way to do this. > > Finally, I understand that "efficient" data structure can be > problem-dependent, but I have no problem defining many different such > "generic" types for different applications. The simplest example would be > something like (invalid Haskell): > > (Data.Vector.Unboxed.Vector v a) => data instance (ListType a) = v > (Data.Vector.Generic.Vector v a) => data instance (ListType a) = v > data instance (ListType a) = ([]) > > Of course implementing fmap is a whole separate issue. The point is I do > not think this is the right way/possible, but am wondering what the "true" > solution is. > > Thanks. > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok at cs.otago.ac.nz Sun Jun 29 08:51:48 2014 From: ok at cs.otago.ac.nz (ok at cs.otago.ac.nz) Date: Sun, 29 Jun 2014 20:51:48 +1200 Subject: [Haskell-cafe] HSpec vs Doctest for TDD In-Reply-To: References: <9326C827-727F-4C5F-A96B-7879A8CEB6C3@cs.otago.ac.nz> Message-ID: > On 27 June 2014 00:22, Richard A. O'Keefe wrote: > >> >> For one thing, tests can be automatically generated from a grammar. >> The first time I demonstrated this to a class of students, I said >> "now, here I've got this program that I wrote a few years ago and >> I know it works, this is just demonstrating how you can generate >> tests from a grammar." And then the very first generated test >> revealed a bug. At that point I was Enlightened. >> >> > Sure that is awesome, same kind of thing as using QuickCheck in a way... > but do you consider this as TDD? No, OF COURSE NOT. I never said it was. All I was doing is saying that generating tests from a grammar is easy, so don't ever believe "this might not be the real grammar so it would be too much wasted work testing from it." > I always seen TDD as "writing test first", where here you generate them > once you have the grammar... that feel different to me, but as said before > I'm realizing my definition was wrong. Having a GRAMMAR is one thing. Having a PARSER is another. Suppose I say "write me some tests for function f". You will say back, if you have any sense: "I cannot possibly do that until I have some idea what f is supposed to do." Not the most rabid advocate of TDD would claim that you can write tests in a knowledge vacuum. The strongest claim I've seen is that the process of constructing the specification and the process of constructing the tests can be so interwoven that they are the same activity, but even then you have to have *some* idea of what you want before you start. > But don't you think this particular step can be achieved in your head? > Maybe not for complex thing, but at least it work for me for simple > case... Everything works for simple cases. The problem is that some of the things we think are simple aren't. Programmers tend to be an optimistic lot, and we tend not to think of all the things that can go wrong. (Like someone I once worked with who used to teach students NOT to check the result of malloc() because on today's machines they would never run out of memory. I kid you not.) For example, there was one specification I implemented where there was a signed integer parameter and the original designers neither said what was supposed to happen if it was negative, nor said that it was an error or undefined or anything. I reckon they just never thought about it. Here's another one. There is a standard for a certain programming language which states that (1) the timestamp datatype uses UTC (2) timestamps can be calculated for thousands of years in the future. This requires a computer that can predict the choices of a human committee far into the future, as you discover as soon as you try to construct test cases and realise that you don't actually know what addSeconds(new TimeStamp(), 10*1000*1000) should be because your leap second table doesn't extend into the future. > Once you deliver a piece of work, it should be proven it work... Maybe > doing it earlier help, but that's more about fighting procrastination than > anything else, because I'm sure you hate as much as me writing tests ;-) You will find that most traditional books about testing (including Boris Beizer's, for example) say that the earlier a bug goes into a system, the longer it stays and the harder it is to get it out. That's not a *proof* that doing testing as early as you can will save you effort, but it's suggestive. And one thing is certain, if you think about testing early, you'll aim for a design that *can* be tested. From ok at cs.otago.ac.nz Sun Jun 29 09:28:25 2014 From: ok at cs.otago.ac.nz (ok at cs.otago.ac.nz) Date: Sun, 29 Jun 2014 21:28:25 +1200 Subject: [Haskell-cafe] Monad laws In-Reply-To: References: <53AA5127.8010900@fuuzetsu.co.uk> <35C3CFD5-339E-43E2-88F4-60B896922058@cis.upenn.edu> Message-ID: On the subject of Double and laws, I imagine it would have been possible to do the kind of thing the SML Basis Library does for equality. SML spells equality '=' and it's not defined on the floating point types, which have a *different* operator, '=='. In the same way, the Prelude could have been structured so that integers and ratios belonged to Ord but floats did not. Floats could have had operators like #< #= instead. It would have been surprising, but so is x == x being False surprising. From mwm at mired.org Sun Jun 29 09:53:03 2014 From: mwm at mired.org (Mike Meyer) Date: Sun, 29 Jun 2014 04:53:03 -0500 Subject: [Haskell-cafe] Monad laws In-Reply-To: References: <53AA5127.8010900@fuuzetsu.co.uk> <35C3CFD5-339E-43E2-88F4-60B896922058@cis.upenn.edu> Message-ID: On Sun, Jun 29, 2014 at 4:28 AM, wrote: > On the subject of Double and laws, I imagine it would have been > possible to do the kind of thing the SML Basis Library does for > equality. SML spells equality '=' and it's not defined on the > floating point types, which have a *different* operator, '=='. > If you do that, where do you stop? Not all Int's have additive inverses, and most floats have multiple things they can be added to that don't change their value. Can we call both of those +? Or do we need a name for them or two? Actually, I don't know if SML got it right or not, because I don't know what the "==" operator does. But you should *never* compare floats for equality. While there are exceptions, they are so rare that you're likely never to run into one, so just be safe, and don't do it. So if SML's "==" operator is an equality comparison, they at best got it half right. If it's some kind of programmer-controlled "fuzzy equality", well, maybe. But I think just leaving it out would be a better solution. In the same way, the Prelude could have been structured so that > integers and ratios belonged to Ord but floats did not. Floats > could have had operators like #< #= instead. It would have been > surprising, but so is x == x being False surprising. > Is x == x being false really any more surprising than x + 1 == x being true? -------------- next part -------------- An HTML attachment was scrubbed... URL: From timur.deteam at gmail.com Sun Jun 29 13:39:59 2014 From: timur.deteam at gmail.com (Timur Amirov) Date: Sun, 29 Jun 2014 15:39:59 +0200 Subject: [Haskell-cafe] Declarative database migrations Message-ID: Hello! Looking for tools to use discovered ?that I miss something like Rails database migrations in haskell. Is there a package for it (describe the whole schema and/or particular migrations)? --? Timur Amirov Berlin, Germany -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at snoyman.com Sun Jun 29 16:02:28 2014 From: michael at snoyman.com (Michael Snoyman) Date: Sun, 29 Jun 2014 19:02:28 +0300 Subject: [Haskell-cafe] Requesting maintainership: bzlib-conduit and process-conduit Message-ID: I'd like to request to be granted maintainership of two conduit-related packages: bzlib-conduit and process-conduit. Both packages are maintained by the same author. I opened up a pull request[1] on bzlib-conduit back in January, and haven't heard back yet. There's also an issue with process-conduit[2] which I'd like to address, but given the lack of response of bzlib-conduit, haven't sent a pull request yet. I also emailed the author directly five days ago regarding the bzlib-conduit pull request, and have not received a response. [1] https://github.com/tanakh/bzlib-conduit/pull/7 [2] https://github.com/tanakh/process-conduit/issues/14 -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuuzetsu at fuuzetsu.co.uk Sun Jun 29 16:12:20 2014 From: fuuzetsu at fuuzetsu.co.uk (Mateusz Kowalczyk) Date: Sun, 29 Jun 2014 18:12:20 +0200 Subject: [Haskell-cafe] Requesting maintainership: bzlib-conduit and process-conduit In-Reply-To: References: Message-ID: <53B03AE4.8090906@fuuzetsu.co.uk> On 06/29/2014 06:02 PM, Michael Snoyman wrote: > I'd like to request to be granted maintainership of two conduit-related > packages: bzlib-conduit and process-conduit. Both packages are maintained > by the same author. I opened up a pull request[1] on bzlib-conduit back in > January, and haven't heard back yet. There's also an issue with > process-conduit[2] which I'd like to address, but given the lack of > response of bzlib-conduit, haven't sent a pull request yet. > > I also emailed the author directly five days ago regarding the > bzlib-conduit pull request, and have not received a response. > > [1] https://github.com/tanakh/bzlib-conduit/pull/7 > [2] https://github.com/tanakh/process-conduit/issues/14 > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > Two things: 1. Does this not need to go on libraries@ instead? 2. I happen to know the author is an active Twitter user under the ?tanakh?. I will tweet him your e-mail but perhaps it's worth trying that method of communication too. -- Mateusz K. From tanaka.hideyuki at gmail.com Sun Jun 29 16:28:55 2014 From: tanaka.hideyuki at gmail.com (Hideyuki Tanaka) Date: Sun, 29 Jun 2014 09:28:55 -0700 (PDT) Subject: [Haskell-cafe] Requesting maintainership: bzlib-conduit and process-conduit In-Reply-To: References: Message-ID: <75ec0121-8ca0-4bd7-80d4-8cd43ba5a32a@googlegroups.com> Sorry for late reply. It is no problem to give you the maintainership. -- Hideyuki Tanaka -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at snoyman.com Sun Jun 29 16:30:06 2014 From: michael at snoyman.com (Michael Snoyman) Date: Sun, 29 Jun 2014 19:30:06 +0300 Subject: [Haskell-cafe] Requesting maintainership: bzlib-conduit and process-conduit In-Reply-To: <53B03AE4.8090906@fuuzetsu.co.uk> References: <53B03AE4.8090906@fuuzetsu.co.uk> Message-ID: Oops, you're right. I've added libraries@ to the CC list. On Sun, Jun 29, 2014 at 7:12 PM, Mateusz Kowalczyk wrote: > On 06/29/2014 06:02 PM, Michael Snoyman wrote: > > I'd like to request to be granted maintainership of two conduit-related > > packages: bzlib-conduit and process-conduit. Both packages are maintained > > by the same author. I opened up a pull request[1] on bzlib-conduit back > in > > January, and haven't heard back yet. There's also an issue with > > process-conduit[2] which I'd like to address, but given the lack of > > response of bzlib-conduit, haven't sent a pull request yet. > > > > I also emailed the author directly five days ago regarding the > > bzlib-conduit pull request, and have not received a response. > > > > [1] https://github.com/tanakh/bzlib-conduit/pull/7 > > [2] https://github.com/tanakh/process-conduit/issues/14 > > > > > > > > _______________________________________________ > > Haskell-Cafe mailing list > > Haskell-Cafe at haskell.org > > http://www.haskell.org/mailman/listinfo/haskell-cafe > > > > Two things: > > 1. Does this not need to go on libraries@ instead? > 2. I happen to know the author is an active Twitter user under the > ?tanakh?. I will tweet him your e-mail but perhaps it's worth trying > that method of communication too. > > -- > Mateusz K. > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at snoyman.com Sun Jun 29 16:30:48 2014 From: michael at snoyman.com (Michael Snoyman) Date: Sun, 29 Jun 2014 19:30:48 +0300 Subject: [Haskell-cafe] Requesting maintainership: bzlib-conduit and process-conduit In-Reply-To: <75ec0121-8ca0-4bd7-80d4-8cd43ba5a32a@googlegroups.com> References: <75ec0121-8ca0-4bd7-80d4-8cd43ba5a32a@googlegroups.com> Message-ID: Thanks! On Sun, Jun 29, 2014 at 7:28 PM, Hideyuki Tanaka wrote: > Sorry for late reply. > It is no problem to give you the maintainership. > > -- > Hideyuki Tanaka > -------------- next part -------------- An HTML attachment was scrubbed... URL: From escherdragon at gmail.com Sun Jun 29 18:42:02 2014 From: escherdragon at gmail.com (=?UTF-8?B?Sm9zw6kgQS4gUm9tZXJvIEwu?=) Date: Sun, 29 Jun 2014 20:42:02 +0200 Subject: [Haskell-cafe] Implementing parental using blood type In-Reply-To: References: Message-ID: To solve the specific problem you pose, one doesn't need to know anything about the relationship between alleles and blood types -- you don't even need to know what an allele is :-) If I didn't need to do anything else than just calculate whether a given father's blood type is 'viable', I'd rather go for something like the solution in attachment. I took advantage of this handy calculator while writing it. Cheers, On Sun, Jun 29, 2014 at 4:16 AM, Rafael Almeida wrote: > Hello, > > I'm trying to practice my Haskell. So I had the idea of making a program > which, given a mother's and a child blood type, it can determine whether a > certain father is possible or not. > > Please take a look on this gist with my implementation: > > > https://gist.github.com/aflag/14429dfb2e89791a44e2#file-parentaltesting > > Would you care to comment on it? It looks a bit cumbersome to my eyes. I'm > trying to find the most intuitive and elegant way of do it. I'm not so much > worried with performance. > > []'s > Rafael > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- Jos? A. Romero L. escherdragon at gmail.com "We who cut mere stones must always be envisioning cathedrals." (Quarry worker's creed) -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Blood.hs Type: text/x-haskell Size: 590 bytes Desc: not available URL: From fa-ml at ariis.it Sun Jun 29 19:10:35 2014 From: fa-ml at ariis.it (Francesco Ariis) Date: Sun, 29 Jun 2014 21:10:35 +0200 Subject: [Haskell-cafe] Implementing parental using blood type In-Reply-To: References: Message-ID: <20140629191035.GA31734@x60s.casa> On Sun, Jun 29, 2014 at 08:42:02PM +0200, Jos? A. Romero L. wrote: > To solve the specific problem you pose, one doesn't need to know anything > about the relationship between alleles and blood types -- you don't even > need to know what an allele is :-) Cleverly written (especially the last line of (#)! Though as it is: ?> (A # A) hangs -F From escherdragon at gmail.com Sun Jun 29 19:33:47 2014 From: escherdragon at gmail.com (=?UTF-8?B?Sm9zw6kgQS4gUm9tZXJvIEwu?=) Date: Sun, 29 Jun 2014 21:33:47 +0200 Subject: [Haskell-cafe] Implementing parental using blood type In-Reply-To: <20140629191035.GA31734@x60s.casa> References: <20140629191035.GA31734@x60s.casa> Message-ID: :-) Of course, if I were really serious about it I'd have written at least one quickCheck test, right? Fixed version in attachment. Cheers, On Sun, Jun 29, 2014 at 9:10 PM, Francesco Ariis wrote: > On Sun, Jun 29, 2014 at 08:42:02PM +0200, Jos? A. Romero L. wrote: > > To solve the specific problem you pose, one doesn't need to know anything > > about the relationship between alleles and blood types -- you don't even > > need to know what an allele is :-) > > Cleverly written (especially the last line of (#)! Though as it is: > > ?> (A # A) > > hangs > -F > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Jos? A. Romero L. escherdragon at gmail.com "We who cut mere stones must always be envisioning cathedrals." (Quarry worker's creed) -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Blood.hs Type: text/x-haskell Size: 798 bytes Desc: not available URL: From omari at smileystation.com Sun Jun 29 22:44:35 2014 From: omari at smileystation.com (Omari Norman) Date: Sun, 29 Jun 2014 18:44:35 -0400 Subject: [Haskell-cafe] Smallcheck Depth Message-ID: The docs for smallcheck, and the original paper, say that the depth is the depth of nested constructor applications. For some reason this behavior has changed in newer versions of Smallcheck and maybe someone can shed some light on why. For instance, I would think the depth of True and False is 0, as there are no nested constructors. Sure enough, in Smallcheck 0.2.1, (series 0) :: [Bool] gives [True, False]. Yet in smallcheck 1.1.1, (list 0 series) :: [Bool] gives []. Thanks. Omari -------------- next part -------------- An HTML attachment was scrubbed... URL: From alex.solla at gmail.com Sun Jun 29 23:05:29 2014 From: alex.solla at gmail.com (Alexander Solla) Date: Sun, 29 Jun 2014 16:05:29 -0700 Subject: [Haskell-cafe] Monad laws In-Reply-To: References: <53AA5127.8010900@fuuzetsu.co.uk> <35C3CFD5-339E-43E2-88F4-60B896922058@cis.upenn.edu> Message-ID: > > > Is x == x being false really any more surprising than x + 1 == x being > true? > Yes, a lot more. Equality is a symmetric relation. So "x equals x" is true for every x. A logic/language in which that is not true is unsound. x + 1 == x is just an equation. Coming up with a theory where it holds is straightforward. For example, addition followed by the "fractional part" operation, on the set [0,1]. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mwm at mired.org Sun Jun 29 23:29:16 2014 From: mwm at mired.org (Mike Meyer) Date: Sun, 29 Jun 2014 18:29:16 -0500 Subject: [Haskell-cafe] Monad laws In-Reply-To: References: <53AA5127.8010900@fuuzetsu.co.uk> <35C3CFD5-339E-43E2-88F4-60B896922058@cis.upenn.edu> Message-ID: On Sun, Jun 29, 2014 at 6:05 PM, Alexander Solla wrote: > >> Is x == x being false really any more surprising than x + 1 == x being >> true? >> > > Yes, a lot more. Equality is a symmetric relation. So "x equals x" is > true for every x. A logic/language in which that is not true is unsound. > > x + 1 == x is just an equation. Coming up with a theory where it holds is > straightforward. For example, addition followed by the "fractional part" > operation, on the set [0,1]. > Your theory is wrong. This is the same problem you run into with "x == x" being False: you create theories from assumptions about how these things behave based on your experience with abstract mathematical objects, and there are values for which those assumptions do not hold. Surprise results when you run into those cases. IEEE 754 floats under + and * are *not* ?. Or even ?. They just play them in the computer. There are simple large subsets of possible operands for which addition (and hence the other three operators) doesn't work like the mathematical realities they model. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ok at cs.otago.ac.nz Mon Jun 30 00:23:47 2014 From: ok at cs.otago.ac.nz (Richard A. O'Keefe) Date: Mon, 30 Jun 2014 12:23:47 +1200 Subject: [Haskell-cafe] Monad laws In-Reply-To: References: <53AA5127.8010900@fuuzetsu.co.uk> <35C3CFD5-339E-43E2-88F4-60B896922058@cis.upenn.edu> Message-ID: On 29/06/2014, at 9:53 PM, Mike Meyer wrote: > On Sun, Jun 29, 2014 at 4:28 AM, wrote: > On the subject of Double and laws, I imagine it would have been > possible to do the kind of thing the SML Basis Library does for > equality. SML spells equality '=' and it's not defined on the > floating point types, which have a *different* operator, '=='. > > > If you do that, where do you stop? Well, SML stopped right there. > Not all Int's have additive inverses, and most floats have multiple things they can be added to that don't change their value. Can we call both of those +? Or do we need a name for them or two? For what it's worth, O'CAML *does* have separate operators for integer addition and floating-point addition. > > Actually, I don't know if SML got it right or not, because I don't know what the "==" operator does. It's really very easy to find on the web. val == real * real -> bool val != real * real -> bool val ?= real * real -> bool [x == y] returns true if and only if neither x nor y is a NaN and x and y are equal, ignoring signs on zeros. This function is equivalent to the IEEE = operator. The second function != is equivalent to (not o op ==) and the IEEE ?<> operator. [?=] returns true if and only if either argument is a NaN or the arguments are bitwise equal, ignoring signs on zeros. It is equivalent to the IEEE ?= operator. > But you should *never* compare floats for equality. You are mistaken. > While there are exceptions, they are so rare that you're likely never to run into one, so just be safe, and don't do it. I have in fact *often* run into the so-called exceptions. Indeed, anyone using Javascript and wanting to compare two "integers" will in fact be comparing floating point numbers and they will be fully justified in doing so. > > So if SML's "==" operator is an equality comparison, they at best got it half right. It depends on what you want to call 'an equality comparison'. It is one of the comparison operators specified in the IEEE standard. There is no fuzziness or ambiguity about its semantics. They COULDN'T leave it out and claim IEEE conformance. > If it's some kind of programmer-controlled "fuzzy equality", > well, maybe. But I think just leaving it out would be a better > solution. I have seldom seen any kind of programmer-controlled "fuzzy equality" that wasn't either dangerously wrong or dangerously misapplied, and I speak as an old APLer who knows what ?CT stands for, where to find it in the standard, and why it is risky. If you leave out ==, some irritated programmer will just define fun ==(x, y) = x >= y andalso x <= y and you're back where you started. To prevent anyone doing that, you have to leave out *ALL* the floating-point comparison operators. That is not sensible. > Is x == x being false really any more surprising than x + 1 == x being true? Yes. The idea of there being a "number" x such that x + 1 == x is familiar to anyone who has ever met the extended real line. Or who knows that ?? + 1 = ??. > From roma at ro-che.info Mon Jun 30 01:37:37 2014 From: roma at ro-che.info (Roman Cheplyaka) Date: Sun, 29 Jun 2014 21:37:37 -0400 Subject: [Haskell-cafe] Smallcheck Depth In-Reply-To: References: Message-ID: <20140630013736.GA3211@sniper> * Omari Norman [2014-06-29 18:44:35-0400] > The docs for smallcheck, and the original paper, say that the depth is the > depth of nested constructor applications. > > For some reason this behavior has changed in newer versions of Smallcheck > and maybe someone can shed some light on why. For instance, I would think > the depth of True and False is 0, as there are no nested constructors. > Sure enough, in Smallcheck 0.2.1, > > (series 0) :: [Bool] > > gives [True, False]. Yet in smallcheck 1.1.1, > > (list 0 series) :: [Bool] > > gives []. No good reason (for either behavior). A general principle on how series begin would be good to have. series 0 = [] could be one such principle (but I'm not sure all the instances follow it at the moment). Roman -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: Digital signature URL: From ydl at ydl.cm Mon Jun 30 05:12:26 2014 From: ydl at ydl.cm (Yuri Lensky) Date: Mon, 30 Jun 2014 01:12:26 -0400 Subject: [Haskell-cafe] Conceptualizing Functor vs Performance In-Reply-To: References: Message-ID: My version of GHC (7.6) didn't have closed type families, but after upgrading to 7.8.2 it seems with your suggestion I can indeed get halfway to what I want (having such functionality only be available to pre-selected types is totally acceptable). I can now write import qualified Data.Vector.Storable as SV type family F a where F Double = SV.Vector F a = [] data T a = T ((F a) a) instance Functor T where ??? But I still have no idea how to implement Functor. Once again, conceptually I know that if (F a) == SV.Vector, fmap = SV.map, otherwise fmap = map, but how can I tell this to Haskell? Thanks. On Sun, Jun 29, 2014 at 4:08 AM, John Lato wrote: > First of all, in your use case are you sure that using Data.Vector is much > less efficient than one of the specialized types? It's possible that all > the allocations are fused away entirely after all. > > Secondly, the module Data.Vector.Generic allows you to write functions > that will work on all types of vectors, including unboxed and > Storable-based vectors. Would it be possible to use this module to write > the desired code? You'd then need to include a type annotation only once > at the top level. > > Finally, I supposed you could get something like this by creating a class > similar to Data.Vector.Generic but using closed type families. I haven't > worked out the details but I think it would work. The vector would only be > available for a pre-defined list of available types though. > > > On Sat, Jun 28, 2014 at 5:37 PM, Yuri Lensky wrote: > >> I am having trouble consolidating a performance-based data representation >> decision I would like to make against the concept of a "functor". The >> question can be reduced to the following: >> >> Conceptually I think that Data.Vector /should/ be a functor. More >> specifically, I see no CONCEPTUAL reason that it shouldn't be possible to >> define some "efficient" container-like object (for example for fast Matrix >> operations for unboxable numbers, but something that still works for a >> symbolic variable type) that chooses to represent its data as a >> Data.Vector.Unboxed if possible, but chooses some more generic structure >> (perhaps a strict list or a generic Data.Vector) if that is not the case. I >> haven't found such a functor, and can't seem to implement it on my own. The >> point is that in theory there is no true constraint on the type of the >> object being contained so it SHOULD be a Functor/Traversable/etc., the >> representation simply changes to something more efficient only if possible, >> and decays to a more generic type gracefully if necessary. >> >> Perhaps there is some type hackery that can be done with TypeFamilies? >> I.E. define some container type "data C a = (ListType a) a", but I haven't >> found a generic way to do this. >> >> Finally, I understand that "efficient" data structure can be >> problem-dependent, but I have no problem defining many different such >> "generic" types for different applications. The simplest example would be >> something like (invalid Haskell): >> >> (Data.Vector.Unboxed.Vector v a) => data instance (ListType a) = v >> (Data.Vector.Generic.Vector v a) => data instance (ListType a) = v >> data instance (ListType a) = ([]) >> >> Of course implementing fmap is a whole separate issue. The point is I do >> not think this is the right way/possible, but am wondering what the "true" >> solution is. >> >> Thanks. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From hoerdegen at funktional.info Mon Jun 30 07:27:20 2014 From: hoerdegen at funktional.info (=?ISO-8859-15?Q?Heinrich_H=F6rdegen?=) Date: Mon, 30 Jun 2014 09:27:20 +0200 Subject: [Haskell-cafe] Munich Haskell Meeting Message-ID: <53B11158.4020408@funktional.info> Dear all, today again is out monthly Haskell Meeting in Munich. I completly forgot inviting you! Sorry! Today at 19h30, we will meet here: http://www.max-emanuel-brauerei.de/de/Kontakt.html I will try to reserve a table for 10 to 12 persons. If the weather is fine, it will be outside. Please be early, because I cannot defend the table very long if nobody shows up! Cheers, Heinrich From alex.solla at gmail.com Mon Jun 30 07:48:35 2014 From: alex.solla at gmail.com (Alexander Solla) Date: Mon, 30 Jun 2014 00:48:35 -0700 Subject: [Haskell-cafe] Monad laws In-Reply-To: References: <53AA5127.8010900@fuuzetsu.co.uk> <35C3CFD5-339E-43E2-88F4-60B896922058@cis.upenn.edu> Message-ID: On Sun, Jun 29, 2014 at 4:29 PM, Mike Meyer wrote: > On Sun, Jun 29, 2014 at 6:05 PM, Alexander Solla > wrote: > >> >>> Is x == x being false really any more surprising than x + 1 == x being >>> true? >>> >> >> Yes, a lot more. Equality is a symmetric relation. So "x equals x" is >> true for every x. A logic/language in which that is not true is unsound. >> >> x + 1 == x is just an equation. Coming up with a theory where it holds >> is straightforward. For example, addition followed by the "fractional >> part" operation, on the set [0,1]. >> > > Your theory is wrong. This is the same problem you run into with "x == x" > being False: you create theories from assumptions about how these things > behave based on your experience with abstract mathematical objects, and > there are values for which those assumptions do not hold. Surprise results > when you run into those cases. > You can call it "wrong", but it doesn't make it so. (==) is supposed to model (witness) equality. The laws for Eq are the theory. > > IEEE 754 floats under + and * are *not* ?. Or even ?. They just play them > in the computer. There are simple large subsets of possible operands for > which addition (and hence the other three operators) doesn't work like the > mathematical realities they model. > I didn't say they are. I had not committed myself to any position about floating point numbers. They are certainly degenerate objects, similar to bottom, and do not "model" numbers. Specifically because they (floats) I think the problem here is that you're confusing the theory with the model. You are definitely misusing the terminology, and unfortunately, projecting at us for not understanding it they way you want us to. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mwm at mired.org Mon Jun 30 08:10:49 2014 From: mwm at mired.org (Mike Meyer) Date: Mon, 30 Jun 2014 03:10:49 -0500 Subject: [Haskell-cafe] Monad laws In-Reply-To: References: <53AA5127.8010900@fuuzetsu.co.uk> <35C3CFD5-339E-43E2-88F4-60B896922058@cis.upenn.edu> Message-ID: On Mon, Jun 30, 2014 at 2:48 AM, Alexander Solla wrote: > On Sun, Jun 29, 2014 at 4:29 PM, Mike Meyer wrote: > >> On Sun, Jun 29, 2014 at 6:05 PM, Alexander Solla >> wrote: >> >>> x + 1 == x is just an equation. Coming up with a theory where it >>>> holds is straightforward. For example, addition followed by the >>>> "fractional part" operation, on the set [0,1]. >>>> >>> >> Your theory is wrong. This is the same problem you run into with "x == x" >> being False: you create theories from assumptions about how these things >> behave based on your experience with abstract mathematical objects, and >> there are values for which those assumptions do not hold. Surprise results >> when you run into those cases. >> > > You can call it "wrong", but it doesn't make it so. (==) is supposed to > model (witness) equality. The laws for Eq are the theory. > That is true, but what you said was "coming up with a theory where it [the equation x == x + 1 being false] holds is straightforward. For example, addition followed by ...". Ah, I see. You're not trying to provide a theory as to why "floats" don't behave like real numbers, but a mathematical operation which includes objects that act like some "floats". True, any sufficiently sophisticated developer won't have problems with x == x + 1 being true. Then again, that's also true for x == x being false. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mle+hs at mega-nerd.com Mon Jun 30 09:21:42 2014 From: mle+hs at mega-nerd.com (Erik de Castro Lopo) Date: Mon, 30 Jun 2014 19:21:42 +1000 Subject: [Haskell-cafe] Declarative database migrations In-Reply-To: References: Message-ID: <20140630192142.b3373ff21f2de71b72ef7825@mega-nerd.com> Timur Amirov wrote: > Hello! > > Looking for tools to use discovered ?that I miss something like Rails > database migrations in haskell. > Is there a package for it (describe the whole schema and/or particular > migrations)? I haven't used Rails but Persistent does migrations quite nicely. Erik -- ---------------------------------------------------------------------- Erik de Castro Lopo http://www.mega-nerd.com/ From haskell at ibotty.net Mon Jun 30 10:46:33 2014 From: haskell at ibotty.net (Tobias Florek) Date: Mon, 30 Jun 2014 12:46:33 +0200 Subject: [Haskell-cafe] Declarative database migrations In-Reply-To: References: Message-ID: <53B14009.9080503@ibotty.net> hi, > database migrations in haskell. i strongly advise (general) you to look not lock yourself into database migration within a host language. i have yet to see a db migration scheme that supports good rollback _and_ is expressive enough. have a look into [sqitch](http://sqitch.org/) for a very good database change management system. cheers, tobias florek From chriswarbo at googlemail.com Mon Jun 30 12:08:37 2014 From: chriswarbo at googlemail.com (Chris Warburton) Date: Mon, 30 Jun 2014 13:08:37 +0100 Subject: [Haskell-cafe] Testing web-interfacing applications In-Reply-To: <53AEBCCC.7010304@fuuzetsu.co.uk> (Mateusz Kowalczyk's message of "Sat, 28 Jun 2014 15:02:04 +0200") References: <53AEBCCC.7010304@fuuzetsu.co.uk> Message-ID: <86lhselhve.fsf@gmail.com> Mateusz Kowalczyk writes: > Hi, > > Whenever I write a program which has to interface with the web > (scraping, POSTing, whatever), I never know how to properly test it. > What I have been doing up to date is fetching some pages ahead of time, > saving locally and running my parsers or whatever it is I'm coding at > the moment against that. > > The problem with this approach is that we can't test a whole lot: if we > have a crawler, how do we test it it goes to the next page properly? > Testing things like logging in and such seems close to impossible, we > can only test if we are making a good POST. > > Let's stick to a crawler example. How would you test that it follows > links? Do people set up local webservers with few dummy pages they > download? Do you just inspect that GET and POST ?look? correct? > > Assume that we don't own the sites so we can't let the program run tests > in the wild: page content might change (parser tests fail), APIs might > change (unexpected stuff back), our account might be locked (guess they > didn't like us logging in 20 times in last hour during tests) &c. > > Of course there is nothing which can prevent upstream changes but I'm > wondering how we can test the more-or-less static stuff without calling > out into the world. I'd use a "Self-Initialising Fake": http://martinfowler.com/bliki/SelfInitializingFake.html 1) Make sure you're not hard-coding the IO functions you're using, ie. use dependency injection, either via explicit parameters or via a typeclass. 2) If you wrote a typeclass or some other fancy abstraction for (1), implement it using the real HTTP procedures you want to use. 3) Write another implementation which reads canned responses from files, eg. comparing filenames to hashed requests. If no file is found, it should use the real HTTP implementation to get the data, store it in an appropriate file, then return it. Use the implementation from (2) in production (or just the raw procedures if you didn't abstract them) and use the implementation from (3) in tests. This lets you test real responses without having to rely on the network, without having to worry about hammering other people's machines, etc. Since all responses are static, it won't model dynamic server-side processing, but it sounds like you're OK with that. Note that caching won't work for randomised requests, eg. if your data is coming from QuickCheck. You can either limit your ranges to ensure more overlap, eg. using randomInt % 20 instead of randomInt, or write a custom pattern-matching/response-rewriting layer on top of the cache. For extra confidence that your tests are safe, eg. if you have some highly-randomised tests which will often miss the cache, you could also write a pure implementation based around a Data.Map, returning a canned 404 response for anything else. A simple driver function can populate the Map based on any existing cache files, assuring that the tests themselves are always pure. Cheers, Chris From lykahb at gmail.com Mon Jun 30 12:51:33 2014 From: lykahb at gmail.com (Boris Lykah) Date: Mon, 30 Jun 2014 08:51:33 -0400 Subject: [Haskell-cafe] Declarative database migrations In-Reply-To: <53B14009.9080503@ibotty.net> References: <53B14009.9080503@ibotty.net> Message-ID: Groundhog produces migrations that can be executed or stored as script. It can create schema from scratch or alter existing schema. There is support for composite keys and multiple schemas (as namespaces). On Mon, Jun 30, 2014 at 6:46 AM, Tobias Florek wrote: > hi, > > > database migrations in haskell. > > i strongly advise (general) you to look not lock yourself into database > migration within a host language. i have yet to see a db migration scheme > that supports good rollback _and_ is expressive enough. > > have a look into [sqitch](http://sqitch.org/) for a very good database > change management system. > > cheers, > tobias florek > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -- Regards, Boris -------------- next part -------------- An HTML attachment was scrubbed... URL: From adam at bergmark.nl Mon Jun 30 14:27:15 2014 From: adam at bergmark.nl (Adam Bergmark) Date: Mon, 30 Jun 2014 16:27:15 +0200 Subject: [Haskell-cafe] ANN: rest Message-ID: We at Silk are proud to announce the release of our Haskell REST framework `rest'. Please see the related blog post for more information: http://engineering.silk.co/post/90354057868/announcing-rest-a-haskell-rest-framework Cheers, Adam -------------- next part -------------- An HTML attachment was scrubbed... URL: From i.vysniauskas at gmail.com Mon Jun 30 15:09:21 2014 From: i.vysniauskas at gmail.com (=?UTF-8?Q?Ignas_Vy=C5=A1niauskas?=) Date: Mon, 30 Jun 2014 17:09:21 +0200 Subject: [Haskell-cafe] ANN: rest In-Reply-To: References: Message-ID: Oh, this looks pretty sweet! Would be great if the rest-example and its docs were also served / hosted somewhere so we could see how it feels and looks. -- Ignas From haithamgad at gmail.com Mon Jun 30 15:33:36 2014 From: haithamgad at gmail.com (Haitham Gad) Date: Mon, 30 Jun 2014 11:33:36 -0400 Subject: [Haskell-cafe] Haskell Wiki user account creation Message-ID: Hi, I read the following note at the log-in page of haskell wiki: NOTE: Automatic wiki account creation has been disabled. If you would like an account please email "nominolo" (at the email service from Google) or on the haskell-cafe mailing list. Does anyone know the exact email address I should be sending to (is it nominolo at gmail.com)? Thanks, Haitham -------------- next part -------------- An HTML attachment was scrubbed... URL: From carter.schonwald at gmail.com Mon Jun 30 15:38:54 2014 From: carter.schonwald at gmail.com (Carter Schonwald) Date: Mon, 30 Jun 2014 11:38:54 -0400 Subject: [Haskell-cafe] Haskell Wiki user account creation In-Reply-To: References: Message-ID: did you try doing that? :) On Mon, Jun 30, 2014 at 11:33 AM, Haitham Gad wrote: > Hi, > > I read the following note at the log-in page of haskell wiki: > > NOTE: Automatic wiki account creation has been disabled. If you would like > an account please email "nominolo" (at the email service from Google) or on > the haskell-cafe mailing list. > > Does anyone know the exact email address I should be sending to (is it > nominolo at gmail.com)? > > Thanks, > Haitham > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From adam at bergmark.nl Mon Jun 30 16:10:56 2014 From: adam at bergmark.nl (Adam Bergmark) Date: Mon, 30 Jun 2014 18:10:56 +0200 Subject: [Haskell-cafe] ANN: rest In-Reply-To: References: Message-ID: Thanks! We are running rest for Silk's public API, so you can see an example of generated documentation here: https://api.silk.co/ The look and feel of the docs could use a bit of work, I added a ticket for that https://github.com/silkapp/rest/issues/34 On Mon, Jun 30, 2014 at 5:09 PM, Ignas Vy?niauskas wrote: > Oh, this looks pretty sweet! > > Would be great if the rest-example and its docs were also served / > hosted somewhere so we could see how it feels and looks. > > -- > Ignas > -------------- next part -------------- An HTML attachment was scrubbed... URL: From schlepptop at henning-thielemann.de Mon Jun 30 17:31:05 2014 From: schlepptop at henning-thielemann.de (Henning Thielemann) Date: Mon, 30 Jun 2014 19:31:05 +0200 Subject: [Haskell-cafe] [Haskell] I've just published an introductory book on Haskell Data Analysis In-Reply-To: References: Message-ID: <53B19ED9.50702@henning-thielemann.de> Am 30.06.2014 19:24, schrieb Heinrich Apfelmus: > The word "blog" was hyperlinked to a blog post of mine [1] which has > absolutely nothing to do with finance or data analysis. I don't know > how, on the basis of this evidence, Packt came to the conclusion that > I would have any expertise in "Haskell financial data modelling and > predictive analysis". The blog post contains a screenshot showing Dollar and Euro amounts. FRP might be "Financial Rewarding Programming". It matches the scope of the book pretty much, doesn't it? :-) From georg+haskell at schaathun.net Mon Jun 30 18:55:02 2014 From: georg+haskell at schaathun.net (Hans Georg Schaathun) Date: Mon, 30 Jun 2014 19:55:02 +0100 Subject: [Haskell-cafe] Making new Unboxed Algebraic Types? (A Repa Problem) Message-ID: <20140630185502.GA20690@golay.schaathun.net> Hi, could someone offer som advice on handling composite types with the Repa library? I can see a /long/ way around my problem, but I wonder what is the /best/ way ... The problem is that I am trying to parallellise a probabilistic algorithm using Repa. To handle pseudo-randomness in parallel, I couple each data element with a generator state, in a tuple. The generator state is of type TFGen (tf-random package) or StdGen? (random package), neither of which is an Unbox instance. Hence, I have been using boxed repa arrays. The code does not execute in parallel, and if I understand correctly this is because of the Boxed type. There is a workaround?, but that requires an NFData instance. To make a NFData instance and work through the code to support it should be as simple as it is tedious, but it would still leave the other drawbacks of a boxed type. (In particular, I do sequential fold because the Repa fold function did not support boxed types.) I could of course rewrite the published libraries to use tuples instead of algebraic types, and benefit from the pre-made Unbox instances, but sounds messy and error-prone (as well as boring). If I have to I have to. Is there a quick and robust way to make Unbox instances from composite datatypes? Or any other advice on how to approach the matter? Both random ideas, references, and concrete solutions are welcome. [The other element of the tuple is an vector of unboxed constituent type. I am not sure how that's going to work, but I'll cross that bridge when I get there. For the time being it is the generator that stops type checking.] TIA ? Yes, I know that StdGen is statistically unsound. ? http://stackoverflow.com/questions/16097418/parallel-repa-code-doesnt-create-sparks -- :-- Hans Georg From carter.schonwald at gmail.com Mon Jun 30 19:53:55 2014 From: carter.schonwald at gmail.com (Carter Schonwald) Date: Mon, 30 Jun 2014 15:53:55 -0400 Subject: [Haskell-cafe] Making new Unboxed Algebraic Types? (A Repa Problem) In-Reply-To: <20140630185502.GA20690@golay.schaathun.net> References: <20140630185502.GA20690@golay.schaathun.net> Message-ID: boxity has nothing to do with parallelism. none :) On Mon, Jun 30, 2014 at 2:55 PM, Hans Georg Schaathun < georg+haskell at schaathun.net> wrote: > Hi, > > could someone offer som advice on handling composite types with > the Repa library? I can see a /long/ way around my problem, but > I wonder what is the /best/ way ... > > The problem is that I am trying to parallellise a probabilistic > algorithm using Repa. To handle pseudo-randomness in parallel, > I couple each data element with a generator state, in a tuple. > The generator state is of type TFGen (tf-random package) or > StdGen? (random package), neither of which is an Unbox instance. > Hence, I have been using boxed repa arrays. > > The code does not execute in parallel, and if I understand correctly > this is because of the Boxed type. There is a workaround?, but that > requires an NFData instance. > > To make a NFData instance and work through the code to support it > should be as simple as it is tedious, but it would still leave the > other drawbacks of a boxed type. (In particular, I do sequential > fold because the Repa fold function did not support boxed types.) > > I could of course rewrite the published libraries to use tuples instead > of algebraic types, and benefit from the pre-made Unbox instances, but > sounds messy and error-prone (as well as boring). If I have to I have > to. > > Is there a quick and robust way to make Unbox instances from composite > datatypes? Or any other advice on how to approach the matter? > Both random ideas, references, and concrete solutions are welcome. > > [The other element of the tuple is an vector of unboxed constituent > type. I am not sure how that's going to work, but I'll cross that > bridge when I get there. For the time being it is the generator that > stops type checking.] > > TIA > > > ? Yes, I know that StdGen is statistically unsound. > ? > http://stackoverflow.com/questions/16097418/parallel-repa-code-doesnt-create-sparks > > > -- > :-- Hans Georg > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > -------------- next part -------------- An HTML attachment was scrubbed... URL: From felipe.lessa at gmail.com Mon Jun 30 20:43:01 2014 From: felipe.lessa at gmail.com (Felipe Lessa) Date: Mon, 30 Jun 2014 17:43:01 -0300 Subject: [Haskell-cafe] ANNOUNCE: stm-containers In-Reply-To: References: Message-ID: <53B1CBD5.2050809@gmail.com> Awesome! Thanks for the nice post and for the library. It's a very important addition to the STM ecosystem that was sorely needed! Cheers, =) -- Felipe. -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 884 bytes Desc: OpenPGP digital signature URL: From georg+haskell at schaathun.net Mon Jun 30 20:43:07 2014 From: georg+haskell at schaathun.net (Hans Georg Schaathun) Date: Mon, 30 Jun 2014 21:43:07 +0100 Subject: [Haskell-cafe] Making new Unboxed Algebraic Types? (A Repa Problem) In-Reply-To: References: <20140630185502.GA20690@golay.schaathun.net> Message-ID: <20140630204307.GA31033@golay.schaathun.net> On Mon, Jun 30, 2014 at 03:53:55PM -0400, Carter Schonwald wrote: > boxity has nothing to do with parallelism. none :) No, but it may affect /when/ haskell computes a value, and if the computation is delayed until the value is requested, then --hey-- we just missed the parallel opportunity. Quite simply, Repa's computeP does not work as expected out of the box when it is applied to a boxed return type. If that amounts to ?nothing to do with? in your book, that's ok; it is still a problem which requires a solution. BTW, I thought a bit more and the solution using NFData suggested in http://stackoverflow.com/questions/16097418/parallel-repa-code-doesnt-create-sparks was easier to implement than I feared, and more importantly, it works. I don't find it entirely satisfactory though, so any hints on how to use unboxed arrays with composite constituent types are still very welcome. -- :-- Hans Georg From johnw at newartisans.com Mon Jun 30 21:46:24 2014 From: johnw at newartisans.com (John Wiegley) Date: Mon, 30 Jun 2014 16:46:24 -0500 Subject: [Haskell-cafe] ANNOUNCE: stm-containers In-Reply-To: <53B1CBD5.2050809@gmail.com> (Felipe Lessa's message of "Mon, 30 Jun 2014 17:43:01 -0300") References: <53B1CBD5.2050809@gmail.com> Message-ID: >>>>> Felipe Lessa writes: > Awesome! Thanks for the nice post and for the library. It's a very > important addition to the STM ecosystem that was sorely needed! Yes, this is truly an excellent addition. I've use dtoo many HashMaps-under-TVars thus far. John From georg+haskell at schaathun.net Mon Jun 30 22:06:37 2014 From: georg+haskell at schaathun.net (Hans Georg Schaathun) Date: Mon, 30 Jun 2014 23:06:37 +0100 Subject: [Haskell-cafe] Making new Unboxed Algebraic Types? (A Repa Problem) In-Reply-To: <5672251404164612@web14j.yandex.ru> References: <20140630185502.GA20690@golay.schaathun.net> <5672251404164612@web14j.yandex.ru> Message-ID: <20140630220637.GA4214@golay.schaathun.net> On Tue, Jul 01, 2014 at 01:43:32AM +0400, Dmitry Dzhus wrote: > This implies that the amount of generator states used in your parallel > computation is equal to data array size N. This is not the case in > general (unless the computation is split into N processes running in > parallel by the scheduler). On the contrary, commonly you would even > want to minimize the amount of generator states used (for resource > efficiency reasons). Fair point. The large number of states may be a disadvantage. > Generator states may be implicitly passed into sequential > subcomputations (scheduled by the parallel planner). This of course > calls for some hacking on Repa harness that runs the computations in > parallel (computeP). Such a solution would probably not be determinstic, and it would definitely make the output depend on the run-time environment (such as the number of threads). I am interested in the particular problem of pseudo-random, /deterministic/, parallel programs. I think the large number of generator states is necessary to achieve deterministic, parallel behaviour. If someone knows otherwise, I would be curious to learn. > Some time ago I was also struggling find a way to parallelize a > probabilistic algorithm (Monte-Carlo molecular simulation) and > eventually I settled with even simpler solution based on strategies > instead of Repa: > https://github.com/dzhus/dsmc/blob/master/src/Control/Parallel/Stochastic.hs. > It can be easily ported to any stateful mapping computation that needs > parallelization (including your PRNGs of choice). See the whole package > for usage examples. Thanks a lot for the pointer. I shall have a look. In fact I am curious to learn about strategies as well. (Contrary to low-level hacking of Repa features which I am not at all curious about :-) -- :-- Hans Georg From ben at smart-cactus.org Mon Jun 30 22:40:10 2014 From: ben at smart-cactus.org (Ben Gamari) Date: Mon, 30 Jun 2014 18:40:10 -0400 Subject: [Haskell-cafe] Making new Unboxed Algebraic Types? (A Repa Problem) In-Reply-To: <20140630185502.GA20690@golay.schaathun.net> References: <20140630185502.GA20690@golay.schaathun.net> Message-ID: <87pphqrph1.fsf@gmail.com> Hans Georg Schaathun writes: > > Is there a quick and robust way to make Unbox instances from composite > datatypes? > You will probably want to look at the vector-th-unbox package[1]. Cheers, - Ben [1] http://hackage.haskell.org/package/vector-th-unbox -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 472 bytes Desc: not available URL: From trebla at vex.net Mon Jun 30 22:43:38 2014 From: trebla at vex.net (Albert Y. C. Lai) Date: Mon, 30 Jun 2014 18:43:38 -0400 Subject: [Haskell-cafe] Monad laws In-Reply-To: References: <53AA5127.8010900@fuuzetsu.co.uk> <35C3CFD5-339E-43E2-88F4-60B896922058@cis.upenn.edu> Message-ID: <53B1E81A.8060607@vex.net> On 14-06-28 11:38 PM, Rafael Almeida wrote: > People are indeed going to expect that the < operator is transitive. > Even though the compiler can do nothing about it. I'm not sure how to > explain why we need < to be transitive. If you do so, please explain > that to me as well. I always took it for granted that such law must be > obeyed. Every sub-quadratic-time comparison-based sorting algorithm assumes that comparisons are transitive. From nominolo at googlemail.com Mon Jun 30 22:49:01 2014 From: nominolo at googlemail.com (Thomas Schilling) Date: Tue, 1 Jul 2014 00:49:01 +0200 Subject: [Haskell-cafe] Haskell Wiki user account creation In-Reply-To: References: Message-ID: Yeah, that's me. I asked on this list to set up a shared mail queue that goes into phabricator (or some other ticketing system), but I didn't get any actionable reply. On 30 June 2014 17:38, Carter Schonwald wrote: > did you try doing that? :) > > > On Mon, Jun 30, 2014 at 11:33 AM, Haitham Gad wrote: >> >> Hi, >> >> I read the following note at the log-in page of haskell wiki: >> >> NOTE: Automatic wiki account creation has been disabled. If you would like >> an account please email "nominolo" (at the email service from Google) or on >> the haskell-cafe mailing list. >> >> Does anyone know the exact email address I should be sending to (is it >> nominolo at gmail.com)? >> >> Thanks, >> Haitham >> >> _______________________________________________ >> Haskell-Cafe mailing list >> Haskell-Cafe at haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > From mail at nh2.me Mon Jun 30 23:05:49 2014 From: mail at nh2.me (=?ISO-8859-1?Q?Niklas_Hamb=FCchen?=) Date: Tue, 01 Jul 2014 00:05:49 +0100 Subject: [Haskell-cafe] Making new Unboxed Algebraic Types? (A Repa Problem) In-Reply-To: <87pphqrph1.fsf@gmail.com> References: <20140630185502.GA20690@golay.schaathun.net> <87pphqrph1.fsf@gmail.com> Message-ID: <53B1ED4D.1090507@nh2.me> vector-th-unbox describes one way to make an Unbox instance, but this StackOverflow answer goes into much more detail: http://stackoverflow.com/questions/22882228/how-to-store-a-haskell-data-type-in-an-unboxed-vector-in-continuous-memory On 30/06/14 23:40, Ben Gamari wrote: > Hans Georg Schaathun writes: > >> >> Is there a quick and robust way to make Unbox instances from composite >> datatypes? >> > You will probably want to look at the vector-th-unbox package[1]. > > Cheers, > > - Ben > > [1] http://hackage.haskell.org/package/vector-th-unbox > > > > _______________________________________________ > Haskell-Cafe mailing list > Haskell-Cafe at haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe >