From sylvain at haskus.fr Mon Apr 1 18:42:56 2019 From: sylvain at haskus.fr (Sylvain Henry) Date: Mon, 1 Apr 2019 20:42:56 +0200 Subject: [Haskell-beginners] Integrating external dependencies with stack In-Reply-To: References: Message-ID: Hi, There is no version 1.8.0 for curl on Hackage: https://hackage.haskell.org/package/curl If you want to use version 1.3.8 (the latest one), add an extra dep into "stack.yaml": extra-deps: - curl-1.3.8 You also have to add a dependency on "curl" into "package.yaml" (if you use hpack) or "yourpackage.cabal" (if you don't). Cheers, Sylvain On 31/03/2019 14:55, Noel Kwan wrote: > I am trying to use stack to build a web scraper with scalpel. However, > it requires curl-1.8.0 as a dependency and I have no clue how to > integrate this dependency. Any insight would be greatly appreciated. > > _______________________________________________ > 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 DekuDekuplex at Yahoo.com Tue Apr 2 05:32:39 2019 From: DekuDekuplex at Yahoo.com (Benjamin L. Russell) Date: Tue, 02 Apr 2019 14:32:39 +0900 Subject: [Haskell-beginners] ANN: Haskell Beginners PASHpost Community: "Haskell: The Haskell-Beginners Community" Message-ID: Since the Google+ social network service is scheduled to be "sunset" (i.e., put out of service) on April 2, 2019, I have created a new Haskell beginners PASHpost community, "Haskell: The Haskell-Beginners Community" (see https://pashpost.com/group/haskell-the-haskell-beginners-community), and migrated a substantial portion of the original posts thereto (sans posts with missing links or irrelevant content). Feel free to join and contribute! -- Benjamin L. Russell -- Benjamin L. Russell / DekuDekuplex at Yahoo dot com http://dekudekuplex.wordpress.com/ Computer Science Document Translator/Editor "Furuike ya, kawazu tobikomu mizu no oto." -- Matsuo Basho^ From stevix at zoho.com Tue Apr 2 19:56:57 2019 From: stevix at zoho.com (stevix at zoho.com) Date: Tue, 2 Apr 2019 12:56:57 -0700 Subject: [Haskell-beginners] How to use earlier ghc version with stack References: Message-ID: <0f587e54-1e09-441c-8f08-fb2fbed284df@Spark> I'm going through a book on Haskell that is based on a ghc version between 7.8 and 8.0 I created a new project using the default settings and have a much more recent version of ghc installed How to I fall back to an earlier version? Using haskell stack on manjaro linux Steve -------------- next part -------------- An HTML attachment was scrubbed... URL: From simon.jakobi at googlemail.com Tue Apr 2 20:28:22 2019 From: simon.jakobi at googlemail.com (Simon Jakobi) Date: Tue, 2 Apr 2019 22:28:22 +0200 Subject: [Haskell-beginners] How to use earlier ghc version with stack In-Reply-To: <0f587e54-1e09-441c-8f08-fb2fbed284df@Spark> References: <0f587e54-1e09-441c-8f08-fb2fbed284df@Spark> Message-ID: Hi Steve, on https://www.stackage.org/, at the bottom of the page, you can find Stackage LTS versions using older GHC versions. Pick one of those and update the resolver in your stack.yaml. E.g. resolver: lts-6.35 Hope that helps! Simon Am Di., 2. Apr. 2019 um 22:17 Uhr schrieb : > I'm going through a book on Haskell that is based on a ghc version between > 7.8 and 8.0 > > I created a new project using the default settings and have a much more > recent version of ghc installed > > How to I fall back to an earlier version? > > Using haskell stack on manjaro linux > > Steve > _______________________________________________ > 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 stevix at zoho.com Wed Apr 3 23:20:15 2019 From: stevix at zoho.com (stevix at zoho.com) Date: Wed, 3 Apr 2019 16:20:15 -0700 Subject: [Haskell-beginners] Beginners Digest, Vol 130, Issue 3 In-Reply-To: References: Message-ID: <020b09b2-76c9-47e7-bece-d5ab3ab8e428@Spark> Thank you, Simon. That worked Steve On Apr 3, 2019, 05:50 -0700, beginners-request at haskell.org, 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. How to use earlier ghc version with stack (stevix at zoho.com) > 2. Re: How to use earlier ghc version with stack (Simon Jakobi) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Tue, 2 Apr 2019 12:56:57 -0700 > From: stevix at zoho.com > To: beginners at haskell.org > Subject: [Haskell-beginners] How to use earlier ghc version with stack > Message-ID: <0f587e54-1e09-441c-8f08-fb2fbed284df at Spark> > Content-Type: text/plain; charset="utf-8" > > I'm going through a book on Haskell that is based on a ghc version between 7.8 and 8.0 > > I created a new project using the default settings and have a much more recent version of ghc installed > > How to I fall back to an earlier version? > > Using haskell stack on manjaro linux > > Steve > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Message: 2 > Date: Tue, 2 Apr 2019 22:28:22 +0200 > From: Simon Jakobi > To: The Haskell-Beginners Mailing List - Discussion of primarily > beginner-level topics related to Haskell > Subject: Re: [Haskell-beginners] How to use earlier ghc version with > stack > Message-ID: > > Content-Type: text/plain; charset="utf-8" > > Hi Steve, > > on https://www.stackage.org/, at the bottom of the page, you can find > Stackage LTS versions using older GHC versions. Pick one of those and > update the resolver in your stack.yaml. E.g. > > resolver: lts-6.35 > > Hope that helps! > Simon > > Am Di., 2. Apr. 2019 um 22:17 Uhr schrieb : > > > I'm going through a book on Haskell that is based on a ghc version between > > 7.8 and 8.0 > > > > I created a new project using the default settings and have a much more > > recent version of ghc installed > > > > How to I fall back to an earlier version? > > > > Using haskell stack on manjaro linux > > > > Steve > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > ------------------------------ > > End of Beginners Digest, Vol 130, Issue 3 > ***************************************** -------------- next part -------------- An HTML attachment was scrubbed... URL: From guy-laurent at subri.ch Thu Apr 11 12:51:49 2019 From: guy-laurent at subri.ch (Guy-Laurent Subri) Date: Thu, 11 Apr 2019 14:51:49 +0200 Subject: [Haskell-beginners] Newtype, Data.Text and instance declarations... Message-ID: <155498710941.10670.4303100488048989055@lennie> Hi all, There are a few things that I don't understand involving Data.Text and instance declarations... I'm building a small web app to practise Haskell and am using the SQLite.Simple library. I have defined a few types and functions like so: ''' data BookmarkDB = BookmarkDB Connection Table newtype Table = Table Text instance ToField Table where toField = SQLText initDB :: FilePath -> Table -> IO BookmarkDB initDB fp table = do let query = Query ("CREATE TABLE IF NOT EXISTS :table " <> " (url TEXT, tags TEXT, date INTEGER)") conn <- open fp executeNamed conn query [":table" := table] return $ BookmarkDB conn table ''' 1. My first question is about the instance declaration. Why would ''' instance ToField Table where toField = SQLText ''' return this error ? ''' Couldn't match type ‘Table’ with ‘Text’ Expected type: Table -> SQLData Actual type: Text -> SQLData • In the expression: SQLText In an equation for ‘toField’: toField = SQLText In the instance declaration for ‘ToField Table’ ''' I've noticed that if I write ''' instance ToField Table where toField (Table t) = SQLText t ''' I have no error and it compiles. I don't get it, what is 'toField' supposed to receive except a Table? 2. My second question is concerning the initDB function. If I write it that way, the code compiles, but I get an error during execution: bkmrk: SQLite3 returned ErrorError while attempting to perform prepare "CREATE TABLE IF NOT EXISTS :table (url TEXT, tags TEXT, date INTEGER)": near ":table": syntax error I don't understand what is wrong with the code and I doubt that my query is wrong because everything works with the last code snippet I wrote (see question #3). 3. Trying to get around the error I've noticed a few things. If I try to write this instead: ''' initDB :: FilePath -> Table -> IO BookmarkDB initDB fp table = do let query = Query ("CREATE TABLE IF NOT EXISTS " <> table <> " (url TEXT, tags TEXT, date INTEGER)") conn <- open fp execute_ conn query return $ BookmarkDB conn table ''' it doesn't compile because table is of type Table and not Data.Text.Internal.Text, which I get, but I don't know what is the Haskell way of resolving this. I've also noticed that this will help: ''' initDB :: FilePath -> Table -> IO BookmarkDB initDB fp t@(Table table) = do let query = Query ("CREATE TABLE IF NOT EXISTS " <> table <> " (url TEXT, tags TEXT, date INTEGER)") conn <- open fp execute_ conn query return $ BookmarkDB conn t ''' But I *really* don't get why! The most confusing part for me is that the last initDB function will do exactly what I want it to do, but I am unable to understand why it works...Why am I able to concatenate the 'table' now and not before and why is 't' of a different type than 'table'? All of this is very confusing and I find myself unable to reason about it. Sorry if this is a big/messy question. I hope everything is clear enough to answer... Thank you all! From bdezonia at gmail.com Mon Apr 22 21:25:47 2019 From: bdezonia at gmail.com (Barry DeZonia) Date: Mon, 22 Apr 2019 16:25:47 -0500 Subject: [Haskell-beginners] multidimensional data Message-ID: I've played with Haskell on and off for a number of years. I have a question that isn't directly related to Haskell only but to functional programming. Sorry if this is off topic. In Haskell, how would you represent a 5 dimensional data structure of numeric values? Imagine a dataset with axes x, y, z, channel, and time. Is there an easy way to represent this in the data that doesn't run into all kinds of memory limits? How would you map the data to a new state such that the new state had pixel (1000, 2000, 100, 1, 20) set to 53? Thanks for any info. -------------- next part -------------- An HTML attachment was scrubbed... URL: From fa-ml at ariis.it Mon Apr 22 21:47:18 2019 From: fa-ml at ariis.it (Francesco Ariis) Date: Mon, 22 Apr 2019 23:47:18 +0200 Subject: [Haskell-beginners] multidimensional data In-Reply-To: References: Message-ID: <20190422214718.dhkelmlvziijtvcr@x60s.casa> Hello Barry, On Mon, Apr 22, 2019 at 04:25:47PM -0500, Barry DeZonia wrote: > In Haskell, how would you represent a 5 dimensional data structure of > numeric values? Imagine a dataset with axes x, y, z, channel, and time. Is > there an easy way to represent this in the data that doesn't run into all > kinds of memory limits? How would you map the data to a new state such that > the new state had pixel (1000, 2000, 100, 1, 20) set to 53? Maybe a HashMap[1] or similar structure? [1] http://hackage.haskell.org/package/unordered-containers-0.2.10.0 From agander at gmail.com Tue Apr 23 04:54:53 2019 From: agander at gmail.com (agander) Date: Tue, 23 Apr 2019 06:54:53 +0200 Subject: [Haskell-beginners] multidimensional data In-Reply-To: References: Message-ID: On Monday, 22 April 2019, Barry DeZonia wrote: > I've played with Haskell on and off for a number of years. I have a > question that isn't directly related to Haskell only but to functional > programming. Sorry if this is off topic. > > In Haskell, how would you represent a 5 dimensional data structure of > numeric values? Imagine a dataset with axes x, y, z, channel, and time. Is > there an easy way to represent this in the data that doesn't run into all > kinds of memory limits? How would you map the data to a new state such that > the new state had pixel (1000, 2000, 100, 1, 20) set to 53? > Maybe a lens [1] [1] http://hackage.haskell.org/package/lens-tutorial-1.0. 3/docs/Control-Lens-Tutorial.html -------------- next part -------------- An HTML attachment was scrubbed... URL: From Leonhard.Applis at protonmail.com Tue Apr 23 14:55:22 2019 From: Leonhard.Applis at protonmail.com (Leonhard Applis) Date: Tue, 23 Apr 2019 14:55:22 +0000 Subject: [Haskell-beginners] IO Control Structures Message-ID: Hey there, I am writing a simple game and the only missing part is IO (Sadly, i need that to play). I've got most things pure, e.g. makeMove :: GameState -> Move -> GameState, initialBoard:: GameState and lost :: GameState -> Bool work pure and as intended. I also got a function gameLoop :: GameState -> IO GameState which asks for Input and applies it. I don`t know how to do my main :: IO () which should welcome the player, start the gameloop, and print godbyes the game if it's either won or lost Here i am missing a control structure, to demonstrate: show hello board = initialBoard while (not end board) board = gameLoop board show winner I could also make my Gameloop recursive, while i think that i get this working, it seems awfully complex (and ugly) to me. Best regards Leonhard -------------- next part -------------- An HTML attachment was scrubbed... URL: From fa-ml at ariis.it Tue Apr 23 15:32:58 2019 From: fa-ml at ariis.it (Francesco Ariis) Date: Tue, 23 Apr 2019 17:32:58 +0200 Subject: [Haskell-beginners] IO Control Structures In-Reply-To: References: Message-ID: <20190423153258.bsnjkvjfwdpvd3l7@x60s.casa> Hello Leonhard, On Tue, Apr 23, 2019 at 02:55:22PM +0000, Leonhard Applis wrote: > I don`t know how to do my main :: IO () > which should welcome the player, start the gameloop, and print godbyes the game if it's either won or lost > Here i am missing a control structure, to demonstrate: > > show hello > board = initialBoard > while (not end board) > board = gameLoop board > show winner > > I could also make my Gameloop recursive, while i think that i get this working, it seems awfully complex (and ugly) to me. Indeed making gameLoop recursive is the (a) solution. As now `gameLoop` isn't much of a loop, is it? If gameLoop has a signature like this: gameLoop :: GameState -> -- Initial State (IO Move) -> -- Input function (State -> Move -> State) -> -- Logic function (State -> IO ()) -> -- Blit function (State -> Bool) -> -- "Should I quit?" function IO () then main is trivial to write: main = do show hello board = initialBoard gameLoop board someInputFun makeMove drawState isOver show ciao From kothariyugesh at gmail.com Sat Apr 27 14:31:18 2019 From: kothariyugesh at gmail.com (Yugesh Kothari) Date: Sat, 27 Apr 2019 20:01:18 +0530 Subject: [Haskell-beginners] Pattern Matching Message-ID: This is probably a stupid question but I can't seem to understand the use of @ in haskell pattern matching. Ex - compress (x:ys@(y:_)) | x==y = compress us | otherwise = x : compress us compress us = us Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: From bob at redivi.com Sat Apr 27 15:24:07 2019 From: bob at redivi.com (Bob Ippolito) Date: Sat, 27 Apr 2019 08:24:07 -0700 Subject: [Haskell-beginners] Pattern Matching In-Reply-To: References: Message-ID: That’s called an as-pattern. It binds part of the pattern match to a variable. In this case you might want to do that for efficiency reasons. You can find an example of them here: https://www.haskell.org/tutorial/patterns.html I think your example isn’t correct, the `us` variable is only defined for the last clause. The first two should use `compress ys`. Without as-patterns this would look like: compress (x:y:ys’) | x==y = compress (y:ys’) | otherwise = x : compress (y:ys’) compress us = us It can be more efficient and concise to use ys@(y:_) in the pattern match and ys elsewhere instead of having to repeat (y:ys’) which without optimizations would call the : constructor again and may not share memory in the same way. -bob On Sat, Apr 27, 2019 at 07:31 Yugesh Kothari wrote: > This is probably a stupid question but I can't seem to understand the use > of @ in haskell pattern matching. > > Ex - > compress (x:ys@(y:_)) > | x==y = compress us > | otherwise = x : compress us > compress us = us > > Thanks! > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > -------------- next part -------------- An HTML attachment was scrubbed... URL: