From kaetheweber at freenet.de Mon Dec 1 15:21:49 2014 From: kaetheweber at freenet.de (Claudia Weber) Date: Mon, 01 Dec 2014 16:21:49 +0100 Subject: [Haskell-beginners] haskell Time Message-ID: Hi guys,? ? I'm ?new to Haskell and I'm just trying out some easy functions right now, but I'm having some trouble here... ? I want to display a clock ? type Time = (Int, Int) ? (hoursx,minutesy) x ={0,1,...,23} y={0,1,...,59} where I can add hours and minutes or set back time.? If its 23,58 for example and I want to add 35 minutes, the clock has to set to 0,33 not 24,23. ? Because I'm just getting started with Haskell, I have nooo idea what to do. Would be great if someone could help me out with this :) ? --- Alle Postf?cher an einem Ort. Jetzt wechseln und E-Mail-Adresse mitnehmen! Rundum gl?cklich mit freenetMail -------------- next part -------------- An HTML attachment was scrubbed... URL: From byorgey at gmail.com Mon Dec 1 16:16:17 2014 From: byorgey at gmail.com (Brent Yorgey) Date: Mon, 1 Dec 2014 11:16:17 -0500 Subject: [Haskell-beginners] haskell Time In-Reply-To: References: Message-ID: Hi Claudia, It sounds like you will find the mod and div functions helpful. div does integer division, that is, it rounds down to the nearest integer. mod gives the remainder after doing division. For example: (58 + 33) `div` 60 = 1 (58 + 33) `mod` 60 = 33 -Brent On Mon, Dec 1, 2014 at 10:21 AM, Claudia Weber wrote: > Hi guys, > > > > I'm new to Haskell and I'm just trying out some easy functions right now, > but I'm having some trouble here.. > > > > I want to display a clock > > > > type Time = (Int, Int) > > > > (hoursx,minutesy) x ={0,1,...,23} y={0,1,...,59} where I can add hours and > minutes or set back time. > > If its 23,58 for example and I want to add 35 minutes, the clock has to > set to 0,33 not 24,23. > > > > Because I'm just getting started with Haskell, I have nooo idea what to do. > > Would be great if someone could help me out with this :) > > > > > --- > Alle Postf?cher an einem Ort Jetzt wechseln und E-Mail-Adresse mitnehmen! Rundum > gl?cklich mit freenetMail > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From corentin.dupont at gmail.com Mon Dec 1 18:16:50 2014 From: corentin.dupont at gmail.com (Corentin Dupont) Date: Mon, 1 Dec 2014 19:16:50 +0100 Subject: [Haskell-beginners] haskell Time In-Reply-To: References: Message-ID: Hi Claudia, your type "Time" is good. Here is how you'd define the functions for adding hours: addHour :: Int -> Time -> Time addHour myHour (hour, minute) = ((hour + myHour) `mod` 24, minute) As can be seen in the first line, this function takes an integer where you put the number of hours to add, takes a certain Time and then returns an updated time. You can try that in GHCi: put the code in a file and load it in GHCi (you need to install Haskell platform: https://www.haskell.org/platform/). $ ghci my_file.hs Then you can play with your function by typing: $ addHour 5 (10, 0) (15, 0) If you want a real program, you need to add some I/O: import Data.Time main = do time <- getCurrentTime putStrLn (show time) You can compile this short program with: ghc my_file.hs Launch it with (or click on the generated executable under windows): $ ./my_file 2014-12-01 18:12:26.989883 UTC Tada! You have a clock. Good luck with Haskell, it's not always easy but very rewarding language. Corentin On Mon, Dec 1, 2014 at 4:21 PM, Claudia Weber wrote: > Hi guys, > > > > I'm new to Haskell and I'm just trying out some easy functions right now, > but I'm having some trouble here.. > > > > I want to display a clock > > > > type Time = (Int, Int) > > > > (hoursx,minutesy) x ={0,1,...,23} y={0,1,...,59} where I can add hours and > minutes or set back time. > > If its 23,58 for example and I want to add 35 minutes, the clock has to > set to 0,33 not 24,23. > > > > Because I'm just getting started with Haskell, I have nooo idea what to do. > > Would be great if someone could help me out with this :) > > > > > --- > Alle Postf?cher an einem Ort Jetzt wechseln und E-Mail-Adresse mitnehmen! Rundum > gl?cklich mit freenetMail > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From derek.mcloughlin at gmail.com Sun Dec 7 09:37:11 2014 From: derek.mcloughlin at gmail.com (Derek McLoughlin) Date: Sun, 7 Dec 2014 09:37:11 +0000 Subject: [Haskell-beginners] Record types with multiple constructors Message-ID: Hi, Record types usually have a single constructor. I've even seen blog posts that suggest that they must have a single constructor. However, multiple constructors are allowed: data Employee = RegularEmployee { name :: String } | Supervisor { name :: String, salesTarget :: Double } Manager { name :: String, salesTarget :: Double budget :: Double } I don't see this used much in Haskell code - either in explanatory books/tutorials or in code I've examined on GitHub. Are there drawbacks to using multiple constructors in this way? Derek. From michael at snoyman.com Sun Dec 7 09:47:33 2014 From: michael at snoyman.com (Michael Snoyman) Date: Sun, 07 Dec 2014 09:47:33 +0000 Subject: [Haskell-beginners] Record types with multiple constructors References: Message-ID: Yes: it becomes really easy to write partial/broken programs, e.g.: let myEmployee = RegularEmployee "Alice" ... supervisor = myEmployee { salesTarget = 5.4 } If you want to have both multiple constructors *and* multiple fields per constructor, I'd recommend one of the following: 1. Don't name the fields. 2. Use another type in between that has only one constructor, e.g. `data Supervisor = Supervisor { name :: String, salesTarget :: Double }`. A great example of this is the Node datatype[1] from xml-types. [1] http://www.stackage.org/haddock/2014-11-27-ghc78-exc-1/xml-types-0.3.4/Data-XML-Types.html#t:Node On Sun Dec 07 2014 at 11:37:16 AM Derek McLoughlin < derek.mcloughlin at gmail.com> wrote: > Hi, > > Record types usually have a single constructor. I've even seen blog > posts that suggest that they must have a single constructor. However, > multiple constructors are allowed: > > data Employee = RegularEmployee { > name :: String > } | > Supervisor { > name :: String, > salesTarget :: Double > } > Manager { > name :: String, > salesTarget :: Double > budget :: Double > } > > I don't see this used much in Haskell code - either in explanatory > books/tutorials or in code I've examined on GitHub. Are there > drawbacks to using multiple constructors in this way? > > Derek. > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From maydwell at gmail.com Sun Dec 7 09:52:47 2014 From: maydwell at gmail.com (Lyndon Maydwell) Date: Sun, 7 Dec 2014 20:52:47 +1100 Subject: [Haskell-beginners] Record types with multiple constructors In-Reply-To: References: Message-ID: Absolutely! Any record fields not defined for all constructors become partial. The correct way would be to have each constructor take a distinct type (if they are indeed distinct). Unfortunately this isn't nearly as succinct, but it is much safer. - Lyndon On Sun, Dec 7, 2014 at 8:37 PM, Derek McLoughlin wrote: > Hi, > > Record types usually have a single constructor. I've even seen blog > posts that suggest that they must have a single constructor. However, > multiple constructors are allowed: > > data Employee = RegularEmployee { > name :: String > } | > Supervisor { > name :: String, > salesTarget :: Double > } > Manager { > name :: String, > salesTarget :: Double > budget :: Double > } > > I don't see this used much in Haskell code - either in explanatory > books/tutorials or in code I've examined on GitHub. Are there > drawbacks to using multiple constructors in this way? > > Derek. > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zach.lists at gmail.com Sun Dec 7 16:08:01 2014 From: zach.lists at gmail.com (Zach Moazeni) Date: Sun, 7 Dec 2014 11:08:01 -0500 Subject: [Haskell-beginners] Use Lens to manipulate Data.Tree Message-ID: Hello, I'm trying to understand how I would manipulate a Data.Tree in Haskell. I came across this StackOverflow answer and accompanying blog post, but it doesn't run locally for me: * http://stackoverflow.com/a/15489761/410759 * https://www.fpcomplete.com/user/davorak/code-snippets/zipper-tree-examples Here's a gist with the code and the error I'm seeing: https://gist.github.com/zmoazeni/0049f3ab365ae600b131 I just want to start slow and be able to do three actions: * add +10 to all values in the tree * add a node to an existing node's subForest * remove a node (along with its subForest) from the tree I understand that this won't actually "edit in place" and my code would need to call a function which would return an updated version of the original tree. Finally, Lens wasn't my first choice. I was trying to understand Zippers from http://learnyouahaskell.com/zippers and my brain seized. I'm just falling back to Lens because it seems like the simplest/dsl-ish way to manipulate structures like this. Thanks for any help! -Zach -------------- next part -------------- An HTML attachment was scrubbed... URL: From zach.lists at gmail.com Sun Dec 7 19:17:33 2014 From: zach.lists at gmail.com (Zach Moazeni) Date: Sun, 7 Dec 2014 14:17:33 -0500 Subject: [Haskell-beginners] Use Lens to manipulate Data.Tree In-Reply-To: References: Message-ID: The folks in the #haskell-lens irc channel helped me out. Installing and importing http://hackage.haskell.org/package/zippers fixed my problem. Sounds like it was split out of the lens package at some point. -Zach On Sun, Dec 7, 2014 at 11:08 AM, Zach Moazeni wrote: > Hello, > > I'm trying to understand how I would manipulate a Data.Tree in Haskell. I > came across this StackOverflow answer and accompanying blog post, but it > doesn't run locally for me: > > * http://stackoverflow.com/a/15489761/410759 > * > https://www.fpcomplete.com/user/davorak/code-snippets/zipper-tree-examples > > Here's a gist with the code and the error I'm seeing: > https://gist.github.com/zmoazeni/0049f3ab365ae600b131 > > I just want to start slow and be able to do three actions: > > * add +10 to all values in the tree > * add a node to an existing node's subForest > * remove a node (along with its subForest) from the tree > > I understand that this won't actually "edit in place" and my code would > need to call a function which would return an updated version of the > original tree. > > Finally, Lens wasn't my first choice. I was trying to understand Zippers > from http://learnyouahaskell.com/zippers and my brain seized. I'm just > falling back to Lens because it seems like the simplest/dsl-ish way to > manipulate structures like this. > > Thanks for any help! > -Zach > -------------- next part -------------- An HTML attachment was scrubbed... URL: From magnus at therning.org Sun Dec 7 21:55:22 2014 From: magnus at therning.org (Magnus Therning) Date: Sun, 7 Dec 2014 22:55:22 +0100 Subject: [Haskell-beginners] Record types with multiple constructors In-Reply-To: References: Message-ID: <20141207215522.GA6812@tatooine.lan> On Sun, Dec 07, 2014 at 09:37:11AM +0000, Derek McLoughlin wrote: > Hi, > > Record types usually have a single constructor. I've even seen blog > posts that suggest that they must have a single constructor. However, > multiple constructors are allowed: > > data Employee = RegularEmployee { > name :: String > } | > Supervisor { > name :: String, > salesTarget :: Double > } > Manager { > name :: String, > salesTarget :: Double > budget :: Double > } > > I don't see this used much in Haskell code - either in explanatory > books/tutorials or in code I've examined on GitHub. Are there > drawbacks to using multiple constructors in this way? I think you might see it fairly frequently in users of command line parser libs, e.g. optparse-applicative[^1], for accepting sub-commands. /M [^1]: http://hackage.haskell.org/package/optparse-applicative -- Magnus Therning OpenPGP: 0xAB4DFBA4 email: magnus at therning.org jabber: magnus at therning.org twitter: magthe http://therning.org/magnus Perl is another example of filling a tiny, short-term need, and then being a real problem in the longer term. -- Alan Kay -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 181 bytes Desc: not available URL: From hawu.bnu at gmail.com Mon Dec 8 10:17:32 2014 From: hawu.bnu at gmail.com (jean lopes) Date: Mon, 8 Dec 2014 08:17:32 -0200 Subject: [Haskell-beginners] =?utf-8?q?Solution_to_problem_17_=2899_Haskel?= =?utf-8?b?bCBwcm9ibGVtcynigI8=?= Message-ID: Hello, I am wondering, is this solution acceptable to the question 17 ? ( https://www.haskell.org/haskellwiki/99_questions/11_to_20) code: split :: [a] -> Int -> ([a], [a]) split xs y = fst (mapAccumL (\a b -> (let f = fst a s = snd a l = length f in if l < y then (f ++ [b], s) else (f, s ++ [b]), b)) ([],[]) xs) Also, any inputs are welcome (indentation, misuse of something) Best regards, Jean Lopes -------------- next part -------------- An HTML attachment was scrubbed... URL: From info at rotnetix.com Mon Dec 8 10:34:07 2014 From: info at rotnetix.com (Riaan) Date: Mon, 8 Dec 2014 21:34:07 +1100 Subject: [Haskell-beginners] Support for PostgreSQL array types Message-ID: This is a question about database query libraries. I am trying to do some analytics on a Postgresql database and up to now have been using Database.HDBC for most of my querying. One of the columns on the database is a two dimensional float8 array. I tried using Database.PostgreSQL.Simple but got stuck on this array as I could not figure out how to extend the built in conversion functions to cater for something like this. So went back to HDBC. But now my queries are starting to get fairly long and I have been looking at libraries like Persistent with Esqualeto, HaskellDB and Groundhog to make my queries a little more composable and type safe. However I have not been able to find any examples of any of these libraries using postgres arrays and given my postgresql-simple experience I worried that I might similarly be unable, because of my low level of haskell ability, to extend the conversion functions. So to my question. Does anyone have experience with one of these libraries in dealing with postgresql arrays and could someone perhaps send me a simple example that I could use as a basis. Failing that, can anyone advise me on which of these libraries have the most haskell newbie (LYAH trained, but still struggling with RWH) friendly approach to writing new conversion functions? Thanks Riaan -------------- next part -------------- An HTML attachment was scrubbed... URL: From creichert07 at gmail.com Mon Dec 8 14:53:20 2014 From: creichert07 at gmail.com (Christopher Reichert) Date: Mon, 08 Dec 2014 08:53:20 -0600 Subject: [Haskell-beginners] =?utf-8?q?Solution_to_problem_17_=2899_Haskel?= =?utf-8?b?bCBwcm9ibGVtcynigI8=?= In-Reply-To: (jean lopes's message of "Mon, 8 Dec 2014 08:17:32 -0200") References: Message-ID: <5485bb5f.2241b60a.344e.ffffd059@mx.google.com> On Mon, Dec 08 2014, jean lopes wrote: > Hello, I am wondering, is this solution acceptable to the question 17 ? ( > https://www.haskell.org/haskellwiki/99_questions/11_to_20) > > code: > split :: [a] -> Int -> ([a], [a]) > split xs y = fst (mapAccumL (\a b -> (let f = fst a > s = snd a > l = length f > in if l < y > then (f ++ [b], s) > else (f, s ++ [b]), b)) ([],[]) xs) The example worked for me, so yes! It's a bit hard to read, though. Stylistically, I would move the the let expressions into a where block for readability. That would open up a few other pattern matching opportunities. e.g. split :: [a] -> Int -> ([a], [a]) split xs y = fst (mapAccumL go ([],[]) xs) where go (f,s) b = if length f < y then ((f ++ [b], s), b) else ((f, s ++ [b]), b) Cheers, -Christopher > > Also, any inputs are welcome (indentation, misuse of something) > > Best regards, > Jean Lopes > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners -- Christopher Reichert irc: creichert gpg: C81D 18C8 862A 3618 1376 FFA5 6BFC A992 9955 929B -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 818 bytes Desc: not available URL: From zplesiv at gmail.com Tue Dec 9 20:21:52 2014 From: zplesiv at gmail.com (=?UTF-8?Q?Zoran_Plesiv=C4=8Dak?=) Date: Tue, 9 Dec 2014 21:21:52 +0100 Subject: [Haskell-beginners] Buggy behavior of "withFile" Message-ID: I've encountered unexplainable of "withFile" function. Consider "example.hs" program: import System.IO main = do cnts <- withFile "example.hs" ReadMode $ (\h -> do res <- hGetContents h --putStr res return res) putStr cnts When commented-out line is like that, program doesn't write out anything to the STDOUT. If "--" (commend characters) are removed, program writes out contents of "example.hs" two times. Is this expected behavior? I asked on #haskell (freenode) and one fellow there found it equally confusing... ------------------------------------------- GHC version: The Glorious Glasgow Haskell Compilation System, version 7.6.3 OS: Linux Thanks, Zoran Plesiv?ak From creichert07 at gmail.com Tue Dec 9 20:34:11 2014 From: creichert07 at gmail.com (Christopher Reichert) Date: Tue, 09 Dec 2014 14:34:11 -0600 Subject: [Haskell-beginners] Buggy behavior of "withFile" In-Reply-To: ("Zoran =?utf-8?Q?Plesiv=C4=8Dak=22's?= message of "Tue, 9 Dec 2014 21:21:52 +0100") References: Message-ID: <54875cc1.4fe5ca0a.2d19.4a92@mx.google.com> On Tue, Dec 09 2014, Zoran Plesiv?ak wrote: > I've encountered unexplainable of "withFile" function. Consider > "example.hs" program: > > import System.IO > > main = do > cnts <- withFile "example.hs" ReadMode $ (\h -> do > res <- hGetContents h > --putStr res > return res) > putStr cnts > > When commented-out line is like that, program doesn't write out > anything to the STDOUT. > If "--" (commend characters) are removed, program writes out contents > of "example.hs" two times. > > Is this expected behavior? I asked on #haskell (freenode) and one > fellow there found it equally confusing... > This is an example of where Lazy IO can get tricky. withFile is closing the handle before you are able to evaluate the contents. When you use putStr in the lambda function, `res` is evaluated (and thus evaluated when it's returned). When it's commented, res is not evaluated before you close the file. See the documentation: http://hackage.haskell.org/package/base-4.7.0.1/docs/System-IO.html#v%3awithFile Specifically note: "The handle will be closed on exit from withFile" Google around for "haskell lazy io withFile" and you might find more detailed explanations. -- Christopher Reichert irc: creichert gpg: C81D 18C8 862A 3618 1376 FFA5 6BFC A992 9955 929B -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 818 bytes Desc: not available URL: From mwm at mired.org Tue Dec 9 20:36:50 2014 From: mwm at mired.org (Mike Meyer) Date: Tue, 9 Dec 2014 14:36:50 -0600 Subject: [Haskell-beginners] Buggy behavior of "withFile" In-Reply-To: References: Message-ID: On Tue, Dec 9, 2014 at 2:21 PM, Zoran Plesiv?ak wrote: > I've encountered unexplainable of "withFile" function. Consider > "example.hs" program: > > import System.IO > > main = do > cnts <- withFile "example.hs" ReadMode $ (\h -> do > res <- hGetContents h > --putStr res > return res) > putStr cnts > > When commented-out line is like that, program doesn't write out > anything to the STDOUT. > If "--" (commend characters) are removed, program writes out contents > of "example.hs" two times. > I'm not an expert, but I believe you're problem is lazy IO. hGetContents doesn't actually read the file until something consumes it. In the version with the first putStr commented out, that doesn't happen until you do the putStr outside the withFile - by which time the file handle has been closed, so nothing ever gets read. With the putStr inside the withFile, that consumes the contents before the file is closed, so it gets read and then returned, where the second putStr outputs it a second time. If I'm right, you need to force the evaluation of res before the return, with something like "res seq return res" instead of just "return res". Or use the BangPatterns extension and then write "!res <- hGetContents h" -------------- next part -------------- An HTML attachment was scrubbed... URL: From pascal.knodel at mail.com Fri Dec 12 03:14:47 2014 From: pascal.knodel at mail.com (Pascal Knodel) Date: Fri, 12 Dec 2014 04:14:47 +0100 Subject: [Haskell-beginners] exercises/examples for streams Message-ID: <548A5DA7.6000504@mail.com> Hello, I'm preparing for an exam (university level introductory course). Functional programming in Haskell is part of it. That includes the concept of streams (theoretically infinite list computations). I have difficulties in solving exercises that ask me to define streams for a given problem. Do you know good examples, the difficulty should be maybe a little harder than Fibonacci or intersections, but solvable in about 5 to 10 minutes. If there are examples from the book "Haskell - the craft of functional programming", please don't spoiler, I'm reading it parallel to this conversation. Don't give solutions, just problems (5 to 10 more will do). Examples, other than integer sequences are welcome. Pascal From ky3 at atamo.com Fri Dec 12 03:29:03 2014 From: ky3 at atamo.com (Kim-Ee Yeoh) Date: Fri, 12 Dec 2014 10:29:03 +0700 Subject: [Haskell-beginners] Buggy behavior of "withFile" In-Reply-To: <54875cc1.4fe5ca0a.2d19.4a92@mx.google.com> References: <54875cc1.4fe5ca0a.2d19.4a92@mx.google.com> Message-ID: On Wed, Dec 10, 2014 at 3:34 AM, Christopher Reichert wrote: > > Google around for "haskell lazy io withFile" and you might find more > detailed explanations. > Yes indeed. The explanations are pretty good too. This is a gotcha that deserves to be more widely known. A recent patch to ghc gives a better error message explaining what's going on. How does one go about using withFile correctly then? If you see the code "withFile filename ReadMode" chances are you should replace it with "readFile filename". Hence, instead of main = do cnts <- withFile "example.hs" ReadMode $ (\h -> do res <- hGetContents h --putStr res return res) putStr cnts write main = do cnts <- readFile "example.hs" putStr cnts or more idiomatically main = readFile "example.hs" >>= putStr -- Kim-Ee -------------- next part -------------- An HTML attachment was scrubbed... URL: From ky3 at atamo.com Fri Dec 12 08:36:32 2014 From: ky3 at atamo.com (Kim-Ee Yeoh) Date: Fri, 12 Dec 2014 15:36:32 +0700 Subject: [Haskell-beginners] Buggy behavior of "withFile" In-Reply-To: References: Message-ID: On Wed, Dec 10, 2014 at 3:36 AM, Mike Meyer wrote: > > If I'm right, you need to force the evaluation of res before the return, > with something like "res seq return res" instead of just "return res". Or > use the BangPatterns extension and then write "!res <- hGetContents h" This will read one byte (or none at all if the file is empty). That one byte will then be displayed by the putStr outside the withFile expression. It's a small but noticeable improvement to nothing being displayed at all. Why one byte? Because seq evaluates only to weak head normal form (WHNF), which in the case of a list, amounts to determining whether it's [] or (x:xs). You could write res <- hGetContents h evaluate $ length res -- Control.Exception.evaluate return res but if you're going to do that, you're better off using Strict I/O. And in fact, strict _bytestring_ I/O because the spatial footprint of lists is 10x bytestrings. But really, the default built-in lazy I/O on standard lists are fine for general usage. Avoid premature optimization. -- Kim-Ee -------------- next part -------------- An HTML attachment was scrubbed... URL: From eyeinsky9 at gmail.com Fri Dec 12 08:40:36 2014 From: eyeinsky9 at gmail.com (Carl Eyeinsky) Date: Fri, 12 Dec 2014 09:40:36 +0100 Subject: [Haskell-beginners] exercises/examples for streams In-Reply-To: <548A5DA7.6000504@mail.com> References: <548A5DA7.6000504@mail.com> Message-ID: Hi, Pascal (and hi, list!) 1. Here is one: define a function that takes two lists, both of which have elements in growing order (i.e 1,2,3,3,5,9,9,..), and outputs a list with the type of [Either a a], where a `Left a' would represent an element from the first list, a `Right a' from the second list. Make it so that the elements are in order, and also that the lefts preceede the rights. Example, the inputs of [1,1,3,7,7] and [1,2,3,5,5] would result in [Left 1, Left 1, Right 1, Right 2, Left 3, Right 3, Right 5, Right 5, Left 7, Left 7] 2. As an extension (not sure if this is too difficult for what you're looking for): write another function that takes a list-of-lists as input and outputs the result in tuples, where the first member is the index of the list (counting from zero), and the second is the value itself. Example [[1,3],[2,3],[1,3,4]] should result in [(0,1),(2,1),(1,2),(0,3),(1,3),(2,3),(2,4)] On Fri, Dec 12, 2014 at 4:14 AM, Pascal Knodel wrote: > > Hello, > > I'm preparing for an exam (university level introductory course). > Functional programming in Haskell is part of it. That includes the > concept of streams (theoretically infinite list computations). > > I have difficulties in solving exercises that ask me to define streams > for a given problem. Do you know good examples, the difficulty should > be maybe a little harder than Fibonacci or intersections, but solvable in > about 5 to 10 minutes. If there are examples from the book "Haskell - > the craft of functional programming", please don't spoiler, I'm reading > it parallel to this conversation. Don't give solutions, just problems (5 to > 10 more will do). Examples, other than integer sequences are welcome. > > Pascal > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > -- Carl Eyeinsky -------------- next part -------------- An HTML attachment was scrubbed... URL: From venuchv at gmail.com Sat Dec 13 07:44:07 2014 From: venuchv at gmail.com (Venu Chakravorty) Date: Sat, 13 Dec 2014 13:14:07 +0530 Subject: [Haskell-beginners] Doubts regarding the "read" function. Message-ID: Hello everyone, I am new to Haskell and this might seem very naive, please bear with me. ======================================= Prelude> read "4" + 4 8 Prelude> (read "4" :: Int) + 4 8 Prelude> read "hello " ++ "world" "*** Exception: Prelude.read: no parse Prelude> (read "hello" :: String) ++ " world" "*** Exception: Prelude.read: no parse ======================================= Could someone please explain why the last two statements don't work? My understanding is that "read" has a type of "read :: (Read a) => String -> a". So, "read "hello" " should give me an instance of type "Read" to which I am appending the string "world" (just like the first 2 cases where I get an instance of "Read" ("Int" in this case) to which I am adding another "Int" and I get a "Num" which is then displayed). I expected to see "hello world" as the output. Is it that the type "String" is not an instance of type class "Read"? Please tell me what I am missing here. Regards, Venu Chakravorty. From bob at redivi.com Sat Dec 13 08:03:19 2014 From: bob at redivi.com (Bob Ippolito) Date: Sat, 13 Dec 2014 00:03:19 -0800 Subject: [Haskell-beginners] Doubts regarding the "read" function. In-Reply-To: References: Message-ID: Read instances tend to be implemented such that they parse a string that looks like the source code for that type. This is usually the inverse of Show. ?> show "hello" "\"hello\"" ?> read "\"hello\"" :: String "hello" ?> read (show "hello") :: String "hello" On Fri, Dec 12, 2014 at 11:44 PM, Venu Chakravorty wrote: > Hello everyone, > > I am new to Haskell and this might seem very naive, please bear with me. > > ======================================= > Prelude> read "4" + 4 > 8 > Prelude> (read "4" :: Int) + 4 > 8 > Prelude> read "hello " ++ "world" > "*** Exception: Prelude.read: no parse > Prelude> (read "hello" :: String) ++ " world" > "*** Exception: Prelude.read: no parse > ======================================= > > Could someone please explain why the last two statements don't work? > > My understanding is that "read" has a type of "read :: (Read a) => String > -> a". > So, "read "hello" " should give me an instance of type "Read" to which I am > appending the string "world" (just like the first 2 cases where I get > an instance of > "Read" ("Int" in this case) to which I am adding another "Int" and I > get a "Num" which > is then displayed). I expected to see "hello world" as the output. > > Is it that the type "String" is not an instance of type class "Read"? > Please tell me what > I am missing here. > > Regards, > Venu Chakravorty. > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alanbuxton at gmail.com Sat Dec 13 13:54:40 2014 From: alanbuxton at gmail.com (Alan Buxton) Date: Sat, 13 Dec 2014 13:54:40 -0000 Subject: [Haskell-beginners] Deploying a haskell application (not a webapp) Message-ID: <05ee01d016dc$5a5aca20$0f105e60$@gmail.com> Hi I have created an application using cabal that now installs fine and runs fine on my dev machine. I now want to deploy this application onto a separate server. This is not a webapp. Try as I might, Google will not point me in the direction of how to do this, apart from loads of links to Keter which is not what I want (there is no nginx or any other web server involved). Any advice on the neatest way to do this? Thanks Alan -------------- next part -------------- An HTML attachment was scrubbed... URL: From creichert07 at gmail.com Sat Dec 13 14:51:41 2014 From: creichert07 at gmail.com (Christopher Reichert) Date: Sat, 13 Dec 2014 08:51:41 -0600 Subject: [Haskell-beginners] Deploying a haskell application (not a webapp) In-Reply-To: <05ee01d016dc$5a5aca20$0f105e60$@gmail.com> (Alan Buxton's message of "Sat, 13 Dec 2014 13:54:40 -0000") References: <05ee01d016dc$5a5aca20$0f105e60$@gmail.com> Message-ID: <548c5281.0f4bca0a.5ae9.25a5@mx.google.com> On Sat, Dec 13 2014, "Alan Buxton" wrote: > Hi > > > > I have created an application using cabal that now installs fine and runs > fine on my dev machine. > > > > I now want to deploy this application onto a separate server. This is not a > webapp. > So, what kind of application is it? What are your requirements? It would certainly help to know a bit more about what you are trying to do. > > Try as I might, Google will not point me in the direction of how to do this, > apart from loads of links to Keter which is not what I want (there is no > nginx or any other web server involved). > What have you tried searching for? > > > Any advice on the neatest way to do this? > It all depends. Do you want to share your app with others? Are you researching how you might deploy a Haskell app to some production scenario? GHC compiled binaries statically link haskell libraries and link against some dynamic libraries (primarily C libs). The binary can be copied between machines of the same architecture (assuming dynamically linked libraries are satisfied on the target machine). You can see runtime dependencies of your app: $ ghc --make ./Main.hs not a dynamic executable $ ldd ./Main linux-vdso.so.1 (0x00007fff201fc000) libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007fcc42fe6000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fcc42ce5000) librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007fcc42adc000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fcc428d8000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007fcc426c2000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fcc42318000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fcc420fb000) /lib64/ld-linux-x86-64.so.2 (0x00007fcc43296000) For the most simple case you can just copy your app to a target machine: $ scp ./app me at host: Regards, -- Christopher Reichert irc: creichert gpg: C81D 18C8 862A 3618 1376 FFA5 6BFC A992 9955 929B -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 818 bytes Desc: not available URL: From ky3 at atamo.com Sat Dec 13 16:49:26 2014 From: ky3 at atamo.com (Kim-Ee Yeoh) Date: Sat, 13 Dec 2014 23:49:26 +0700 Subject: [Haskell-beginners] Doubts regarding the "read" function. In-Reply-To: References: Message-ID: On Sat, Dec 13, 2014 at 2:44 PM, Venu Chakravorty wrote: > > Prelude> read "hello " ++ "world" > "*** Exception: Prelude.read: no parse > Yes, as Bob said, first take a look at: show "hello" Then redo your expression as: read (show "hello") ++ "world" -- Kim-Ee -------------- next part -------------- An HTML attachment was scrubbed... URL: From ky3 at atamo.com Sat Dec 13 16:52:43 2014 From: ky3 at atamo.com (Kim-Ee Yeoh) Date: Sat, 13 Dec 2014 23:52:43 +0700 Subject: [Haskell-beginners] Deploying a haskell application (not a webapp) In-Reply-To: <05ee01d016dc$5a5aca20$0f105e60$@gmail.com> References: <05ee01d016dc$5a5aca20$0f105e60$@gmail.com> Message-ID: On Sat, Dec 13, 2014 at 8:54 PM, Alan Buxton wrote: > > I now want to deploy this application onto a separate server. This is not > a webapp. > > > > Try as I might, Google will not point me in the direction of how to do > this, apart from loads of links to Keter which is not what I want (there is > no nginx or any other web server involved). > Looks like there are some assumptions probably based on familiarity with some other language + toolchain. Of what is the haskell analogue you're looking for? -- Kim-Ee -------------- next part -------------- An HTML attachment was scrubbed... URL: From alanbuxton at gmail.com Sat Dec 13 17:33:54 2014 From: alanbuxton at gmail.com (Alan Buxton) Date: Sat, 13 Dec 2014 17:33:54 -0000 Subject: [Haskell-beginners] Deploying a haskell application (not a webapp) In-Reply-To: References: <05ee01d016dc$5a5aca20$0f105e60$@gmail.com> Message-ID: <06c201d016fa$f83544a0$e89fcde0$@gmail.com> Hi thanks for the input so far. See attached a zipfile of a simplified version of the app. It runs locally on my dev machine and I want to be able to run it on a separate server. I don?t want to share the app with anyone else. If I do ?cabal install? with this particular application then it creates an executable at ~/.cabal/bin/app1 If I copy that file onto the target server then I get the following output: $ ./app1 fred Hi fred Time now is 2014-12-13 17:27:21.764048 UTC app1: /home/alan/.cabal/share/app1-0.1.0.0/data/file1.txt: openFile: does not exist (No such file or directory) So sort of works but in particular the file attachment piece doesn?t work. From: Beginners [mailto:beginners-bounces at haskell.org] On Behalf Of Kim-Ee Yeoh Sent: 13 December 2014 16:53 To: The Haskell-Beginners Mailing List - Discussion of primarily beginner-level topics related to Haskell Subject: Re: [Haskell-beginners] Deploying a haskell application (not a webapp) On Sat, Dec 13, 2014 at 8:54 PM, Alan Buxton wrote: I now want to deploy this application onto a separate server. This is not a webapp. Try as I might, Google will not point me in the direction of how to do this, apart from loads of links to Keter which is not what I want (there is no nginx or any other web server involved). Looks like there are some assumptions probably based on familiarity with some other language + toolchain. Of what is the haskell analogue you're looking for? -- Kim-Ee -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: app1.zip Type: application/x-zip-compressed Size: 372658 bytes Desc: not available URL: From ryan.trinkle at gmail.com Sat Dec 13 17:50:19 2014 From: ryan.trinkle at gmail.com (Ryan Trinkle) Date: Sat, 13 Dec 2014 12:50:19 -0500 Subject: [Haskell-beginners] Deploying a haskell application (not a webapp) In-Reply-To: <06c201d016fa$f83544a0$e89fcde0$@gmail.com> References: <05ee01d016dc$5a5aca20$0f105e60$@gmail.com> <06c201d016fa$f83544a0$e89fcde0$@gmail.com> Message-ID: I use Nix package manager for binary deployment of Haskell applications, and it works great. Feel free to email me directly if you're interested in the specifics. On Dec 13, 2014 12:34 PM, "Alan Buxton" wrote: > Hi thanks for the input so far. > > > > See attached a zipfile of a simplified version of the app. It runs locally > on my dev machine and I want to be able to run it on a separate server. I > don?t want to share the app with anyone else. > > > > If I do ?cabal install? with this particular application then it creates > an executable at ~/.cabal/bin/app1 > > > > If I copy that file onto the target server then I get the following output: > > > > $ ./app1 fred > > Hi fred > > Time now is 2014-12-13 17:27:21.764048 UTC > > app1: /home/alan/.cabal/share/app1-0.1.0.0/data/file1.txt: openFile: does > not exist (No such file or directory) > > > > So sort of works but in particular the file attachment piece doesn?t work. > > > > > > > > *From:* Beginners [mailto:beginners-bounces at haskell.org] *On Behalf Of *Kim-Ee > Yeoh > *Sent:* 13 December 2014 16:53 > *To:* The Haskell-Beginners Mailing List - Discussion of primarily > beginner-level topics related to Haskell > *Subject:* Re: [Haskell-beginners] Deploying a haskell application (not a > webapp) > > > > > > On Sat, Dec 13, 2014 at 8:54 PM, Alan Buxton wrote: > > I now want to deploy this application onto a separate server. This is not > a webapp. > > > > Try as I might, Google will not point me in the direction of how to do > this, apart from loads of links to Keter which is not what I want (there is > no nginx or any other web server involved). > > > > Looks like there are some assumptions probably based on familiarity with > some other language + toolchain. > > Of what is the haskell analogue you're looking for? > > > -- Kim-Ee > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From timmelzer at gmail.com Sat Dec 13 18:01:23 2014 From: timmelzer at gmail.com (Norbert Melzer) Date: Sat, 13 Dec 2014 19:01:23 +0100 Subject: [Haskell-beginners] Deploying a haskell application (not a webapp) In-Reply-To: References: <05ee01d016dc$5a5aca20$0f105e60$@gmail.com> <06c201d016fa$f83544a0$e89fcde0$@gmail.com> Message-ID: I'd think the details would be of general interest, why don't write an article/blogpost? Am 13.12.2014 18:50 schrieb "Ryan Trinkle" : > I use Nix package manager for binary deployment of Haskell applications, > and it works great. Feel free to email me directly if you're interested in > the specifics. > On Dec 13, 2014 12:34 PM, "Alan Buxton" wrote: > >> Hi thanks for the input so far. >> >> >> >> See attached a zipfile of a simplified version of the app. It runs >> locally on my dev machine and I want to be able to run it on a separate >> server. I don?t want to share the app with anyone else. >> >> >> >> If I do ?cabal install? with this particular application then it creates >> an executable at ~/.cabal/bin/app1 >> >> >> >> If I copy that file onto the target server then I get the following >> output: >> >> >> >> $ ./app1 fred >> >> Hi fred >> >> Time now is 2014-12-13 17:27:21.764048 UTC >> >> app1: /home/alan/.cabal/share/app1-0.1.0.0/data/file1.txt: openFile: does >> not exist (No such file or directory) >> >> >> >> So sort of works but in particular the file attachment piece doesn?t >> work. >> >> >> >> >> >> >> >> *From:* Beginners [mailto:beginners-bounces at haskell.org] *On Behalf Of *Kim-Ee >> Yeoh >> *Sent:* 13 December 2014 16:53 >> *To:* The Haskell-Beginners Mailing List - Discussion of primarily >> beginner-level topics related to Haskell >> *Subject:* Re: [Haskell-beginners] Deploying a haskell application (not >> a webapp) >> >> >> >> >> >> On Sat, Dec 13, 2014 at 8:54 PM, Alan Buxton >> wrote: >> >> I now want to deploy this application onto a separate server. This is not >> a webapp. >> >> >> >> Try as I might, Google will not point me in the direction of how to do >> this, apart from loads of links to Keter which is not what I want (there is >> no nginx or any other web server involved). >> >> >> >> Looks like there are some assumptions probably based on familiarity with >> some other language + toolchain. >> >> Of what is the haskell analogue you're looking for? >> >> >> -- Kim-Ee >> >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://www.haskell.org/mailman/listinfo/beginners >> >> > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From zach.lists at gmail.com Sat Dec 13 18:21:33 2014 From: zach.lists at gmail.com (Zach Moazeni) Date: Sat, 13 Dec 2014 13:21:33 -0500 Subject: [Haskell-beginners] Buggy behavior of "withFile" In-Reply-To: References: Message-ID: I ran into this issue recently for some code that needed to both read and then later write to the same file. readFile didn't work as expected because it kept the file handle open. I could restructure the code so the entire logic was in inside a `withFile` block, but I preferred not to. I wrote something similar to Zoran's original code and was stumped until I googled around. I want to share this stackoverflow answer regarding deepseq to force evaluation http://stackoverflow.com/a/9423349 (the key takeaway being `return $!! res` for Zoran's code) But really, the default built-in lazy I/O on standard lists are fine for > general usage. Avoid premature optimization. I agree with Kim here, so I'm not contradicting that sentiment. It's just nice to know the next step to take if the original lazy I/O code isn't working out. On Fri, Dec 12, 2014 at 3:36 AM, Kim-Ee Yeoh wrote: > > > On Wed, Dec 10, 2014 at 3:36 AM, Mike Meyer wrote: >> >> If I'm right, you need to force the evaluation of res before the return, >> with something like "res seq return res" instead of just "return res". Or >> use the BangPatterns extension and then write "!res <- hGetContents h" > > > This will read one byte (or none at all if the file is empty). > > That one byte will then be displayed by the putStr outside the withFile > expression. It's a small but noticeable improvement to nothing being > displayed at all. > > Why one byte? Because seq evaluates only to weak head normal form (WHNF), > which in the case of a list, amounts to determining whether it's [] or > (x:xs). > > You could write > > res <- hGetContents h > evaluate $ length res -- Control.Exception.evaluate > return res > > but if you're going to do that, you're better off using Strict I/O. And in > fact, strict _bytestring_ I/O because the spatial footprint of lists is 10x > bytestrings. > > But really, the default built-in lazy I/O on standard lists are fine for > general usage. Avoid premature optimization. > > -- Kim-Ee > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dontdieych at gmail.com Sun Dec 14 08:26:56 2014 From: dontdieych at gmail.com (Dontdie YCH) Date: Sun, 14 Dec 2014 17:26:56 +0900 Subject: [Haskell-beginners] Output of `ghc-mod check` and `runhaskell` Message-ID: Hello, My current setup for haskell. Arch Linux nix package manager - only for haskell stuff nix-shell vim syntastic + ghc-mod guard - `cabal run` on change of '*.hs' I would like to improve readability of ghc-mod's output. Compare to output of runhaskell, It's quite hard to understand. ~~~ % ghc-mod check LogAnalysis.hs LogAnalysis.hs:90:25:Couldn't match expected type ?[ghc-prim:GHC.Types.Char]? with actual type ?Log.LogMessage -> [ghc-prim:GHC.Types.Char]?In the second argument of ?(ghc-prim:GHC.Classes.==)?, namely ?upcase GHC.Base.. LogAnalysis.getMsg?In the expression: str' ghc-prim:GHC.Classes.== upcase GHC.Base.. LogAnalysis.getMsgIn the expression: str' ghc-prim:GHC.Classes.== upcase GHC.Base.. LogAnalysis.getMsg GHC.Base.$ x LogAnalysis.hs:90:17:Couldn't match expected type ?s -> t? with actual type ?ghc-prim:GHC.Types.Bool?Relevant bindings include x :: s (bound at LogAnalysis.hs:90:13) p :: s -> t (bound at LogAnalysis.hs:90:11)The first argument of ($) takes one argument,but its type ?ghc-prim:GHC.Types.Bool? has noneIn the expression: str' ghc-prim:GHC.Classes.== upcase GHC.Base.. LogAnalysis.getMsg GHC.Base.$ xIn an equation for ?p?: p x = str' ghc-prim:GHC.Classes.== upcase GHC.Base.. LogAnalysis.getMsg GHC.Base.$ x % runhaskell LogAnalysis.hs LogAnalysis.hs:90:17: Couldn't match expected type ?s -> t? with actual type ?Bool? Relevant bindings include x :: s (bound at LogAnalysis.hs:90:13) p :: s -> t (bound at LogAnalysis.hs:90:11) The first argument of ($) takes one argument, but its type ?Bool? has none In the expression: str' == upcase . getMsg $ x In an equation for ?p?: p x = str' == upcase . getMsg $ x LogAnalysis.hs:90:25: Couldn't match expected type ?[Char]? with actual type ?LogMessage -> [Char]? In the second argument of ?(==)?, namely ?upcase . getMsg? In the expression: str' == upcase . getMsg In the expression: str' == upcase . getMsg $ x ~~~ How I can do either - change ghc-mod's output like runhaskell or - use runhaskell for vim syntastic Thanks. From tjakway at nyu.edu Sun Dec 14 09:21:29 2014 From: tjakway at nyu.edu (Thomas Jakway) Date: Sun, 14 Dec 2014 04:21:29 -0500 Subject: [Haskell-beginners] Deploying a haskell application (not a webapp) In-Reply-To: References: <05ee01d016dc$5a5aca20$0f105e60$@gmail.com> <06c201d016fa$f83544a0$e89fcde0$@gmail.com> Message-ID: <548D5699.9020105@nyu.edu> I'd be interested in reading that and am sure others would be too! On 12/13/14 1:01 PM, Norbert Melzer wrote: > > I'd think the details would be of general interest, why don't write an > article/blogpost? > > Am 13.12.2014 18:50 schrieb "Ryan Trinkle" >: > > I use Nix package manager for binary deployment of Haskell > applications, and it works great. Feel free to email me directly > if you're interested in the specifics. > > On Dec 13, 2014 12:34 PM, "Alan Buxton" > wrote: > > Hi thanks for the input so far. > > See attached a zipfile of a simplified version of the app. It > runs locally on my dev machine and I want to be able to run it > on a separate server. I don?t want to share the app with > anyone else. > > If I do ?cabal install? with this particular application then > it creates an executable at ~/.cabal/bin/app1 > > If I copy that file onto the target server then I get the > following output: > > $ ./app1 fred > > Hi fred > > Time now is 2014-12-13 17:27:21.764048 UTC > > app1: /home/alan/.cabal/share/app1-0.1.0.0/data/file1.txt: > openFile: does not exist (No such file or directory) > > So sort of works but in particular the file attachment piece > doesn?t work. > > *From:*Beginners [mailto:beginners-bounces at haskell.org > ] *On Behalf Of *Kim-Ee Yeoh > *Sent:* 13 December 2014 16:53 > *To:* The Haskell-Beginners Mailing List - Discussion of > primarily beginner-level topics related to Haskell > *Subject:* Re: [Haskell-beginners] Deploying a haskell > application (not a webapp) > > On Sat, Dec 13, 2014 at 8:54 PM, Alan Buxton > > wrote: > > I now want to deploy this application onto a separate server. > This is not a webapp. > > Try as I might, Google will not point me in the direction of > how to do this, apart from loads of links to Keter which is > not what I want (there is no nginx or any other web server > involved). > > Looks like there are some assumptions probably based on > familiarity with some other language + toolchain. > > Of what is the haskell analogue you're looking for? > > > -- Kim-Ee > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners -------------- next part -------------- An HTML attachment was scrubbed... URL: From martin.drautzburg at web.de Sun Dec 14 11:15:46 2014 From: martin.drautzburg at web.de (martin) Date: Sun, 14 Dec 2014 12:15:46 +0100 Subject: [Haskell-beginners] Creating Indexes Message-ID: <548D7162.1020903@web.de> Hello all, I recently wrote a Haskell program, which accesses Lists extensivly. That was okay to verify the overall idea, but performance degraded rapidly when I made the lists bigger. There was a quadratic effect and this was not surprizing, given the nature of the code. I am somewhat aware of Haskell types which offer faster access. But they all seem to assume that I know the way data is accessed when I write the type. A new access path may force me to rededign the type. What I am looking for is something which behaves like indexes in a RDBMS, i.e. to define a list-like type on an innocent data type (like a tuple) and then add indexes as needed. Is there such a thing? From creichert07 at gmail.com Sun Dec 14 15:41:39 2014 From: creichert07 at gmail.com (Christopher Reichert) Date: Sun, 14 Dec 2014 09:41:39 -0600 Subject: [Haskell-beginners] Creating Indexes In-Reply-To: <548D7162.1020903@web.de> (martin's message of "Sun, 14 Dec 2014 12:15:46 +0100") References: <548D7162.1020903@web.de> Message-ID: <548dafb8.8680b60a.58a6.fffff780@mx.google.com> On Sun, Dec 14 2014, martin wrote: > Hello all, > > I recently wrote a Haskell program, which accesses Lists extensivly. That was okay to verify the overall idea, but > performance degraded rapidly when I made the lists bigger. There was a quadratic effect and this was not surprizing, > given the nature of the code. > Are you certain this was because of the List and not something else? If you are constantly doing lookups on lists then, indeed, performance will suffer. > I am somewhat aware of Haskell types which offer faster access. But they all seem to assume that I know the way data is > accessed when I write the type. A new access path may force me to rededign the type. > > What I am looking for is something which behaves like indexes in a RDBMS, i.e. to define a list-like type on an innocent > data type (like a tuple) and then add indexes as needed. Is there such a thing? Would an association list fit the model you are talking about? ghci> let al = [ (1, "hello"), (2, "world") ] ghci> Prelude.lookup 1 al Just "hello" ghci> Prelude.lookup 3 al Nothing You can then transform to Map (and back) easily: ghci> Data.Map.fromList al fromList [(1,"hello"),(2,"world")] ghci> Data.Map.insert 42 "foo" $ fromList al fromList [(1,"hello"),(2,"world"),(42,"foo")] See Real World Haskell (http://book.realworldhaskell.org/read/data-structures.html): -- Christopher Reichert irc: creichert gpg: C81D 18C8 862A 3618 1376 FFA5 6BFC A992 9955 929B -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 818 bytes Desc: not available URL: From ryan.trinkle at gmail.com Sun Dec 14 15:45:10 2014 From: ryan.trinkle at gmail.com (Ryan Trinkle) Date: Sun, 14 Dec 2014 10:45:10 -0500 Subject: [Haskell-beginners] Deploying a haskell application (not a webapp) In-Reply-To: <548D5699.9020105@nyu.edu> References: <05ee01d016dc$5a5aca20$0f105e60$@gmail.com> <06c201d016fa$f83544a0$e89fcde0$@gmail.com> <548D5699.9020105@nyu.edu> Message-ID: Duly noted! I didn't think an in-depth discussion of Nix would be on-topic for this mailing list, but it looks like there's more interested than I thought. When I get the chance to put something together, I'll make sure to send out a link here. On Sun, Dec 14, 2014 at 4:21 AM, Thomas Jakway wrote: > > I'd be interested in reading that and am sure others would be too! > > > On 12/13/14 1:01 PM, Norbert Melzer wrote: > > I'd think the details would be of general interest, why don't write an > article/blogpost? > Am 13.12.2014 18:50 schrieb "Ryan Trinkle" : > >> I use Nix package manager for binary deployment of Haskell applications, >> and it works great. Feel free to email me directly if you're interested in >> the specifics. >> On Dec 13, 2014 12:34 PM, "Alan Buxton" wrote: >> >>> Hi thanks for the input so far. >>> >>> >>> >>> See attached a zipfile of a simplified version of the app. It runs >>> locally on my dev machine and I want to be able to run it on a separate >>> server. I don?t want to share the app with anyone else. >>> >>> >>> >>> If I do ?cabal install? with this particular application then it creates >>> an executable at ~/.cabal/bin/app1 >>> >>> >>> >>> If I copy that file onto the target server then I get the following >>> output: >>> >>> >>> >>> $ ./app1 fred >>> >>> Hi fred >>> >>> Time now is 2014-12-13 17:27:21.764048 UTC >>> >>> app1: /home/alan/.cabal/share/app1-0.1.0.0/data/file1.txt: openFile: >>> does not exist (No such file or directory) >>> >>> >>> >>> So sort of works but in particular the file attachment piece doesn?t >>> work. >>> >>> >>> >>> >>> >>> >>> >>> *From:* Beginners [mailto:beginners-bounces at haskell.org] *On Behalf Of *Kim-Ee >>> Yeoh >>> *Sent:* 13 December 2014 16:53 >>> *To:* The Haskell-Beginners Mailing List - Discussion of primarily >>> beginner-level topics related to Haskell >>> *Subject:* Re: [Haskell-beginners] Deploying a haskell application (not >>> a webapp) >>> >>> >>> >>> >>> >>> On Sat, Dec 13, 2014 at 8:54 PM, Alan Buxton >>> wrote: >>> >>> I now want to deploy this application onto a separate server. This is >>> not a webapp. >>> >>> >>> >>> Try as I might, Google will not point me in the direction of how to do >>> this, apart from loads of links to Keter which is not what I want (there is >>> no nginx or any other web server involved). >>> >>> >>> >>> Looks like there are some assumptions probably based on familiarity with >>> some other language + toolchain. >>> >>> Of what is the haskell analogue you're looking for? >>> >>> >>> -- Kim-Ee >>> >>> _______________________________________________ >>> Beginners mailing list >>> Beginners at haskell.org >>> http://www.haskell.org/mailman/listinfo/beginners >>> >>> >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://www.haskell.org/mailman/listinfo/beginners >> >> > > _______________________________________________ > Beginners mailing listBeginners at haskell.orghttp://www.haskell.org/mailman/listinfo/beginners > > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pascal.knodel at mail.com Sun Dec 14 22:52:24 2014 From: pascal.knodel at mail.com (Pascal Knodel) Date: Sun, 14 Dec 2014 23:52:24 +0100 Subject: [Haskell-beginners] exercises/examples for streams In-Reply-To: References: <548A5DA7.6000504@mail.com> Message-ID: <548E14A8.3000300@mail.com> Hi Carl, --------------------------------------- snip --------------------------------------- module BeginnerStreams where -- 1. First try: -- Contract: Input lists are sorted. -- -- Notes: -- -- (!) Duplicate elements are allowed. -- (!) Sort `Left` before `Right`. sorts :: Ord a => [a] -> [a] -> [Either a a] sorts (l : ls) (r : rs) | l <= r = Left l : sorts ls (r : rs) | otherwise = Right r : sorts (l : ls) rs -- l > r sorts [] (r : rs) = Right r : sorts' Right rs sorts (l : ls) [] = Left l : sorts' Left ls sorts [] [] = [] sorts' e (i : is) = e i : sorts' e is sorts' _ [] = [] -- The difficulty for me was: "Either". -- I forgot about it while defining and -- did wrong in defining the empty list -- cases in my first definition: -- -- sorts ls rs = ls ++ rs -- -- That isn't possible without constructor application, -- because of the output type "[Either a a]". Is it? -- -- Wish there would be GHCi in the exam. -- Where else did I fail and didn't notice it? -- What higher order functions would you use to define "sorts"? -- 2. First try: -- I'm not sure, what do you mean by 'value itself'? -- Why is the second tuple (2,1)? Ah, I see, is it sth. like: -- -- [1,3] is index 0 and becomes (0,1), (03) -- [2,3] 1 (1,2), (1,3) -- ... -- -- And those sorted in ascending order by the sum of the components? -- Is it possible to stream this computation without blocking? -- Is the list-of-lists sorted? --------------------------------------- snip --------------------------------------- The exercises from old exams that I have solved are at: https://github.com/pascal-knodel/Programming-Paradigms-KIT-2014-2015/tree/master/3 Pascal From pascal.knodel at mail.com Mon Dec 15 01:42:09 2014 From: pascal.knodel at mail.com (Pascal Knodel) Date: Mon, 15 Dec 2014 02:42:09 +0100 Subject: [Haskell-beginners] structural induction, two lists, simultaneous Message-ID: <548E3C71.9010709@mail.com> Hi list, Proposition: map f (ys ++ zs) = map f ys ++ map f zs (Haskell, the craft of functional programming, exercise 11.31) Almost every time I'm asked to do (structural) induction over multiple 'things', in this example lists, I don't know how to do it. (I encountered similar difficulties when I worked through chapter 9, see https://github.com/pascal-knodel/haskell-craft/tree/master/Chapter%209 , ex. 9.5 , https://github.com/pascal-knodel/haskell-craft/blob/master/Chapter%209/E%279%27%275.hs). I think my proof in this case isn't formally correct. It feels like it isn't. I would like to do the example with your help, so that I feel a little bit safer. Let's start with the base case. If I have two lists, do I select one, say ys := [] . Only one or one after another? Or both 'parallel'? I could state ys ++ zs := [] too, does it help? I could imagine that the proposition could be expanded to something like map f (l1 ++ l2 ++ ... ++ lN) = map f ys ++ map f zs = map f l1 ++ map f l2 ++ ... ++ map f lN And I could imagine that it is possible to do induction over more than two lists too. What is the reason why we can do it over two 'objects' at the same time? How do I start? Can you explain this to me? Attempt: -- --------------- -- 1. Proposition: -- --------------- -- -- map f (ys ++ zs) = map f ys ++ map f zs -- -- -- Proof By Structural Induction: -- ------------------------------ -- -- -- 1. Induction Beginning (1. I.B.): -- --------------------------------- -- -- -- (Base case 1.) :<=> ys := [] -- -- => (left) := map f (ys ++ zs) -- | (Base case 1.) -- = map f ([] ++ zs) -- | ++ -- = map f zs -- -- -- (right) := map f ys ++ map f zs -- | (Base case 1.) -- = map f [] ++ map f zs -- | map -- = map f zs -- -- -- => (left) = (right) -- -- ? -- -- -- 1. Induction Hypothesis (1. I.H.): -- ---------------------------------- -- -- For an arbitrary, but fixed list "ys", the statement ... -- -- map f (ys ++ zs) = map f ys ++ map f zs -- -- ... holds. -- -- -- 1. Induction Step (1. I.S.): -- ---------------------------- -- -- -- (left) := map f ( (y : ys) ++ zs ) -- | ++ -- = map f ( y : ( ys ++ zs ) ) -- | map -- = f y : map f ( ys ++ zs ) -- | (1. I.H.) -- = f y : map f ys ++ map f zs -- | map -- = map f (y : ys) ++ map f zs -- -- -- (right) := map f (y : ys) ++ map f zs -- -- -- => (left) = (right) -- -- -- ??? (1. Proof) But in this 'proof attempt' only "ys" was considered (1. I.H.). What do I miss? Pascal From johnw at newartisans.com Mon Dec 15 05:23:44 2014 From: johnw at newartisans.com (John Wiegley) Date: Sun, 14 Dec 2014 23:23:44 -0600 Subject: [Haskell-beginners] structural induction, two lists, simultaneous In-Reply-To: <548E3C71.9010709@mail.com> (Pascal Knodel's message of "Mon, 15 Dec 2014 02:42:09 +0100") References: <548E3C71.9010709@mail.com> Message-ID: >>>>> Pascal Knodel writes: > But in this 'proof attempt' only "ys" was considered (1. I.H.). What do I > miss? You only need induction on 'ys' to proof the stated proposition. John From martin.drautzburg at web.de Mon Dec 15 06:20:04 2014 From: martin.drautzburg at web.de (martin) Date: Mon, 15 Dec 2014 07:20:04 +0100 Subject: [Haskell-beginners] Creating Indexes In-Reply-To: <548dafb8.8680b60a.58a6.fffff780@mx.google.com> References: <548D7162.1020903@web.de> <548dafb8.8680b60a.58a6.fffff780@mx.google.com> Message-ID: <548E7D94.5070502@web.de> Am 12/14/2014 04:41 PM, schrieb Christopher Reichert: > > On Sun, Dec 14 2014, martin wrote: >> Hello all, >> >> I recently wrote a Haskell program, which accesses Lists extensivly. That was okay to verify the overall idea, but >> performance degraded rapidly when I made the lists bigger. There was a quadratic effect and this was not surprizing, >> given the nature of the code. >> > > Are you certain this was because of the List and not something else? > > If you are constantly doing lookups on lists then, indeed, performance > will suffer. > >> I am somewhat aware of Haskell types which offer faster access. But they all seem to assume that I know the way data is >> accessed when I write the type. A new access path may force me to rededign the type. >> >> What I am looking for is something which behaves like indexes in a RDBMS, i.e. to define a list-like type on an innocent >> data type (like a tuple) and then add indexes as needed. Is there such a thing? > > > Would an association list fit the model you are talking about? Well I *have* an association list, however with more than one column by which I lookup rows (relationally spreaking). I know I can use Maps, but I cannot convert to a map for every lookup, because it will be more expensive than just taversing the list. I can also just use Maps all along, but this requires I settle for one key column (or a combination of columns). When the necessity arises to lookup by new criteria (other columns) I would have to redesign the map or add another map or whatever. In any case it is very different to adding an index in a RDBMS. From info at rotnetix.com Mon Dec 15 08:45:40 2014 From: info at rotnetix.com (Riaan) Date: Mon, 15 Dec 2014 19:45:40 +1100 Subject: [Haskell-beginners] Haskell type conversion for postgresql array types Message-ID: This is a question about database query libraries. I am trying to do some analytics on a Postgresql database and up to now have been using Database.HDBC for most of my querying. One of the columns on the database is a two dimensional float8 array. I tried using Database.PostgreSQL.Simple but got stuck on this array as I could not figure out how to extend the built in conversion functions to cater for something like this. So went back to HDBC. But now my queries are starting to get fairly long and I have been looking at libraries like Persistent with Esqualeto, HaskellDB and Groundhog to make my queries a little more composable and type safe. However I have not been able to find any examples of any of these libraries using postgres arrays and given my postgresql-simple experience I worried that I might similarly be unable, because of my low level of haskell ability, to extend the conversion functions. So to my question. Does anyone have experience with one of these libraries in dealing with postgresql arrays and could someone perhaps send me a simple example that I could use as a basis. Failing that, can anyone advise me on which of these libraries have the most haskell newbie (LYAH trained, but still struggling with RWH) friendly approach to writing new conversion functions? Thanks -------------- next part -------------- An HTML attachment was scrubbed... URL: From ky3 at atamo.com Mon Dec 15 10:16:10 2014 From: ky3 at atamo.com (Kim-Ee Yeoh) Date: Mon, 15 Dec 2014 17:16:10 +0700 Subject: [Haskell-beginners] Haskell type conversion for postgresql array types In-Reply-To: References: Message-ID: On Mon, Dec 15, 2014 at 3:45 PM, Riaan wrote: > > Failing that, can anyone advise me on which of these libraries have the > most haskell newbie (LYAH trained, but still struggling with RWH) friendly > approach to writing new conversion functions? You may get some responses here, and you'll find that if you ask on cafe, there are many more people with practical experience of the sort you're asking. This list was forked from cafe because there were complaints that some of the questions being asked on cafe were too simple, i.e. at the level of LYAH, e.g. monads, number type class, etc. Over time, haskell-beginners has gotten really good at such questions. YMMV for anything else. -- Kim-Ee -------------- next part -------------- An HTML attachment was scrubbed... URL: From eyeinsky9 at gmail.com Mon Dec 15 12:52:07 2014 From: eyeinsky9 at gmail.com (Carl Eyeinsky) Date: Mon, 15 Dec 2014 13:52:07 +0100 Subject: [Haskell-beginners] Creating Indexes In-Reply-To: <548E7D94.5070502@web.de> References: <548D7162.1020903@web.de> <548dafb8.8680b60a.58a6.fffff780@mx.google.com> <548E7D94.5070502@web.de> Message-ID: Hi, Martin try ixset [0]. But as you said, a simple data structure is not enough for your use case, as any "mere" data structure has some concrete performance characteristics. Something more abstract is needed. [0] http://hackage.haskell.org/package/ixset On Mon, Dec 15, 2014 at 7:20 AM, martin wrote: > > Am 12/14/2014 04:41 PM, schrieb Christopher Reichert: > > > > On Sun, Dec 14 2014, martin wrote: > >> Hello all, > >> > >> I recently wrote a Haskell program, which accesses Lists extensivly. > That was okay to verify the overall idea, but > >> performance degraded rapidly when I made the lists bigger. There was a > quadratic effect and this was not surprizing, > >> given the nature of the code. > >> > > > > Are you certain this was because of the List and not something else? > > > > If you are constantly doing lookups on lists then, indeed, performance > > will suffer. > > > >> I am somewhat aware of Haskell types which offer faster access. But > they all seem to assume that I know the way data is > >> accessed when I write the type. A new access path may force me to > rededign the type. > >> > >> What I am looking for is something which behaves like indexes in a > RDBMS, i.e. to define a list-like type on an innocent > >> data type (like a tuple) and then add indexes as needed. Is there such > a thing? > > > > > > Would an association list fit the model you are talking about? > > > Well I *have* an association list, however with more than one column by > which I lookup rows (relationally spreaking). I > know I can use Maps, but I cannot convert to a map for every lookup, > because it will be more expensive than just > taversing the list. > > I can also just use Maps all along, but this requires I settle for one key > column (or a combination of columns). When > the necessity arises to lookup by new criteria (other columns) I would > have to redesign the map or add another map or > whatever. In any case it is very different to adding an index in a RDBMS. > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > -- Carl Eyeinsky -------------- next part -------------- An HTML attachment was scrubbed... URL: From rustompmody at gmail.com Mon Dec 15 17:54:35 2014 From: rustompmody at gmail.com (Rustom Mody) Date: Mon, 15 Dec 2014 23:24:35 +0530 Subject: [Haskell-beginners] structural induction, two lists, simultaneous In-Reply-To: <548E3C71.9010709@mail.com> References: <548E3C71.9010709@mail.com> Message-ID: On Mon, Dec 15, 2014 at 7:12 AM, Pascal Knodel wrote: > > Hi list, > > > Proposition: > > map f (ys ++ zs) = map f ys ++ map f zs > > (Haskell, the craft of functional programming, exercise 11.31) > > > Almost every time I'm asked to do (structural) induction over multiple > 'things', in this example lists, I don't know how to do it. > (I encountered similar difficulties when I worked through chapter 9, see > https://github.com/pascal-knodel/haskell-craft/tree/master/Chapter%209 , > ex. 9.5 , https://github.com/pascal-knodel/haskell-craft/blob/ > master/Chapter%209/E%279%27%275.hs). > I think my proof in this case isn't formally correct. It feels like it > isn't. > > I would like to do the example with your help, so that I feel a > little bit safer. > > Let's start with the base case. If I have two lists, do I select > one, say ys := [] . Only one or one after another? Or both 'parallel'? > I could state ys ++ zs := [] too, does it help? > > I could imagine that the proposition could be expanded to something like > > map f (l1 ++ l2 ++ ... ++ lN) = map f ys ++ map f zs > = map f l1 ++ map f l2 ++ ... ++ map f lN > > And I could imagine that it is possible to do induction over more than two > lists too. > > What is the reason why we can do it over two 'objects' at the same time? > How do I start? Can you explain this to me? > > This is a right question It is somewhat a proof-version of currying What you want to prove is (? f,ys,zs ? map f (ys ++ zs) = map f ys ++ map f zs) = "reorder the variables" (? ys,f,zs ? map f (ys ++ zs) = map f ys ++ map f zs) = "(? x,y ? ...) = (?x ? (? y ? ...))" (? ys ? (? f,zs ? map f (ys ++ zs) = map f ys ++ map f zs)) And now you can see that you want a proof of a one-variable theorem Of course at this stage you might ask "Why did you choose to pull ys out and not zs (or f for that matter)?" One possible answer: Experience! Another: Recursion in definitions and induction in proofs go hand in hand. Clearly the recursion is happening on the first list. So we may expect the induction to focus there > > Attempt: > > -- --------------- > -- 1. Proposition: > -- --------------- > -- > -- map f (ys ++ zs) = map f ys ++ map f zs > -- > -- > -- Proof By Structural Induction: > -- ------------------------------ > -- > -- > -- 1. Induction Beginning (1. I.B.): > -- --------------------------------- > -- > -- > -- (Base case 1.) :<=> ys := [] > -- > -- => (left) := map f (ys ++ zs) > -- | (Base case 1.) > -- = map f ([] ++ zs) > -- | ++ > -- = map f zs > -- > -- > -- (right) := map f ys ++ map f zs > -- | (Base case 1.) > -- = map f [] ++ map f zs > -- | map > -- = map f zs > -- > -- > -- => (left) = (right) > -- > -- ? > -- > -- > -- 1. Induction Hypothesis (1. I.H.): > -- ---------------------------------- > -- > -- For an arbitrary, but fixed list "ys", the statement ... > -- > -- map f (ys ++ zs) = map f ys ++ map f zs > -- > -- ... holds. > -- > -- > -- 1. Induction Step (1. I.S.): > -- ---------------------------- > -- > -- > -- (left) := map f ( (y : ys) ++ zs ) > -- | ++ > -- = map f ( y : ( ys ++ zs ) ) > -- | map > -- = f y : map f ( ys ++ zs ) > -- | (1. I.H.) > -- = f y : map f ys ++ map f zs > -- | map > -- = map f (y : ys) ++ map f zs > -- > -- > -- (right) := map f (y : ys) ++ map f zs > -- > -- > -- => (left) = (right) > -- > -- > -- ??? (1. Proof) > > > But in this 'proof attempt' only "ys" was considered (1. I.H.). > What do I miss? > > Pascal > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > -- http://www.the-magus.in http://blog.languager.org -------------- next part -------------- An HTML attachment was scrubbed... URL: From eyeinsky9 at gmail.com Mon Dec 15 20:46:27 2014 From: eyeinsky9 at gmail.com (Carl Eyeinsky) Date: Mon, 15 Dec 2014 21:46:27 +0100 Subject: [Haskell-beginners] exercises/examples for streams In-Reply-To: <548E14A8.3000300@mail.com> References: <548A5DA7.6000504@mail.com> <548E14A8.3000300@mail.com> Message-ID: Hi Pascal, for the 2., yes, the first member of the tuple is the list index in the list-of-lists (i.e for [[1], [2,3], [4,5,6]], the 0th is [1], and 2nd is [4,5,6]). The other questions in order: * Yes the sublists themselves have ascending order elements in themselves (you can just 'map sort' if otherwise). * I think the computation is non-blocking, even if the sublists themselves are infinite. The conditions for non-blocking'ness are that (1) the sublists are in ascending oreder, and (2) the outer list is finite. I think these are enough. * The list-of-lists (=outer list) is not sorted. I presume you mean by its sub-lists' heads? The main idea (which you probably get, but to spell it out :) ) is that in previously we had Left for index 0 and Right for index 1, but now we use tuples as it fits better than using nested Either's. And on the typing of 'sorts ls rs = ls ++ rs' -- yes, its about types. There was a simila remark some moths ago in the lines of if say you have a function: f :: Either Int Integer -> Either Int String then why doesn't this work: f (Right x) = Right (show x) f left = left The trouble is the second definition where 'left' on both sides of the definition is a Left with an Int in it, but the types the lhs and rhs are different. The solution is to spell out both the input and output Left's: f (Left i) = Left i The same would go for the lists -- if you expect both of them to be empty, then 'sorts ls rs = []' would work. Happy hacking, On Sun, Dec 14, 2014 at 11:52 PM, Pascal Knodel wrote: > > Hi Carl, > > --------------------------------------- snip > --------------------------------------- > module BeginnerStreams where > > -- 1. First try: > > -- Contract: Input lists are sorted. > -- > -- Notes: > -- > -- (!) Duplicate elements are allowed. > -- (!) Sort `Left` before `Right`. > > > sorts :: Ord a => [a] -> [a] -> [Either a a] > sorts (l : ls) (r : rs) > > | l <= r = Left l : sorts ls (r : rs) > > | otherwise = Right r : sorts (l : ls) rs > -- l > r > > sorts [] (r : rs) = Right r : sorts' Right rs > sorts (l : ls) [] = Left l : sorts' Left ls > sorts [] [] = [] > > sorts' e (i : is) = e i : sorts' e is > sorts' _ [] = [] > > > -- The difficulty for me was: "Either". > -- I forgot about it while defining and > -- did wrong in defining the empty list > -- cases in my first definition: > -- > -- sorts ls rs = ls ++ rs > -- > -- That isn't possible without constructor application, > -- because of the output type "[Either a a]". Is it? > -- > -- Wish there would be GHCi in the exam. > > -- Where else did I fail and didn't notice it? > -- What higher order functions would you use to define "sorts"? > > > -- 2. First try: > > -- I'm not sure, what do you mean by 'value itself'? > -- Why is the second tuple (2,1)? Ah, I see, is it sth. like: > -- > -- [1,3] is index 0 and becomes (0,1), (03) > -- [2,3] 1 (1,2), (1,3) > -- ... > -- > -- And those sorted in ascending order by the sum of the components? > -- Is it possible to stream this computation without blocking? > -- Is the list-of-lists sorted? > --------------------------------------- snip > --------------------------------------- > > The exercises from old exams that I have solved are at: > https://github.com/pascal-knodel/Programming-Paradigms- > KIT-2014-2015/tree/master/3 > > > > Pascal > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > -- Carl Eyeinsky -------------- next part -------------- An HTML attachment was scrubbed... URL: From zach.lists at gmail.com Tue Dec 16 00:38:19 2014 From: zach.lists at gmail.com (Zach Moazeni) Date: Mon, 15 Dec 2014 19:38:19 -0500 Subject: [Haskell-beginners] Why does Haskell PVP have two values for the major version? "A.B..." and a couple other questions Message-ID: Hello, Forgive me if this is a frequently asked question, I've searched the web and can't find an answer. What is the history that led up to the PVP specifying two values as the major version? I come from other tools that primarily use http://semver.org/ (or a variant) and I'm confused in what cases I should bump "A" but not "B" (or bump "B" but not "A")? A concrete example: If I make backwards incompatible changes to a package whose latest version is 1.0.x, should the next version be 2.0.x or 1.1.x? What sorts of things should I consider for choosing 2.0 over 1.1 and vice versa? Another question, by far most packages I have encountered either lead with a 0 or a 1 for "A". Does that have some bearing on the long term stability that package users should expect in the future? Finally, if "1.0.x.." is meant to convey a level of long term support, does "B" get rarely used? Since "C" version bumps to include backwards compatible additions, and "D"+ for backwards compatible bug fixes. (I know "D" isn't technically a PVP category, I'm just relating it to the patch version of semver). Thanks for your help! -Zach -------------- next part -------------- An HTML attachment was scrubbed... URL: From zach.lists at gmail.com Tue Dec 16 00:40:27 2014 From: zach.lists at gmail.com (Zach Moazeni) Date: Mon, 15 Dec 2014 19:40:27 -0500 Subject: [Haskell-beginners] Why does Haskell PVP have two values for the major version? "A.B..." and a couple other questions In-Reply-To: References: Message-ID: Oh! I sent this to the Beginner list because it feels Beginner-ish (at least to me, who might be missing something obvious). But if this is more appropriate for Cafe, someone please let me know and I'll email that list instead. On Mon, Dec 15, 2014 at 7:38 PM, Zach Moazeni wrote: > > Hello, > > Forgive me if this is a frequently asked question, I've searched the web > and can't find an answer. > > What is the history that led up to the PVP > > specifying two values as the major version? > > I come from other tools that primarily use http://semver.org/ (or a > variant) and I'm confused in what cases I should bump "A" but not "B" (or > bump "B" but not "A")? > > A concrete example: If I make backwards incompatible changes to a package > whose latest version is 1.0.x, should the next version be 2.0.x or 1.1.x? > What sorts of things should I consider for choosing 2.0 over 1.1 and vice > versa? > > > Another question, by far most packages I have encountered either lead with > a 0 or a 1 for "A". Does that have some bearing on the long term stability > that package users should expect in the future? > > Finally, if "1.0.x.." is meant to convey a level of long term support, > does "B" get rarely used? Since "C" version bumps to include backwards > compatible additions, and "D"+ for backwards compatible bug fixes. (I know > "D" isn't technically a PVP category, I'm just relating it to the patch > version of semver). > > Thanks for your help! > -Zach > -------------- next part -------------- An HTML attachment was scrubbed... URL: From creichert07 at gmail.com Tue Dec 16 01:30:56 2014 From: creichert07 at gmail.com (Christopher Reichert) Date: Mon, 15 Dec 2014 19:30:56 -0600 Subject: [Haskell-beginners] Why does Haskell PVP have two values for the major version? "A.B..." and a couple other questions In-Reply-To: (Zach Moazeni's message of "Mon, 15 Dec 2014 19:40:27 -0500") References: Message-ID: <548f8b5d.6bb33c0a.53d8.ffffa0b9@mx.google.com> I don't think this question is off-topic but you will probably get more feedback on Haskell Cafe. As a matter of fact there is a discussion regarding the PVP ongoing now: https://groups.google.com/forum/#!topic/haskell-cafe/X2-X3ohWAgI Hope that helps, -Christopher On Mon, Dec 15 2014, Zach Moazeni wrote: > Oh! I sent this to the Beginner list because it feels Beginner-ish (at > least to me, who might be missing something obvious). But if this is more > appropriate for Cafe, someone please let me know and I'll email that list > instead. > > On Mon, Dec 15, 2014 at 7:38 PM, Zach Moazeni wrote: >> >> Hello, >> >> Forgive me if this is a frequently asked question, I've searched the web >> and can't find an answer. >> >> What is the history that led up to the PVP >> >> specifying two values as the major version? >> >> I come from other tools that primarily use http://semver.org/ (or a >> variant) and I'm confused in what cases I should bump "A" but not "B" (or >> bump "B" but not "A")? >> >> A concrete example: If I make backwards incompatible changes to a package >> whose latest version is 1.0.x, should the next version be 2.0.x or 1.1.x? >> What sorts of things should I consider for choosing 2.0 over 1.1 and vice >> versa? >> >> >> Another question, by far most packages I have encountered either lead with >> a 0 or a 1 for "A". Does that have some bearing on the long term stability >> that package users should expect in the future? >> >> Finally, if "1.0.x.." is meant to convey a level of long term support, >> does "B" get rarely used? Since "C" version bumps to include backwards >> compatible additions, and "D"+ for backwards compatible bug fixes. (I know >> "D" isn't technically a PVP category, I'm just relating it to the patch >> version of semver). >> >> Thanks for your help! >> -Zach >> > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners -- Christopher Reichert irc: creichert gpg: C81D 18C8 862A 3618 1376 FFA5 6BFC A992 9955 929B -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 818 bytes Desc: not available URL: From ram at rkrishnan.org Tue Dec 16 08:12:36 2014 From: ram at rkrishnan.org (Ramakrishnan Muthukrishnan) Date: Tue, 16 Dec 2014 13:42:36 +0530 Subject: [Haskell-beginners] Deploying a haskell application (not a webapp) In-Reply-To: <05ee01d016dc$5a5aca20$0f105e60$@gmail.com> References: <05ee01d016dc$5a5aca20$0f105e60$@gmail.com> Message-ID: <1418717556.611560.203413033.364969E1@webmail.messagingengine.com> On Sat, Dec 13, 2014, at 07:24 PM, Alan Buxton wrote: > Hi > > I have created an application using cabal that now installs fine and > runs fine on my dev machine. > > I now want to deploy this application onto a separate server. This is > not a webapp. > > Try as I might, Google will not point me in the direction of how to do > this, apart from loads of links to Keter which is not what I want > (there is no nginx or any other web server involved). > > Any advice on the neatest way to do this? Hi, Can't you build a static binary and deploy it? (something like this -- http://stackoverflow.com/questions/5953199/create-a-static-haskell-linux-executable) Ramakrishnan http://rkrishnan.org/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From alanbuxton at gmail.com Tue Dec 16 13:47:42 2014 From: alanbuxton at gmail.com (Alan Buxton) Date: Tue, 16 Dec 2014 13:47:42 -0000 Subject: [Haskell-beginners] Deploying a haskell application (not a webapp) In-Reply-To: <1418717556.611560.203413033.364969E1@webmail.messagingengine.com> References: <05ee01d016dc$5a5aca20$0f105e60$@gmail.com> <1418717556.611560.203413033.364969E1@webmail.messagingengine.com> Message-ID: <024201d01936$dea97400$9bfc5c00$@gmail.com> Hiya It turned out that my issue was to do with the data files. When compiling locally, cabal puts the files in /home/alan/.cabal/share and the compiled application expects to find the files there. So when I deploy my binary I have to also put some files into /home/alan/.cabal/share which feels wrong. Alternatives to me seemed to be to set up cabal on my dev pc to install globally rather than user-based, but that also feels a bit wrong. Sandboxes looks like they might be useful but I've been having all kinds of problems with getting vmware tools installed on a sufficiently new version of Ubuntu to get a more up to cabal. So I guess the real question behind the question is .. how best to set up your dev environment when developing in Haskell so you don't end up with problems like this one where you have data files compiled into some obscure place. Alan From: Beginners [mailto:beginners-bounces at haskell.org] On Behalf Of Ramakrishnan Muthukrishnan Sent: 16 December 2014 08:13 To: beginners at haskell.org Subject: Re: [Haskell-beginners] Deploying a haskell application (not a webapp) On Sat, Dec 13, 2014, at 07:24 PM, Alan Buxton wrote: Hi I have created an application using cabal that now installs fine and runs fine on my dev machine. I now want to deploy this application onto a separate server. This is not a webapp. Try as I might, Google will not point me in the direction of how to do this, apart from loads of links to Keter which is not what I want (there is no nginx or any other web server involved). Any advice on the neatest way to do this? Hi, Can't you build a static binary and deploy it? (something like this -- http://stackoverflow.com/questions/5953199/create-a-static-haskell-linux-exe cutable) Ramakrishnan http://rkrishnan.org/ -------------- next part -------------- An HTML attachment was scrubbed... URL: From allbery.b at gmail.com Tue Dec 16 14:18:41 2014 From: allbery.b at gmail.com (Brandon Allbery) Date: Tue, 16 Dec 2014 09:18:41 -0500 Subject: [Haskell-beginners] Deploying a haskell application (not a webapp) In-Reply-To: <024201d01936$dea97400$9bfc5c00$@gmail.com> References: <05ee01d016dc$5a5aca20$0f105e60$@gmail.com> <1418717556.611560.203413033.364969E1@webmail.messagingengine.com> <024201d01936$dea97400$9bfc5c00$@gmail.com> Message-ID: On Tue, Dec 16, 2014 at 8:47 AM, Alan Buxton wrote: > > I?ve been having all kinds of problems with getting vmware tools installed > on a sufficiently new version of Ubuntu to get a more up to cabal. open-vm-tools{,-desktop} doesn't work? I've been using it in Mint. (In general, the "official" vmware tools don't keep up with open source OSes very well.) -- 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 michael at orlitzky.com Tue Dec 16 15:24:07 2014 From: michael at orlitzky.com (Michael Orlitzky) Date: Tue, 16 Dec 2014 10:24:07 -0500 Subject: [Haskell-beginners] Deploying a haskell application (not a webapp) In-Reply-To: <024201d01936$dea97400$9bfc5c00$@gmail.com> References: <05ee01d016dc$5a5aca20$0f105e60$@gmail.com> <1418717556.611560.203413033.364969E1@webmail.messagingengine.com> <024201d01936$dea97400$9bfc5c00$@gmail.com> Message-ID: <54904E97.9080806@orlitzky.com> On 12/16/2014 08:47 AM, Alan Buxton wrote: > Hiya > > > > It turned out that my issue was to do with the data files. When > compiling locally, cabal puts the files in /home/alan/.cabal/share and > the compiled application expects to find the files there. So when I > deploy my binary I have to also put some files into > /home/alan/.cabal/share which feels wrong. If you list the data files in Cabal's "data-files" field, and you use Cabal to build on the server, then you can ask Cabal where it put those files at runtime: https://www.haskell.org/cabal/users-guide/developing-packages.html#accessing-data-files-from-package-code From fuuzetsu at fuuzetsu.co.uk Wed Dec 17 14:16:54 2014 From: fuuzetsu at fuuzetsu.co.uk (Mateusz Kowalczyk) Date: Wed, 17 Dec 2014 14:16:54 +0000 Subject: [Haskell-beginners] Deploying a haskell application (not a webapp) In-Reply-To: <54904E97.9080806@orlitzky.com> References: <05ee01d016dc$5a5aca20$0f105e60$@gmail.com> <1418717556.611560.203413033.364969E1@webmail.messagingengine.com> <024201d01936$dea97400$9bfc5c00$@gmail.com> <54904E97.9080806@orlitzky.com> Message-ID: <54919056.3040807@fuuzetsu.co.uk> On 12/16/2014 03:24 PM, Michael Orlitzky wrote: > On 12/16/2014 08:47 AM, Alan Buxton wrote: >> Hiya >> >> >> >> It turned out that my issue was to do with the data files. When >> compiling locally, cabal puts the files in /home/alan/.cabal/share and >> the compiled application expects to find the files there. So when I >> deploy my binary I have to also put some files into >> /home/alan/.cabal/share which feels wrong. > > If you list the data files in Cabal's "data-files" field, and you use > Cabal to build on the server, then you can ask Cabal where it put those > files at runtime: > > https://www.haskell.org/cabal/users-guide/developing-packages.html#accessing-data-files-from-package-code > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > Pretty sure the whole point of this thread is that the OP does not want to build on the server. Personally I have inlined some data files into the source directly at compile time with Template Haskell: no hassle at run-time about finding the files, no hassle with copying them over to the target machine? Of course this might not cut it if your files are huge or are meant to be more dynamic. If that's the case then you should copy the data files along with the binary and teach your program how to find them. -- Mateusz K. From alanbuxton at gmail.com Wed Dec 17 14:24:38 2014 From: alanbuxton at gmail.com (Alan Buxton) Date: Wed, 17 Dec 2014 14:24:38 +0000 Subject: [Haskell-beginners] Deploying a haskell application (not a webapp) In-Reply-To: <54919056.3040807@fuuzetsu.co.uk> References: <05ee01d016dc$5a5aca20$0f105e60$@gmail.com> <1418717556.611560.203413033.364969E1@webmail.messagingengine.com> <024201d01936$dea97400$9bfc5c00$@gmail.com> <54904E97.9080806@orlitzky.com> <54919056.3040807@fuuzetsu.co.uk> Message-ID: Hi mateusz yes thanks for this. You've basically hit the nail on the head with that summary "teach your program how to find them". On 17 Dec 2014 14:17, "Mateusz Kowalczyk" wrote: > On 12/16/2014 03:24 PM, Michael Orlitzky wrote: > > On 12/16/2014 08:47 AM, Alan Buxton wrote: > >> Hiya > >> > >> > >> > >> It turned out that my issue was to do with the data files. When > >> compiling locally, cabal puts the files in /home/alan/.cabal/share and > >> the compiled application expects to find the files there. So when I > >> deploy my binary I have to also put some files into > >> /home/alan/.cabal/share which feels wrong. > > > > If you list the data files in Cabal's "data-files" field, and you use > > Cabal to build on the server, then you can ask Cabal where it put those > > files at runtime: > > > > > https://www.haskell.org/cabal/users-guide/developing-packages.html#accessing-data-files-from-package-code > > > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://www.haskell.org/mailman/listinfo/beginners > > > > Pretty sure the whole point of this thread is that the OP does not want > to build on the server. > > Personally I have inlined some data files into the source directly at > compile time with Template Haskell: no hassle at run-time about finding > the files, no hassle with copying them over to the target machine? Of > course this might not cut it if your files are huge or are meant to be > more dynamic. If that's the case then you should copy the data files > along with the binary and teach your program how to find them. > > -- > Mateusz K. > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at orlitzky.com Wed Dec 17 17:52:56 2014 From: michael at orlitzky.com (Michael Orlitzky) Date: Wed, 17 Dec 2014 12:52:56 -0500 Subject: [Haskell-beginners] Deploying a haskell application (not a webapp) In-Reply-To: <54919056.3040807@fuuzetsu.co.uk> References: <05ee01d016dc$5a5aca20$0f105e60$@gmail.com> <1418717556.611560.203413033.364969E1@webmail.messagingengine.com> <024201d01936$dea97400$9bfc5c00$@gmail.com> <54904E97.9080806@orlitzky.com> <54919056.3040807@fuuzetsu.co.uk> Message-ID: <5491C2F8.30004@orlitzky.com> On 12/17/2014 09:16 AM, Mateusz Kowalczyk wrote: > > Pretty sure the whole point of this thread is that the OP does not want > to build on the server. > Oh, sorry, I missed that. You can pass --datadir to Cabal's configure step; e.g. $ runghc Setup.hs configure --datadir=/usr/local/share/ I believe it's using /home/alan/.cabal/share as the default, but if you tell it to do otherwise, it will. From chuchao333 at gmail.com Wed Dec 17 17:55:33 2014 From: chuchao333 at gmail.com (chao chu) Date: Thu, 18 Dec 2014 01:55:33 +0800 Subject: [Haskell-beginners] Anyone here self-studying upenn's CIS 552 taught by Benjamin Pierce Message-ID: Hi, The course website: http://www.seas.upenn.edu/~cis552/ I found the lecture and lab materials are very good and I am self-studying the course by reading the lecture notes and doing the labs on my own. Just want to check if anyone is also following the course so that we can form a study group to discuss whatever we want about the course and also about learning haskell. Thanks & Regards, -- ChuChao -------------- next part -------------- An HTML attachment was scrubbed... URL: From nadirsampaoli at gmail.com Wed Dec 17 18:35:49 2014 From: nadirsampaoli at gmail.com (Nadir Sampaoli) Date: Wed, 17 Dec 2014 19:35:49 +0100 Subject: [Haskell-beginners] Anyone here self-studying upenn's CIS 552 taught by Benjamin Pierce In-Reply-To: References: Message-ID: 17/dec/2014 18:56 "chao chu" > > Hi, > > The course website: http://www.seas.upenn.edu/~cis552/ > > I found the lecture and lab materials are very good and I am self-studying the course by reading the lecture notes and doing the labs on my own. > > Just want to check if anyone is also following the course so that we can form a study group to discuss whatever we want about the course and also about learning haskell. > It would be great. I bookmarked it few months ago but never came around starting it. I like the idea and would definitely benefit from other people following along. Last year I did cis194 and compared solutions week-by-week with another person I met on IRC but somehow stopped at about 2 thirds. Are you already much further into the course? Side note about cis194: mr Pierce asked us to avoid publishing the solutions so we set up private repos at bitbucket. -- Nadir -------------- next part -------------- An HTML attachment was scrubbed... URL: From defigueiredo at ucdavis.edu Wed Dec 17 19:11:47 2014 From: defigueiredo at ucdavis.edu (Dimitri DeFigueiredo) Date: Wed, 17 Dec 2014 17:11:47 -0200 Subject: [Haskell-beginners] Anyone here self-studying upenn's CIS 552 taught by Benjamin Pierce In-Reply-To: References: Message-ID: <5491D573.9040207@ucdavis.edu> Hi ChuChao, I am going thru the lectures at a very slow pace (have other commitments). I'm currently at Monad Transformers, but would like/be willing to discuss the material. I think the class is *very good*, but there are one or two lectures which should be avoided. cheers, Dimitri On 17/12/14 15:55, chao chu wrote: > Hi, > > The course website: http://www.seas.upenn.edu/~cis552/ > > > I found the lecture and lab materials are very good and I am > self-studying the course by reading the lecture notes and doing the > labs on my own. > > Just want to check if anyone is also following the course so that we > can form a study group to discuss whatever we want about the course > and also about learning haskell. > > Thanks & Regards, > > -- > ChuChao > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners -------------- next part -------------- An HTML attachment was scrubbed... URL: From pascal.knodel at mail.com Thu Dec 18 06:58:48 2014 From: pascal.knodel at mail.com (Pascal Knodel) Date: Thu, 18 Dec 2014 07:58:48 +0100 Subject: [Haskell-beginners] structural induction, two lists, simultaneous In-Reply-To: References: <548E3C71.9010709@mail.com> Message-ID: <54927B28.1090909@mail.com> > (? ys ? (? f,zs ? map f (ys ++ zs) = map f ys ++ map f zs)) > > And now you can see that you want a proof of a one-variable theorem Thank you, Rustom Mody, that's it, reordering of universal quantifiers. By the way, I'm searching for a 'good' book about predicate logic for quite some time now. One with a strong link to mathematics and the quantification style that is used there would be nice. By chance, is there a reference (script/paper/book ) you would recommend? I have rewritten my first proof a little. It mentions the other variables now explicitly. This way it should be cleaner: -- 1. Induction Hypothesis (1. I.H.): -- ---------------------------------- -- -- For an arbitrary but fixed list "ys", for all lists "zs" and for all functions f the statement ... -- -- map f (ys ++ zs) = map f ys ++ map f zs -- -- ... holds. When proving the proposition the first time I've used a different approach (the chapter heavily promoted generalization and because I tried to get around the dilemma that I wasn't sure if I understood 'simultaneous induction' correctly): -- --------------- -- 1. Proposition: -- --------------- -- -- map f (ys ++ zs) = map f ys ++ map f zs -- -- -- -- Proof By Generalization: -- ------------------------ -- -- -- ------------------------------ -- 1. Specialization Proposition: -- ------------------------------ -- -- map f (ys ++ zs) = map f ys ++ map f zs -- -- -- ------------------------------ -- 1. Generalization Proposition: -- ------------------------------ -- -- map f (foldr (++) [] ls) = foldr ( (++) . (f `map`) ) [] ls -- -- -- Proof By Structural Induction: -- ------------------------------ -- -- -- 1. Induction Beginning (1. I.B.): -- --------------------------------- -- -- -- (Base case 1.) :<=> ls := [] -- -- => (left) := map f (foldr (++) [] ls) -- | (Base case 1.) -- = map f (foldr (++) [] []) -- | foldr -- = map f [] -- | map -- = [] -- -- -- (right) := foldr ( (++) . (f `map`) ) [] ls -- | (Base case 1.) -- = foldr ( (++) . (f `map`) ) [] [] -- | foldr -- = [] -- -- -- => (left) = (right) -- -- ? -- -- -- 1. Induction Hypothesis (1. I.H.): -- ---------------------------------- -- -- For an arbitrary but fixed (list-of-)lists "ls" and ? functions f, the statement ... -- -- map f ( foldr (++) [] ls ) = foldr ( (++) . (f `map`) ) [] ls -- -- ... holds. -- -- -- 1. Induction Step (1. I.S.): -- ---------------------------- -- -- -- (left) := map f ( foldr (++) [] (l : ls) ) -- | foldr -- = map f ( l ++ foldr (++) [] ls ) -- | (Specialized 1. I.H.) -- = map f l ++ map f ( foldr (++) [] ls ) -- | (1. I.H.) -- = map f l ++ ( foldr ( (++) . (f `map`) ) [] ls ) -- -- -- (right) := foldr ( (++) . (f `map`) ) [] (l : ls) -- | foldr -- = ( (++) . (f `map`) ) l foldr ( (++) . (f `map`) ) [] ls -- | General rule of function application (left associativity) -- = ( ( (++) . (f `map`) ) l ) foldr ( (++) . (f `map`) ) [] ls -- | (.) -- = ( (++) ( (f `map`) l ) ) foldr ( (++) . (f `map`) ) [] ls -- | (f `map`) -- = ( (++) (map f l) ) foldr ( (++) . (f `map`) ) [] ls -- | General rule of function application (left associativity) -- = (++) (map f l) ( foldr ( (++) . (f `map`) ) [] ls ) -- | ++ -- = map f l ++ ( foldr ( (++) . (f `map`) ) [] ls ) -- -- -- => (left) = (right) -- -- -- ??? (1. Generalization Proof) -- -- -- (Generalization) -- -- :<=> map f ( foldr (++) [] ls ) = foldr ( (++) . (f `map`) ) [] ls -- | ls := [ys , zs] -- |=> map f ( foldr (++) [] [ys , zs] ) = foldr ( (++) . (f `map`) ) [] [ys , zs] -- -- <=> map f (ys ++ zs) = map f ys ++ map f zs -- -- <=>: (Specialization) -- -- -- ? (1. Specialization Proof) Is this also possible? Is it allowed to use a specialized induction hypothesis like that ( see '| (Specialized 1. I.H.)' above )? Pascal > > > On Mon, Dec 15, 2014 at 7:12 AM, Pascal Knodel > wrote: > > Hi list, > > > Proposition: > > map f (ys ++ zs) = map f ys ++ map f zs > > (Haskell, the craft of functional programming, exercise 11.31) > > > Almost every time I'm asked to do (structural) induction over multiple > 'things', in this example lists, I don't know how to do it. > (I encountered similar difficulties when I worked through chapter > 9, see > https://github.com/pascal-knodel/haskell-craft/tree/master/Chapter%209 > , > ex. 9.5 , > https://github.com/pascal-knodel/haskell-craft/blob/master/Chapter%209/E%279%27%275.hs). > I think my proof in this case isn't formally correct. It feels > like it isn't. > > I would like to do the example with your help, so that I feel a > little bit safer. > > Let's start with the base case. If I have two lists, do I select > one, say ys := [] . Only one or one after another? Or both > 'parallel'? > I could state ys ++ zs := [] too, does it help? > > I could imagine that the proposition could be expanded to > something like > > map f (l1 ++ l2 ++ ... ++ lN) = map f ys ++ map f zs > = map f l1 ++ map f l2 ++ ... ++ map f lN > > And I could imagine that it is possible to do induction over more > than two lists too. > > What is the reason why we can do it over two 'objects' at the same > time? > How do I start? Can you explain this to me? > > > > This is a right question > > It is somewhat a proof-version of currying > > What you want to prove is > > (? f,ys,zs ? map f (ys ++ zs) = map f ys ++ map f zs) > > = "reorder the variables" > > (? ys,f,zs ? map f (ys ++ zs) = map f ys ++ map f zs) > > = "(? x,y ? ...) = (?x ? (? y ? ...))" > > (? ys ? (? f,zs ? map f (ys ++ zs) = map f ys ++ map f zs)) > > And now you can see that you want a proof of a one-variable theorem > > Of course at this stage you might ask "Why did you choose to pull ys > out and not zs (or f for that matter)?" > > One possible answer: Experience! > > Another: Recursion in definitions and induction in proofs go hand in hand. > Clearly the recursion is happening on the first list. So we may expect > the induction to focus there > > > > Attempt: > > -- --------------- > -- 1. Proposition: > -- --------------- > -- > -- map f (ys ++ zs) = map f ys ++ map f zs > -- > -- > -- Proof By Structural Induction: > -- ------------------------------ > -- > -- > -- 1. Induction Beginning (1. I.B.): > -- --------------------------------- > -- > -- > -- (Base case 1.) :<=> ys := [] > -- > -- => (left) := map f (ys ++ zs) > -- | (Base case 1.) > -- = map f ([] ++ zs) > -- | ++ > -- = map f zs > -- > -- > -- (right) := map f ys ++ map f zs > -- | (Base case 1.) > -- = map f [] ++ map f zs > -- | map > -- = map f zs > -- > -- > -- => (left) = (right) > -- > -- ? > -- > -- > -- 1. Induction Hypothesis (1. I.H.): > -- ---------------------------------- > -- > -- For an arbitrary, but fixed list "ys", the statement ... > -- > -- map f (ys ++ zs) = map f ys ++ map f zs > -- > -- ... holds. > -- > -- > -- 1. Induction Step (1. I.S.): > -- ---------------------------- > -- > -- > -- (left) := map f ( (y : ys) ++ zs ) > -- | ++ > -- = map f ( y : ( ys ++ zs ) ) > -- | map > -- = f y : map f ( ys ++ zs ) > -- | (1. I.H.) > -- = f y : map f ys ++ map f zs > -- | map > -- = map f (y : ys) ++ map f zs > -- > -- > -- (right) := map f (y : ys) ++ map f zs > -- > -- > -- => (left) = (right) > -- > -- > -- ??? (1. Proof) > > > But in this 'proof attempt' only "ys" was considered (1. I.H.). > What do I miss? > > Pascal > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > > > -- > http://www.the-magus.in > http://blog.languager.org > > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners -------------- next part -------------- An HTML attachment was scrubbed... URL: From alanbuxton at gmail.com Thu Dec 18 08:20:14 2014 From: alanbuxton at gmail.com (Alan Buxton) Date: Thu, 18 Dec 2014 08:20:14 -0000 Subject: [Haskell-beginners] Deploying a haskell application (not a webapp) In-Reply-To: <5491C2F8.30004@orlitzky.com> References: <05ee01d016dc$5a5aca20$0f105e60$@gmail.com> <1418717556.611560.203413033.364969E1@webmail.messagingengine.com> <024201d01936$dea97400$9bfc5c00$@gmail.com> <54904E97.9080806@orlitzky.com> <54919056.3040807@fuuzetsu.co.uk> <5491C2F8.30004@orlitzky.com> Message-ID: <085a01d01a9b$73b9bdb0$5b2d3910$@gmail.com> Oh that's cool. Is there a way to configure this in some file so that when I build just this application a particular datadir is used? -----Original Message----- From: Beginners [mailto:beginners-bounces at haskell.org] On Behalf Of Michael Orlitzky Sent: 17 December 2014 17:53 To: beginners at haskell.org Subject: Re: [Haskell-beginners] Deploying a haskell application (not a webapp) On 12/17/2014 09:16 AM, Mateusz Kowalczyk wrote: > > Pretty sure the whole point of this thread is that the OP does not > want to build on the server. > Oh, sorry, I missed that. You can pass --datadir to Cabal's configure step; e.g. $ runghc Setup.hs configure --datadir=/usr/local/share/ I believe it's using /home/alan/.cabal/share as the default, but if you tell it to do otherwise, it will. _______________________________________________ Beginners mailing list Beginners at haskell.org http://www.haskell.org/mailman/listinfo/beginners From corentin.dupont at gmail.com Thu Dec 18 09:31:15 2014 From: corentin.dupont at gmail.com (Corentin Dupont) Date: Thu, 18 Dec 2014 10:31:15 +0100 Subject: [Haskell-beginners] Deploying a haskell application (not a webapp) In-Reply-To: <085a01d01a9b$73b9bdb0$5b2d3910$@gmail.com> References: <05ee01d016dc$5a5aca20$0f105e60$@gmail.com> <1418717556.611560.203413033.364969E1@webmail.messagingengine.com> <024201d01936$dea97400$9bfc5c00$@gmail.com> <54904E97.9080806@orlitzky.com> <54919056.3040807@fuuzetsu.co.uk> <5491C2F8.30004@orlitzky.com> <085a01d01a9b$73b9bdb0$5b2d3910$@gmail.com> Message-ID: I add a command line parameter to my programs to specify the location of config files: -c This overrides the Cabal default location. Without arguments I keep the Cabal default location because it's convenient during development :) On Thu, Dec 18, 2014 at 9:20 AM, Alan Buxton wrote: > > Oh that's cool. Is there a way to configure this in some file so that when > I > build just this application a particular datadir is used? > > -----Original Message----- > From: Beginners [mailto:beginners-bounces at haskell.org] On Behalf Of > Michael > Orlitzky > Sent: 17 December 2014 17:53 > To: beginners at haskell.org > Subject: Re: [Haskell-beginners] Deploying a haskell application (not a > webapp) > > On 12/17/2014 09:16 AM, Mateusz Kowalczyk wrote: > > > > Pretty sure the whole point of this thread is that the OP does not > > want to build on the server. > > > > Oh, sorry, I missed that. You can pass --datadir to Cabal's configure step; > e.g. > > $ runghc Setup.hs configure --datadir=/usr/local/share/ > > I believe it's using /home/alan/.cabal/share as the default, but if you > tell > it to do otherwise, it will. > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rustompmody at gmail.com Thu Dec 18 13:47:24 2014 From: rustompmody at gmail.com (Rustom Mody) Date: Thu, 18 Dec 2014 19:17:24 +0530 Subject: [Haskell-beginners] structural induction, two lists, simultaneous In-Reply-To: <54927B28.1090909@mail.com> References: <548E3C71.9010709@mail.com> <54927B28.1090909@mail.com> Message-ID: On Thu, Dec 18, 2014 at 12:28 PM, Pascal Knodel wrote: > > > > (? ys ? (? f,zs ? map f (ys ++ zs) = map f ys ++ map f zs)) > > > > And now you can see that you want a proof of a one-variable theorem > > Thank you, Rustom Mody, that's it, reordering of universal quantifiers. > By the way, I'm searching for a 'good' book about predicate logic for > quite some time now. > One with a strong link to mathematics and the quantification style > that is used there would be nice. By chance, is there a reference > (script/paper/book ) > you would recommend? > Two predicate calculus books that are particularly my favorites: 1. Dijkstra and Scholtens Predicate Calculus and Program semantics (5th chapter is logic) 2. Logical Approach to Discrete Math by Gries and Schneider Second is more of a student textbook My own attempts (20 year old!) at integrating the Haskell philosophy with the Dijkstra style of logic described in these books is here: http://blog.languager.org/2014/09/pugofer.html -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at orlitzky.com Thu Dec 18 15:39:55 2014 From: michael at orlitzky.com (Michael Orlitzky) Date: Thu, 18 Dec 2014 10:39:55 -0500 Subject: [Haskell-beginners] Deploying a haskell application (not a webapp) In-Reply-To: <085a01d01a9b$73b9bdb0$5b2d3910$@gmail.com> References: <05ee01d016dc$5a5aca20$0f105e60$@gmail.com> <1418717556.611560.203413033.364969E1@webmail.messagingengine.com> <024201d01936$dea97400$9bfc5c00$@gmail.com> <54904E97.9080806@orlitzky.com> <54919056.3040807@fuuzetsu.co.uk> <5491C2F8.30004@orlitzky.com> <085a01d01a9b$73b9bdb0$5b2d3910$@gmail.com> Message-ID: <5492F54B.8040402@orlitzky.com> On 12/18/2014 03:20 AM, Alan Buxton wrote: > Oh that's cool. Is there a way to configure this in some file so that when I > build just this application a particular datadir is used? The usual Setup.hs is just a dummy file; Cabal even ignores it. But if you switch to a "custom" build (from "simple") you can do some preprocessing in Setup.hs: https://www.haskell.org/cabal/users-guide/developing-packages.html In the section "More complex packages", it shows you how to add hooks that get executed before each configure/build/etc stage. If you add a configure hook that mangles the datadir template, you can override the default. Here's a Setup.hs that seems to work: -- Welcome to the jungle, baby. import Distribution.PackageDescription import Distribution.Simple import Distribution.Simple.Configure import Distribution.Simple.InstallDirs import Distribution.Simple.LocalBuildInfo import Distribution.Simple.Setup my_hooks :: UserHooks my_hooks = simpleUserHooks { confHook = my_conf_hook } main :: IO () main = defaultMainWithHooks my_hooks my_conf_hook :: (GenericPackageDescription, HookedBuildInfo) -> ConfigFlags -> IO LocalBuildInfo my_conf_hook (gpd,hbi) cf = do lbi <- configure (gpd, hbi) cf let orig_dirs = installDirTemplates lbi let my_datadir = toPathTemplate "/foo/bar" let my_dirs = orig_dirs { datadir = my_datadir } let my_lbi = lbi { installDirTemplates = my_dirs } return my_lbi From vale.cofershabica at gmail.com Thu Dec 18 17:50:00 2014 From: vale.cofershabica at gmail.com (Vale Cofer-Shabica) Date: Thu, 18 Dec 2014 12:50:00 -0500 Subject: [Haskell-beginners] Deploying a haskell application (not a webapp) In-Reply-To: <5492F54B.8040402@orlitzky.com> References: <05ee01d016dc$5a5aca20$0f105e60$@gmail.com> <1418717556.611560.203413033.364969E1@webmail.messagingengine.com> <024201d01936$dea97400$9bfc5c00$@gmail.com> <54904E97.9080806@orlitzky.com> <54919056.3040807@fuuzetsu.co.uk> <5491C2F8.30004@orlitzky.com> <085a01d01a9b$73b9bdb0$5b2d3910$@gmail.com> <5492F54B.8040402@orlitzky.com> Message-ID: Does anyone have any experience with Halcyon[1]? It purports to do just this. [1] https://halcyon.sh/ -- vale cofer-shabica <401.267.8253> On Thu, Dec 18, 2014 at 10:39 AM, Michael Orlitzky wrote: > > On 12/18/2014 03:20 AM, Alan Buxton wrote: > > Oh that's cool. Is there a way to configure this in some file so that > when I > > build just this application a particular datadir is used? > > The usual Setup.hs is just a dummy file; Cabal even ignores it. But if > you switch to a "custom" build (from "simple") you can do some > preprocessing in Setup.hs: > > https://www.haskell.org/cabal/users-guide/developing-packages.html > > In the section "More complex packages", it shows you how to add hooks > that get executed before each configure/build/etc stage. If you add a > configure hook that mangles the datadir template, you can override the > default. Here's a Setup.hs that seems to work: > > -- Welcome to the jungle, baby. > import Distribution.PackageDescription > import Distribution.Simple > import Distribution.Simple.Configure > import Distribution.Simple.InstallDirs > import Distribution.Simple.LocalBuildInfo > import Distribution.Simple.Setup > > my_hooks :: UserHooks > my_hooks = simpleUserHooks { confHook = my_conf_hook } > > main :: IO () > main = defaultMainWithHooks my_hooks > > my_conf_hook :: (GenericPackageDescription, HookedBuildInfo) > -> ConfigFlags > -> IO LocalBuildInfo > my_conf_hook (gpd,hbi) cf = do > lbi <- configure (gpd, hbi) cf > > let orig_dirs = installDirTemplates lbi > let my_datadir = toPathTemplate "/foo/bar" > let my_dirs = orig_dirs { datadir = my_datadir } > let my_lbi = lbi { installDirTemplates = my_dirs } > return my_lbi > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From pascal.knodel at mail.com Fri Dec 19 01:39:21 2014 From: pascal.knodel at mail.com (Pascal Knodel) Date: Fri, 19 Dec 2014 02:39:21 +0100 Subject: [Haskell-beginners] Does/How does GHC/Haskell optimize this ('almost identical associative expressions', pattern matching reordering) Message-ID: <549381C9.6050907@mail.com> Hi all, a) I've learned that Haskell uses graphs (graph reduction) to do optimizations / 'sharing'. Calculation example: -- (1 + 2) + (1 + 2) -- ~> 3 + 3 -- ~> 6 in contrast to -- (1 + 2) + (3 + 0) -- ~> 3 + (3 + 0) -- ~> 3 + 3 -- ~> 6 What does it do in a case like: ... min 0 1 ... min 1 0 ..., or: (1 + 2) + (2 + 1) where a function definition is used which has the same result in both cases, but arguments are flipped. This is a simple example for a very general problem. What does the underlying system do about it? (a1) Can it detect and optimize it? In the example it would be easy to reduce it to the relations that define the min function. Is GHC able to detect it? (a2) Is there a super language to Haskell, like an speci. assembler in other paradigms, that could split code into even smaller pieces? (a3) What happens at run-time, for example: ... min a b ... min b a ...? b) About 'pattern matching': Does Haskell reorder patterns for optimization? How/what technique does it use there? Example: ... f [] = ... f (a : as) = ... f ( b(a) ) ... ... VS. ... f (a : as) = ... f ( b(a) ) ... f [] = ... ... If Haskell does pattern matching like I've been told: top down, the first definition would statistically be inefficient, because recursive functions are normally called with the intension to do some (recursive) calculations. I tested (*) it (without optimization). What do I need to know to understand this behavior? * Tests were (+RTS - -RTS): -------------------- snip -------------------- module Test where f1 :: String -> String f1 [] = [] f1 [a1] = [a1] f1 [a1,a2] = [a1,a2] f1 [a1,a2,a3] = [a1,a2,a3] f1 [a1,a2,a3,a4] = [a1,a2,a3,a4] f1 [a1,a2,a3,a4,a5] = [a1,a2,a3,a4,a5] f1 [a1,a2,a3,a4,a5,a6] = [a1,a2,a3,a4,a5,a6] f1 (a1 : a2 : a3 : a4 : a5 : a6 : a7 : as) = f1 as f2 :: String -> String f2 (a1 : a2 : a3 : a4 : a5 : a6 : a7 : as) = f2 as f2 [a1,a2,a3,a4,a5,a6] = [a1,a2,a3,a4,a5,a6] f2 [a1,a2,a3,a4,a5] = [a1,a2,a3,a4,a5] f2 [a1,a2,a3,a4] = [a1,a2,a3,a4] f2 [a1,a2,a3] = [a1,a2,a3] f2 [a1,a2] = [a1,a2] f2 [a1] = [a1] f2 [] = [] p1 :: IO () p1 = print $ f1 [' ' | _ <-[1 .. 10^9] ] -- 63.87 secs p2 :: IO () p2 = print $ f2 [' ' | _ <-[1 .. 10^9] ] -- 62.68 secs -------------------- snip -------------------- From sagar.srivastava4595 at gmail.com Sun Dec 21 16:24:53 2014 From: sagar.srivastava4595 at gmail.com (Sagar Srivastava) Date: Sun, 21 Dec 2014 21:54:53 +0530 Subject: [Haskell-beginners] Getting started with Haskell Message-ID: Hello All! I'm Sagar, from India.I'm a sophomore at BITS Pilani,Hyderabad ,currently pursuing a B.E(Hons) degree in Computer Science. I've just started learning Haskell and i was aiming to participate in this year's Google Summer of Code,and so i was wondering if i could get comfortable enough with the language ,given enough effort so that i might be able to contribute to the project and maybe participate in GSoC with this organization. Also,wishing all of you a Merry Christmas and a Happy New Year! :) Regards, Sagar -------------- next part -------------- An HTML attachment was scrubbed... URL: From animeshsaxena at icloud.com Mon Dec 22 03:57:10 2014 From: animeshsaxena at icloud.com (Animesh Saxena) Date: Mon, 22 Dec 2014 11:57:10 +0800 Subject: [Haskell-beginners] Getting started with Haskell In-Reply-To: References: Message-ID: For basics this is very good .... learnyouahaskell.com. See if you can solve this... HTTPS://www.haskell.org/haskellwiki/99_questions. Sent from my iPhone > On 22-Dec-2014, at 12:24 am, Sagar Srivastava wrote: > > Hello All! > > I'm Sagar, from India.I'm a sophomore at BITS Pilani,Hyderabad ,currently pursuing a B.E(Hons) degree in Computer Science. > > I've just started learning Haskell and i was aiming to participate in this year's Google Summer of Code,and so i was wondering if > i could get comfortable enough with the language ,given enough effort so that i might be able to contribute to the project and maybe participate in GSoC with this organization. > > Also,wishing all of you a Merry Christmas and a Happy New Year! :) > > Regards, > Sagar > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners From cma at bitemyapp.com Mon Dec 22 04:02:55 2014 From: cma at bitemyapp.com (Christopher Allen) Date: Sun, 21 Dec 2014 22:02:55 -0600 Subject: [Haskell-beginners] Getting started with Haskell In-Reply-To: References: Message-ID: I don't recommend Learn You A Haskell. I usually point people to my guide here: https://github.com/bitemyapp/learnhaskell And tell them to do cis194 and then the NICTA course. On Sun, Dec 21, 2014 at 9:57 PM, Animesh Saxena wrote: > For basics this is very good .... learnyouahaskell.com. See if you can > solve this... HTTPS://www.haskell.org/haskellwiki/99_questions. > > Sent from my iPhone > > > On 22-Dec-2014, at 12:24 am, Sagar Srivastava < > sagar.srivastava4595 at gmail.com> wrote: > > > > Hello All! > > > > I'm Sagar, from India.I'm a sophomore at BITS Pilani,Hyderabad > ,currently pursuing a B.E(Hons) degree in Computer Science. > > > > I've just started learning Haskell and i was aiming to participate in > this year's Google Summer of Code,and so i was wondering if > > i could get comfortable enough with the language ,given enough effort so > that i might be able to contribute to the project and maybe participate in > GSoC with this organization. > > > > Also,wishing all of you a Merry Christmas and a Happy New Year! :) > > > > Regards, > > Sagar > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://www.haskell.org/mailman/listinfo/beginners > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mwanikibusiness at gmail.com Mon Dec 22 15:03:38 2014 From: mwanikibusiness at gmail.com (Njagi Mwaniki) Date: Mon, 22 Dec 2014 18:03:38 +0300 Subject: [Haskell-beginners] Google Summer of Code Message-ID: <549832CA.507@gmail.com> -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512 Which books or resources or libraries should one read to get ready for the Google summer of code? Also which projects would be easiest to work on for beginners? Anything that would make one ready for Google summer of code and complete their project with ease. I'm currently taking cs194 from upenn online http://www.seas.upenn.edu/~cis194/lectures.html -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQJ8BAEBCgBmBQJUmDLFXxSAAAAAAC4AKGlzc3Vlci1mcHJAbm90YXRpb25zLm9w ZW5wZ3AuZmlmdGhob3JzZW1hbi5uZXRGMjlGREM4Qjk5M0I2NEFEODkwMzFEQkRB MDNCNjA0MzJCQzVCQjdEAAoJEKA7YEMrxbt9H7MP/j89OarC7pjq80dwRT8OltbW d1xj6wabb7RsvRH0rrvo5iBbSG7PNTq22cEbhlWukBToCRpo7YKX75EqLVuYwXl+ wPnTbKrerbsslslQruDkDkV3ilXA59uVFK7pLcbU9CN0TjAdUEA30ih+UAQihkjc +knhhB4iBAK/wYzN8VUwkfSCzxEb1YSZR5Ax99deAP7QzjmEaWwf9do9LLtrQZUu +Z9nl5HehUC3A9ESR/9DDCVvAKOQEQNSuhYGWI2HbzviXFg4Q4++6ZgHCg01/1m8 HeZPXzj+P1r8Is1KU4G88rK2oaLkjHWBkix703LzWzwdhu9pN2KN4SHshzdbajbm efVpE6/cPTjd1UtHZYHw5hwqfFrXVUkXgNuMAb7LA3CAy5HtZGOelHTyhgcouaVw TuGaYqDmF4E4Dw/f9HpvifvK4C/tBEXObXMLc28eXScdBa1HLZvKbkcEN1LtS0Gk KptDtPV7QWmSeRIoykhhKti53EuLaPrHZImFUwW8bxT1hZXAC04LoUKyYXnek8Sq tlOKEWnmgSPSanHQXSi3s8D39KJLX1W7Itcuxg6urwBrKB7BjWOO7ns1EVJKCw2X RsMorWwX2p5OvJYQrfTjfH6H9sfmXfknlyRpdp4DJ7qIlrQOKSpM8atU9uKvXyuI haO3utPRp68x5ItCi6G0 =9H6s -----END PGP SIGNATURE----- From derek.mahar at gmail.com Mon Dec 22 23:57:31 2014 From: derek.mahar at gmail.com (Derek Mahar) Date: Mon, 22 Dec 2014 18:57:31 -0500 Subject: [Haskell-beginners] Getting started with Haskell In-Reply-To: References: Message-ID: Follow the next session of FP101x Introduction to Functional Programming ( https://courses.edx.org/courses/DelftX/FP101x/3T2014/). This session is almost over, but the material is still available and a member of the staff has claimed that they will offer the course again, but there is no definite date. Derek On 21 December 2014 at 23:02, Christopher Allen wrote: > > I don't recommend Learn You A Haskell. > > I usually point people to my guide here: > https://github.com/bitemyapp/learnhaskell > > And tell them to do cis194 and then the NICTA course. > > On Sun, Dec 21, 2014 at 9:57 PM, Animesh Saxena > wrote: > >> For basics this is very good .... learnyouahaskell.com. See if you can >> solve this... HTTPS://www.haskell.org/haskellwiki/99_questions. >> >> Sent from my iPhone >> >> > On 22-Dec-2014, at 12:24 am, Sagar Srivastava < >> sagar.srivastava4595 at gmail.com> wrote: >> > >> > Hello All! >> > >> > I'm Sagar, from India.I'm a sophomore at BITS Pilani,Hyderabad >> ,currently pursuing a B.E(Hons) degree in Computer Science. >> > >> > I've just started learning Haskell and i was aiming to participate in >> this year's Google Summer of Code,and so i was wondering if >> > i could get comfortable enough with the language ,given enough effort >> so that i might be able to contribute to the project and maybe participate >> in GSoC with this organization. >> > >> > Also,wishing all of you a Merry Christmas and a Happy New Year! :) >> > >> > Regards, >> > Sagar >> > _______________________________________________ >> > Beginners mailing list >> > Beginners at haskell.org >> > http://www.haskell.org/mailman/listinfo/beginners >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://www.haskell.org/mailman/listinfo/beginners >> > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > -- Derek Mahar 1.514.316.6736 Home 1.514.316.7348 Mobile 1.514.931.6222 #7754 Work 102-1365 boulevard Ren?-L?vesque Est Montr?al QC H2L 2M1 Canada -------------- next part -------------- An HTML attachment was scrubbed... URL: From cma at bitemyapp.com Tue Dec 23 00:07:37 2014 From: cma at bitemyapp.com (Christopher Allen) Date: Mon, 22 Dec 2014 18:07:37 -0600 Subject: [Haskell-beginners] Getting started with Haskell In-Reply-To: References: Message-ID: Most people from the haskell-beginners IRC channel that did FP101x didn't like it as much as the cis194 -> NICTA course progression. One common complaint was the tedious homework. Another was that it seemed like a thin layer over Hutton's book. Exercises are a prominent part of cis194 and NICTA course - they're not easy either. But those exercises don't feel unfair, trifling, or trivial in the way FP101x's homework did. As a result, I don't recommend FP101x. I would like to see more and better multimedia resources for learning Haskell. Some people take to audio/video more readily. --- Chris Allen On Mon, Dec 22, 2014 at 5:57 PM, Derek Mahar wrote: > Follow the next session of FP101x Introduction to Functional Programming ( > https://courses.edx.org/courses/DelftX/FP101x/3T2014/). This session is > almost over, but the material is still available and a member of the staff > has claimed that they will offer the course again, but there is no definite > date. > > Derek > > On 21 December 2014 at 23:02, Christopher Allen wrote: >> >> I don't recommend Learn You A Haskell. >> >> I usually point people to my guide here: >> https://github.com/bitemyapp/learnhaskell >> >> And tell them to do cis194 and then the NICTA course. >> >> On Sun, Dec 21, 2014 at 9:57 PM, Animesh Saxena > > wrote: >> >>> For basics this is very good .... learnyouahaskell.com. See if you can >>> solve this... HTTPS://www.haskell.org/haskellwiki/99_questions. >>> >>> Sent from my iPhone >>> >>> > On 22-Dec-2014, at 12:24 am, Sagar Srivastava < >>> sagar.srivastava4595 at gmail.com> wrote: >>> > >>> > Hello All! >>> > >>> > I'm Sagar, from India.I'm a sophomore at BITS Pilani,Hyderabad >>> ,currently pursuing a B.E(Hons) degree in Computer Science. >>> > >>> > I've just started learning Haskell and i was aiming to participate in >>> this year's Google Summer of Code,and so i was wondering if >>> > i could get comfortable enough with the language ,given enough effort >>> so that i might be able to contribute to the project and maybe participate >>> in GSoC with this organization. >>> > >>> > Also,wishing all of you a Merry Christmas and a Happy New Year! :) >>> > >>> > Regards, >>> > Sagar >>> > _______________________________________________ >>> > Beginners mailing list >>> > Beginners at haskell.org >>> > http://www.haskell.org/mailman/listinfo/beginners >>> _______________________________________________ >>> Beginners mailing list >>> Beginners at haskell.org >>> http://www.haskell.org/mailman/listinfo/beginners >>> >> >> >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://www.haskell.org/mailman/listinfo/beginners >> >> > > -- > Derek Mahar > 1.514.316.6736 Home > 1.514.316.7348 Mobile > 1.514.931.6222 #7754 Work > 102-1365 boulevard Ren?-L?vesque Est > Montr?al QC H2L 2M1 > Canada > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From akaberto at gmail.com Tue Dec 23 16:17:26 2014 From: akaberto at gmail.com (akash g) Date: Tue, 23 Dec 2014 21:47:26 +0530 Subject: [Haskell-beginners] Getting started with Haskell In-Reply-To: References: Message-ID: This set of lecture notes covers a lot of ground: http://www.scs.stanford.edu/14sp-cs240h/ You can also google their old set of lecture notes (2011), which was different in its treatment of lenses and parsec (attoparsec; from the cursory glance, 2014 seems to a lot more different on these too points). Also, 2014 has a chapter on commonly used extensions that'll be quiet helpful. - G Akash On Tue, Dec 23, 2014 at 5:37 AM, Christopher Allen wrote: > Most people from the haskell-beginners IRC channel that did FP101x didn't > like it as much as the cis194 -> NICTA course progression. One common > complaint was the tedious homework. Another was that it seemed like a thin > layer over Hutton's book. Exercises are a prominent part of cis194 and > NICTA course - they're not easy either. But those exercises don't feel > unfair, trifling, or trivial in the way FP101x's homework did. > > As a result, I don't recommend FP101x. I would like to see more and better > multimedia resources for learning Haskell. Some people take to audio/video > more readily. > > > --- Chris Allen > > > On Mon, Dec 22, 2014 at 5:57 PM, Derek Mahar > wrote: > >> Follow the next session of FP101x Introduction to Functional Programming ( >> https://courses.edx.org/courses/DelftX/FP101x/3T2014/). This session is >> almost over, but the material is still available and a member of the staff >> has claimed that they will offer the course again, but there is no definite >> date. >> >> Derek >> >> On 21 December 2014 at 23:02, Christopher Allen >> wrote: >>> >>> I don't recommend Learn You A Haskell. >>> >>> I usually point people to my guide here: >>> https://github.com/bitemyapp/learnhaskell >>> >>> And tell them to do cis194 and then the NICTA course. >>> >>> On Sun, Dec 21, 2014 at 9:57 PM, Animesh Saxena < >>> animeshsaxena at icloud.com> wrote: >>> >>>> For basics this is very good .... learnyouahaskell.com. See if you can >>>> solve this... HTTPS://www.haskell.org/haskellwiki/99_questions. >>>> >>>> Sent from my iPhone >>>> >>>> > On 22-Dec-2014, at 12:24 am, Sagar Srivastava < >>>> sagar.srivastava4595 at gmail.com> wrote: >>>> > >>>> > Hello All! >>>> > >>>> > I'm Sagar, from India.I'm a sophomore at BITS Pilani,Hyderabad >>>> ,currently pursuing a B.E(Hons) degree in Computer Science. >>>> > >>>> > I've just started learning Haskell and i was aiming to participate in >>>> this year's Google Summer of Code,and so i was wondering if >>>> > i could get comfortable enough with the language ,given enough effort >>>> so that i might be able to contribute to the project and maybe participate >>>> in GSoC with this organization. >>>> > >>>> > Also,wishing all of you a Merry Christmas and a Happy New Year! :) >>>> > >>>> > Regards, >>>> > Sagar >>>> > _______________________________________________ >>>> > Beginners mailing list >>>> > Beginners at haskell.org >>>> > http://www.haskell.org/mailman/listinfo/beginners >>>> _______________________________________________ >>>> Beginners mailing list >>>> Beginners at haskell.org >>>> http://www.haskell.org/mailman/listinfo/beginners >>>> >>> >>> >>> _______________________________________________ >>> Beginners mailing list >>> Beginners at haskell.org >>> http://www.haskell.org/mailman/listinfo/beginners >>> >>> >> >> -- >> Derek Mahar >> 1.514.316.6736 Home >> 1.514.316.7348 Mobile >> 1.514.931.6222 #7754 Work >> 102-1365 boulevard Ren?-L?vesque Est >> Montr?al QC H2L 2M1 >> Canada >> >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://www.haskell.org/mailman/listinfo/beginners >> >> > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fuuzetsu at fuuzetsu.co.uk Wed Dec 24 07:51:51 2014 From: fuuzetsu at fuuzetsu.co.uk (Mateusz Kowalczyk) Date: Wed, 24 Dec 2014 07:51:51 +0000 Subject: [Haskell-beginners] Google Summer of Code In-Reply-To: <549832CA.507@gmail.com> References: <549832CA.507@gmail.com> Message-ID: <549A7097.7070600@fuuzetsu.co.uk> On 12/22/2014 03:03 PM, Njagi Mwaniki wrote: > Which books or resources or libraries should one read to get ready for > the Google summer of code? Also which projects would be easiest to work > on for beginners? > > Anything that would make one ready for Google summer of code and > complete their project with ease. > > I'm currently taking cs194 from upenn online > http://www.seas.upenn.edu/~cis194/lectures.html > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > What matters the most[?] is the project you pick (in respect of how useful to the Haskell community it is), what you promise to do with it and how likely it is that you can fulfill your promise. Notably, GSOC is not a project that aims to teach you (Haskell|C|Python|LISP|pick your poison). For this reason your question about books to read on beginners mailing list seems slightly misguided to me. I do not think you are expecting there to be a ?How to prepare for GSOC? book ;). By no means do I hope to discourage you somehow of course but if you hope to have a serious chance at having an idea accepted, you need to start gaining some expertise in the area ASAP. I commend you on sending out your e-mail before 2015! It is of course best to find a project you are interested in: you probably don't want to dive into linear algebra package for GSOC if you have 0 interest or previous exposure to the topic. It is also unlikely that a brand new project will be accepted unless it offers great benefits and is likely to do great things after GSOC is over. It seems difficult to imagine, especially for a beginner. My advice is that you should start looking at existing projects *now* and see if you can't start committing straight away while having a grander scheme in mind: you are much more likely to get accepted if your proposal says ?I have already been committing to this project for past 3 months? than ?I will spend first two weeks familiarising myself with the codebase?. It's favourable if you already have some rough idea how you would go about hacking your project rather than having to investigate once the project starts. The project you will work on has to somehow benefit Haskell community. ?I will write a game and people will have fun hour playing it? is probably not good. ?I will improve Hackage/cabal/Haddock/GHC? is much more likely to make it through. You are meant to have a pretty good idea of what you will doing: ?I will fix whatever issues I can for 3 months? is probably not good but ?I will fix X, Y, Z tickets which currently hinder the community/will allow the community to become a better place because ABC? seems much more likely to be accepted. The project has to be reasonable for your skillset: do not try to promise to do work which is obviously out of your ability (Haskell or otherwise) or one that you can do but will simply take too long. Your proposal and subsequent 3 months of work need a mentor: this is most likely going to be someone involved with the project already. If you have an idea of what project you would like to help out, you should by all means seek out people involved earlier than later. They can most likely advise you on your proposal, say how viable your ideas are and probably mentor it. Lastly, remember that you are competing with other people. I believe there were some ~30 proposals submitted last year for only 15 or so slots. I recommend you try to find past proposals. There is usually a template you are asked to fill out and the questions there should help you form the idea of what you're expected to write down. Hopefully this helps somehow. There is #haskell-gsoc on Freenode where a few people are idling and it gets much busier closer to the proposal deadlines. PS: Shameless plug time! Haddock is a pretty core tool and we could always use some helpers! If you end up looking at Haddock as one of the possible projects, I could advise you and probably mentor it. A weaker candidate is the Yi text editor: it's not exactly a core tool but there is quite a bit of interest in it. I hear that it has very nearly made it into GSOC last year! I could probably also mentor this if need be. I don't know if I'm eligible to take part myself this year or if I will even have time so if you're interested in either of these you should let me know sooner than later. ?: In my opinion, based on having taken part, including one successful completion and one failure to get in. -- Mateusz K. From tjakway at nyu.edu Wed Dec 24 17:22:36 2014 From: tjakway at nyu.edu (Thomas Jakway) Date: Wed, 24 Dec 2014 09:22:36 -0800 Subject: [Haskell-beginners] Google Summer of Code In-Reply-To: <549A7097.7070600@fuuzetsu.co.uk> References: <549832CA.507@gmail.com> <549A7097.7070600@fuuzetsu.co.uk> Message-ID: <549AF65C.4030703@nyu.edu> I usually just lurk on the mailing lists and am nowhere near experienced enough in Haskell to consider applying for GSOC, but just wanted to say how impressed I am at the Haskell community for seeing someone from a major project encouraging to mentor someone on the beginner mailing list. It's really important to feeling like those projects are accessible. On 12/23/14 11:51 PM, Mateusz Kowalczyk wrote: > On 12/22/2014 03:03 PM, Njagi Mwaniki wrote: >> Which books or resources or libraries should one read to get ready for >> the Google summer of code? Also which projects would be easiest to work >> on for beginners? >> >> Anything that would make one ready for Google summer of code and >> complete their project with ease. >> >> I'm currently taking cs194 from upenn online >> http://www.seas.upenn.edu/~cis194/lectures.html >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://www.haskell.org/mailman/listinfo/beginners >> > What matters the most[?] is the project you pick (in respect of how > useful to the Haskell community it is), what you promise to do with it > and how likely it is that you can fulfill your promise. Notably, GSOC is > not a project that aims to teach you (Haskell|C|Python|LISP|pick your > poison). For this reason your question about books to read on beginners > mailing list seems slightly misguided to me. I do not think you are > expecting there to be a ?How to prepare for GSOC? book ;). By no means > do I hope to discourage you somehow of course but if you hope to have a > serious chance at having an idea accepted, you need to start gaining > some expertise in the area ASAP. I commend you on sending out your > e-mail before 2015! > > It is of course best to find a project you are interested in: you > probably don't want to dive into linear algebra package for GSOC if you > have 0 interest or previous exposure to the topic. > > It is also unlikely that a brand new project will be accepted unless it > offers great benefits and is likely to do great things after GSOC is > over. It seems difficult to imagine, especially for a beginner. > > My advice is that you should start looking at existing projects *now* > and see if you can't start committing straight away while having a > grander scheme in mind: you are much more likely to get accepted if your > proposal says ?I have already been committing to this project for past 3 > months? than ?I will spend first two weeks familiarising myself with the > codebase?. It's favourable if you already have some rough idea how you > would go about hacking your project rather than having to investigate > once the project starts. > > The project you will work on has to somehow benefit Haskell community. > ?I will write a game and people will have fun hour playing it? is > probably not good. ?I will improve Hackage/cabal/Haddock/GHC? is much > more likely to make it through. You are meant to have a pretty good idea > of what you will doing: ?I will fix whatever issues I can for 3 months? > is probably not good but ?I will fix X, Y, Z tickets which currently > hinder the community/will allow the community to become a better place > because ABC? seems much more likely to be accepted. The project has to > be reasonable for your skillset: do not try to promise to do work which > is obviously out of your ability (Haskell or otherwise) or one that you > can do but will simply take too long. > > Your proposal and subsequent 3 months of work need a mentor: this is > most likely going to be someone involved with the project already. If > you have an idea of what project you would like to help out, you should > by all means seek out people involved earlier than later. They can most > likely advise you on your proposal, say how viable your ideas are and > probably mentor it. > > Lastly, remember that you are competing with other people. I believe > there were some ~30 proposals submitted last year for only 15 or so slots. > > I recommend you try to find past proposals. There is usually a template > you are asked to fill out and the questions there should help you form > the idea of what you're expected to write down. > > Hopefully this helps somehow. There is #haskell-gsoc on Freenode where a > few people are idling and it gets much busier closer to the proposal > deadlines. > > PS: Shameless plug time! Haddock is a pretty core tool and we could > always use some helpers! If you end up looking at Haddock as one of the > possible projects, I could advise you and probably mentor it. A weaker > candidate is the Yi text editor: it's not exactly a core tool but there > is quite a bit of interest in it. I hear that it has very nearly made it > into GSOC last year! I could probably also mentor this if need be. I > don't know if I'm eligible to take part myself this year or if I will > even have time so if you're interested in either of these you should let > me know sooner than later. > > ?: In my opinion, based on having taken part, including one successful > completion and one failure to get in. > From bouanto at vivaldi.net Fri Dec 26 19:44:28 2014 From: bouanto at vivaldi.net (Antoni Boucher) Date: Fri, 26 Dec 2014 14:44:28 -0500 Subject: [Haskell-beginners] Generalizing traversal of expressions with changes on specific nodes Message-ID: <20141226194427.GA1679@bouanto-laptop> Hi. I read the lectures from the CIS194 course (version fall 2014) and I wanted to have some comments on my solution to the Exercise 7 of the Homework 5. Here is the question: Exercise 7 (Optional) The distribute and squashMulId functions are quite similar, in that they traverse over the whole expression to make changes to specific nodes. Generalize this notion, so that the two functions can concentrate on just the bit that they need to transform. (You can see the whole homework here: http://www.seas.upenn.edu/~cis194/hw/05-type-classes.pdf) Here is my squashMulId function from Exercise 6: squashMulId :: (Eq a, Ring a) => RingExpr a -> RingExpr a squashMulId AddId = AddId squashMulId MulId = MulId squashMulId (Lit n) = Lit n squashMulId (AddInv x) = AddInv (squashMulId x) squashMulId (Add x y) = Add (squashMulId x) (squashMulId y) squashMulId (Mul x (Lit y)) | y == mulId = squashMulId x squashMulId (Mul (Lit x) y) | x == mulId = squashMulId y squashMulId (Mul x y) = Mul (squashMulId x) (squashMulId y) And here is my solution to Exercise 7: distribute :: RingExpr a -> RingExpr a distribute = transform distribute' where distribute' (Mul x (Add y z)) = Just $ Add (Mul x y) (Mul x z) distribute' (Mul (Add x y) z) = Just $ Add (Mul x z) (Mul y z) distribute' _ = Nothing squashMulId :: (Eq a, Ring a) => RingExpr a -> RingExpr a squashMulId = transform simplifyMul where simplifyMul (Mul x (Lit y)) | y == mulId = Just $ squashMulId x simplifyMul (Mul (Lit x) y) | x == mulId = Just $ squashMulId y simplifyMul _ = Nothing transform :: (RingExpr a -> Maybe (RingExpr a)) -> RingExpr a -> RingExpr a transform f e | Just expr <- f e = expr transform _ AddId = AddId transform _ MulId = MulId transform _ e@(Lit n) = e transform f (AddInv x) = AddInv (transform f x) transform f (Add x y) = Add (transform f x) (transform f y) transform f (Mul x y) = Mul (transform f x) (transform f y) Is there a better way of doing such generalization? Thanks for your help. -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 473 bytes Desc: not available URL: From doug at cs.dartmouth.edu Sun Dec 28 14:49:51 2014 From: doug at cs.dartmouth.edu (Doug McIlroy) Date: Sun, 28 Dec 2014 09:49:51 -0500 Subject: [Haskell-beginners] ghc prelude home Message-ID: <201412281449.sBSEnpbk007869@coolidge.cs.dartmouth.edu> Where can I find the full ghc prelude? In the local installation I was able to find only .hi files, not .hs. Poking around github, I found module Prelude.hs. It's a skeleton that imports many submodules, which I wasn't clever enough to find. \ Doug McIlroy From allbery.b at gmail.com Sun Dec 28 14:53:45 2014 From: allbery.b at gmail.com (Brandon Allbery) Date: Sun, 28 Dec 2014 09:53:45 -0500 Subject: [Haskell-beginners] ghc prelude home In-Reply-To: <201412281449.sBSEnpbk007869@coolidge.cs.dartmouth.edu> References: <201412281449.sBSEnpbk007869@coolidge.cs.dartmouth.edu> Message-ID: On Sun, Dec 28, 2014 at 9:49 AM, Doug McIlroy wrote: > Where can I find the full ghc prelude? > There was at one point an intention of making the "base" package available on Hackage, but at the moment you need the ghc source to get it. -- 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 ben at smart-cactus.org Sun Dec 28 16:58:57 2014 From: ben at smart-cactus.org (Ben Gamari) Date: Sun, 28 Dec 2014 11:58:57 -0500 Subject: [Haskell-beginners] ghc prelude home In-Reply-To: References: <201412281449.sBSEnpbk007869@coolidge.cs.dartmouth.edu> Message-ID: <8761cvg17y.fsf@gmail.com> Brandon Allbery writes: > On Sun, Dec 28, 2014 at 9:49 AM, Doug McIlroy wrote: > >> Where can I find the full ghc prelude? >> > > There was at one point an intention of making the "base" package available > on Hackage, but at the moment you need the ghc source to get it. > And `base` is now living in the GHC tree itself; it no longer has its own repository which further complicates its status as a free-standing package. This was a conscious decision as much of `base` is quite tied to GHC. There have been various attempts to split base up into packages of finer granularity ([1] being the latest, as far as I know); unfortunately they have all run into various practical issues. Cheers, - Ben [1] https://www.haskell.org/pipermail/libraries/2013-July/020390.html -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 472 bytes Desc: not available URL: From gale at sefer.org Sun Dec 28 17:13:20 2014 From: gale at sefer.org (Yitzchak Gale) Date: Sun, 28 Dec 2014 19:13:20 +0200 Subject: [Haskell-beginners] ghc prelude home In-Reply-To: <8761cvg17y.fsf@gmail.com> References: <201412281449.sBSEnpbk007869@coolidge.cs.dartmouth.edu> <8761cvg17y.fsf@gmail.com> Message-ID: >> There was at one point an intention of making the "base" package available >> on Hackage, but at the moment you need the ghc source to get it. So - the standard place to see the haddocks for base isn't hackage anymore? Then, where? Thanks, Yitz From allbery.b at gmail.com Sun Dec 28 17:18:42 2014 From: allbery.b at gmail.com (Brandon Allbery) Date: Sun, 28 Dec 2014 12:18:42 -0500 Subject: [Haskell-beginners] ghc prelude home In-Reply-To: References: <201412281449.sBSEnpbk007869@coolidge.cs.dartmouth.edu> <8761cvg17y.fsf@gmail.com> Message-ID: On Sun, Dec 28, 2014 at 12:13 PM, Yitzchak Gale wrote: > So - the standard place to see the haddocks for base > isn't hackage anymore? Then, where? > I typically use http://lambda.haskell.org/platform/doc/current/index.html or https://downloads.haskell.org/~ghc/latest/docs/html/libraries/index.html which afaik are the canonical locations. -- 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 gale at sefer.org Sun Dec 28 17:47:32 2014 From: gale at sefer.org (Yitzchak Gale) Date: Sun, 28 Dec 2014 19:47:32 +0200 Subject: [Haskell-beginners] ghc prelude home In-Reply-To: References: <201412281449.sBSEnpbk007869@coolidge.cs.dartmouth.edu> <8761cvg17y.fsf@gmail.com> Message-ID: I wrote: >> So - the standard place to see the haddocks for base >> isn't hackage anymore? Then, where? Brandon Allbery wrote: > I typically use http://lambda.haskell.org/platform/doc/current/index.html or > https://downloads.haskell.org/~ghc/latest/docs/html/libraries/index.html > which afaik are the canonical locations. The first links to the Haskell 2010 libraries. Those are interesting, but I was referring to a working copy. The second links to 7.8.3. You can also get to 7.8.4 on that site if you poke around, but I don't see any obvious way to get the haddocks for 7.10 there. For me, the "canonical" place to find all haddocks is Hackage. Won't it be inconvenient for users now to need two different bookmarks in their browser, and to be forced to remember which packages are bundled with GHC and which are not? Even if base "lives in the GHC tree", can't base be uploaded to hackage in a way that intentionally fails to install via cabal, with an informative message? That way, at least the haddocks can be available on hackage, and if we're lucky perhaps even the source. Thanks, Yitz From karl at karlv.net Sun Dec 28 18:46:00 2014 From: karl at karlv.net (Karl Voelker) Date: Sun, 28 Dec 2014 10:46:00 -0800 Subject: [Haskell-beginners] ghc prelude home In-Reply-To: References: <201412281449.sBSEnpbk007869@coolidge.cs.dartmouth.edu> <8761cvg17y.fsf@gmail.com> Message-ID: <1419792360.304034.207381885.45DCCAB6@webmail.messagingengine.com> On Sun, Dec 28, 2014, at 09:47 AM, Yitzchak Gale wrote: > Even if base "lives in the GHC tree", can't base be uploaded to > hackage in a way that intentionally fails to install via cabal, with > an informative message? That way, at least the haddocks can be > available on hackage, and if we're lucky perhaps even the source. It seems to me that it is already there: http://hackage.haskell.org/package/base It even has working source code links. Maybe I am completely missing the point of this discussion? -Karl From gale at sefer.org Sun Dec 28 19:15:56 2014 From: gale at sefer.org (Yitzchak Gale) Date: Sun, 28 Dec 2014 21:15:56 +0200 Subject: [Haskell-beginners] ghc prelude home In-Reply-To: <1419792360.304034.207381885.45DCCAB6@webmail.messagingengine.com> References: <201412281449.sBSEnpbk007869@coolidge.cs.dartmouth.edu> <8761cvg17y.fsf@gmail.com> <1419792360.304034.207381885.45DCCAB6@webmail.messagingengine.com> Message-ID: Doug McIlroy wrote: >>> Where can I find the full ghc prelude? >>> In the local installation I was able to find only .hi files, >>> not .hs. I wrote: >> Even if base "lives in the GHC tree", can't base be uploaded to >> hackage in a way that intentionally fails to install via cabal, with >> an informative message? That way, at least the haddocks can be >> available on hackage, and if we're lucky perhaps even the source. Karl Voelker wrote: > It seems to me that it is already there: > http://hackage.haskell.org/package/base > It even has working source code links. Well, that does answer Doug's original question. For now, if Doug is still using GHC 7.8.3. But the 7.10 series is out now, and it seems from what Ben and Brandon are saying that the practice of uploading GHC-bundled libraries such as base to hackage has now ended. From ben at smart-cactus.org Sun Dec 28 19:40:26 2014 From: ben at smart-cactus.org (Ben Gamari) Date: Sun, 28 Dec 2014 14:40:26 -0500 Subject: [Haskell-beginners] ghc prelude home In-Reply-To: References: <201412281449.sBSEnpbk007869@coolidge.cs.dartmouth.edu> <8761cvg17y.fsf@gmail.com> <1419792360.304034.207381885.45DCCAB6@webmail.messagingengine.com> Message-ID: <87387zftqt.fsf@gmail.com> Yitzchak Gale writes: > Doug McIlroy wrote: >>>> Where can I find the full ghc prelude? >>>> In the local installation I was able to find only .hi files, >>>> not .hs. > > I wrote: >>> Even if base "lives in the GHC tree", can't base be uploaded to >>> hackage in a way that intentionally fails to install via cabal, with >>> an informative message? That way, at least the haddocks can be >>> available on hackage, and if we're lucky perhaps even the source. > > Karl Voelker wrote: >> It seems to me that it is already there: >> http://hackage.haskell.org/package/base >> It even has working source code links. > > Well, that does answer Doug's original question. For now, > if Doug is still using GHC 7.8.3. But the 7.10 series is > out now, and it seems from what Ben and Brandon are > saying that the practice of uploading GHC-bundled > libraries such as base to hackage has now ended. > Well, I didn't mean to impl that. I just meant that source-wise base is certainly not a free-standing package (and hasn't been for some time). Despite this, there is no reason (that I know of) why the documentation couldn't be uploaded to Hackage. Cheers, - Ben -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 472 bytes Desc: not available URL: From aslatter at gmail.com Sun Dec 28 19:50:12 2014 From: aslatter at gmail.com (Antoine Latter) Date: Sun, 28 Dec 2014 19:50:12 +0000 Subject: [Haskell-beginners] ghc prelude home References: <201412281449.sBSEnpbk007869@coolidge.cs.dartmouth.edu> <8761cvg17y.fsf@gmail.com> <1419792360.304034.207381885.45DCCAB6@webmail.messagingengine.com> Message-ID: I don't think GHC 7.10 is out yet: https://www.haskell.org/ghc/download Although that page doesn't have 7.8.4 on it. -------------- next part -------------- An HTML attachment was scrubbed... URL: From gale at sefer.org Sun Dec 28 21:28:19 2014 From: gale at sefer.org (Yitzchak Gale) Date: Sun, 28 Dec 2014 23:28:19 +0200 Subject: [Haskell-beginners] ghc prelude home In-Reply-To: References: <201412281449.sBSEnpbk007869@coolidge.cs.dartmouth.edu> <8761cvg17y.fsf@gmail.com> <1419792360.304034.207381885.45DCCAB6@webmail.messagingengine.com> Message-ID: Yes, sorry, neither 7.8.4 nor 7.10.1 is actually out yet. They are both release candidates, and will be out soon. Thanks, Yitz On Sun, Dec 28, 2014 at 9:50 PM, Antoine Latter wrote: > I don't think GHC 7.10 is out yet: https://www.haskell.org/ghc/download > > Although that page doesn't have 7.8.4 on it. From Christian.Maeder at dfki.de Mon Dec 29 13:53:39 2014 From: Christian.Maeder at dfki.de (Christian Maeder) Date: Mon, 29 Dec 2014 14:53:39 +0100 Subject: [Haskell-beginners] ghc prelude home In-Reply-To: References: <201412281449.sBSEnpbk007869@coolidge.cs.dartmouth.edu> <8761cvg17y.fsf@gmail.com> <1419792360.304034.207381885.45DCCAB6@webmail.messagingengine.com> Message-ID: <54A15CE3.2070501@dfki.de> 23 December 2014 GHC 7.8.4 Released! https://www.haskell.org/ghc/ So 7.8.4 is out! Only the download subpage https://www.haskell.org/ghc/download is not updated yet. Also http://downloads.haskell.org/~ghc/latest/ still refers to http://downloads.haskell.org/~ghc/7.8.3/ (and has a funny 7.8.4 subdirectory). I send this also to glasgow-haskell-users to reach someone who can fix this. Cheers Christian Am 28.12.2014 um 22:28 schrieb Yitzchak Gale: > Yes, sorry, neither 7.8.4 nor 7.10.1 is actually out yet. > They are both release candidates, and will be out soon. > > Thanks, > Yitz > > On Sun, Dec 28, 2014 at 9:50 PM, Antoine Latter wrote: >> I don't think GHC 7.10 is out yet: https://www.haskell.org/ghc/download >> >> Although that page doesn't have 7.8.4 on it. > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://www.haskell.org/mailman/listinfo/beginners > From nicholls.mark at vimn.com Wed Dec 31 11:15:29 2014 From: nicholls.mark at vimn.com (Nicholls, Mark) Date: Wed, 31 Dec 2014 11:15:29 +0000 Subject: [Haskell-beginners] Long time no Haskell....simple typeclass question Message-ID: This is the basic problem... I have a data type, that has some functions that require typeclass constraints (this example doesn't...but that's not the point). I have a typeclass, and I want to declare my datatype inhabits that type class.... > data Func a b = Func (a->b) > exeFunc :: (Ord a) => Func a b -> a -> b > exeFunc (Func g) = g > class IFunc f where > exe :: f a b -> a -> b > instance IFunc Func where > exe = exeFunc Follow your nose and obviously "No instance for (Ord a) arising from a use of 'exeFunc'" But how do I constain "a" in the instance declaration, when "a" doesn't even appear CONFIDENTIALITY NOTICE This e-mail (and any attached files) is confidential and protected by copyright (and other intellectual property rights). If you are not the intended recipient please e-mail the sender and then delete the email and any attached files immediately. Any further use or dissemination is prohibited. While MTV Networks Europe has taken steps to ensure that this email and any attachments are virus free, it is your responsibility to ensure that this message and any attachments are virus free and do not affect your systems / data. Communicating by email is not 100% secure and carries risks such as delay, data corruption, non-delivery, wrongful interception and unauthorised amendment. If you communicate with us by e-mail, you acknowledge and assume these risks, and you agree to take appropriate measures to minimise these risks when e-mailing us. MTV Networks International, MTV Networks UK & Ireland, Greenhouse, Nickelodeon Viacom Consumer Products, VBSi, Viacom Brand Solutions International, Be Viacom, Viacom International Media Networks and VIMN and Comedy Central are all trading names of MTV Networks Europe. MTV Networks Europe is a partnership between MTV Networks Europe Inc. and Viacom Networks Europe Inc. Address for service in Great Britain is 17-29 Hawley Crescent, London, NW1 8TT. -------------- next part -------------- An HTML attachment was scrubbed... URL: From nicholls.mark at vimn.com Wed Dec 31 11:21:09 2014 From: nicholls.mark at vimn.com (Nicholls, Mark) Date: Wed, 31 Dec 2014 11:21:09 +0000 Subject: [Haskell-beginners] Long time no Haskell....simple typeclass question In-Reply-To: References: Message-ID: I can obviously follow Haskell's advice and go... > class IFunc f where > exe :: (Ord a) => f a b -> a -> b But that's not really what I want to say...that's constraining the class to make it clear that the type inhabits it...not constraining the instance. CONFIDENTIALITY NOTICE This e-mail (and any attached files) is confidential and protected by copyright (and other intellectual property rights). If you are not the intended recipient please e-mail the sender and then delete the email and any attached files immediately. Any further use or dissemination is prohibited. While MTV Networks Europe has taken steps to ensure that this email and any attachments are virus free, it is your responsibility to ensure that this message and any attachments are virus free and do not affect your systems / data. Communicating by email is not 100% secure and carries risks such as delay, data corruption, non-delivery, wrongful interception and unauthorised amendment. If you communicate with us by e-mail, you acknowledge and assume these risks, and you agree to take appropriate measures to minimise these risks when e-mailing us. MTV Networks International, MTV Networks UK & Ireland, Greenhouse, Nickelodeon Viacom Consumer Products, VBSi, Viacom Brand Solutions International, Be Viacom, Viacom International Media Networks and VIMN and Comedy Central are all trading names of MTV Networks Europe. MTV Networks Europe is a partnership between MTV Networks Europe Inc. and Viacom Networks Europe Inc. Address for service in Great Britain is 17-29 Hawley Crescent, London, NW1 8TT. -------------- next part -------------- An HTML attachment was scrubbed... URL: From nicholls.mark at vimn.com Wed Dec 31 13:26:03 2014 From: nicholls.mark at vimn.com (Nicholls, Mark) Date: Wed, 31 Dec 2014 13:26:03 +0000 Subject: [Haskell-beginners] Long time no Haskell....simple typeclass question In-Reply-To: References: Message-ID: Actually I can fix it by following the Haskell advice and reading http://blog.omega-prime.co.uk/?p=127 and turning on some extensions... Basically.... You DO follow Haskell's advice by amending the class declaration with a class content on the exe function, but you can let the instance declaration declare the constraint by.... turning the constraint into a type (ConstraintKinds) You then use type families (TypeFamilies) to calculate the constraint in the instance declaration. > {-# LANGUAGE TypeFamilies, ConstraintKinds #-} > import GHC.Prim > data Func a b = Func (a->b) > exeFunc :: (Ord a) => Func a b -> a -> b > exeFunc (Func g) = g > class IFunc f where > type ExeConstraint f a b :: Constraint > exe :: (ExeConstraint f a b) => f a b -> a -> b > instance IFunc Func where > type ExeConstraint Func a b = Ord a > exe = exeFunc As opposed to the instance declaration for the function type, which has no constraint > instance IFunc (->) where > type ExeConstraint (->) a b = () > exe f = f In some sense it still feels clumsy....with my F bounded OO type head on...which I'm told I must ignore....in something like C# this would be something like... interface IOrd {} interface IFunc { B Exe(A a); } class Fun : IFunc where A : IOrd { readonly Func f; public Fun(Func f) { this.f = f; } public B Exe(A a) { return this.f(a); } } i.e. here the IFunc declaration is closed...and blissfully unaware of any horrible constraints that need to be applied in order for the compiler to make the data type inhabit the type. If I want to make my typeclass definitions as closed in Haskell, it would seem that I would always have to declare them with indexed types as constraints? Or am I missing something? (I expect there is a reason, and I'm aware I'm comparing apple Haskell type(classe)s with orange C# types). CONFIDENTIALITY NOTICE This e-mail (and any attached files) is confidential and protected by copyright (and other intellectual property rights). If you are not the intended recipient please e-mail the sender and then delete the email and any attached files immediately. Any further use or dissemination is prohibited. While MTV Networks Europe has taken steps to ensure that this email and any attachments are virus free, it is your responsibility to ensure that this message and any attachments are virus free and do not affect your systems / data. Communicating by email is not 100% secure and carries risks such as delay, data corruption, non-delivery, wrongful interception and unauthorised amendment. If you communicate with us by e-mail, you acknowledge and assume these risks, and you agree to take appropriate measures to minimise these risks when e-mailing us. MTV Networks International, MTV Networks UK & Ireland, Greenhouse, Nickelodeon Viacom Consumer Products, VBSi, Viacom Brand Solutions International, Be Viacom, Viacom International Media Networks and VIMN and Comedy Central are all trading names of MTV Networks Europe. MTV Networks Europe is a partnership between MTV Networks Europe Inc. and Viacom Networks Europe Inc. Address for service in Great Britain is 17-29 Hawley Crescent, London, NW1 8TT.