From mike_k_houghton at yahoo.co.uk Sat May 5 16:50:14 2018 From: mike_k_houghton at yahoo.co.uk (mike h) Date: Sat, 5 May 2018 17:50:14 +0100 Subject: [Haskell-beginners] Graph path Message-ID: Does anyone know of a good description of the algorithm to visit (if possible) each node in a graph? I can find a few links that describe the imperative way of doing it but I struggle converting to functional style :) Many Thanks Mike From hjgtuyl at chello.nl Wed May 9 18:46:09 2018 From: hjgtuyl at chello.nl (Henk-Jan van Tuyl) Date: Wed, 09 May 2018 20:46:09 +0200 Subject: [Haskell-beginners] Graph path In-Reply-To: References: Message-ID: Maybe Structuring Depth-First Search Algorithms in Haskell https://galois.com/wp-content/uploads/2014/08/pub_JL_StructuringDFSAlgorithms.pdf can be of any help? (It's not my field of expertise.) Since you haven't received any answer for several days on this mailing list, you might ask this question again on the Haskell Café mailing list, there are more people reading that list. Regards, Henk-Jan van Tuyl On Sat, 05 May 2018 18:50:14 +0200, mike h wrote: > Does anyone know of a good description of the algorithm to visit (if > possible) each node in a graph? I can find a few links that describe the > imperative way of doing it but I struggle converting to functional style -- Message from Stanford University: Folding at home What if you could share your unused computer power to help find a cure? In just 5 minutes you can join the world's biggest networked computer and get us closer sooner. Watch the video. http://foldingathome.stanford.edu/ -- http://members.chello.nl/hjgtuyl/tourdemonad.html Haskell programming -- From 50295 at web.de Thu May 10 00:24:31 2018 From: 50295 at web.de (Olumide) Date: Thu, 10 May 2018 01:24:31 +0100 Subject: [Haskell-beginners] Join'ing a State Monad, example from LYH In-Reply-To: <20180210152540.llwsh53dgobkw3i7@x60s.casa> References: <20180210152540.llwsh53dgobkw3i7@x60s.casa> Message-ID: <9df7028e-4ca8-3c32-15fd-2ccce66e32fc@web.de> Francesco, Your explantion makes sense but in a very general way that still left me trying, and failing, explain why the result of runState (join (State $ \s -> (push 10,1:2:s))) [0,0,0] is ((),[10,1,2,0,0,0]). After so many months of thinking I think I now do. Here's my reasoning, please correct me if I am wrong. I'm sure my explanation is far from precise even if the jist of it is correct, so I'd appreciate corrections about that too. As you said join mm = mm >>= \m -> m. \m -> m looks like the identify function, so that join x = x >>= id, (from Haskell Wikibooks). Considering the definition of the State monad bind (State h) >>= f = State $ \s -> let (a, newState) = h s (State g) = f a in g newState where h is \s -> (push 10,1:2:s), h s = (push 10,1:2:s) where a = push 10 and newState = 1:2:s Also f = id, so that f a = push 10 = State $ \xs -> ((),10:xs), where g = \xs -> ((),10:xs) Finally, g newState = ((),10:1:2:s) So that, join (State $ \s -> (push 10,1:2:s) = state \s -> ((),10:1:2:s) Finally runState( state \s -> ((),10:1:2:s) ) [0,0,0] = (\s -> ((),10:1:2:s) ) [0,0,0] = ((),10,1,2,0,0,0) Regards, - Olumide On 10/02/18 15:25, Francesco Ariis wrote: > On Sat, Feb 10, 2018 at 02:48:07PM +0000, Olumide wrote: >> I find the following implementation of join in the text is hard to >> understand or apply >> >> join :: (Monad m) => m (m a) -> m a >> join mm = do >> m <- mm >> m > > Hello Olumide, > > remember that: > > join :: (Monad m) => m (m a) -> m a > join mm = do m <- mm > m > > is the same as: > > join :: (Monad m) => m (m a) -> m a > join mm = mm >>= \m -> > m > > In general remember that when you have a "plain" value, the last line > of a monadic expression is often: > > return someSimpleVal > > So: > > monadicexpr = do x <- [4] > return x -- can't just write `x` > > When you have a monad inside a monad, you can just "peel" the outer > layer and live happily thereafter: > > > monadicexpr = do x <- [[4]] > x -- result will be: [4], no need to use return > -- because [4] (and not 4) is still a > -- list monad > > As for State, remember that State is: > > data State s a = State $ s -> (a, s) -- almost > > So a function that from a state s, calculates a new state s' and returns > a value of type `a`. > When we use the bind operator in a do block, it's like we're extracting > that value of type `a` > > monadicexpr = do x <- someState > return x -- again we need to wrap this value > -- before returning it, this state being > -- > -- \s -> (x, s) > -- > -- i.e. we do nothing to the parameter state > -- and place `x` as a result. > -- > > Same trick there, if `x` is actually a State-inside-State (e.g. of > type `State s (State s a)`), there is no need for wrapping anymore. > > Does this make sense? > -F > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > From guthrie at mum.edu Thu May 10 16:24:08 2018 From: guthrie at mum.edu (Gregory Guthrie) Date: Thu, 10 May 2018 16:24:08 +0000 Subject: [Haskell-beginners] EasyPlot on Windows Message-ID: A very simple test program with Graphics.EasyPlot, flashes up a window, but too fast to see it. There are several old posts on this issue with gnuplot, but I haven't seen any current solutions. Example: import Graphics.EasyPlot tData = [ (1,2), (2,3), (3,1), (4,5), (5,3), (6,1) ] main = do plot Windows $ Data2D [Title "Demo Title"] [] tData -------------- next part -------------- An HTML attachment was scrubbed... URL: From tanuki at gmail.com Thu May 10 21:17:45 2018 From: tanuki at gmail.com (Theodore Lief Gannon) Date: Thu, 10 May 2018 14:17:45 -0700 Subject: [Haskell-beginners] EasyPlot on Windows In-Reply-To: References: Message-ID: My first hunch was that, since the program ends right after plotting, it cleans up the plot window and exits. But trying it on an X11 system, I got a persistent window despite the program exiting. That may be a difference between Unix and Windows child process handling; I don't have a Windows machine handy right now to test, but you could try this: main = do plot Windows $ Data2D [Title "Demo Title"] [] tData _ <- getLine return () If that doesn't fix it, my only guess is there's either a difference between the Unix and Windows versions of gnuplot, or a bug in easyplot's Windows handling. On Thu, May 10, 2018 at 9:24 AM, Gregory Guthrie wrote: > A very simple test program with Graphics.EasyPlot, flashes up a window, > but too fast to see it. There are several old posts on this issue with > gnuplot, but I haven’t seen any current solutions. > > > > Example: > > import Graphics.EasyPlot > > > > tData = [ (1,2), (2,3), (3,1), (4,5), (5,3), (6,1) ] > > > > main = do plot Windows $ Data2D [Title "Demo Title"] [] tData > > > > _______________________________________________ > 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 guthrie at mum.edu Fri May 11 13:10:28 2018 From: guthrie at mum.edu (Gregory Guthrie) Date: Fri, 11 May 2018 13:10:28 +0000 Subject: [Haskell-beginners] EasyPlot on Windows Message-ID: Thanks; good idea - but nope. I'd file a report to EasyPlot, but not sure where to do that. Older discussions on this issue note that there is a "persist" option for gnuplot, but I didn't yet see how to pass that to try it. -----Original Message----- My first hunch was that, since the program ends right after plotting, it cleans up the plot window and exits. But trying it on an X11 system, I got a persistent window despite the program exiting. That may be a difference between Unix and Windows child process handling; I don't have a Windows machine handy right now to test, but you could try this: main = do plot Windows $ Data2D [Title "Demo Title"] [] tData _ <- getLine return () If that doesn't fix it, my only guess is there's either a difference between the Unix and Windows versions of gnuplot, or a bug in easyplot's Windows handling. From utprimum at gmail.com Fri May 11 13:42:02 2018 From: utprimum at gmail.com (Ut Primum) Date: Fri, 11 May 2018 15:42:02 +0200 Subject: [Haskell-beginners] EasyPlot on Windows In-Reply-To: References: Message-ID: Maybe you could try with plot' Il ven 11 mag 2018, 15:11 Gregory Guthrie ha scritto: > Thanks; good idea - but nope. > > I'd file a report to EasyPlot, but not sure where to do that. > > Older discussions on this issue note that there is a "persist" option for > gnuplot, but I didn't yet see how to pass that to try it. > > -----Original Message----- > > > My first hunch was that, since the program ends right after plotting, it > cleans up the plot window and exits. But trying it on an X11 system, I got > a persistent window despite the program exiting. That may be a difference > between Unix and Windows child process handling; I don't have a Windows > machine handy right now to test, but you could try this: > > main = do > plot Windows $ Data2D [Title "Demo Title"] [] tData > _ <- getLine > return () > > If that doesn't fix it, my only guess is there's either a difference > between the Unix and Windows versions of gnuplot, or a bug in easyplot's > Windows handling. > _______________________________________________ > 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 mike_k_houghton at yahoo.co.uk Fri May 11 16:25:50 2018 From: mike_k_houghton at yahoo.co.uk (mike h) Date: Fri, 11 May 2018 17:25:50 +0100 Subject: [Haskell-beginners] Graph path In-Reply-To: References: Message-ID: <4EF0F568-1E8D-47A7-BD22-3843FCDAA9C1@yahoo.co.uk> thanks Henk-Jan Mike > On 9 May 2018, at 19:46, Henk-Jan van Tuyl wrote: > > > Maybe > Structuring Depth-First Search Algorithms in Haskell > https://galois.com/wp-content/uploads/2014/08/pub_JL_StructuringDFSAlgorithms.pdf > can be of any help? (It's not my field of expertise.) > > Since you haven't received any answer for several days on this mailing > list, you might ask this question again on the Haskell Café mailing list, > there are more people reading that list. > > Regards, > Henk-Jan van Tuyl > > > On Sat, 05 May 2018 18:50:14 +0200, mike h > wrote: > >> Does anyone know of a good description of the algorithm to visit (if possible) each node in a graph? I can find a few links that describe the imperative way of doing it but I struggle converting to functional style > > -- > Message from Stanford University: > > Folding at home > > What if you could share your unused computer power to help find a cure? In > just 5 minutes you can join the world's biggest networked computer and get > us closer sooner. Watch the video. > http://foldingathome.stanford.edu/ > > -- > http://members.chello.nl/hjgtuyl/tourdemonad.html > Haskell programming > -- > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners From utprimum at gmail.com Fri May 11 19:06:16 2018 From: utprimum at gmail.com (Ut Primum) Date: Fri, 11 May 2018 21:06:16 +0200 Subject: [Haskell-beginners] EasyPlot on Windows In-Reply-To: References: Message-ID: What I meant was: import Graphics.EasyPlot tData = [ (1,2), (2,3), (3,1), (4,5), (5,3), (6,1) ] main = do plot' [Interactive] Windows $ Data2D [Title "Demo Title"] [] tData this should work, but it keeps gnuplot open (so you have to type "quit" on the terminal). (I think there is a difference between the Unix and Windows versions for Gnuplot; I had the same problem when I used gnuplot in C programs) 2018-05-11 15:42 GMT+02:00 Ut Primum : > Maybe you could try with plot' > > Il ven 11 mag 2018, 15:11 Gregory Guthrie ha scritto: > >> Thanks; good idea - but nope. >> >> I'd file a report to EasyPlot, but not sure where to do that. >> >> Older discussions on this issue note that there is a "persist" option for >> gnuplot, but I didn't yet see how to pass that to try it. >> >> -----Original Message----- >> >> >> My first hunch was that, since the program ends right after plotting, it >> cleans up the plot window and exits. But trying it on an X11 system, I got >> a persistent window despite the program exiting. That may be a difference >> between Unix and Windows child process handling; I don't have a Windows >> machine handy right now to test, but you could try this: >> >> main = do >> plot Windows $ Data2D [Title "Demo Title"] [] tData >> _ <- getLine >> return () >> >> If that doesn't fix it, my only guess is there's either a difference >> between the Unix and Windows versions of gnuplot, or a bug in easyplot's >> Windows handling. >> _______________________________________________ >> 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 50295 at web.de Mon May 14 12:15:31 2018 From: 50295 at web.de (Olumide) Date: Mon, 14 May 2018 13:15:31 +0100 Subject: [Haskell-beginners] Adding 1 to Just 9 Message-ID: <7b423875-731c-8cb6-f4a7-410f59940d5c@web.de> Dear List, Chapter 14 of LYH appears to suggest that a Just value can be added to an Int. Quote from http://learnyouahaskell.com/for-a-few-monads-more#useful-monadic-functions "For instance, say we have Just 9 and the function \x -> Just (x+1). If we map this function over Just 9, we're left with Just (Just 10)." I've tried the following in ghci but got the error: :12:1: error: • Non type-variable argument in the constraint: Num (Maybe a) (Use FlexibleContexts to permit this) • When checking the inferred type it :: forall a. (Num (Maybe a), Num a) => Maybe a Am I reading the quote wrong? Is Just (Just 10) a hypothetical? Regards, - Olumide From toad3k at gmail.com Mon May 14 12:18:31 2018 From: toad3k at gmail.com (David McBride) Date: Mon, 14 May 2018 08:18:31 -0400 Subject: [Haskell-beginners] Adding 1 to Just 9 In-Reply-To: <7b423875-731c-8cb6-f4a7-410f59940d5c@web.de> References: <7b423875-731c-8cb6-f4a7-410f59940d5c@web.de> Message-ID: let foo = \x -> Just (x + 1) fmap foo (Just 9) Just (Just 10) On Mon, May 14, 2018 at 8:15 AM, Olumide <50295 at web.de> wrote: > Dear List, > > Chapter 14 of LYH appears to suggest that a Just value can be added to an > Int. Quote from http://learnyouahaskell.com/fo > r-a-few-monads-more#useful-monadic-functions > > "For instance, say we have Just 9 and the function \x -> Just (x+1). If we > map this function over Just 9, we're left with Just (Just 10)." > > I've tried the following in ghci but got the error: > > :12:1: error: > • Non type-variable argument in the constraint: Num (Maybe a) > (Use FlexibleContexts to permit this) > • When checking the inferred type > it :: forall a. (Num (Maybe a), Num a) => Maybe a > > > Am I reading the quote wrong? Is Just (Just 10) a hypothetical? > > Regards, > > - Olumide > _______________________________________________ > 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 i.caught.air at gmail.com Mon May 14 13:17:57 2018 From: i.caught.air at gmail.com (Alex Belanger) Date: Mon, 14 May 2018 09:17:57 -0400 Subject: [Haskell-beginners] Adding 1 to Just 9 In-Reply-To: References: <7b423875-731c-8cb6-f4a7-410f59940d5c@web.de> Message-ID: A first approximative intuition is to think of Functors as containers (or more like a context) and of fmap as a way to apply a transformation function of your choice on the contained value, respecting the signification of that context. For example, Maybe represents the possibility of having or not having a value, therefore, fmap will apply your transformation on that value if it exists, otherwise you're still left with nothing. This example might seem straight forward but it had to be defined somewhere, thus, made possible by the Functor instance implementation for the type Maybe. Let's have a look at it: fmap :: Functor f => (a -> b) -> f a -> f b Specialized: fmap ~ (a -> b) -> Maybe a -> Maybe b And concretize further: fmap ~ Num n => (n -> n) -> Maybe n -> Maybe n As you can see, given a transformation function and maybe some numeral, you'll get maybe another numeral. The implementation lools like this: fmap f (Just n) = Just (f n) fmap f Nothing = Nothing Thus, starting with Nothing, we cannot apply our tranformation so you stay with Nothing. Similarly, with Just n, we're able to pattern match to obtain that n, apply our transformation f on that n, and then rewrap everything back into Just. You can see how the value cannot escape its container / context. Of course there are more complex such containers / context. Either represents a choice between two values. [] contains multiple values, IO contains (side-)effects, and so on. Hope this helps. nitrix On Mon, May 14, 2018, 08:18 David McBride wrote: > let foo = \x -> Just (x + 1) > fmap foo (Just 9) > > Just (Just 10) > > > On Mon, May 14, 2018 at 8:15 AM, Olumide <50295 at web.de> wrote: > >> Dear List, >> >> Chapter 14 of LYH appears to suggest that a Just value can be added to an >> Int. Quote from >> http://learnyouahaskell.com/for-a-few-monads-more#useful-monadic-functions >> >> "For instance, say we have Just 9 and the function \x -> Just (x+1). If >> we map this function over Just 9, we're left with Just (Just 10)." >> >> I've tried the following in ghci but got the error: >> >> :12:1: error: >> • Non type-variable argument in the constraint: Num (Maybe a) >> (Use FlexibleContexts to permit this) >> • When checking the inferred type >> it :: forall a. (Num (Maybe a), Num a) => Maybe a >> >> >> Am I reading the quote wrong? Is Just (Just 10) a hypothetical? >> >> Regards, >> >> - Olumide >> _______________________________________________ >> 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 i.caught.air at gmail.com Mon May 14 13:42:21 2018 From: i.caught.air at gmail.com (Alex Belanger) Date: Mon, 14 May 2018 09:42:21 -0400 Subject: [Haskell-beginners] Adding 1 to Just 9 In-Reply-To: <714376.05c78a6be8c6a600cf7ac295e7e9a4c5606d144b@popretr.messagingengine.com> References: <7b423875-731c-8cb6-f4a7-410f59940d5c@web.de> <714376.05c78a6be8c6a600cf7ac295e7e9a4c5606d144b@popretr.messagingengine.com> Message-ID: <1526305341.1178196.1371365704.6A24C961@webmail.messagingengine.com> Applicative is taking one step further, where the transformation itself is also in such container/context. <*> :: Functor => f (a -> b) -> f a -> f b <*> ~ Maybe (a -> b) -> Maybe a -> Maybe b <*> ~ Num n => Maybe (n -> n) -> Maybe n -> Maybe n And the implementation: (<*>) (Just f) (Just n) = Just (f n) (<*>) Nothing (Just n) = Just n (<*>) (Just f) Nothing = Nothing (<*>) Nothing Nothing = Nothing Thus, with everything we've learned, we should be able to deal with any situation thrown at use, using Functor or Applicative. Given (+1) and 42, I can basic function application with ($) or writing it (+1) 42.Given (+1) and Just 42, I can use fmap to apply my transformation on that functor, fmap (+1) (Just 42).Given Just (+1) and Just 42, I can use <*> to apply my transformation inside a functor (applicative functor) to another functor, Just (+1) <*> Just 42.Given Just (+1) and 42, I can wrap 42 with Just and again use <*> as earlier, Just (+1) <*> Just 42. Hope this helps. nitrix On Mon, May 14, 2018, at 9:17 AM, Alex Belanger wrote: > A first approximative intuition is to think of Functors as containers > (or more like a context) and of fmap as a way to apply a > transformation function of your choice on the contained value, > respecting the signification of that context.> > For example, Maybe represents the possibility of having or not having > a value, therefore, fmap will apply your transformation on that value > if it exists, otherwise you're still left with nothing.> > This example might seem straight forward but it had to be defined > somewhere, thus, made possible by the Functor instance implementation > for the type Maybe.> > Let's have a look at it: > > fmap :: Functor f => (a -> b) -> f a -> f b > > Specialized: > > fmap ~ (a -> b) -> Maybe a -> Maybe b > > And concretize further: > > fmap ~ Num n => (n -> n) -> Maybe n -> Maybe n > > As you can see, given a transformation function and maybe some > numeral, you'll get maybe another numeral.> > The implementation lools like this: > > fmap f (Just n) = Just (f n) > fmap f Nothing = Nothing > > Thus, starting with Nothing, we cannot apply our tranformation so you > stay with Nothing. Similarly, with Just n, we're able to pattern match > to obtain that n, apply our transformation f on that n, and then > rewrap everything back into Just.> > You can see how the value cannot escape its container / context. > > Of course there are more complex such containers / context. > > Either represents a choice between two values. [] contains multiple > values, IO contains (side-)effects, and so on.> > Hope this helps. > > nitrix > > On Mon, May 14, 2018, 08:18 David McBride wrote: >> let foo = \x -> Just (x + 1) >> fmap foo (Just 9) >> >> Just (Just 10) >> >> >> On Mon, May 14, 2018 at 8:15 AM, Olumide <50295 at web.de> wrote: >>> Dear List, >>> >>> Chapter 14 of LYH appears to suggest that a Just value can be added >>> to an Int. Quote from >>> http://learnyouahaskell.com/for-a-few-monads-more#useful-monadic-functions>>> >>> "For instance, say we have Just 9 and the function \x -> Just >>> (x+1). If we map this function over Just 9, we're left with Just >>> (Just 10).">>> >>> I've tried the following in ghci but got the error: >>> >>> :12:1: error: >>> • Non type-variable argument in the constraint: Num (Maybe a) >>> (Use FlexibleContexts to permit this) >>> • When checking the inferred type >>> it :: forall a. (Num (Maybe a), Num a) => Maybe a >>> >>> >>> Am I reading the quote wrong? Is Just (Just 10) a hypothetical? >>> >>> Regards, >>> >>> - Olumide >>> _______________________________________________ >>> 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 borgauf at gmail.com Mon May 14 16:52:01 2018 From: borgauf at gmail.com (Lawrence Bottorff) Date: Mon, 14 May 2018 12:52:01 -0400 Subject: [Haskell-beginners] Can't remove old haskell Message-ID: I've followed the steps here ; however, it doesn't replace or supercede an older version of ghci from my Ubuntu 18.04: 12:47:02:~$ which ghci /opt/ghc/8.0.2/bin/ghci 12:47:14:~$ ghci --version The Glorious Glasgow Haskell Compilation System, version 8.0.2 I've tried various removes, but to no avail. The newer version is on my system: 12:50:32:/usr/local/haskell/ghc-8.4.2-x86_64/bin$ ./ghci --version The Glorious Glasgow Haskell Compilation System, version 8.4.2 But I don't know what to do about this old "default" version. LB -------------- next part -------------- An HTML attachment was scrubbed... URL: From fa-ml at ariis.it Mon May 14 17:56:36 2018 From: fa-ml at ariis.it (Francesco Ariis) Date: Mon, 14 May 2018 19:56:36 +0200 Subject: [Haskell-beginners] Can't remove old haskell In-Reply-To: References: Message-ID: <20180514175636.2v7rvmfxdejfgzuv@x60s.casa> Hello Lawrence, On Mon, May 14, 2018 at 12:52:01PM -0400, Lawrence Bottorff wrote: > I've tried various removes, but to no avail. The newer version is on my > system: There should be no need of removing the old version. > 12:50:32:/usr/local/haskell/ghc-8.4.2-x86_64/bin$ ./ghci --version > The Glorious Glasgow Haskell Compilation System, version 8.4.2 What does `echo $PATH` say? -F From borgauf at gmail.com Mon May 14 20:14:40 2018 From: borgauf at gmail.com (Lawrence Bottorff) Date: Mon, 14 May 2018 16:14:40 -0400 Subject: [Haskell-beginners] Can't remove old haskell In-Reply-To: <20180514175636.2v7rvmfxdejfgzuv@x60s.casa> References: <20180514175636.2v7rvmfxdejfgzuv@x60s.casa> Message-ID: PATH does indeed have /opt/ghc/8.0.2/bin which is no doubt why my command line call gets version 8.0.2. But since I didn't put it there (I didn't add it in my .bashrc; some older Haskell setup did?), I don't know how to get it out. Also, I need to use Haskell in Emacs org-mode which tends not to go by the $PATH in a Ubuntu GUI environment. So I've installed Emacs haskell-mode (latest from melpa, I believe.) I start it up -- and it gives me this: 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 Changed directory: /home/hercynian/Programs/Haskell/ λ> . . . but this doesn't tell me what version. Is there a Haskell REPL command to find out what version? On Mon, May 14, 2018 at 1:57 PM Francesco Ariis wrote: > Hello Lawrence, > > On Mon, May 14, 2018 at 12:52:01PM -0400, Lawrence Bottorff wrote: > > I've tried various removes, but to no avail. The newer version is on my > > system: > > There should be no need of removing the old version. > > > 12:50:32:/usr/local/haskell/ghc-8.4.2-x86_64/bin$ ./ghci --version > > The Glorious Glasgow Haskell Compilation System, version 8.4.2 > > What does `echo $PATH` say? > > -F > _______________________________________________ > 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 fa-ml at ariis.it Mon May 14 20:31:03 2018 From: fa-ml at ariis.it (Francesco Ariis) Date: Mon, 14 May 2018 22:31:03 +0200 Subject: [Haskell-beginners] Can't remove old haskell In-Reply-To: References: <20180514175636.2v7rvmfxdejfgzuv@x60s.casa> Message-ID: <20180514203103.4rhan5ej4nyczggv@x60s.casa> On Mon, May 14, 2018 at 04:14:40PM -0400, Lawrence Bottorff wrote: > Is there a Haskell REPL command to find out what version? Type :t (<>) inside the repl, if it gives an error you are still inside 8.0.2. From borgauf at gmail.com Mon May 14 22:17:33 2018 From: borgauf at gmail.com (Lawrence Bottorff) Date: Mon, 14 May 2018 18:17:33 -0400 Subject: [Haskell-beginners] Can't remove old haskell In-Reply-To: <20180514203103.4rhan5ej4nyczggv@x60s.casa> References: <20180514175636.2v7rvmfxdejfgzuv@x60s.casa> <20180514203103.4rhan5ej4nyczggv@x60s.casa> Message-ID: λ> :t (<>) (<>) :: Semigroup a => a -> a -> a I'm curious what this is. I'm guessing it's something that later versions can do? On Mon, May 14, 2018 at 4:31 PM Francesco Ariis wrote: > On Mon, May 14, 2018 at 04:14:40PM -0400, Lawrence Bottorff wrote: > > Is there a Haskell REPL command to find out what version? > > Type > > :t (<>) > > inside the repl, if it gives an error you are still inside 8.0.2. > _______________________________________________ > 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 fa-ml at ariis.it Tue May 15 07:45:50 2018 From: fa-ml at ariis.it (Francesco Ariis) Date: Tue, 15 May 2018 09:45:50 +0200 Subject: [Haskell-beginners] Can't remove old haskell In-Reply-To: References: <20180514175636.2v7rvmfxdejfgzuv@x60s.casa> <20180514203103.4rhan5ej4nyczggv@x60s.casa> Message-ID: <20180515074550.hxxifw5daf3li7nd@x60s.casa> On Mon, May 14, 2018 at 06:17:33PM -0400, Lawrence Bottorff wrote: > λ> :t (<>) > (<>) :: Semigroup a => a -> a -> a > > I'm curious what this is. I'm guessing it's something that later versions > can do? Yes, since GHC 8.4 the operator `<>` is part of the Prelude. Congrats on 8.4.2 working! From mihai.maruseac at gmail.com Wed May 16 02:34:37 2018 From: mihai.maruseac at gmail.com (Mihai Maruseac) Date: Tue, 15 May 2018 19:34:37 -0700 Subject: [Haskell-beginners] ANNOUNCE: Haskell Communities and Activities Report (34th ed., May 2018) Message-ID: On behalf of all the contributors, we are pleased to announce that the Haskell Communities and Activities Report (34th edition, May 2018) is now available, in PDF and HTML formats: http://haskell.org/communities/05-2018/report.pdf http://haskell.org/communities/05-2018/html/report.html All previous editions of HCAR can be accessed on the wiki at https://wiki.haskell.org/Haskell_Communities_and_Activities_Report Many thanks go to all the people that contributed to this report, both directly, by sending in descriptions, and indirectly, by doing all the interesting things that are reported. We hope you will find it as interesting a read as we did. If you have not encountered the Haskell Communities and Activities Reports before, you may like to know that the first of these reports was published in November 2001. Their goal is to improve the communication between the increasingly diverse groups, projects, and individuals working on, with, or inspired by Haskell. The idea behind these reports is simple: Every six months, a call goes out to all of you enjoying Haskell to contribute brief summaries of your own area of work. Many of you respond (eagerly, unprompted, and sometimes in time for the actual deadline) to the call. The editors collect all the contributions into a single report and feed that back to the community. When we try for the next update, six months from now, you might want to report on your own work, project, research area or group as well. So, please put the following into your diaries now: ======================================== End of September 2018: target deadline for contributions to the October 2018 edition of the HCAR Report ======================================== Unfortunately, many Haskellers working on interesting projects are so busy with their work that they seem to have lost the time to follow the Haskell related mailing lists and newsgroups, and have trouble even finding time to report on their work. If you are a member, user or friend of a project so burdened, please find someone willing to make time to report and ask them to "register" with the editors for a simple e-mail reminder in November (you could point us to them as well, and we can then politely ask if they want to contribute, but it might work better if you do the initial asking). Of course, they will still have to find the ten to fifteen minutes to draw up their report, but maybe we can increase our coverage of all that is going on in the community. Feel free to circulate this announcement further in order to reach people who might otherwise not see it. Enjoy! -- Mihai Maruseac (MM) "If you can't solve a problem, then there's an easier problem you can solve: find it." -- George Polya From trent.shipley at gmail.com Fri May 18 05:20:36 2018 From: trent.shipley at gmail.com (trent shipley) Date: Thu, 17 May 2018 22:20:36 -0700 Subject: [Haskell-beginners] merge error Message-ID: The below produces an error. And I am very proud that I could use the GHCi debugging tools to get this far. merge [] [] works. merge [1] [] works. I don't know why the failing example fails. It should return: [4,5] Help to unstuck is appreciated. :step merge [4,5] [] *** Exception: ex6_8.hs:(12,1)-(16,66): Non-exhaustive patterns in function merge Given: merge :: Ord a => [a] -> [a] -> [a] merge [] [] = [] merge [x] [] = [x] merge [] [y] = [y] merge first@(x:xs) second@(y:ys) | x <= y = x : merge xs second | otherwise = y : merge first ys -------------- next part -------------- An HTML attachment was scrubbed... URL: From rpglover64 at gmail.com Fri May 18 05:28:23 2018 From: rpglover64 at gmail.com (Alex Rozenshteyn) Date: Thu, 17 May 2018 22:28:23 -0700 Subject: [Haskell-beginners] merge error In-Reply-To: References: Message-ID: If you compile with -Wall, you get the following foo.hs:2:1: warning: [-Wincomplete-patterns] Pattern match(es) are non-exhaustive In an equation for ‘merge’: Patterns not matched: [] (_:_:_) (_:_:_) [] | 2 | merge [] [] = [] | ^^^^^^^^^^^^^^^^... That is to say, you never match if there is an empty list and a list of 2 or more. Try this: merge :: Ord a => [a] -> [a] -> [a] merge [] ys = ys merge xs [] = xs merge first@(x:xs) second@(y:ys) | x <= y = x : merge xs second | otherwise = y : merge first ys On Thu, May 17, 2018 at 10:21 PM trent shipley wrote: > The below produces an error. And I am very proud that I could use the GHCi > debugging tools to get this far. > > merge [] [] works. > > merge [1] [] works. > > I don't know why the failing example fails. It should return: > > [4,5] > > Help to unstuck is appreciated. > > :step merge [4,5] [] > > *** Exception: ex6_8.hs:(12,1)-(16,66): Non-exhaustive patterns in > function merge > > Given: > > merge :: Ord a => [a] -> [a] -> [a] > > merge [] [] = [] > > merge [x] [] = [x] > > merge [] [y] = [y] > > merge first@(x:xs) second@(y:ys) | x <= y = x : merge xs second > > | otherwise = y : merge first ys > > _______________________________________________ > 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 mukeshtiwari.iiitm at gmail.com Fri May 18 05:33:12 2018 From: mukeshtiwari.iiitm at gmail.com (mukesh tiwari) Date: Fri, 18 May 2018 15:33:12 +1000 Subject: [Haskell-beginners] merge error In-Reply-To: References: Message-ID: I have changed your code little bit, and now it works. merge :: Ord a => [a] -> [a] -> [a] merge [] second = second merge first [] = first merge first@(x:xs) second@(y:ys) | x <= y = x : merge xs second | otherwise = y : merge first ys The reason your code is not working because merge [4,5] [] is trying to match it against merge [x] [] = [x] which expects one element list at first place so merge [1] [] would work,but not merge (list having more than one element) []. Best, Mukesh Tiwari On Fri, May 18, 2018 at 3:20 PM, trent shipley wrote: > The below produces an error. And I am very proud that I could use the GHCi > debugging tools to get this far. > > merge [] [] works. > > merge [1] [] works. > > I don't know why the failing example fails. It should return: > > [4,5] > > Help to unstuck is appreciated. > > :step merge [4,5] [] > > *** Exception: ex6_8.hs:(12,1)-(16,66): Non-exhaustive patterns in > function merge > > Given: > > merge :: Ord a => [a] -> [a] -> [a] > > merge [] [] = [] > > merge [x] [] = [x] > > merge [] [y] = [y] > > merge first@(x:xs) second@(y:ys) | x <= y = x : merge xs second > > | otherwise = y : merge first ys > > > _______________________________________________ > 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 hemanth.420 at gmail.com Fri May 18 05:38:46 2018 From: hemanth.420 at gmail.com (Hemanth Gunda) Date: Fri, 18 May 2018 11:08:46 +0530 Subject: [Haskell-beginners] merge error In-Reply-To: References: Message-ID: Hi Trent, This works: merge:: Ord a => [a] -> [a] -> [a] merge [] [] = [] merge x [] = x merge [] y = y merge first@(x:xs) second@(y:ys) | x <= y = x : merge xs second | otherwise = y : merge first ys Difference in the lines merge x [] = x merge [] y = y As the input is of type [a] where a belongs to typeclass Ord, you must pass x instead of [x]. [x] would work if you tried merge [4] []. but will fail if you tried merge [4,5] []. because "4,5" isn't of type a. Regards, Hemanth On Fri, May 18, 2018 at 10:51 AM trent shipley wrote: > The below produces an error. And I am very proud that I could use the GHCi > debugging tools to get this far. > > merge [] [] works. > > merge [1] [] works. > > I don't know why the failing example fails. It should return: > > [4,5] > > Help to unstuck is appreciated. > > :step merge [4,5] [] > > *** Exception: ex6_8.hs:(12,1)-(16,66): Non-exhaustive patterns in > function merge > > Given: > > merge :: Ord a => [a] -> [a] -> [a] > > merge [] [] = [] > > merge [x] [] = [x] > > merge [] [y] = [y] > > merge first@(x:xs) second@(y:ys) | x <= y = x : merge xs second > > | otherwise = y : merge first ys > > _______________________________________________ > 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 trent.shipley at gmail.com Fri May 18 06:04:07 2018 From: trent.shipley at gmail.com (trent shipley) Date: Thu, 17 May 2018 23:04:07 -0700 Subject: [Haskell-beginners] merge error In-Reply-To: References: Message-ID: Thanks to all. I used Mukesh's suggestion. I am still not clear on: why [x] /= xs why first == first@(x:xs), especially weather the variable declarations are considered names for the same thing. On Thu, May 17, 2018 at 10:39 PM Hemanth Gunda wrote: > Hi Trent, > > This works: > > merge:: Ord a => [a] -> [a] -> [a] > merge [] [] = [] > merge x [] = x > merge [] y = y > merge first@(x:xs) second@(y:ys) > | x <= y = x : merge xs second > | otherwise = y : merge first ys > > Difference in the lines > > merge x [] = x > merge [] y = y > > As the input is of type [a] where a belongs to typeclass Ord, you must > pass x instead of [x]. > > [x] would work if you tried merge [4] []. but will fail if you tried merge > [4,5] []. because "4,5" isn't of type a. > > Regards, Hemanth > > > On Fri, May 18, 2018 at 10:51 AM trent shipley > wrote: > >> The below produces an error. And I am very proud that I could use the >> GHCi debugging tools to get this far. >> >> merge [] [] works. >> >> merge [1] [] works. >> >> I don't know why the failing example fails. It should return: >> >> [4,5] >> >> Help to unstuck is appreciated. >> >> :step merge [4,5] [] >> >> *** Exception: ex6_8.hs:(12,1)-(16,66): Non-exhaustive patterns in >> function merge >> >> Given: >> >> merge :: Ord a => [a] -> [a] -> [a] >> >> merge [] [] = [] >> >> merge [x] [] = [x] >> >> merge [] [y] = [y] >> >> merge first@(x:xs) second@(y:ys) | x <= y = x : merge xs second >> >> | otherwise = y : merge first ys >> >> _______________________________________________ >> 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 utprimum at gmail.com Fri May 18 06:39:48 2018 From: utprimum at gmail.com (Ut Primum) Date: Fri, 18 May 2018 08:39:48 +0200 Subject: [Haskell-beginners] merge error In-Reply-To: References: Message-ID: [x] means a list containing the element x xs in general is only a variable named xs, and in particular could be a list; in this case, if you write first@(x:xs) you mean that first is a list, its "head" is x and xs is its "tail", i.e. all the elements of the list first following x. For example if the arguments of merge are [1,2,4] and [3,6], then first = [1,2,4] x=1 xs = [2,4] second=[3,6] y=3 ys=[6] Note that [1,2,4] could not be pattern-matchd with [x]. [6] could (because contains just one element) Il ven 18 mag 2018, 08:04 trent shipley ha scritto: > Thanks to all. I used Mukesh's suggestion. > > I am still not clear on: > > why [x] /= xs > why first == first@(x:xs), especially weather the variable declarations > are considered names for the same thing. > > On Thu, May 17, 2018 at 10:39 PM Hemanth Gunda > wrote: > >> Hi Trent, >> >> This works: >> >> merge:: Ord a => [a] -> [a] -> [a] >> merge [] [] = [] >> merge x [] = x >> merge [] y = y >> merge first@(x:xs) second@(y:ys) >> | x <= y = x : merge xs second >> | otherwise = y : merge first ys >> >> Difference in the lines >> >> merge x [] = x >> merge [] y = y >> >> As the input is of type [a] where a belongs to typeclass Ord, you must >> pass x instead of [x]. >> >> [x] would work if you tried merge [4] []. but will fail if you tried >> merge [4,5] []. because "4,5" isn't of type a. >> >> Regards, Hemanth >> >> >> On Fri, May 18, 2018 at 10:51 AM trent shipley >> wrote: >> >>> The below produces an error. And I am very proud that I could use the >>> GHCi debugging tools to get this far. >>> >>> merge [] [] works. >>> >>> merge [1] [] works. >>> >>> I don't know why the failing example fails. It should return: >>> >>> [4,5] >>> >>> Help to unstuck is appreciated. >>> >>> :step merge [4,5] [] >>> >>> *** Exception: ex6_8.hs:(12,1)-(16,66): Non-exhaustive patterns in >>> function merge >>> >>> Given: >>> >>> merge :: Ord a => [a] -> [a] -> [a] >>> >>> merge [] [] = [] >>> >>> merge [x] [] = [x] >>> >>> merge [] [y] = [y] >>> >>> merge first@(x:xs) second@(y:ys) | x <= y = x : merge xs second >>> >>> | otherwise = y : merge first ys >>> >>> _______________________________________________ >>> 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 hemanth.420 at gmail.com Fri May 18 06:48:14 2018 From: hemanth.420 at gmail.com (Hemanth Gunda) Date: Fri, 18 May 2018 12:18:14 +0530 Subject: [Haskell-beginners] merge error In-Reply-To: References: Message-ID: Hi Trent, *why first == first@(x:xs), especially weather the variable declarations are considered names for the same thing. * first@(x:xs) is meant to be read as below: "first as (x:xs)". This is syntactic sugar that gives you the flexibility to address the entire list as "first", the first element (head) of the list as "x" and the rest of the list (tail) as xs. If you don't want to use @, you can write the last case in your program as: merge first second | (head first) <= (head second) = (head first) : merge (tail first) second | otherwise = (head second): merge first (tail second) instead of merge first@(x:xs) second@(y:ys) | x <= y = x : merge xs second | otherwise = y : merge first ys Relevant SO question : https://stackoverflow.com/questions/1153465/what-does-the-symbol-mean-in-reference-to-lists-in-haskell *why [x] /= xs * when you call merge as: > merge first second from merge type signature, merge :: Ord a => [a] -> [a] -> [a] we know it takes two lists of type a, belonging to typeclass Ord (where <, > has meaning) first & second checked for being a list & whatever is present inside the list is expected to be of typeclass Ord. Case A: If you wrote merge [x] [] = [x] [x] is expected to be a list of Ord which means x is expected to be Ord. Case B: if you called merge x [] = x x is expected to be a list of Ord. When you call merge [4,5] [] In Case A, it implies "4,5" is a member of Ord, as this is x. Which it isn't (as 3 <"4,5" has no meaning). Therefore merge [x] [] = [x] isn't executed here, the program goes looking for other cases & doesn't find any that satisfies these input types & leads to the error you encountered. In Case B, it imples [4,5] is a list of Ords, which corresponds to the correct type. Therefore this statement is executed. Regards, Hemanth On Fri, May 18, 2018 at 11:34 AM trent shipley wrote: > Thanks to all. I used Mukesh's suggestion. > > I am still not clear on: > > why [x] /= xs > why first == first@(x:xs), especially weather the variable declarations > are considered names for the same thing. > > On Thu, May 17, 2018 at 10:39 PM Hemanth Gunda > wrote: > >> Hi Trent, >> >> This works: >> >> merge:: Ord a => [a] -> [a] -> [a] >> merge [] [] = [] >> merge x [] = x >> merge [] y = y >> merge first@(x:xs) second@(y:ys) >> | x <= y = x : merge xs second >> | otherwise = y : merge first ys >> >> Difference in the lines >> >> merge x [] = x >> merge [] y = y >> >> As the input is of type [a] where a belongs to typeclass Ord, you must >> pass x instead of [x]. >> >> [x] would work if you tried merge [4] []. but will fail if you tried >> merge [4,5] []. because "4,5" isn't of type a. >> >> Regards, Hemanth >> >> >> On Fri, May 18, 2018 at 10:51 AM trent shipley >> wrote: >> >>> The below produces an error. And I am very proud that I could use the >>> GHCi debugging tools to get this far. >>> >>> merge [] [] works. >>> >>> merge [1] [] works. >>> >>> I don't know why the failing example fails. It should return: >>> >>> [4,5] >>> >>> Help to unstuck is appreciated. >>> >>> :step merge [4,5] [] >>> >>> *** Exception: ex6_8.hs:(12,1)-(16,66): Non-exhaustive patterns in >>> function merge >>> >>> Given: >>> >>> merge :: Ord a => [a] -> [a] -> [a] >>> >>> merge [] [] = [] >>> >>> merge [x] [] = [x] >>> >>> merge [] [y] = [y] >>> >>> merge first@(x:xs) second@(y:ys) | x <= y = x : merge xs second >>> >>> | otherwise = y : merge first ys >>> >>> _______________________________________________ >>> 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 ddinesh31 at yahoo.com Sun May 20 07:52:33 2018 From: ddinesh31 at yahoo.com (Dinesh Amerasekara) Date: Sun, 20 May 2018 07:52:33 +0000 (UTC) Subject: [Haskell-beginners] How to get IO String from Network.Socket.ByteString.recv method References: <1643328860.3250152.1526802753434.ref@mail.yahoo.com> Message-ID: <1643328860.3250152.1526802753434@mail.yahoo.com> Hi, I am unable to compile the below code. import Network.Socket hiding(recv) import Network.Socket.ByteString as S (recv) import qualified Data.ByteString.Lazy.Char8 as Char8   getMessage :: Socket -> IO String getMessage sock =  Char8.unpack <$> S.recv sock 8888 It gives the below error. Couldn't match type ‘Data.ByteString.Internal.ByteString’                     with ‘ByteString’NB: ‘ByteString’ is defined in ‘Data.ByteString.Lazy.Internal’    ‘Data.ByteString.Internal.ByteString’        is defined in ‘Data.ByteString.Internal’    Expected type: IO ByteString    Actual type: IO Data.ByteString.Internal.ByteString In the second argument of ‘(<$>)’, namely ‘recv sock 8888’In the expression: unpack <$> recv sock 8888In an equation for ‘getMsg’:      getMsg sock = unpack <$> recv sock 8888 Can somebody tell me how I can return the IO String using Network.Socket.ByteString.recv? Best Regards,Dinesh. -------------- next part -------------- An HTML attachment was scrubbed... URL: From bergey at teallabs.org Sun May 20 23:56:47 2018 From: bergey at teallabs.org (Daniel Bergey) Date: Sun, 20 May 2018 19:56:47 -0400 Subject: [Haskell-beginners] How to get IO String from Network.Socket.ByteString.recv method In-Reply-To: <1643328860.3250152.1526802753434@mail.yahoo.com> References: <1643328860.3250152.1526802753434.ref@mail.yahoo.com> <1643328860.3250152.1526802753434@mail.yahoo.com> Message-ID: Network.Socket.ByteString.recv uses the strict ByteString from Data.ByteString, not the lazy one from Data.ByteString.Lazy. So you want the `unpack` from Data.ByteString.Char8, rather than Data.ByteString.Lazy.Char8. I never remember which functions return strict or lazy ByteString. I find the easiest way to check is to open the online docs and see where the `ByteString` link points: https://hackage.haskell.org/package/network-2.7.0.0/docs/Network-Socket-ByteString.html#v:recv points to: https://hackage.haskell.org/package/bytestring-0.10.8.2/docs/Data-ByteString.html#t:ByteString hope this helps, bergey On 2018-05-20 at 07:52, Dinesh Amerasekara wrote: > Hi, > > I am unable to compile the below code. > > import Network.Socket hiding(recv) > import Network.Socket.ByteString as S (recv) > import qualified Data.ByteString.Lazy.Char8 as Char8 > > getMessage :: Socket -> IO String > getMessage sock = Char8.unpack <$> S.recv sock 8888 > > It gives the below error. > > Couldn't match type ‘Data.ByteString.Internal.ByteString’ > with ‘ByteString’ > NB: ‘ByteString’ is defined in ‘Data.ByteString.Lazy.Internal’ > ‘Data.ByteString.Internal.ByteString’ > is defined in ‘Data.ByteString.Internal’ > Expected type: IO ByteString > Actual type: IO Data.ByteString.Internal.ByteString > > In the second argument of ‘(<$>)’, namely ‘recv sock 8888’ > In the expression: unpack <$> recv sock 8888 > In an equation for ‘getMsg’: > getMsg sock = unpack <$> recv sock 8888 > > Can somebody tell me how I can return the IO String using > Network.Socket.ByteString.recv? > > Best Regards, > Dinesh. > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners From patrick.browne at dit.ie Mon May 21 10:20:53 2018 From: patrick.browne at dit.ie (PATRICK BROWNE) Date: Mon, 21 May 2018 11:20:53 +0100 Subject: [Haskell-beginners] Understanding type variables in Haskell class declarations Message-ID: I am trying to understand how to interpret type variables in Haskell class declarations from a paper . With respect to the code below I have the following questions: 1. What is the difference between "a b" in the header of the Container class and "a b" in the signature of the class methods? Does the whitespace in header mean 2 distinct types and in the methods mean function application? 2. In the Boathouse class what is the difference between the first ocurance of "b p" and the second bracketed "(b p)"? 3. When I try to make instance of these classes I seem to need FlexibleInstances. Why is this? {-# LANGUAGE MultiParamTypeClasses #-} -- Containers a b stands for all container types a holding things of type b. -- from :info command a has kind *->*, b has kind * class Containers a b where insert :: b -> a b -> a b remove :: b -> a b -> a b whatsIn :: a b -> [b] class Surfaces a b where put :: b -> a b -> a b takeOff :: b -> a b -> a b whatsOn :: a b -> [b] -- from :info command "p" has kind *, "h" and "b" have kind *->* class People p class Containers h p => Houses h p where class (People p, Surfaces h p) => Boats h p where class (Boats b p,Houses h (b p)) => BoatHouses h b p where class (People p, Houses h (b p),Boats b p) => HouseBoats h b p -- This email originated from DIT. If you received this email in error, please delete it from your system. Please note that if you are not the named addressee, disclosing, copying, distributing or taking any action based on the contents of this email or attachments is prohibited.  www.dit.ie Is ó ITBÁC a tháinig an ríomhphost seo. Má fuair tú an ríomhphost seo trí earráid, scrios de do chóras é le do thoil. Tabhair ar aird, mura tú an seolaí ainmnithe, go bhfuil dianchosc ar aon nochtadh, aon chóipeáil, aon dáileadh nó ar aon ghníomh a dhéanfar bunaithe ar an ábhar atá sa ríomhphost nó sna hiatáin seo. www.dit.ie Tá ITBÁC ag aistriú go Gráinseach Ghormáin – DIT is on the move to Grangegorman -------------- next part -------------- An HTML attachment was scrubbed... URL: From toad3k at gmail.com Mon May 21 12:31:33 2018 From: toad3k at gmail.com (David McBride) Date: Mon, 21 May 2018 08:31:33 -0400 Subject: [Haskell-beginners] Understanding type variables in Haskell class declarations In-Reply-To: References: Message-ID: 1, a and b are distinct types. However b is of kind * while a is of kind * -> *, which means it takes a type and returns a type. That means that b can be a type like Int, (), or Char, while a has to be a type like Maybe, [], or (Either ()). That way they fit together into a type like (Maybe Char) or [Int]. 2. In the constraint Boats b p, there it says b and p are two types that form an instance the Boats class (the class of boats and the things that are on a boat. usually people). The next constraint says that h and (b p) are each two types that satisfy the Houses constraint (the class of houses and things that are in houses in this case boats, but boats have things aboard them, so that has to be listed). 3. Haskell98 did not allow classes or instances with two type variables. FlexibleInstances and MultiParamTypeClasses remove that limitation, and they've been around for a very long time and will probably end up as part of the standard at some point. You can read about them here, along with other similar language features. http://downloads.haskell.org/~ghc/latest/docs/html/users_guide/glasgow_exts.html#class-declarations On Mon, May 21, 2018 at 6:20 AM, PATRICK BROWNE wrote: > I am trying to understand how to interpret type variables in Haskell > class declarations from a paper > > . > With respect to the code below I have the following questions: > 1. What is the difference between "a b" in the header of the Container > class and "a b" in the signature of the class methods? Does the whitespace > in header mean 2 distinct types and in the methods mean function > application? > 2. In the Boathouse class what is the difference between the first > ocurance of "b p" and the second bracketed "(b p)"? > 3. When I try to make instance of these classes I seem to need > FlexibleInstances. Why is this? > > > > {-# LANGUAGE MultiParamTypeClasses #-} > -- Containers a b stands for all container types a holding things of type > b. > -- from :info command a has kind *->*, b has kind * > class Containers a b where > insert :: b -> a b -> a b > remove :: b -> a b -> a b > whatsIn :: a b -> [b] > > > class Surfaces a b where > put :: b -> a b -> a b > takeOff :: b -> a b -> a b > whatsOn :: a b -> [b] > > -- from :info command "p" has kind *, "h" and "b" have kind *->* > class People p > class Containers h p => Houses h p where > class (People p, Surfaces h p) => Boats h p where > class (Boats b p,Houses h (b p)) => BoatHouses h b p where > class (People p, Houses h (b p),Boats b p) => HouseBoats h b p > > This email originated from DIT. If you received this email in error, > please delete it from your system. Please note that if you are not the > named addressee, disclosing, copying, distributing or taking any action > based on the contents of this email or attachments is prohibited. > www.dit.ie > > Is ó ITBÁC a tháinig an ríomhphost seo. Má fuair tú an ríomhphost seo trí > earráid, scrios de do chóras é le do thoil. Tabhair ar aird, mura tú an > seolaí ainmnithe, go bhfuil dianchosc ar aon nochtadh, aon chóipeáil, aon > dáileadh nó ar aon ghníomh a dhéanfar bunaithe ar an ábhar atá sa > ríomhphost nó sna hiatáin seo. www.dit.ie > > Tá ITBÁC ag aistriú go Gráinseach Ghormáin – DIT is on the move to > Grangegorman > > _______________________________________________ > 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 patrick.browne at dit.ie Mon May 21 14:04:07 2018 From: patrick.browne at dit.ie (PATRICK BROWNE) Date: Mon, 21 May 2018 15:04:07 +0100 Subject: [Haskell-beginners] Understanding type variables in Haskell class declarations In-Reply-To: References: Message-ID: David, Thanks for you clear and helpful answers. Pat On 21 May 2018 at 13:31, David McBride wrote: > 1, a and b are distinct types. However b is of kind * while a is of kind > * -> *, which means it takes a type and returns a type. That means that b > can be a type like Int, (), or Char, while a has to be a type like Maybe, > [], or (Either ()). That way they fit together into a type like (Maybe > Char) or [Int]. > > 2. In the constraint Boats b p, there it says b and p are two types that > form an instance the Boats class (the class of boats and the things that > are on a boat. usually people). The next constraint says that h and (b p) > are each two types that satisfy the Houses constraint (the class of houses > and things that are in houses in this case boats, but boats have things > aboard them, so that has to be listed). > > 3. Haskell98 did not allow classes or instances with two type variables. > FlexibleInstances and MultiParamTypeClasses remove that limitation, and > they've been around for a very long time and will probably end up as part > of the standard at some point. You can read about them here, along with > other similar language features. http://downloads.haskell.org/~ > ghc/latest/docs/html/users_guide/glasgow_exts.html#class-declarations > > On Mon, May 21, 2018 at 6:20 AM, PATRICK BROWNE > wrote: > >> I am trying to understand how to interpret type variables in Haskell >> class declarations from a paper >> >> . >> With respect to the code below I have the following questions: >> 1. What is the difference between "a b" in the header of the Container >> class and "a b" in the signature of the class methods? Does the whitespace >> in header mean 2 distinct types and in the methods mean function >> application? >> 2. In the Boathouse class what is the difference between the first >> ocurance of "b p" and the second bracketed "(b p)"? >> 3. When I try to make instance of these classes I seem to need >> FlexibleInstances. Why is this? >> >> >> >> {-# LANGUAGE MultiParamTypeClasses #-} >> -- Containers a b stands for all container types a holding things of type >> b. >> -- from :info command a has kind *->*, b has kind * >> class Containers a b where >> insert :: b -> a b -> a b >> remove :: b -> a b -> a b >> whatsIn :: a b -> [b] >> >> >> class Surfaces a b where >> put :: b -> a b -> a b >> takeOff :: b -> a b -> a b >> whatsOn :: a b -> [b] >> >> -- from :info command "p" has kind *, "h" and "b" have kind *->* >> class People p >> class Containers h p => Houses h p where >> class (People p, Surfaces h p) => Boats h p where >> class (Boats b p,Houses h (b p)) => BoatHouses h b p where >> class (People p, Houses h (b p),Boats b p) => HouseBoats h b p >> >> This email originated from DIT. If you received this email in error, >> please delete it from your system. Please note that if you are not the >> named addressee, disclosing, copying, distributing or taking any action >> based on the contents of this email or attachments is prohibited. >> www.dit.ie >> >> Is ó ITBÁC a tháinig an ríomhphost seo. Má fuair tú an ríomhphost seo trí >> earráid, scrios de do chóras é le do thoil. Tabhair ar aird, mura tú an >> seolaí ainmnithe, go bhfuil dianchosc ar aon nochtadh, aon chóipeáil, aon >> dáileadh nó ar aon ghníomh a dhéanfar bunaithe ar an ábhar atá sa >> ríomhphost nó sna hiatáin seo. www.dit.ie >> >> Tá ITBÁC ag aistriú go Gráinseach Ghormáin – DIT is on the move to >> Grangegorman >> >> _______________________________________________ >> Beginners mailing list >> Beginners at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners >> >> > -- This email originated from DIT. If you received this email in error, please delete it from your system. Please note that if you are not the named addressee, disclosing, copying, distributing or taking any action based on the contents of this email or attachments is prohibited.  www.dit.ie Is ó ITBÁC a tháinig an ríomhphost seo. Má fuair tú an ríomhphost seo trí earráid, scrios de do chóras é le do thoil. Tabhair ar aird, mura tú an seolaí ainmnithe, go bhfuil dianchosc ar aon nochtadh, aon chóipeáil, aon dáileadh nó ar aon ghníomh a dhéanfar bunaithe ar an ábhar atá sa ríomhphost nó sna hiatáin seo. www.dit.ie Tá ITBÁC ag aistriú go Gráinseach Ghormáin – DIT is on the move to Grangegorman -------------- next part -------------- An HTML attachment was scrubbed... URL: From ddinesh31 at yahoo.com Thu May 24 10:12:24 2018 From: ddinesh31 at yahoo.com (Dinesh Amerasekara) Date: Thu, 24 May 2018 10:12:24 +0000 (UTC) Subject: [Haskell-beginners] Error stack install ghc-mod References: <1527775599.4883383.1527156744251.ref@mail.yahoo.com> Message-ID: <1527775599.4883383.1527156744251@mail.yahoo.com> Hi, When I executed the command stack install ghc-mod, it gave me the following error. In the dependencies for ghc-mod-5.8.0.0:     Cabal-2.0.1.1 from stack configuration does not match >=1.18 && <1.25  (latest matching version is 1.24.2.0)    base-4.10.1.0 from stack configuration does not match >=4.6.0.1 && <4.10  (latest matching version is 4.9.1.0)    cabal-helper must match <0.8 && >=0.7.3.0, but the stack configuration has no specified version  (latest matching version is 0.7.3.0)    extra-1.6.2 from stack configuration does not match <1.6 && >=1.4  (latest matching version is 1.5.3)    ghc-8.2.2 from stack configuration does not match >=7.6 && <8.2     monad-journal-0.8.1 from stack configuration does not match <0.8 && >=0.4  (latest matching version is 0.7.2)    optparse-applicative-0.14.0.0 from stack configuration does not match >=0.13.0.0 && <0.14  (latest matching version is 0.13.2.0) needed since ghc-mod is a build target. Can I get an advice to solve this error? Thanks And Best Regards,Dinesh -------------- next part -------------- An HTML attachment was scrubbed... URL: From michael at snoyman.com Thu May 24 18:21:36 2018 From: michael at snoyman.com (Michael Snoyman) Date: Thu, 24 May 2018 21:21:36 +0300 Subject: [Haskell-beginners] Error stack install ghc-mod In-Reply-To: <1527775599.4883383.1527156744251@mail.yahoo.com> References: <1527775599.4883383.1527156744251.ref@mail.yahoo.com> <1527775599.4883383.1527156744251@mail.yahoo.com> Message-ID: ghc-mod doesn't yet support GHC 8.2 or later[1]. You'll need to use an older version of the compiler if you want ghc-mod support. If you check out ghc-mod's Stackage page[2], you can see that the latest snapshots supporting it are lts-8.24 and nightly-2017-06-28, so those are options if you need ghc-mod support. Note, however, that they're relatively old, so may be missing other things you want. I wrote a blog post recently about selecting older snapshots for building tools[3], which may be helpful. [1] On the Hackage page (http://hackage.haskell.org/package/ghc-mod), you can see that it says base < 4.10. On this page (https://www.snoyman.com/base), you can see that 4.10 ships with GHC 8.2. base is a library which cannot be upgraded. [2] https://www.stackage.org/package/ghc-mod [3] https://www.snoyman.com/blog/2018/05/building-packages-outside-snapshots On Thu, May 24, 2018 at 1:12 PM Dinesh Amerasekara wrote: > Hi, > > When I executed the command *stack install ghc-mod*, it gave me the > following error. > > In the dependencies for ghc-mod-5.8.0.0: > > Cabal-2.0.1.1 from stack configuration does not match >=1.18 && <1.25 > (latest matching version is 1.24.2.0) > base-4.10.1.0 from stack configuration does not match >=4.6.0.1 && > <4.10 (latest matching version is 4.9.1.0) > cabal-helper must match <0.8 && >=0.7.3.0, but the stack configuration > has no specified version (latest matching version is 0.7.3.0) > extra-1.6.2 from stack configuration does not match <1.6 && >=1.4 > (latest matching version is 1.5.3) > ghc-8.2.2 from stack configuration does not match >=7.6 && <8.2 > monad-journal-0.8.1 from stack configuration does not match <0.8 && > >=0.4 (latest matching version is 0.7.2) > optparse-applicative-0.14.0.0 from stack configuration does not match > >=0.13.0.0 && <0.14 (latest matching version is 0.13.2.0) > > needed since ghc-mod is a build target. > > Can I get an advice to solve this error? > > Thanks And Best Regards, > Dinesh > _______________________________________________ > 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 mike_k_houghton at yahoo.co.uk Fri May 25 11:26:47 2018 From: mike_k_houghton at yahoo.co.uk (mike h) Date: Fri, 25 May 2018 12:26:47 +0100 Subject: [Haskell-beginners] ghci timings Message-ID: <2B4ECCF7-53D6-49D1-AE17-6A5A388F4148@yahoo.co.uk> Hi, I have a function that takes a while to execute and its output is a list of 1000 numbers. I’ve setup ghci to show timings. So in ghci I run the function, it churns away and then starts display the output list and finally shows the timings. I’m assuming that the execution time includes the time taken to output the result. Is it possible to get the execution time that does not include the time to output the result? Thanks Mike From mike_k_houghton at yahoo.co.uk Fri May 25 11:33:32 2018 From: mike_k_houghton at yahoo.co.uk (mike h) Date: Fri, 25 May 2018 12:33:32 +0100 Subject: [Haskell-beginners] ghci timings In-Reply-To: <2B4ECCF7-53D6-49D1-AE17-6A5A388F4148@yahoo.co.uk> References: <2B4ECCF7-53D6-49D1-AE17-6A5A388F4148@yahoo.co.uk> Message-ID: <51AC0111-D3A7-46C4-A23D-73C95FD68ECD@yahoo.co.uk> Sorry - I’m being stupid, Just use last to print the last in the list. List is still evaluated but no real print overhead. duh. Mike > On 25 May 2018, at 12:26, mike h wrote: > > Hi, > I have a function that takes a while to execute and its output is a list of 1000 numbers. I’ve setup ghci to show timings. > So in ghci I run the function, it churns away and then starts display the output list and finally shows the timings. > I’m assuming that the execution time includes the time taken to output the result. Is it possible to get the execution time that does not include the time to output the result? > > Thanks > > Mike > > > > > From doug at cs.dartmouth.edu Fri May 25 13:51:37 2018 From: doug at cs.dartmouth.edu (Doug McIlroy) Date: Fri, 25 May 2018 09:51:37 -0400 Subject: [Haskell-beginners] ghci timings Message-ID: <201805251351.w4PDpb1I032518@coolidge.cs.Dartmouth.EDU> > Just use last to print the last in the list. Because of lazy evaluation, this doesn't guarantee that the earlier elements have been computed. You might use "sum" to assure that they are. Doug From andreas.roehler at easy-emacs.de Mon May 28 07:03:11 2018 From: andreas.roehler at easy-emacs.de (=?UTF-8?Q?Andreas_R=c3=b6hler?=) Date: Mon, 28 May 2018 09:03:11 +0200 Subject: [Haskell-beginners] Conflict with global lib from sandbox Message-ID: Hi, called "cabal sandbox init" from inside an empty directory. When running cabal install... see errors like that: /home/my-name/.cabal/lib/i386-linux-ghc-7.6.3/unix-2.7.2.2/libHSunix-2.7.2.2.a(HsUnix.o):(.text+0x20): first defined here /usr/lib/ghc/unix-2.6.0.1/libHSunix-2.6.0.1.a(HsUnix.o): In function `__hsunix_grantpt': Shouldn't /usr/lib/... be hidden from inside a sandbox? Thanks, Andreas