Send Beginners mailing list submissions to beginners@haskell.org To subscribe or unsubscribe via the World Wide Web, visit http://www.haskell.org/mailman/listinfo/beginners or, via email, send a message with subject or body 'help' to beginners-requ...@haskell.org
You can reach the person managing the list at beginners-ow...@haskell.org When replying, please edit your Subject line so it is more specific than "Re: Contents of Beginners digest..." Today's Topics: 1. Re: Vaccum Cairo Errors (Daniel Fischer) 2. Question regarding infering the type of a function (MoC) 3. Re: Question regarding infering the type of a function (Joe Fredette) 4. Re: Question regarding infering the type of a function (Daniel Fischer) 5. Re: Question regarding infering the type of a function (MoC) 6. edit-compile-test loop (Tom Doris) 7. Re: edit-compile-test loop (Joe Fredette) 8. Re: edit-compile-test loop (Tom Doris) ---------------------------------------------------------------------- Message: 1 Date: Mon, 21 Sep 2009 16:37:04 +0200 From: Daniel Fischer <daniel.is.fisc...@web.de> Subject: Re: [Haskell-beginners] Vaccum Cairo Errors To: beginners@haskell.org Message-ID: <200909211637.04184.daniel.is.fisc...@web.de> Content-Type: text/plain; charset="iso-8859-15" Am Montag 21 September 2009 16:21:10 schrieb aditya siram: > Hi all, > I am trying out the awesome Vacuum Cairo package on GHC 6.10.3 but I am > > getting some interesting errors. The following works in GHCI: > > view [1 .. 3] > > But the following does not work in GHCI: > > let x = [1 .. 3] > > view x > > or, > > > x <- return [1 .. 3] > > view x > > For the last two I get: > context: "(:)|0" -> >>> {"1|1", <<< "(:)|2"} > ghc: ../../src/xcb_lock.c:77: _XGetXCBBuffer: Assertion `((int) ((xcb_req) > - (dpy->request)) >= 0)' failed. > Aborted > > and GHCI quits. > > Any ideas? > thanks ... > deech Probably it's that in the last two, x is given the type [Integer] by ghci (see http://www.haskell.org/haskellwiki/Monomorphism_Restriction ) while view expects an [Int]. Do let x = [1 .. 3] :: [Int] view x and x <- return ([1 .. 3] :: [Int]) view x work? ------------------------------ Message: 2 Date: Mon, 21 Sep 2009 21:47:40 +0200 From: MoC <m...@coders-haven.net> Subject: [Haskell-beginners] Question regarding infering the type of a function To: Haskell Beginners <beginners@haskell.org> Message-ID: <4ab7d85c.5050...@coders-haven.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Hi everybody, today somebody on IRC (#haskell on Freenode) jokingly submitted the following to lambdabot: > (.) (.) It turned out that (.) (.) :: (a1 -> b -> c) -> a1 -> (a -> b) -> a -> c. I got interested in why that is so, but unfortunately I have not been able to figure this out by myself yet. I know that partial application is used, but don't know to what it would expand to and why. Could someone please explain? (I asked on the channel, but nobody did answer so I thought I'd try my luck here.) Regards, MoC ------------------------------ Message: 3 Date: Mon, 21 Sep 2009 16:18:45 -0400 From: Joe Fredette <jfred...@gmail.com> Subject: Re: [Haskell-beginners] Question regarding infering the type of a function To: MoC <m...@coders-haven.net> Cc: Haskell Beginners <beginners@haskell.org> Message-ID: <f6e04b47-bb90-4c06-806b-ce35c482b...@gmail.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes The type of `(.)` is (.) :: (b->c) -> (a->b) -> a -> c it can be defined as: (.) f g x = f (g x) So, let f = (.), then we can plug that in and make it infix in the defn to get: (.) (.) g x q y = g x . q $ y I had to add a few variables there to make it pointed, as opposed to the more succint semipointfree version: (.) (.) g x = (.) g x So we can see that this function, `(.) (.)` takes four arguments, a function on 2 inputs (g, because (.) is going to feed it another one, and it's taking one already, in the form of x). One of the variables of appropriate some arbitrary type `t` (since g is the only thing that will ever see it, you can think of it as a kind of index to an indexed family of functions of type `b->c`.) giving `(.) (.)` just `x` will reduce the type to something you should recognize, that is if: foo x = something in (\ g q y -> (.) (.) g x' q y) then foo has type: foo :: (b -> c) -> (a -> b) -> a -> c eg, foo = (.) So, (.) (.) effectively says, "Given a indexed family of functions from `b -> c`, indexed by some type `t` compose the `t`th function with some function `q` from `a -> b`, and return a function of type `a -> c`. You might use it for something like mapping over a list at a given starting point, or something. HTH. /Joe On Sep 21, 2009, at 3:47 PM, MoC wrote: > Hi everybody, > > today somebody on IRC (#haskell on Freenode) jokingly submitted the > following to lambdabot: > > (.) (.) > It turned out that (.) (.) :: (a1 -> b -> c) -> a1 -> (a -> b) -> a - > > c. I got interested in why that is so, but unfortunately I have > not been able to figure this out by myself yet. I know that partial > application is used, but don't know to what it would expand to and > why. > Could someone please explain? > (I asked on the channel, but nobody did answer so I thought I'd try > my luck here.) > > Regards, > MoC > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners ------------------------------ Message: 4 Date: Mon, 21 Sep 2009 22:18:33 +0200 From: Daniel Fischer <daniel.is.fisc...@web.de> Subject: Re: [Haskell-beginners] Question regarding infering the type of a function To: beginners@haskell.org Message-ID: <200909212218.33909.daniel.is.fisc...@web.de> Content-Type: text/plain; charset="iso-8859-1" Am Montag 21 September 2009 21:47:40 schrieb MoC: > Hi everybody, > > today somebody on IRC (#haskell on Freenode) jokingly submitted the > > following to lambdabot: > > (.) (.) > > It turned out that (.) (.) :: (a1 -> b -> c) -> a1 -> (a -> b) -> a -> > c. I got interested in why that is so, but unfortunately I have not been > able to figure this out by myself yet. I know that partial application > is used, but don't know to what it would expand to and why. > Could someone please explain? > (I asked on the channel, but nobody did answer so I thought I'd try my > luck here.) And it's not futile :) The type of (.) is (forall a, b, c.) (b -> c) -> (a -> b) -> a -> c Now, to not get confused, choose different type variables for the type of the first (.) and the second, say the first has type (b -> c) -> (a -> b) -> a -> c and the second has type (v -> w) -> (u -> v) -> u -> w === (v -> w) -> ((u -> v) -> (u -> w)) Feeding it as an argument to the first, we must unify this type with the type of the first (.)'s (first) argument, (b -> c), thus b = (v -> w) c = (u -> v) -> u -> w and the type of (.) (.) becomes (a -> b) -> a -> c, which is (a -> (v -> w)) -> a -> ((u -> v) -> u -> w) by what we got for b and c. Now remove those parentheses which aren't necessary because (->) is right associative, to get (a -> v -> w) -> a -> (u -> v) -> u -> w and rename the type variables to get exactly lambdabot's answer. > > Regards, > MoC ------------------------------ Message: 5 Date: Mon, 21 Sep 2009 23:06:37 +0200 From: MoC <m...@coders-haven.net> Subject: Re: [Haskell-beginners] Question regarding infering the type of a function To: Haskell Beginners <beginners@haskell.org> Message-ID: <4ab7eadd.8030...@coders-haven.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Daniel Fischer wrote: > > (v -> w) -> (u -> v) -> u -> w === (v -> w) -> ((u -> v) -> (u -> w)) > > Feeding it as an argument to the first, we must unify this type with the type > of the first > (.)'s (first) argument, (b -> c), thus > > b = (v -> w) > c = (u -> v) -> u -> w > > and the type of (.) (.) becomes (a -> b) -> a -> c, which is > > (a -> (v -> w)) -> a -> ((u -> v) -> u -> w) > > by what we got for b and c. I started with the same approach but for whatever reason failed to see the "feeding" process so I basically said that b = (v -> w) -> ((u -> v) -> (u -> w)) which, of course, was a dead end. It's interesting that I did not have problems with acknowledging a feeding process with "simple" (for I don't know the proper term) types, e. g. it was clear to me that if I feed f :: (a->b)->c with g :: Integer -> Integer a and b in this case would be Integer in this case. I think I'm not completely used to functions being value, yet. ;) Anyway, thank you very much for helping out (actually to both replies) and in this case also for clarifying. Regards, MoC ------------------------------ Message: 6 Date: Mon, 21 Sep 2009 22:35:24 +0100 From: Tom Doris <tomdo...@gmail.com> Subject: [Haskell-beginners] edit-compile-test loop To: Haskell Beginners <beginners@haskell.org> Message-ID: <19e5d1d00909211435g1c123fb9m79b45d3736d1...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" Hi I'd like to know what the typical edit-compile-test loop looks like with the Haskell platform; that is, in C++ this would be edit, run make to compile everything in the project into libraries and executables, then run an executable test suite. I'm confused as to how people work on larger projects in Haskell - do you work on a single module and load it into ghci to test as you develop, then compile the entire package and run a test suite? Or do you generally only use ghci for prototyping and not when in the middle of proper development? Or do you compile the package and load that into ghci? I'd like to know as I'm starting to work on patches for some hackage packages which have proper cabal builds etc., and want to follow the correct (and efficient!) convention. Thanks Tom -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20090921/2f01d645/attachment-0001.html ------------------------------ Message: 7 Date: Mon, 21 Sep 2009 17:52:49 -0400 From: Joe Fredette <jfred...@gmail.com> Subject: Re: [Haskell-beginners] edit-compile-test loop To: Tom Doris <tomdo...@gmail.com> Cc: Haskell Beginners <beginners@haskell.org> Message-ID: <14acfc65-6a9c-4549-ae55-be873e202...@gmail.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Assuming I'm starting a brand-new project, it starts by creating a file in my code directory. initing darcs there, creating the .cabal file, and creating a basic module hierarchy. After that, I `touch` a couple of files. add the standard license/description/other header info... When I'm working on the code proper, I have a screen session split to a ghci session and a vim session editing the file. The ghci sits in the base directory of the projects (where the _darcs folder is) and has the files I'm working on loaded. I edit, ^a-tab to ghci, reload, flip back, fix errors, repeat till it loads. After that, I run a few tests to make sure the program does what I think it does, if not, I fix it, then back to adding new functionality. I hope this is what you wanted to know. Towards the point where I'm going to release a version, I substitute the ghci-business to a proper test harness/cabal build to make sure it compiles all correctly. /Joe On Sep 21, 2009, at 5:35 PM, Tom Doris wrote: > Hi > I'd like to know what the typical edit-compile-test loop looks like > with the Haskell platform; that is, in C++ this would be edit, run > make to compile everything in the project into libraries and > executables, then run an executable test suite. I'm confused as to > how people work on larger projects in Haskell - do you work on a > single module and load it into ghci to test as you develop, then > compile the entire package and run a test suite? Or do you generally > only use ghci for prototyping and not when in the middle of proper > development? Or do you compile the package and load that into ghci? > I'd like to know as I'm starting to work on patches for some hackage > packages which have proper cabal builds etc., and want to follow the > correct (and efficient!) convention. > Thanks > Tom > > > _______________________________________________ > Beginners mailing list > Beginners@haskell.org > http://www.haskell.org/mailman/listinfo/beginners ------------------------------ Message: 8 Date: Mon, 21 Sep 2009 23:22:33 +0100 From: Tom Doris <tomdo...@gmail.com> Subject: Re: [Haskell-beginners] edit-compile-test loop To: Joe Fredette <jfred...@gmail.com> Cc: Haskell Beginners <beginners@haskell.org> Message-ID: <19e5d1d00909211522v1a6eac25y862d1164e60c8...@mail.gmail.com> Content-Type: text/plain; charset="iso-8859-1" Thanks, this is very helpful; can you give more detail about your process once you've transitioned to a "proper test harness/cabal build", how does this usually hang together? 2009/9/21 Joe Fredette <jfred...@gmail.com> > Assuming I'm starting a brand-new project, it starts by creating a file in > my code directory. initing darcs there, creating the .cabal file, and > creating a basic module hierarchy. After that, I `touch` a couple of files. > add the standard license/description/other header info... > > When I'm working on the code proper, I have a screen session split to a > ghci session and a vim session editing the file. The ghci sits in the base > directory of the projects (where the _darcs folder is) and has the files I'm > working on loaded. I edit, ^a-tab to ghci, reload, flip back, fix errors, > repeat till it loads. After that, I run a few tests to make sure the program > does what I think it does, if not, I fix it, then back to adding new > functionality. > > I hope this is what you wanted to know. Towards the point where I'm going > to release a version, I substitute the ghci-business to a proper test > harness/cabal build to make sure it compiles all correctly. > > /Joe > > > On Sep 21, 2009, at 5:35 PM, Tom Doris wrote: > > Hi >> I'd like to know what the typical edit-compile-test loop looks like with >> the Haskell platform; that is, in C++ this would be edit, run make to >> compile everything in the project into libraries and executables, then run >> an executable test suite. I'm confused as to how people work on larger >> projects in Haskell - do you work on a single module and load it into ghci >> to test as you develop, then compile the entire package and run a test >> suite? Or do you generally only use ghci for prototyping and not when in the >> middle of proper development? Or do you compile the package and load that >> into ghci? I'd like to know as I'm starting to work on patches for some >> hackage packages which have proper cabal builds etc., and want to follow the >> correct (and efficient!) convention. >> Thanks >> Tom >> >> >> _______________________________________________ >> Beginners mailing list >> Beginners@haskell.org >> http://www.haskell.org/mailman/listinfo/beginners >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.haskell.org/pipermail/beginners/attachments/20090921/d8501178/attachment.html ------------------------------ _______________________________________________ Beginners mailing list Beginners@haskell.org http://www.haskell.org/mailman/listinfo/beginners End of Beginners Digest, Vol 15, Issue 15 *****************************************