From nowsnow at 163.com Thu Mar 19 11:36:50 2020 From: nowsnow at 163.com (nowsnow) Date: Thu, 19 Mar 2020 19:36:50 +0800 Subject: [Haskell-beginners] about "putStr" Message-ID: <20200319193644.F1B5.48398DBD@163.com> GHC 8.6.5 ===== import Data.Char main = do putStr "Give me some input: " l <- getLine putStrLn $ map toUpper l ====run==== my str Give me some input:MY STR ===not:=== Give me some input:my str MY STR -- nowsnow From a.vigneron at protonmail.com Thu Mar 19 11:48:51 2020 From: a.vigneron at protonmail.com (A. Vigneron) Date: Thu, 19 Mar 2020 11:48:51 +0000 Subject: [Haskell-beginners] about "putStr" In-Reply-To: <20200319193644.F1B5.48398DBD@163.com> References: <20200319193644.F1B5.48398DBD@163.com> Message-ID: Try adding hFlush stdout just after your putStr (import System.IO) -- Alex Sent with ProtonMail Secure Email. ‐‐‐‐‐‐‐ Original Message ‐‐‐‐‐‐‐ On Thursday, March 19, 2020 12:36 PM, nowsnow wrote: > GHC 8.6.5 > > ========== > > import Data.Char > > main = do > putStr "Give me some input: " > l <- getLine > putStrLn $ map toUpper l > ====run==== > my str > Give me some input:MY STR > > ===not:=== > Give me some input:my str > MY STR > > > ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- > > nowsnow nowsnow at 163.com > > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners From hongy19 at hongy19.net Sat Mar 21 01:36:00 2020 From: hongy19 at hongy19.net (Henry Yang) Date: Sat, 21 Mar 2020 01:36:00 +0000 (UTC) Subject: [Haskell-beginners] about "putStr" In-Reply-To: <20200319193644.F1B5.48398DBD@163.com> References: <20200319193644.F1B5.48398DBD@163.com> Message-ID: Try putStrLn or put "/n" at end of first putStr main = do putStrLn "Give me some input: " l <- getLine putStrLn $ map toUpper l Mar 19, 2020 7:37:15 PM nowsnow : > GHC 8.6.5 > ===== > import Data.Char > > main = do > putStr "Give me some input: " > l <- getLine > putStrLn $ map toUpper l > ====run==== > my str > Give me some input:MY STR > > ===not:=== > Give me some input:my str > MY STR > > > -- > nowsnow > > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > From doug at cs.dartmouth.edu Sat Mar 21 14:18:07 2020 From: doug at cs.dartmouth.edu (Doug McIlroy) Date: Sat, 21 Mar 2020 10:18:07 -0400 Subject: [Haskell-beginners] curious behavior of Haskell wiki Message-ID: <202003211418.02LEI70X108260@tahoe.cs.Dartmouth.EDU> Why does a search for "bitwise" in the Haskell wiki find an instance of "bitwise AND", whereas a search for "bitwise AND" or "bitwise and" (in quotes) finds nothing? Is this a bug or a (mis)feature? Doug McIlroy From borgauf at gmail.com Sun Mar 22 04:42:53 2020 From: borgauf at gmail.com (Lawrence Bottorff) Date: Sat, 21 Mar 2020 23:42:53 -0500 Subject: [Haskell-beginners] Different versions of ghci REPL in Emacs? Message-ID: I'm using Emacs (26.3) and org-mode (9.3.6) and I seem to have two different versions of ghci going, depending on whether I'm using haskell-mode alone with a *.hs file, or whether I am evaluating an org-mode babel code block. If I open, say, test.hs in Emacs, haskell-mode starts up. And if I choose from the menu, I get this "lambda prompt" REPL The next big Haskell project is about to start! If I break, you can: 1. Restart: M-x haskell-process-restart 2. Configure logging: C-h v haskell-process-log (useful for debugging) 3. General config: M-x customize-mode 4. Hide these tips: C-h v haskell-process-show-debug-tips λ> But if I call M-run-haskell, I get this "Prelude prompt" REPL Configuring GHCi with the following packages: GHCi, version 8.6.5: http://www.haskell.org/ghc/ :? for help Loaded GHCi configuration from /home/lawrence/.ghc/ghci.conf Prelude> Prelude> and this babel bit knows and interacts with it #+BEGIN_SRC haskell :results output :set +m doubleMe x = x + x doubleUs x y = doubleMe x + doubleMe y #+END_SRC but then trying to run this code block with lambda prompt REPL, I get the error executing Haskell code block... org-babel-execute:haskell: Buffer *haskell* does not exist or has no process even though the lambda REPL is called *haskell*. Why am I getting two separate REPLs? BTW, which IDE do Haskell big boys and girls use? LB -------------- next part -------------- An HTML attachment was scrubbed... URL: From doug at cs.dartmouth.edu Tue Mar 24 02:42:18 2020 From: doug at cs.dartmouth.edu (Doug McIlroy) Date: Mon, 23 Mar 2020 22:42:18 -0400 Subject: [Haskell-beginners] curious behavior of Haskell wiki Message-ID: <202003240242.02O2gIF8095160@tahoe.cs.Dartmouth.EDU> Yes, you repeated what I said. That search finds nothing. But it is wrong. A search for "bitwise" finds https://wiki.haskell.org/Ord_instance The context of "bitwise" on that page is "bitwise AND". My question remains. Date: Tue, 24 Mar 2020 01:33:48 +0100 From: "Henk-Jan van Tuyl" If you enter "bitwise AND" with the quotes, the wiki searches for these words next to each other; there is no page with such an occurrence. Regards, Henk-Jan van Tuyl On Sat, 21 Mar 2020 15:18:07 +0100, Doug McIlroy wrote: > Why does a search for "bitwise" in the Haskell wiki find > an instance of "bitwise AND", whereas a search for > "bitwise AND" or "bitwise and" (in quotes) finds nothing? > > Is this a bug or a (mis)feature? > > Doug McIlroy From ashelia1000 at gmail.com Tue Mar 24 15:06:03 2020 From: ashelia1000 at gmail.com (Max Gautier) Date: Tue, 24 Mar 2020 16:06:03 +0100 Subject: [Haskell-beginners] Factor out parsec types Message-ID: I'm writing a parser for polynomial equation (ex : 5 x ^2 + 3 x ^ 1 = 3 x ^ 2). I'm using parsec to decompose my parser into smaller parts, and it works, but all my parser functions have the type : parser :: Stream s m Char => ParsecT s u m Is there a way to factor out that boilerplate, in such a way that I could simply write a type like parser :: Parser ? The farther I've been is : type Parser s = ParsecT s () Identity type St = Stream s Identity Char (using ConstraintKinds) parser :: St s => Parser s But that still feels tedious to write every time... I've tried to search the wiki and the internet in general, but did not find an answer to that particularly. Thxs a lot if you have any hindsights. Max Gautier -------------- next part -------------- An HTML attachment was scrubbed... URL: From fa-ml at ariis.it Tue Mar 24 16:26:55 2020 From: fa-ml at ariis.it (Francesco Ariis) Date: Tue, 24 Mar 2020 17:26:55 +0100 Subject: [Haskell-beginners] Factor out parsec types In-Reply-To: References: Message-ID: <20200324162655.GA21197@aspire.station> Hello Max, On Tue, Mar 24, 2020 at 04:06:03PM +0100, Max Gautier wrote: > Is there a way to factor out that boilerplate, in such a way that I could > simply write a type like > parser :: Parser > ? > > The farther I've been is : > type Parser s = ParsecT s () Identity > type St = Stream s Identity Char (using ConstraintKinds) > parser :: St s => Parser s > > But that still feels tedious to write every time... Is there any reason you are using `St s => s ...` rather than a concrete type? If not, type MyPar a = ParsecT Char () Identity a p :: MyPar Int could be useful. Does that work for you? -F From ashelia1000 at gmail.com Tue Mar 24 17:08:42 2020 From: ashelia1000 at gmail.com (Max Gautier) Date: Tue, 24 Mar 2020 18:08:42 +0100 Subject: [Haskell-beginners] Fwd: Factor out parsec types In-Reply-To: <20200324162655.GA21197@aspire.station> References: <20200324162655.GA21197@aspire.station> Message-ID: Hi Francesco. If I understand correctly the parsec interface, leaving the stream type s as a type variable allows me to specify the concrete stream type at the time of use without changing the parser, as long as that stream gives Char tokens, is that correct ? And using a concrete stream type forfeit that, does'nt it ? (So for example in Quickcheck tests in can just use a String as my stream, and in other contexts something like Text). (I have not really experimented yet with the various "string" type, so maybe this is unnecessary (but in that case, what is the point of ParsecT exposing these type parameters ?)) The main purpose of my project is to learn Haskell, so I'm trying to understand the full power of the tools I use^ . From fa-ml at ariis.it Tue Mar 24 18:52:07 2020 From: fa-ml at ariis.it (Francesco Ariis) Date: Tue, 24 Mar 2020 19:52:07 +0100 Subject: [Haskell-beginners] Fwd: Factor out parsec types In-Reply-To: References: <20200324162655.GA21197@aspire.station> Message-ID: <20200324185207.GA24457@aspire.station> Before replying, my example should have of course been: type MyPar a = ParsecT String () Identity a On Tue, Mar 24, 2020 at 06:08:42PM +0100, Max Gautier wrote: > If I understand correctly the parsec interface, leaving the stream > type s as a type variable > allows me to specify the concrete stream type at the time of use > without changing the parser, > as long as that stream gives Char tokens, is that correct ? > And using a concrete stream type forfeit that, does'nt it ? Yes you do forfeit polymorphism using a concrete type. With your current synonym: type Parser s = ParsecT s () Identity you already missing polymorphism on state (`()`) and a monadic transformers (`Identity`). Parsec itself [1] uses a very similar shorthand type Parser = Parsec String () [1] https://hackage.haskell.org/package/parsec-3.1.14.0/docs/Text-Parsec-String.html I do not think there is a sensible way not to have the constraint part (`... =>`) written out in full.