From W.S.Swierstra at uu.nl Thu May 6 15:05:07 2021 From: W.S.Swierstra at uu.nl (Swierstra, W.S. (Wouter)) Date: Thu, 6 May 2021 15:05:07 +0000 Subject: [Haskell-beginners] (Online) Utrecht Summer School on Advanced functional programming Message-ID: <959d805c-b436-7357-4ba7-893788c394bb@uu.nl> SUMMER SCHOOL ON ADVANCED FUNCTIONAL PROGRAMMING Online - 05-9 July 2021 http://www.afp.school # Call for Participation ## About The Advanced Functional Programming summer school has been running for more than ten years. We aim to educate aspiring Haskell programmers beyond the basic material covered by many textbooks. This year the course will be offered *online only*. A typical day will consist a 2-3 hours of lectures, sandwiched between supervised lab sessions. Lectures will be held in the (European) afternoon, but recordings will be made available if attending live is problematic. The lectures will cover several more advanced topics regarding programming with types in Haskell, including topics such as: * monads and applicative functors; * lambda calculus; * generalized algebraic datatypes; * datatype generic programming * type families and type-level programming; ## Lecturers Utrecht staff: * Gabriele Keller * Trevor McDonell * Wouter Swierstra ## Prerequisites We expect students to have a basic familiarity with Haskell already. You should be able to write recursive functions over algebraic data types, such as lists and trees. There is a great deal of material readily available that covers this material. If you've already started learning Haskell and are looking to take your functional programming skills to the next level, this is the course for you. Soft registration deadline: 1 June, 2021 School: 05-09 July, 2021 ## Costs 50 euro - Registration fee We ask ask participants to pay a small registration fee to cover some of our organizational expenses. If this is problematic for you *for whatever reason*, please let us know and we can waive your registration fee. ## Further information Further information, including instructions on how to register, is available on our website: http://www.afp.school From joeking1809 at yahoo.com Sat May 8 09:39:50 2021 From: joeking1809 at yahoo.com (Joe King) Date: Sat, 8 May 2021 09:39:50 +0000 (UTC) Subject: [Haskell-beginners] Function to compute the mean References: <1095405637.961440.1620466790958.ref@mail.yahoo.com> Message-ID: <1095405637.961440.1620466790958@mail.yahoo.com> Greeetings I am new here and pretty new to Haskell. I was wondering what are the relative advanatges/disadvatnages of specifying a mean function in these two ways: mean :: [Double] -> Double mean xs = sum xs / fromIntegral (length xs) and mean1 :: (Real a, Fractional b) => [a] -> b mean1 xs = realToFrac (sum xs) / genericLength xs I understand that mean1 has the advantage that it can be called with lists of any Real type, so would work with things like  foo :: [Int] foo = [1,2,3] mean foo -- type mismatch error mean1 foo -- no error But suppose that I know I will only ever use lists of Double, is there still any advantage (or disadvantage of using mean1). For example is there any performance benefit by using mean in that case since mean1 has additional function evaluation.  Are there any other considerations ? Thanks in advance JK From tozkanli2023 at gmail.com Sat May 8 13:07:46 2021 From: tozkanli2023 at gmail.com (=?UTF-8?Q?Tarik_=C3=96ZKANLI?=) Date: Sat, 8 May 2021 16:07:46 +0300 Subject: [Haskell-beginners] Function to compute the mean In-Reply-To: <1095405637.961440.1620466790958@mail.yahoo.com> References: <1095405637.961440.1620466790958.ref@mail.yahoo.com> <1095405637.961440.1620466790958@mail.yahoo.com> Message-ID: Hello, In standard usage there is not much difference. But in Haskell, people prefer to write in curried form (first implementation of yours) which has the advantage of using partially applied form when suitable. Regards. Tarık Özkanlı On Sat, 8 May 2021 at 12:43, Joe King wrote: > Greeetings I am new here and pretty new to Haskell. > > I was wondering what are the relative advanatges/disadvatnages of > specifying a mean function in these two ways: > > mean :: [Double] -> Double > mean xs = sum xs / fromIntegral (length xs) > > and > > mean1 :: (Real a, Fractional b) => [a] -> b > mean1 xs = realToFrac (sum xs) / genericLength xs > > I understand that mean1 has the advantage that it can be called with lists > of any Real type, so would work with things like > > foo :: [Int] > foo = [1,2,3] > > mean foo > -- type mismatch error > > mean1 foo > -- no error > > But suppose that I know I will only ever use lists of Double, is there > still any advantage (or disadvantage of using mean1). For example is there > any performance benefit by using mean in that case since mean1 has > additional function evaluation. > > Are there any other considerations ? > > Thanks in advance > JK > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From tozkanli2023 at gmail.com Sat May 8 13:11:03 2021 From: tozkanli2023 at gmail.com (=?UTF-8?Q?Tarik_=C3=96ZKANLI?=) Date: Sat, 8 May 2021 16:11:03 +0300 Subject: [Haskell-beginners] Function to compute the mean In-Reply-To: References: <1095405637.961440.1620466790958.ref@mail.yahoo.com> <1095405637.961440.1620466790958@mail.yahoo.com> Message-ID: No sorry, Both are the same, Discard my previous mail Regards. Tarık On Sat, 8 May 2021 at 16:07, Tarik ÖZKANLI wrote: > Hello, > > In standard usage there is not much difference. But in Haskell, people > prefer to write in curried form (first implementation of yours) which has > the advantage of using partially applied form when suitable. > > Regards. > > Tarık Özkanlı > > > On Sat, 8 May 2021 at 12:43, Joe King wrote: > >> Greeetings I am new here and pretty new to Haskell. >> >> I was wondering what are the relative advanatges/disadvatnages of >> specifying a mean function in these two ways: >> >> mean :: [Double] -> Double >> mean xs = sum xs / fromIntegral (length xs) >> >> and >> >> mean1 :: (Real a, Fractional b) => [a] -> b >> mean1 xs = realToFrac (sum xs) / genericLength xs >> >> I understand that mean1 has the advantage that it can be called with >> lists of any Real type, so would work with things like >> >> foo :: [Int] >> foo = [1,2,3] >> >> mean foo >> -- type mismatch error >> >> mean1 foo >> -- no error >> >> But suppose that I know I will only ever use lists of Double, is there >> still any advantage (or disadvantage of using mean1). For example is there >> any performance benefit by using mean in that case since mean1 has >> additional function evaluation. >> >> Are there any other considerations ? >> >> Thanks in advance >> JK >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From joeking1809 at yahoo.com Sat May 8 19:33:33 2021 From: joeking1809 at yahoo.com (Joe King) Date: Sat, 8 May 2021 19:33:33 +0000 (UTC) Subject: [Haskell-beginners] Function to compute the mean In-Reply-To: References: <1095405637.961440.1620466790958.ref@mail.yahoo.com> <1095405637.961440.1620466790958@mail.yahoo.com> Message-ID: <1008186716.1134708.1620502413155@mail.yahoo.com> Thank Tarik > Both are the same, > Discard my previous mail  Bur surely they are not both the same, as I indicated in my initial email ? Is it not the case that mean1 is a parametrically polymorphic functiion, while mean is a simple function ?  My question is about the relative advantages and disadvantes of each Thanks again J On Saturday, May 8, 2021, 02:12:26 PM GMT+1, Tarik ÖZKANLI wrote: No sorry, Both are the same, Discard my previous mail  Regards. Tarık On Sat, 8 May 2021 at 16:07, Tarik ÖZKANLI wrote: > Hello, > > In standard usage there is not much difference. But in Haskell, people prefer to write in curried form (first implementation of yours) which has the advantage of using partially applied form when suitable. > > Regards. > > Tarık Özkanlı > > > On Sat, 8 May 2021 at 12:43, Joe King wrote: >> Greeetings I am new here and pretty new to Haskell. >> >> I was wondering what are the relative advanatges/disadvatnages of specifying a mean function in these two ways: >> >> mean :: [Double] -> Double >> mean xs = sum xs / fromIntegral (length xs) >> >> and >> >> mean1 :: (Real a, Fractional b) => [a] -> b >> mean1 xs = realToFrac (sum xs) / genericLength xs >> >> I understand that mean1 has the advantage that it can be called with lists of any Real type, so would work with things like  >> >> foo :: [Int] >> foo = [1,2,3] >> >> mean foo >> -- type mismatch error >> >> mean1 foo >> -- no error >> >> But suppose that I know I will only ever use lists of Double, is there still any advantage (or disadvantage of using mean1). For example is there any performance benefit by using mean in that case since mean1 has additional function evaluation.  >> >> Are there any other considerations ? >> >> Thanks in advance >> JK >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> > _______________________________________________ Beginners mailing list Beginners at haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners From tozkanli2023 at gmail.com Sun May 9 11:46:07 2021 From: tozkanli2023 at gmail.com (=?UTF-8?Q?Tarik_=C3=96ZKANLI?=) Date: Sun, 9 May 2021 14:46:07 +0300 Subject: [Haskell-beginners] Function to compute the mean In-Reply-To: <1008186716.1134708.1620502413155@mail.yahoo.com> References: <1095405637.961440.1620466790958.ref@mail.yahoo.com> <1095405637.961440.1620466790958@mail.yahoo.com> <1008186716.1134708.1620502413155@mail.yahoo.com> Message-ID: Hello Joe, I meant they are the same in the curried - not curried sense. I misinterpreted type constraints as actual inputs in tuple form. Otherwise they are different of course :) Although it depends on your specific requirements, the first one seems better for me. It also does not give type error with [Int] inputs. And It also has one less function call as you pointed hopefully more efficient (if we don't miss other considerations) Here is my little experiment with your mean function *but note that I let ghc infer the type for me so it has different type than yours *: *GHCi, version 9.0.1* *ghci> let mean xs = sum xs / fromIntegral(length xs)ghci> mean [2,3,5]3.3333333333333335ghci> :t meanmean :: (Fractional a, Foldable t) => t a -> a* *ghci> * Regards. Tarık On Sat, 8 May 2021 at 22:36, Joe King wrote: > Thank Tarik > > > Both are the same, > > Discard my previous mail > > Bur surely they are not both the same, as I indicated in my initial email ? > > Is it not the case that mean1 is a parametrically polymorphic functiion, > while mean is a simple function ? > > My question is about the relative advantages and disadvantes of each > > Thanks again > J > > > > > > > On Saturday, May 8, 2021, 02:12:26 PM GMT+1, Tarik ÖZKANLI < > tozkanli2023 at gmail.com> wrote: > > > > > > No sorry, > > Both are the same, > Discard my previous mail > > Regards. > > Tarık > > On Sat, 8 May 2021 at 16:07, Tarik ÖZKANLI wrote: > > Hello, > > > > In standard usage there is not much difference. But in Haskell, people > prefer to write in curried form (first implementation of yours) which has > the advantage of using partially applied form when suitable. > > > > Regards. > > > > Tarık Özkanlı > > > > > > On Sat, 8 May 2021 at 12:43, Joe King wrote: > >> Greeetings I am new here and pretty new to Haskell. > >> > >> I was wondering what are the relative advanatges/disadvatnages of > specifying a mean function in these two ways: > >> > >> mean :: [Double] -> Double > >> mean xs = sum xs / fromIntegral (length xs) > >> > >> and > >> > >> mean1 :: (Real a, Fractional b) => [a] -> b > >> mean1 xs = realToFrac (sum xs) / genericLength xs > >> > >> I understand that mean1 has the advantage that it can be called with > lists of any Real type, so would work with things like > >> > >> foo :: [Int] > >> foo = [1,2,3] > >> > >> mean foo > >> -- type mismatch error > >> > >> mean1 foo > >> -- no error > >> > >> But suppose that I know I will only ever use lists of Double, is there > still any advantage (or disadvantage of using mean1). For example is there > any performance benefit by using mean in that case since mean1 has > additional function evaluation. > >> > >> Are there any other considerations ? > >> > >> Thanks in advance > >> JK > >> _______________________________________________ > >> Beginners mailing list > >> Beginners at haskell.org > >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > >> > > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dj112358 at outlook.com Mon May 10 11:43:03 2021 From: dj112358 at outlook.com (David James) Date: Mon, 10 May 2021 11:43:03 +0000 Subject: [Haskell-beginners] Function to compute the mean In-Reply-To: <1095405637.961440.1620466790958@mail.yahoo.com> References: <1095405637.961440.1620466790958.ref@mail.yahoo.com>, <1095405637.961440.1620466790958@mail.yahoo.com> Message-ID: Hello – I wanted to add some comments. mean is as you describe. mean1 as defined can take a list of any Real type, and return any Fractional type. These types need not be the same, and it’s up to the *caller* of mean1 to say what types they want to give and get returned, e.g. the following is possible: > :m +Data.Ratio > :m +Data.Complex > mean1 [6%5, 2%3] :: Complex Double 0.9333333333333333 :+ 0.0 This may not be what you were expecting, and maybe you want something like this: mean2 :: (Fractional a) => [a] -> a mean2 xs = sum xs / genericLength xs (and note the realToFrac is then unces From: Beginners on behalf of Joe King Sent: Saturday, May 8, 2021 10:39:50 AM To: beginners at haskell.org Subject: [Haskell-beginners] Function to compute the mean Greeetings I am new here and pretty new to Haskell. I was wondering what are the relative advanatges/disadvatnages of specifying a mean function in these two ways: mean :: [Double] -> Double mean xs = sum xs / fromIntegral (length xs) and mean1 :: (Real a, Fractional b) => [a] -> b mean1 xs = realToFrac (sum xs) / genericLength xs I understand that mean1 has the advantage that it can be called with lists of any Real type, so would work with things like foo :: [Int] foo = [1,2,3] mean foo -- type mismatch error mean1 foo -- no error But suppose that I know I will only ever use lists of Double, is there still any advantage (or disadvantage of using mean1). For example is there any performance benefit by using mean in that case since mean1 has additional function evaluation. Are there any other considerations ? Thanks in advance JK _______________________________________________ Beginners mailing list Beginners at haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: C41BD4BD0CBD4F519B49D2A93C03CE4A.png Type: image/png Size: 144 bytes Desc: C41BD4BD0CBD4F519B49D2A93C03CE4A.png URL: From dj112358 at outlook.com Mon May 10 12:23:59 2021 From: dj112358 at outlook.com (David James) Date: Mon, 10 May 2021 12:23:59 +0000 Subject: [Haskell-beginners] Function to compute the mean In-Reply-To: References: <1095405637.961440.1620466790958.ref@mail.yahoo.com>, <1095405637.961440.1620466790958@mail.yahoo.com>, Message-ID: Ugh – sent too soon! Hello – I wanted to add some comments. mean is as you describe. mean1 as defined can take a list of any Real type, and return any Fractional type. These types need not be the same, and it’s up to the *caller* of mean1 to say what types they want to give and get returned, e.g. the following is possible: > :m +Data.Ratio > :m +Data.Complex > mean1 [6%5, 2%3] :: Complex Double 0.9333333333333333 :+ 0.0 This may not be what you were expecting? There’s also no need to restrict to Real, since it is valid to calculate the mean of a list of e.g. complex numbers. So maybe you want something like this: mean2 :: (Fractional a) => [a] -> a mean2 xs = sum xs / genericLength xs (the realToFrac is now unnecessary). The caller still decides the type, but the argument and result type now have to be the same. You can’t now do mean2 foo, but you can do mean2 [1,2,3] (and the 1, 2, 3 are interpreted as the default fractional type, probably Double). I personally prefer to write “utility” functions to be as generic as possible. (Imagine you’re including them in some standard library for the whole world to use). But I’m sure there are other opinions. Re performance, there is a comment against “genericLength” to say that it is not as efficient as length. And, as used above, this is the case. So maybe you actually want: mean3 :: (Fractional a) => [a] -> a mean3 xs = sum xs / fromIntegral (length xs) which is as efficient as mean. If you are especially interested in performance, you might want to read this. It’s not really “beginner level” but does look at some issues with mean in some detail (and in particular why it can use so much memory and what you can do about that). Performance of Haskell code is often more difficult to predict than for other languages, for example due to lazy evaluation and some amazing transformations of you code done by GHC. Incidentally, I am in the middle of drafting a page about numbers to include in the Haskell wikibook that might be interesting. It discusses types, classes, defaults numeric conversions, etc. I would be very happy if for any feedback (please leave any on the “Discussion” tab on the page). FYI: I tested performance (on GHC 8.4.3 on Windows) with this: {- compile: ghc -O2 -prof -fprof-auto -rtsopts Mean.hs run: Mean +RTS -p > nul -} module Main (main) where import Data.List mean :: [Double] -> Double mean xs = sum xs / fromIntegral (length xs) mean1 :: (Real a, Fractional b) => [a] -> b mean1 xs = realToFrac (sum xs) / genericLength xs mean2 :: (Fractional a) => [a] -> a mean2 xs = sum xs / genericLength xs mean3 :: (Fractional a) => [a] -> a mean3 xs = sum xs / fromIntegral (length xs) mean4 :: (Fractional a) => [a] -> a mean4 xs = sum xs / fromIntegral (genericLength xs :: Int) main :: IO () main = do let xs = [1 .. 10000000] :: [Double] --may default to Integer unless specified as Double. print $ mean xs --change to mean1, etc, for different runs And got: Total time Total alloc mean 0.10 1,680,096,640 bytes mean1 0.17 2,560,096,656 bytes mean2 0.17 2,560,096,656 bytes mean3 0.10 1,680,096,640 bytes mean4 0.10 1,680,096,640 bytes mean4 also uses genericLength but is as fast as length. This is due to some cleaverness in GHC, where it uses more efficient code when it knows the required result is integral. From: Beginners on behalf of Joe King Sent: Saturday, May 8, 2021 10:39:50 AM To: beginners at haskell.org Subject: [Haskell-beginners] Function to compute the mean Greeetings I am new here and pretty new to Haskell. I was wondering what are the relative advanatges/disadvatnages of specifying a mean function in these two ways: mean :: [Double] -> Double mean xs = sum xs / fromIntegral (length xs) and mean1 :: (Real a, Fractional b) => [a] -> b mean1 xs = realToFrac (sum xs) / genericLength xs I understand that mean1 has the advantage that it can be called with lists of any Real type, so would work with things like foo :: [Int] foo = [1,2,3] mean foo -- type mismatch error mean1 foo -- no error But suppose that I know I will only ever use lists of Double, is there still any advantage (or disadvantage of using mean1). For example is there any performance benefit by using mean in that case since mean1 has additional function evaluation. Are there any other considerations ? Thanks in advance JK _______________________________________________ Beginners mailing list Beginners at haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: C41BD4BD0CBD4F519B49D2A93C03CE4A.png Type: image/png Size: 144 bytes Desc: C41BD4BD0CBD4F519B49D2A93C03CE4A.png URL: From coot at coot.me Fri May 14 07:43:08 2021 From: coot at coot.me (coot at coot.me) Date: Fri, 14 May 2021 07:43:08 +0000 Subject: [Haskell-beginners] Function to compute the mean In-Reply-To: References: <1095405637.961440.1620466790958.ref@mail.yahoo.com> <1095405637.961440.1620466790958@mail.yahoo.com> Message-ID: If you want a much more performant solution, go around the list once. Another advantage is that it will run in constant memory. ``` -- requires BangPatterns extension; bonus questions: -- * Can you predict what will happen with out bang patterns? -- * Would `foldl'` work even without any bang patterns? mean5 :: [Double] -> Double mean5 = snd . foldl (\(!n, !r) a -> (n + 1, a / n + (n - 1) / n * r)) (1, 0) ``` `mean5` on my system reports: ```    1,840,101,632 bytes allocated in the heap          197,896 bytes copied during GC           44,408 bytes maximum residency (2 sample(s))           29,320 bytes maximum slop                2 MiB total memory in use (0 MB lost due to fragmentation)                                      Tot time (elapsed)  Avg pause  Max pause   Gen  0      1774 colls,     0 par    0.005s   0.006s     0.0000s    0.0000s   Gen  1         2 colls,     0 par    0.000s   0.000s     0.0001s    0.0001s   INIT    time    0.000s  (  0.000s elapsed)   MUT     time    0.236s  (  0.235s elapsed)   GC      time    0.005s  (  0.006s elapsed)   EXIT    time    0.000s  (  0.000s elapsed)   Total   time    0.241s  (  0.241s elapsed)   %GC     time       0.0%  (0.0% elapsed)   Alloc rate    7,803,840,935 bytes per MUT second   Productivity  97.9% of total user, 97.5% of total elapsed ``` while `mean` ```    1,280,101,688 bytes allocated in the heap    1,099,489,280 bytes copied during GC      294,937,752 bytes maximum residency (12 sample(s))       50,518,888 bytes maximum slop              670 MiB total memory in use (0 MB lost due to fragmentation)                                      Tot time (elapsed)  Avg pause  Max pause   Gen  0      1209 colls,     0 par    0.379s   0.381s     0.0003s    0.0012s   Gen  1        12 colls,     0 par    0.976s   0.976s     0.0813s    0.3921s   INIT    time    0.000s  (  0.000s elapsed)   MUT     time    0.324s  (  0.322s elapsed)   GC      time    1.355s  (  1.357s elapsed)   EXIT    time    0.000s  (  0.000s elapsed)   Total   time    1.679s  (  1.679s elapsed)   %GC     time       0.0%  (0.0% elapsed)   Alloc rate    3,956,490,811 bytes per MUT second   Productivity  19.3% of total user, 19.2% of total elapsed ``` I  compiled both with `ghc -O2 -rtsopts` and run them with `./Mean +RTS -s` (one does not nead to link the profiled RTS for `-s` to work). Cheers, Marcin Sent with ProtonMail Secure Email. ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Monday, May 10th, 2021 at 14:23, David James wrote: > Ugh – sent too soon! > > Hello – I wanted to add some comments. mean is as you describe. > > mean1 as defined can take a list of any Real type, and return any Fractional type. These types need not be the same, and it’s up to the *caller* of mean1 to say what types they want to give and get returned, e.g. the following is possible: > > > :m +Data.Ratio > > > :m +Data.Complex > > > mean1 [6%5, 2%3] :: Complex Double > > 0.9333333333333333 :+ 0.0 > > This may not be what you were expecting? There’s also no need to restrict to Real, since it is valid to calculate the mean of a list of e.g. complex numbers. So maybe you want something like this: > > mean2 :: (Fractional a) => [a] -> a > > mean2 xs = sum xs / genericLength xs > > (the realToFrac is now unnecessary). The caller still decides the type, but the argument and result type now have to be the same. > > You can’t now do mean2 foo, but you can do mean2 [1,2,3] (and the 1, 2, 3 are interpreted as the default fractional type, probably Double). > > I personally prefer to write “utility” functions to be as generic as possible. (Imagine you’re including them in some standard library for the whole world to use). But I’m sure there are other opinions. > > Re performance, there is a comment against “genericLength” to say that it is not as efficient as length. And, as used above, this is the case. So maybe you actually want: > > mean3 :: (Fractional a) => [a] -> a > > mean3 xs = sum xs / fromIntegral (length xs) > > which is as efficient as mean. > > If you are especially interested in performance, you might want to read this. It’s not really “beginner level” but does look at some issues with mean in some detail (and in particular why it can use so much memory and what you can do about that). Performance of Haskell code is often more difficult to predict than for other languages, for example due to lazy evaluation and some amazing transformations of you code done by GHC. > > Incidentally, I am in the middle of drafting a page about numbers to include in the Haskell wikibook that might be interesting. It discusses types, classes, defaults numeric conversions, etc. I would be very happy if for any feedback (please leave any on the “Discussion” tab on the page). > > FYI: I tested performance (on GHC 8.4.3 on Windows) with this: > > {- > > compile: ghc -O2 -prof -fprof-auto -rtsopts Mean.hs > > run: Mean +RTS -p     > nul > > -} > > module Main (main) where > > import Data.List > > mean :: [Double] -> Double > > mean xs = sum xs / fromIntegral (length xs) > > mean1 :: (Real a, Fractional b) => [a] -> b > > mean1 xs = realToFrac (sum xs) / genericLength xs > > mean2 :: (Fractional a) => [a] -> a > > mean2 xs = sum xs / genericLength xs > > mean3 :: (Fractional a) => [a] -> a > > mean3 xs = sum xs / fromIntegral (length xs) > > mean4 :: (Fractional a) => [a] -> a > > mean4 xs = sum xs / fromIntegral (genericLength xs :: Int) > > main :: IO () > > main = do > >   let xs = [1 .. 10000000] :: [Double] --may default to Integer unless specified as Double. > >   print $ mean xs                      --change to mean1, etc, for different runs > > And got: > > Total time > > Total alloc > > mean > > 0.10 > > 1,680,096,640 bytes > > mean1 > > 0.17 > > 2,560,096,656 bytes > > mean2 > > 0.17 > > 2,560,096,656 bytes > > mean3 > > 0.10 > > 1,680,096,640 bytes > > mean4 > > 0.10 > > 1,680,096,640 bytes > > mean4 also uses genericLength but is as fast as length. This is due to some cleaverness in GHC, where it uses more efficient code when it knows the required result is integral. > > [C41BD4BD0CBD4F519B49D2A93C03CE4A.png] > > From: Beginners on behalf of Joe King > > Sent: Saturday, May 8, 2021 10:39:50 AM > > To: beginners at haskell.org > > Subject: [Haskell-beginners] Function to compute the mean > > Greeetings I am new here and pretty new to Haskell. > > I was wondering what are the relative advanatges/disadvatnages of specifying a mean function in these two ways: > > mean :: [Double] -> Double > > mean xs = sum xs / fromIntegral (length xs) > > and > > mean1 :: (Real a, Fractional b) => [a] -> b > > mean1 xs = realToFrac (sum xs) / genericLength xs > > I understand that mean1 has the advantage that it can be called with lists of any Real type, so would work with things like  > > foo :: [Int] > > foo = [1,2,3] > > mean foo > > -- type mismatch error > > mean1 foo > > -- no error > > But suppose that I know I will only ever use lists of Double, is there still any advantage (or disadvantage of using mean1). For example is there any performance benefit by using mean in that case since mean1 has additional function evaluation.  > > Are there any other considerations ? > > Thanks in advance > > JK > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: C41BD4BD0CBD4F519B49D2A93C03CE4A.png Type: image/png Size: 144 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 509 bytes Desc: OpenPGP digital signature URL: From michael.eugene.turner at gmail.com Tue May 18 08:24:37 2021 From: michael.eugene.turner at gmail.com (Michael Turner) Date: Tue, 18 May 2021 17:24:37 +0900 Subject: [Haskell-beginners] Type inference or just ... a typo in a paper? Message-ID: I've inherited some Haskell code, which you can find here: http://web.cecs.pdx.edu/~mpj/pubs/aug.html The text of the accompanying paper says, "we extend the Text class..." -- but the identifier "Text" appears nowhere in the code. Is this just an error in the paper, or is the Text class getting involved in some indirect way, e.g. through String or perhaps because of the line "instance Show Tree where . . ."? Regards, Michael Turner Executive Director Project Persephone 1-25-33 Takadanobaba Shinjuku-ku Tokyo 169-0075 Mobile: +81 (90) 5203-8682 turner at projectpersephone.org Understand - http://www.projectpersephone.org/ Join - http://www.facebook.com/groups/ProjectPersephone/ Donate - http://www.patreon.com/ProjectPersephone Volunteer - https://github.com/ProjectPersephone "Love does not consist in gazing at each other, but in looking outward together in the same direction." -- Antoine de Saint-Exupéry From fa-ml at ariis.it Tue May 18 11:30:58 2021 From: fa-ml at ariis.it (Francesco Ariis) Date: Tue, 18 May 2021 13:30:58 +0200 Subject: [Haskell-beginners] Type inference or just ... a typo in a paper? In-Reply-To: References: Message-ID: <20210518113058.GB879@extensa> Hello Michael, Il 18 maggio 2021 alle 17:24 Michael Turner ha scritto: > I've inherited some Haskell code, which you can find here: > > http://web.cecs.pdx.edu/~mpj/pubs/aug.html > > The text of the accompanying paper says, "we extend the Text class..." > -- but the identifier "Text" appears nowhere in the code. Is this just > an error in the paper, or is the Text class getting involved in some > indirect way, e.g. through String or perhaps because of the line > "instance Show Tree where . . ."? In the updated source (`augupdated.hs`) that is missing, but in the /original/ one (`aug.hs`) I read at line 255 instance Text Tree where Which was then replaced with: instance Show Tree where in the updated version. Weird to know something like `Show` was not named like that in the early nineties! —F From michael.eugene.turner at gmail.com Wed May 19 11:21:06 2021 From: michael.eugene.turner at gmail.com (Michael Turner) Date: Wed, 19 May 2021 20:21:06 +0900 Subject: [Haskell-beginners] Beginners Digest, Vol 154, Issue 7 In-Reply-To: References: Message-ID: Ah, thank you. I just went with the more up-to-date version of the code, and didn't look at the original. Regards, Michael Turner Executive Director Project Persephone 1-25-33 Takadanobaba Shinjuku-ku Tokyo 169-0075 Mobile: +81 (90) 5203-8682 turner at projectpersephone.org Understand - http://www.projectpersephone.org/ Join - http://www.facebook.com/groups/ProjectPersephone/ Donate - http://www.patreon.com/ProjectPersephone Volunteer - https://github.com/ProjectPersephone "Love does not consist in gazing at each other, but in looking outward together in the same direction." -- Antoine de Saint-Exupéry On Tue, May 18, 2021 at 9:06 PM wrote: > > Send Beginners mailing list submissions to > beginners at haskell.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > or, via email, send a message with subject or body 'help' to > beginners-request at haskell.org > > You can reach the person managing the list at > beginners-owner at haskell.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Beginners digest..." > > > Today's Topics: > > 1. Type inference or just ... a typo in a paper? (Michael Turner) > 2. Re: Type inference or just ... a typo in a paper? > (Francesco Ariis) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Tue, 18 May 2021 17:24:37 +0900 > From: Michael Turner > To: beginners at haskell.org > Subject: [Haskell-beginners] Type inference or just ... a typo in a > paper? > Message-ID: > > Content-Type: text/plain; charset="UTF-8" > > I've inherited some Haskell code, which you can find here: > > http://web.cecs.pdx.edu/~mpj/pubs/aug.html > > The text of the accompanying paper says, "we extend the Text class..." > -- but the identifier "Text" appears nowhere in the code. Is this just > an error in the paper, or is the Text class getting involved in some > indirect way, e.g. through String or perhaps because of the line > "instance Show Tree where . . ."? > > > Regards, > Michael Turner > Executive Director > Project Persephone > 1-25-33 Takadanobaba > Shinjuku-ku Tokyo 169-0075 > Mobile: +81 (90) 5203-8682 > turner at projectpersephone.org > > Understand - http://www.projectpersephone.org/ > Join - http://www.facebook.com/groups/ProjectPersephone/ > Donate - http://www.patreon.com/ProjectPersephone > Volunteer - https://github.com/ProjectPersephone > > "Love does not consist in gazing at each other, but in looking outward > together in the same direction." -- Antoine de Saint-Exupéry > > > ------------------------------ > > Message: 2 > Date: Tue, 18 May 2021 13:30:58 +0200 > From: Francesco Ariis > To: beginners at haskell.org > Subject: Re: [Haskell-beginners] Type inference or just ... a typo in > a paper? > Message-ID: <20210518113058.GB879 at extensa> > Content-Type: text/plain; charset=utf-8 > > Hello Michael, > > Il 18 maggio 2021 alle 17:24 Michael Turner ha scritto: > > I've inherited some Haskell code, which you can find here: > > > > http://web.cecs.pdx.edu/~mpj/pubs/aug.html > > > > The text of the accompanying paper says, "we extend the Text class..." > > -- but the identifier "Text" appears nowhere in the code. Is this just > > an error in the paper, or is the Text class getting involved in some > > indirect way, e.g. through String or perhaps because of the line > > "instance Show Tree where . . ."? > > In the updated source (`augupdated.hs`) that is missing, but in the > /original/ one (`aug.hs`) I read at line 255 > > instance Text Tree where > > Which was then replaced with: > > instance Show Tree where > > in the updated version. > > Weird to know something like `Show` was not named like that in the early > nineties! > —F > > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > ------------------------------ > > End of Beginners Digest, Vol 154, Issue 7 > ***************************************** From michael.eugene.turner at gmail.com Wed May 19 12:10:50 2021 From: michael.eugene.turner at gmail.com (Michael Turner) Date: Wed, 19 May 2021 21:10:50 +0900 Subject: [Haskell-beginners] Getting debugging going in ghci -- is there no mercy? Message-ID: According to the Haskell wiki, "The trace function is located in the base package", which encouraged me to think it should just work by starting ghci. No such luck. So then I tried "stack gchi --package debug". No such luck. I added packages to stack.yaml as suggested. And here's where I am now. Of course, I'd like cookbook instructions, but I'm also including all this error output to give people an idea of how incredibly demoralizing the experience of being a newbie can be. As a newbie, it's easy to get confused about what Haskell is actually doing. So you'd naturally like a way to inspect intermediate results. Which means you'd like tracing and debugging. Why is it so hard to get there? ----------- C:\Users\Michael Turner\aug\aug.cabal was modified manually. Ignoring C:\Users\Michael Turner\aug\package.yaml in favor of the cabal file. If you want to use the package.yaml file instead of the cabal file, then please delete the cabal file. Using main module: 1. Package `aug' component aug:exe:aug-exe with main-is file: C:\Users\Michael Turner\aug\app\Main.hs WARNING: Ignoring transformers-compat's bounds on transformers (>=0.3 && ==0.2.*); using transformers-0.5.6.2. Reason: allow-newer enabled. Error: While constructing the build plan, the following exceptions were encountered: In the dependencies for Hoed-0.5.1: QuickCheck needed, but the stack configuration has no specified version (latest matching version is 2.14.2) cereal needed, but the stack configuration has no specified version (latest matching version is 0.5.8.1) cereal-text needed, but the stack configuration has no specified version (latest matching version is 0.1.0.2) cereal-vector needed, but the stack configuration has no specified version (latest matching version is 0.2.0.1) primitive needed, but the stack configuration has no specified version (latest matching version is 0.7.1.0) regex-tdfa needed, but the stack configuration has no specified version (latest matching version is 1.3.1.0) regex-tdfa-text needed, but the stack configuration has no specified version (latest matching version is 1.0.0.3) semigroups needed, but the stack configuration has no specified version (latest matching version is 0.19.1) strict needed, but the stack configuration has no specified version (latest matching version is 0.4.0.1) terminal-size needed, but the stack configuration has no specified version (latest matching version is 0.3.2.1) vector-th-unbox needed, but the stack configuration has no specified version (latest matching version is 0.2.1.9) needed due to debug-0.1.1 -> Hoed-0.5.1 In the dependencies for aeson-1.5.6.0: attoparsec must match >=0.13.2.2 && <0.15, but the stack configuration has no specified version (latest matching version is 0.14.1) base-compat-batteries must match >=0.10.0 && <0.12, but the stack configuration has no specified version (latest matching version is 0.11.2) data-fix must match >=0.3 && <0.4, but the stack configuration has no specified version (latest matching version is 0.3.1) dlist must match >=0.8.0.4 && <1.1, but the stack configuration has no specified version (latest matching version is 1.0) primitive must match >=0.7.0.1 && <0.8, but the stack configuration has no specified version (latest matching version is 0.7.1.0) scientific must match >=0.3.6.2 && <0.4, but the stack configuration has no specified version (latest matching version is 0.3.6.2) strict must match >=0.4 && <0.5, but the stack configuration has no specified version (latest matching version is 0.4.0.1) tagged must match >=0.8.6 && <0.9, but the stack configuration has no specified version (latest matching version is 0.8.6.1) th-abstraction must match >=0.2.8.0 && <0.5, but the stack configuration has no specified version (latest matching version is 0.4.2.0) these must match >=1.1 && <1.2, but the stack configuration has no specified version (latest matching version is 1.1.1.1) time-compat must match >=1.9.4 && <1.10, but the stack configuration has no specified version (latest matching version is 1.9.5) uuid-types must match >=1.0.3 && <1.1, but the stack configuration has no specified version (latest matching version is 1.0.5) needed due to debug-0.1.1 -> aeson-1.5.6.0 In the dependencies for libgraph-1.14: monads-tf needed, but the stack configuration has no specified version (latest matching version is 0.1.0.3) union-find must match >=0.2, but the stack configuration has no specified version (latest matching version is 0.2) needed due to debug-0.1.1 -> libgraph-1.14 In the dependencies for prettyprinter-compat-ansi-wl-pprint-1.0.1: prettyprinter-ansi-terminal must match >=1.1 && <1.2, but the stack configuration has no specified version (latest matching version is 1.1.2) needed due to debug-0.1.1 -> prettyprinter-compat-ansi-wl-pprint-1.0.1 In the dependencies for uniplate-1.6.13: syb needed, but the stack configuration has no specified version (latest matching version is 0.7.2.1) needed due to debug-0.1.1 -> uniplate-1.6.13 In the dependencies for vector-0.12.3.0: primitive must match >=0.6.4.0 && <0.8, but the stack configuration has no specified version (latest matching version is 0.7.1.0) needed due to debug-0.1.1 -> vector-0.12.3.0 In the dependencies for yaml-0.11.5.0: attoparsec must match >=0.11.3.0, but the stack configuration has no specified version (latest matching version is 0.14.1) conduit must match >=1.2.8 && <1.4, but the stack configuration has no specified version (latest matching version is 1.3.4.1) libyaml must match >=0.1 && <0.2, but the stack configuration has no specified version (latest matching version is 0.1.2) resourcet must match >=0.3 && <1.3, but the stack configuration has no specified version (latest matching version is 1.2.4.2) scientific must match >=0.3, but the stack configuration has no specified version (latest matching version is 0.3.6.2) needed due to debug-0.1.1 -> yaml-0.11.5.0 Some different approaches to resolving this: * Recommended action: try adding the following to your extra-deps in C:\Users\Michael Turner\aug\stack.yaml: - QuickCheck-2.14.2 at sha256:4ce29211223d5e6620ebceba34a3ca9ccf1c10c0cf387d48aea45599222ee5aa,7736 - attoparsec-0.14.1 at sha256:5a11f0339fb7e65429683e8a36d44adca3fd8cd40704525969c691e359c48fa0,5966 - base-compat-batteries-0.11.2 at sha256:eb3b976007754ddc16e8d4afacdd1e575ae746edb57dcd0a1a728ccd4b372a69,8804 - cereal-0.5.8.1 at sha256:37cb7a78c84412e94592a658768320c41f015f2b8707a433de835afb8ebc18d7,2767 - cereal-text-0.1.0.2 at sha256:dc10e00d9e5047d16a129682aac42c95da188d22e9f85856add051b9ace539c3,1349 - cereal-vector-0.2.0.1 at sha256:26d8e359f4c0de6dc06bf29f1cc2805847cdd8576d9f1598ecb263a1ca372bec,1116 - conduit-1.3.4.1 at sha256:eeabaf3f822e3e15317995766f50ef4a20371bdc3bb4721a7541e37228018dcf,5129 - data-fix-0.3.1 at sha256:7aee2c0633632479cef93c8000befd5bc950ba7c329d69e918ca520944164e27,1645 - dlist-1.0 at sha256:124cb3aa1decebd5171b46601b1f74cca6cfae12d266ace3799b86dd05ef7cb4,3560 - libyaml-0.1.2 at sha256:7f14f69ceb14659699974e8e47e1ea6f226ea21ff42a802db03e721c319d201d,2125 - monads-tf-0.1.0.3 at sha256:25b5d97af98adf7eca709c57f159c6c24c773cbb30e153abaeb156d81a451195,1427 - prettyprinter-ansi-terminal-1.1.2 at sha256:90b3b7650bc5b9f0e58da43621d23c817acfc0cf5ce71244b9bd11b8c9f95e3a,2653 - primitive-0.7.1.0 at sha256:29de6bfd0cf8ba023ceb806203dfbec0e51e3524e75ffe41056f70b4229c6f0f,2728 - regex-tdfa-1.3.1.0 at sha256:eb8d0f007cf45faca8574f56f0d19c9b02bc529ef1688d8f8a9751ce7dc36cc3,6483 - regex-tdfa-text-1.0.0.3 at sha256:fb72123627eadf43dd5ca74a2896940d50aac291e61f62177960f0563f7d5c03,1180 - resourcet-1.2.4.2 at sha256:d57516781d1721f70aa0b9ec8ea9200ab02bf76349cb76d73ad57729302289cc,1730 - scientific-0.3.6.2 at sha256:dd49abc76bd8e2b57e7a057dc2bb742a00527b4bf9350f9374be03b5934e55d8,4679 - semigroups-0.19.1 at sha256:ecae129621e0d2f77bef2f01e4458c2e0567ab6e1f39579c61d7cec8058ebb0e,6262 - strict-0.4.0.1 at sha256:08cf72ad570fddfe3b3424117bf20a303a1fb21047b40c1d6c8004c0e3e02a0b,4124 - syb-0.7.2.1 at sha256:bf42655a213402215299e435c52f799e76cbec0b984cd7153d6b9af8a1c0803f,3815 - tagged-0.8.6.1 at sha256:5ddf1e324c3cd644f097a48bf490f0bedf467f723fd240afb3ab3b750577f8e7,2874 - terminal-size-0.3.2.1 at sha256:7b2d8e0475a46961d07ddfb91dee618de70eff55d9ba0402ebeac1f9dcf9b18b,1259 - th-abstraction-0.4.2.0 at sha256:6ba7b201931f614173755f060fdf98f02095df68c1f7bc3e2691cf9d443e81f9,2194 - these-1.1.1.1 at sha256:e981c65228db5ae77a043631f74a1e4a4b770f7213866f584e3476b52512f1af,2631 - time-compat-1.9.5 at sha256:a586bd5a59b47ea0c9eafc55c6936ede11126f4a6e619d6d7aeefee73c43d9b8,4954 - union-find-0.2 at sha256:22e97cd9aeb8c96bf7cd8d359d4eda635dc0e0a6cd91b9a07e5a203b00949c8d,1232 - uuid-types-1.0.5 at sha256:5031383749d57cb95877d7e56f0300be66652b6e57f5ba6681dcc6e4f78d046d,2541 - vector-th-unbox-0.2.1.9 at sha256:5723d9c8a8a941dfeeb59dc42b84b924e4548ab6b5a4afe5b62b39f54667c2dd,1520 Error: Plan construction failed. Warning: Build failed, but trying to launch GHCi anyway The following GHC options are incompatible with GHCi and have not been passed to it: -threaded Configuring GHCi with the following packages: aug * * * * * * * * Warning: Multiple files use the same module name: * Paths_aug found at the following paths * C:\Users\Michael Turner\aug\.stack-work\dist\e626a42b\build\aug-exe\autogen\Paths_aug.hs (aug:exe:aug-exe) * C:\Users\Michael Turner\aug\.stack-work\dist\e626a42b\build\autogen\Paths_aug.hs (aug:lib) * * * * * * * * GHCi, version 8.6.5: http://www.haskell.org/ghc/ :? for help : cannot satisfy -package debug (use -v for more information) Regards, Michael Turner Executive Director Project Persephone 1-25-33 Takadanobaba Shinjuku-ku Tokyo 169-0075 Mobile: +81 (90) 5203-8682 turner at projectpersephone.org Understand - http://www.projectpersephone.org/ Join - http://www.facebook.com/groups/ProjectPersephone/ Donate - http://www.patreon.com/ProjectPersephone Volunteer - https://github.com/ProjectPersephone "Love does not consist in gazing at each other, but in looking outward together in the same direction." -- Antoine de Saint-Exupéry From fa-ml at ariis.it Wed May 19 12:34:28 2021 From: fa-ml at ariis.it (Francesco Ariis) Date: Wed, 19 May 2021 14:34:28 +0200 Subject: [Haskell-beginners] Getting debugging going in ghci -- is there no mercy? In-Reply-To: References: Message-ID: <20210519123428.GA29827@extensa> Il 19 maggio 2021 alle 21:10 Michael Turner ha scritto: > According to the Haskell wiki, "The trace function is located in the > base package", which encouraged me to think it should just work by > starting ghci. No such luck. So then I tried "stack gchi --package > debug". No such luck. I added packages to stack.yaml as suggested. And > here's where I am now. λ> :m +Debug.Trace λ> :t +d trace "prova" 234 trace "prova" 234 :: Integer λ> trace "prova" 234 prova 234 `debug` is an — excellent! — debug package by Neil Mitchell, but not related to `Debug.Trace`. From michael.eugene.turner at gmail.com Sat May 22 09:57:49 2021 From: michael.eugene.turner at gmail.com (Michael Turner) Date: Sat, 22 May 2021 18:57:49 +0900 Subject: [Haskell-beginners] Beginners Digest, Vol 154, Issue 9 In-Reply-To: References: Message-ID: That did work, thank you. I wish instructions in the wiki included examples. A lot of my struggles as a newbie are with (1) cabal+stack, trying to conform to ways of doing things to get effects (e.g., perfect reproducibility) I don't even care about right now, and (2) documentation that doesn't tell you much about how to make things work. Regards, Michael Turner Executive Director Project Persephone 1-25-33 Takadanobaba Shinjuku-ku Tokyo 169-0075 Mobile: +81 (90) 5203-8682 turner at projectpersephone.org Understand - http://www.projectpersephone.org/ Join - http://www.facebook.com/groups/ProjectPersephone/ Donate - http://www.patreon.com/ProjectPersephone Volunteer - https://github.com/ProjectPersephone "Love does not consist in gazing at each other, but in looking outward together in the same direction." -- Antoine de Saint-Exupéry On Thu, May 20, 2021 at 9:08 PM wrote: > > Send Beginners mailing list submissions to > beginners at haskell.org > > To subscribe or unsubscribe via the World Wide Web, visit > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > or, via email, send a message with subject or body 'help' to > beginners-request at haskell.org > > You can reach the person managing the list at > beginners-owner at haskell.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Beginners digest..." > > > Today's Topics: > > 1. Getting debugging going in ghci -- is there no mercy? > (Michael Turner) > 2. Re: Getting debugging going in ghci -- is there no mercy? > (Francesco Ariis) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Wed, 19 May 2021 21:10:50 +0900 > From: Michael Turner > To: beginners at haskell.org > Subject: [Haskell-beginners] Getting debugging going in ghci -- is > there no mercy? > Message-ID: > > Content-Type: text/plain; charset="UTF-8" > > According to the Haskell wiki, "The trace function is located in the > base package", which encouraged me to think it should just work by > starting ghci. No such luck. So then I tried "stack gchi --package > debug". No such luck. I added packages to stack.yaml as suggested. And > here's where I am now. > > Of course, I'd like cookbook instructions, but I'm also including all > this error output to give people an idea of how incredibly > demoralizing the experience of being a newbie can be. As a newbie, > it's easy to get confused about what Haskell is actually doing. So > you'd naturally like a way to inspect intermediate results. Which > means you'd like tracing and debugging. > > Why is it so hard to get there? > > ----------- > > > C:\Users\Michael Turner\aug\aug.cabal was modified manually. Ignoring > C:\Users\Michael Turner\aug\package.yaml in favor of the cabal file. > If you want to use the package.yaml file instead of the cabal file, > then please delete the cabal file. > > Using main module: 1. Package `aug' component aug:exe:aug-exe with > main-is file: C:\Users\Michael Turner\aug\app\Main.hs > WARNING: Ignoring transformers-compat's bounds on transformers (>=0.3 > && ==0.2.*); using transformers-0.5.6.2. > Reason: allow-newer enabled. > > Error: While constructing the build plan, the following exceptions were > encountered: > > In the dependencies for Hoed-0.5.1: > QuickCheck needed, but the stack configuration has no specified version > (latest matching version is 2.14.2) > cereal needed, but the stack configuration has no specified version (latest > matching version is 0.5.8.1) > cereal-text needed, but the stack configuration has no specified version > (latest matching version is 0.1.0.2) > cereal-vector needed, but the stack configuration has no specified version > (latest matching version is 0.2.0.1) > primitive needed, but the stack configuration has no specified version > (latest matching version is 0.7.1.0) > regex-tdfa needed, but the stack configuration has no specified version > (latest matching version is 1.3.1.0) > regex-tdfa-text needed, but the stack configuration has no specified version > (latest matching version is 1.0.0.3) > semigroups needed, but the stack configuration has no specified version > (latest matching version is 0.19.1) > strict needed, but the stack configuration has no specified version (latest > matching version is 0.4.0.1) > terminal-size needed, but the stack configuration has no specified version > (latest matching version is 0.3.2.1) > vector-th-unbox needed, but the stack configuration has no specified version > (latest matching version is 0.2.1.9) > needed due to debug-0.1.1 -> Hoed-0.5.1 > > In the dependencies for aeson-1.5.6.0: > attoparsec must match >=0.13.2.2 && <0.15, but the stack > configuration has no > specified version (latest matching version is 0.14.1) > base-compat-batteries must match >=0.10.0 && <0.12, but the stack > configuration has no specified version > (latest matching > version is 0.11.2) > data-fix must match >=0.3 && <0.4, but the stack configuration has no > specified version (latest matching version is 0.3.1) > dlist must match >=0.8.0.4 && <1.1, but the stack configuration has no > specified version (latest matching version is 1.0) > primitive must match >=0.7.0.1 && <0.8, but the stack configuration has no > specified version (latest matching version is 0.7.1.0) > scientific must match >=0.3.6.2 && <0.4, but the stack configuration has no > specified version (latest matching version is 0.3.6.2) > strict must match >=0.4 && <0.5, but the stack configuration has > no specified > version (latest matching version is 0.4.0.1) > tagged must match >=0.8.6 && <0.9, but the stack configuration has no > specified version (latest matching version is 0.8.6.1) > th-abstraction must match >=0.2.8.0 && <0.5, but the stack configuration has > no specified version (latest matching version is 0.4.2.0) > these must match >=1.1 && <1.2, but the stack configuration has no specified > version (latest matching version is 1.1.1.1) > time-compat must match >=1.9.4 && <1.10, but the stack configuration has no > specified version (latest matching version is 1.9.5) > uuid-types must match >=1.0.3 && <1.1, but the stack configuration has no > specified version (latest matching version is 1.0.5) > needed due to debug-0.1.1 -> aeson-1.5.6.0 > > In the dependencies for libgraph-1.14: > monads-tf needed, but the stack configuration has no specified version > (latest matching version is 0.1.0.3) > union-find must match >=0.2, but the stack configuration has no specified > version (latest matching version is 0.2) > needed due to debug-0.1.1 -> libgraph-1.14 > > In the dependencies for prettyprinter-compat-ansi-wl-pprint-1.0.1: > prettyprinter-ansi-terminal must match >=1.1 && <1.2, but the stack > configuration has no specified version (latest > matching version is 1.1.2) > needed due to debug-0.1.1 -> prettyprinter-compat-ansi-wl-pprint-1.0.1 > > In the dependencies for uniplate-1.6.13: > syb needed, but the stack configuration has no specified version (latest > matching version is 0.7.2.1) > needed due to debug-0.1.1 -> uniplate-1.6.13 > > In the dependencies for vector-0.12.3.0: > primitive must match >=0.6.4.0 && <0.8, but the stack configuration has no > specified version (latest matching version is 0.7.1.0) > needed due to debug-0.1.1 -> vector-0.12.3.0 > > In the dependencies for yaml-0.11.5.0: > attoparsec must match >=0.11.3.0, but the stack configuration has > no specified > version (latest matching version is 0.14.1) > conduit must match >=1.2.8 && <1.4, but the stack configuration has no > specified version (latest matching version is 1.3.4.1) > libyaml must match >=0.1 && <0.2, but the stack configuration has > no specified > version (latest matching version is 0.1.2) > resourcet must match >=0.3 && <1.3, but the stack configuration has no > specified version (latest matching version is 1.2.4.2) > scientific must match >=0.3, but the stack configuration has no specified > version (latest matching version is 0.3.6.2) > needed due to debug-0.1.1 -> yaml-0.11.5.0 > > Some different approaches to resolving this: > > * Recommended action: try adding the following to your extra-deps > in C:\Users\Michael Turner\aug\stack.yaml: > > - QuickCheck-2.14.2 at sha256:4ce29211223d5e6620ebceba34a3ca9ccf1c10c0cf387d48aea45599222ee5aa,7736 > - attoparsec-0.14.1 at sha256:5a11f0339fb7e65429683e8a36d44adca3fd8cd40704525969c691e359c48fa0,5966 > - base-compat-batteries-0.11.2 at sha256:eb3b976007754ddc16e8d4afacdd1e575ae746edb57dcd0a1a728ccd4b372a69,8804 > - cereal-0.5.8.1 at sha256:37cb7a78c84412e94592a658768320c41f015f2b8707a433de835afb8ebc18d7,2767 > - cereal-text-0.1.0.2 at sha256:dc10e00d9e5047d16a129682aac42c95da188d22e9f85856add051b9ace539c3,1349 > - cereal-vector-0.2.0.1 at sha256:26d8e359f4c0de6dc06bf29f1cc2805847cdd8576d9f1598ecb263a1ca372bec,1116 > - conduit-1.3.4.1 at sha256:eeabaf3f822e3e15317995766f50ef4a20371bdc3bb4721a7541e37228018dcf,5129 > - data-fix-0.3.1 at sha256:7aee2c0633632479cef93c8000befd5bc950ba7c329d69e918ca520944164e27,1645 > - dlist-1.0 at sha256:124cb3aa1decebd5171b46601b1f74cca6cfae12d266ace3799b86dd05ef7cb4,3560 > - libyaml-0.1.2 at sha256:7f14f69ceb14659699974e8e47e1ea6f226ea21ff42a802db03e721c319d201d,2125 > - monads-tf-0.1.0.3 at sha256:25b5d97af98adf7eca709c57f159c6c24c773cbb30e153abaeb156d81a451195,1427 > - prettyprinter-ansi-terminal-1.1.2 at sha256:90b3b7650bc5b9f0e58da43621d23c817acfc0cf5ce71244b9bd11b8c9f95e3a,2653 > - primitive-0.7.1.0 at sha256:29de6bfd0cf8ba023ceb806203dfbec0e51e3524e75ffe41056f70b4229c6f0f,2728 > - regex-tdfa-1.3.1.0 at sha256:eb8d0f007cf45faca8574f56f0d19c9b02bc529ef1688d8f8a9751ce7dc36cc3,6483 > - regex-tdfa-text-1.0.0.3 at sha256:fb72123627eadf43dd5ca74a2896940d50aac291e61f62177960f0563f7d5c03,1180 > - resourcet-1.2.4.2 at sha256:d57516781d1721f70aa0b9ec8ea9200ab02bf76349cb76d73ad57729302289cc,1730 > - scientific-0.3.6.2 at sha256:dd49abc76bd8e2b57e7a057dc2bb742a00527b4bf9350f9374be03b5934e55d8,4679 > - semigroups-0.19.1 at sha256:ecae129621e0d2f77bef2f01e4458c2e0567ab6e1f39579c61d7cec8058ebb0e,6262 > - strict-0.4.0.1 at sha256:08cf72ad570fddfe3b3424117bf20a303a1fb21047b40c1d6c8004c0e3e02a0b,4124 > - syb-0.7.2.1 at sha256:bf42655a213402215299e435c52f799e76cbec0b984cd7153d6b9af8a1c0803f,3815 > - tagged-0.8.6.1 at sha256:5ddf1e324c3cd644f097a48bf490f0bedf467f723fd240afb3ab3b750577f8e7,2874 > - terminal-size-0.3.2.1 at sha256:7b2d8e0475a46961d07ddfb91dee618de70eff55d9ba0402ebeac1f9dcf9b18b,1259 > - th-abstraction-0.4.2.0 at sha256:6ba7b201931f614173755f060fdf98f02095df68c1f7bc3e2691cf9d443e81f9,2194 > - these-1.1.1.1 at sha256:e981c65228db5ae77a043631f74a1e4a4b770f7213866f584e3476b52512f1af,2631 > - time-compat-1.9.5 at sha256:a586bd5a59b47ea0c9eafc55c6936ede11126f4a6e619d6d7aeefee73c43d9b8,4954 > - union-find-0.2 at sha256:22e97cd9aeb8c96bf7cd8d359d4eda635dc0e0a6cd91b9a07e5a203b00949c8d,1232 > - uuid-types-1.0.5 at sha256:5031383749d57cb95877d7e56f0300be66652b6e57f5ba6681dcc6e4f78d046d,2541 > - vector-th-unbox-0.2.1.9 at sha256:5723d9c8a8a941dfeeb59dc42b84b924e4548ab6b5a4afe5b62b39f54667c2dd,1520 > > > Error: Plan construction failed. > > Warning: Build failed, but trying to launch GHCi anyway > The following GHC options are incompatible with GHCi and have not been > passed to it: -threaded > Configuring GHCi with the following packages: aug > > * * * * * * * * > > Warning: Multiple files use the same module name: > * Paths_aug found at the following paths > * C:\Users\Michael > Turner\aug\.stack-work\dist\e626a42b\build\aug-exe\autogen\Paths_aug.hs > (aug:exe:aug-exe) > * C:\Users\Michael > Turner\aug\.stack-work\dist\e626a42b\build\autogen\Paths_aug.hs > (aug:lib) > * * * * * * * * > > GHCi, version 8.6.5: http://www.haskell.org/ghc/ :? for help > : cannot satisfy -package debug > (use -v for more information) > > > Regards, > Michael Turner > Executive Director > Project Persephone > 1-25-33 Takadanobaba > Shinjuku-ku Tokyo 169-0075 > Mobile: +81 (90) 5203-8682 > turner at projectpersephone.org > > Understand - http://www.projectpersephone.org/ > Join - http://www.facebook.com/groups/ProjectPersephone/ > Donate - http://www.patreon.com/ProjectPersephone > Volunteer - https://github.com/ProjectPersephone > > "Love does not consist in gazing at each other, but in looking outward > together in the same direction." -- Antoine de Saint-Exupéry > > > ------------------------------ > > Message: 2 > Date: Wed, 19 May 2021 14:34:28 +0200 > From: Francesco Ariis > To: beginners at haskell.org > Subject: Re: [Haskell-beginners] Getting debugging going in ghci -- is > there no mercy? > Message-ID: <20210519123428.GA29827 at extensa> > Content-Type: text/plain; charset=utf-8 > > Il 19 maggio 2021 alle 21:10 Michael Turner ha scritto: > > According to the Haskell wiki, "The trace function is located in the > > base package", which encouraged me to think it should just work by > > starting ghci. No such luck. So then I tried "stack gchi --package > > debug". No such luck. I added packages to stack.yaml as suggested. And > > here's where I am now. > > λ> :m +Debug.Trace > λ> :t +d trace "prova" 234 > trace "prova" 234 :: Integer > λ> trace "prova" 234 > prova > 234 > > `debug` is an — excellent! — debug package by Neil Mitchell, but > not related to `Debug.Trace`. > > > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > ------------------------------ > > End of Beginners Digest, Vol 154, Issue 9 > ***************************************** From develop7 at develop7.info Tue May 25 16:13:04 2021 From: develop7 at develop7.info (Andrei Dziahel) Date: Tue, 25 May 2021 18:13:04 +0200 Subject: [Haskell-beginners] (Online) Utrecht Summer School on Advanced functional programming In-Reply-To: <959d805c-b436-7357-4ba7-893788c394bb@uu.nl> References: <959d805c-b436-7357-4ba7-893788c394bb@uu.nl> Message-ID: Exciting initiative, looking forward to attend it. The afp.school site doesn't seem to mention the link to the course page itself which you'll need along the course of the application, so here it goes for everyone's convenience — https://www.utrechtsummerschool.nl/courses/science/applied-functional-programming-in-haskell On Thu, May 6, 2021 at 5:14 PM Swierstra, W.S. (Wouter) wrote: > > SUMMER SCHOOL ON ADVANCED FUNCTIONAL PROGRAMMING > > Online - 05-9 July 2021 > > http://www.afp.school > > # Call for Participation > > ## About > > The Advanced Functional Programming summer school has been running for > more than ten years. We aim to educate aspiring Haskell programmers > beyond the basic material covered by many textbooks. > > This year the course will be offered *online only*. A typical day will > consist a 2-3 hours of lectures, sandwiched between supervised lab > sessions. Lectures will be held in the (European) afternoon, but > recordings will be made available if attending live is problematic. > > The lectures will cover several more advanced topics regarding > programming with types in Haskell, including topics such as: > > * monads and applicative functors; > * lambda calculus; > * generalized algebraic datatypes; > * datatype generic programming > * type families and type-level programming; > > ## Lecturers > > Utrecht staff: > * Gabriele Keller > * Trevor McDonell > * Wouter Swierstra > > ## Prerequisites > > We expect students to have a basic familiarity with Haskell > already. You should be able to write recursive functions over > algebraic data types, such as lists and trees. There is a great deal > of material readily available that covers this material. If you've > already started learning Haskell and are looking to take your > functional programming skills to the next level, this is the course > for you. > > Soft registration deadline: 1 June, 2021 > School: 05-09 July, 2021 > > ## Costs > > 50 euro - Registration fee > > We ask ask participants to pay a small registration fee to cover some > of our organizational expenses. If this is problematic for you *for > whatever reason*, please let us know and we can waive your > registration fee. > > ## Further information > > Further information, including instructions on how to register, is > available on our website: > > http://www.afp.school > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners -- Regards, Andrei Dziahel From pengyu.ut at gmail.com Wed May 26 23:22:15 2021 From: pengyu.ut at gmail.com (Peng Yu) Date: Wed, 26 May 2021 18:22:15 -0500 Subject: [Haskell-beginners] How to show the help page of a function Message-ID: Hi, I want to check the help page of a function in haskell. For example, to check the help page of "many", could anybody help me know to get to its help page? Thanks. -- Regards, Peng From fa-ml at ariis.it Wed May 26 23:27:06 2021 From: fa-ml at ariis.it (Francesco Ariis) Date: Thu, 27 May 2021 01:27:06 +0200 Subject: [Haskell-beginners] How to show the help page of a function In-Reply-To: References: Message-ID: <20210526232706.GA24795@extensa> Hello Peng, Il 26 maggio 2021 alle 18:22 Peng Yu ha scritto: > I want to check the help page of a function in haskell. For example, > to check the help page of "many", could anybody help me know to get to > its help page? Thanks. A quick way to do it is :doc inside ghci, like λ> :doc head /O(1)/. Extract the first element of a list, which must be non-empty. If you prefer something in your web-browser, hoogle can help you https://hoogle.haskell.org/?hoogle=many&scope=set%3Astackage Does this help? —F From pengyu.ut at gmail.com Wed May 26 23:53:06 2021 From: pengyu.ut at gmail.com (Peng Yu) Date: Wed, 26 May 2021 18:53:06 -0500 Subject: [Haskell-beginners] How to show the help page of a function In-Reply-To: <20210526232706.GA24795@extensa> References: <20210526232706.GA24795@extensa> Message-ID: $ ghci GHCi, version 8.10.4: https://www.haskell.org/ghc/ :? for help Prelude> :doc many :1:1: error: Not in scope: ‘many’ Any way to automatically determine the module to load and load it automatically in the command line? On 5/26/21, Francesco Ariis wrote: > Hello Peng, > > Il 26 maggio 2021 alle 18:22 Peng Yu ha scritto: >> I want to check the help page of a function in haskell. For example, >> to check the help page of "many", could anybody help me know to get to >> its help page? Thanks. > > A quick way to do it is :doc inside ghci, like > > λ> :doc head > /O(1)/. Extract the first element of a list, which must be non-empty. > > If you prefer something in your web-browser, hoogle can help you > > https://hoogle.haskell.org/?hoogle=many&scope=set%3Astackage > > Does this help? > —F > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -- Regards, Peng From fa-ml at ariis.it Thu May 27 15:40:24 2021 From: fa-ml at ariis.it (Francesco Ariis) Date: Thu, 27 May 2021 17:40:24 +0200 Subject: [Haskell-beginners] How to show the help page of a function In-Reply-To: References: <20210526232706.GA24795@extensa> Message-ID: <20210527154024.GB27422@extensa> Il 26 maggio 2021 alle 18:53 Peng Yu ha scritto: > $ ghci > GHCi, version 8.10.4: https://www.haskell.org/ghc/ :? for help > Prelude> :doc many > > :1:1: error: Not in scope: ‘many’ > > Any way to automatically determine the module to load and load it > automatically in the command line? You might do this by installing Hoogle locally [1] [1] https://github.com/ndmitchell/hoogle/blob/master/docs/Install.md