From defigueiredo at ucdavis.edu Wed Nov 13 19:04:22 2019 From: defigueiredo at ucdavis.edu (Dimitri DeFigueiredo) Date: Wed, 13 Nov 2019 11:04:22 -0800 Subject: [Haskell-beginners] What is this? Message-ID: Hello, Can anyone shed a light on the proper way to write the function below. It looks pretty standard, but it's not clear to me what it is? data Abortable res = Aborted | Executed res deriving Functor -- i.e. Maybe abortableThroughEither :: Abortable (Either a b) ->  Either a (Abortable b) abortableThroughEither Aborted              = Right Aborted abortableThroughEither (Executed (Left  a)) = Left  a abortableThroughEither (Executed (Right b)) = Right (Executed b) Thanks! Dimitri -- 2E45 D376 A744 C671 5100 A261 210B 8461 0FB0 CA1F From toad3k at gmail.com Wed Nov 13 19:20:12 2019 From: toad3k at gmail.com (David McBride) Date: Wed, 13 Nov 2019 14:20:12 -0500 Subject: [Haskell-beginners] What is this? In-Reply-To: References: Message-ID: It converts from Abortable (Either a b) to Either a (Abortable b). My guess at their probable intent was that this operation tends to error without aborting more often than it errors from an abort, so they put the error on the outside so they can check the common case more easily. On Wed, Nov 13, 2019 at 2:04 PM Dimitri DeFigueiredo < defigueiredo at ucdavis.edu> wrote: > Hello, > > Can anyone shed a light on the proper way to write the function below. > It looks pretty standard, but it's not clear to me what it is? > > data Abortable res = Aborted | Executed res deriving Functor -- i.e. Maybe > > abortableThroughEither :: Abortable (Either a b) -> Either a (Abortable b) > abortableThroughEither Aborted = Right Aborted > abortableThroughEither (Executed (Left a)) = Left a > abortableThroughEither (Executed (Right b)) = Right (Executed b) > > Thanks! > > Dimitri > > -- > 2E45 D376 A744 C671 5100 A261 210B 8461 0FB0 CA1F > > > _______________________________________________ > 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 tanuki at gmail.com Wed Nov 13 20:46:44 2019 From: tanuki at gmail.com (Akhra Lief Gannon) Date: Wed, 13 Nov 2019 12:46:44 -0800 Subject: [Haskell-beginners] What is this? In-Reply-To: References: Message-ID: Incidentally, if you also derive Foldable and Traversable for Aborted, abortableThroughEither is simply sequence. On Wed, Nov 13, 2019 at 11:20 AM David McBride wrote: > It converts from Abortable (Either a b) to Either a (Abortable b). > > My guess at their probable intent was that this operation tends to error > without aborting more often than it errors from an abort, so they put the > error on the outside so they can check the common case more easily. > > On Wed, Nov 13, 2019 at 2:04 PM Dimitri DeFigueiredo < > defigueiredo at ucdavis.edu> wrote: > >> Hello, >> >> Can anyone shed a light on the proper way to write the function below. >> It looks pretty standard, but it's not clear to me what it is? >> >> data Abortable res = Aborted | Executed res deriving Functor -- i.e. Maybe >> >> abortableThroughEither :: Abortable (Either a b) -> Either a (Abortable >> b) >> abortableThroughEither Aborted = Right Aborted >> abortableThroughEither (Executed (Left a)) = Left a >> abortableThroughEither (Executed (Right b)) = Right (Executed b) >> >> Thanks! >> >> Dimitri >> >> -- >> 2E45 D376 A744 C671 5100 A261 210B 8461 0FB0 CA1F >> >> >> _______________________________________________ >> 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 Leonhard.Applis at protonmail.com Fri Nov 15 11:36:03 2019 From: Leonhard.Applis at protonmail.com (Leonhard Applis) Date: Fri, 15 Nov 2019 11:36:03 +0000 Subject: [Haskell-beginners] Expose every Function of a wrapped type Message-ID: <8VyrlRTZwYrqqkI95kJ3UHQ41YSXFwhcqA4orOfVyau1ULCyCnVVkPI__Ya6rLaYFCUrVB3yM0IqT_l5NcCiMHhyfjsRg0S2xmxG3Cmvkq0=@protonmail.com> Hi,  I currently have a newtype definition of a typed Data.Map.  newtype G = G Data.Map String Values  I have done this because for my specific use-case, I can define G as a monoid and get some nice benefits.  However, I find myself often just re-declaring functions of Data.Map and wrap/unwrap them in my Constructor G, such as  singleton :: String -> Value -> G singleton s v = G $ (Data.Map.singleton s v)  I think I do not need to limit the scope of G's functionality, I basically want everything from Data.Map + Bonus , like my Monoid.  Also I want G to be a specific Data.Map, there is never any other case where it's not a Map String Values.  However, if I have  type G2 = Data.Map String Values  I cannot instance Monoid.  So, I am very sure that I'm not the first person ever doing this. Is there a language extension providing what I want? Or is what i want "bad"? Am I just missing a higher-order base function which does what I want? best regards & thanks Leonhard -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: publickey - Leonhard.Applis at protonmail.com - 0x807FDDF3.asc Type: application/pgp-keys Size: 1843 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 477 bytes Desc: OpenPGP digital signature URL: From fa-ml at ariis.it Fri Nov 15 14:11:12 2019 From: fa-ml at ariis.it (Francesco Ariis) Date: Fri, 15 Nov 2019 15:11:12 +0100 Subject: [Haskell-beginners] Expose every Function of a wrapped type In-Reply-To: <8VyrlRTZwYrqqkI95kJ3UHQ41YSXFwhcqA4orOfVyau1ULCyCnVVkPI__Ya6rLaYFCUrVB3yM0IqT_l5NcCiMHhyfjsRg0S2xmxG3Cmvkq0=@protonmail.com> References: <8VyrlRTZwYrqqkI95kJ3UHQ41YSXFwhcqA4orOfVyau1ULCyCnVVkPI__Ya6rLaYFCUrVB3yM0IqT_l5NcCiMHhyfjsRg0S2xmxG3Cmvkq0=@protonmail.com> Message-ID: <20191115141112.GA15508@x60s.casa> Hello Leonardh, a couple of ideas: On Fri, Nov 15, 2019 at 11:36:03AM +0000, Leonhard Applis wrote: > I currently have a newtype definition of a typed Data.Map.  > > newtype G = G Data.Map String Values  > > [...] > > However, if I have  > > type G2 = Data.Map String Values  `Map k v` is already an instance of `Monoid` (when `v` is an instance of `Ord`), are you sure you need to write another one? If the answer is "yes", you can write a small helper: withG :: (M.Map String a -> M.Map String a) -> G a -> G a withG mf (G m) = G $ mf m or use GeneralizedNewtypeDeriving to ease some pain: {-# Language GeneralizedNewtypeDeriving #-} module Prova where import Data.Map as M import GHC.Exts newtype G a = G { unwrapG :: M.Map String a } deriving (Eq, Show, Functor, Foldable) From traqueofziche at gmail.com Sat Nov 16 23:46:51 2019 From: traqueofziche at gmail.com (=?UTF-8?B?6bKN5Yev5paH?=) Date: Sat, 16 Nov 2019 15:46:51 -0800 Subject: [Haskell-beginners] Expose every Function of a wrapped type In-Reply-To: References: Message-ID: Hi, Have you considered using `Control.Lens.Wrapped` or `Control.Newtype`? You'd have to move the wrapping/unwrapping bits to the sites in your code at which you use underlying `Map` functions (quite repetitive), but it could be easier than redefining all the functions you want (and definitely easier than having to redefine a new one when you think of needing it?). There's probably a canonical way to handle this sort of thing, but I can't find it ATM. Good luck! On Fri, Nov 15, 2019 at 5:00 AM 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. Expose every Function of a wrapped type (Leonhard Applis) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Fri, 15 Nov 2019 11:36:03 +0000 > From: Leonhard Applis > To: "beginners at haskell.org" > Subject: [Haskell-beginners] Expose every Function of a wrapped type > Message-ID: > > <8VyrlRTZwYrqqkI95kJ3UHQ41YSXFwhcqA4orOfVyau1ULCyCnVVkPI__Ya6rLaYFCUrVB3yM0IqT_l5NcCiMHhyfjsRg0S2xmxG3Cmvkq0=@ > protonmail.com> > > Content-Type: text/plain; charset="utf-8" > > Hi, > > I currently have a newtype definition of a typed Data.Map. > > newtype G = G Data.Map String Values > > I have done this because for my specific use-case, I can define G as a > monoid and get some nice benefits. > > However, I find myself often just re-declaring functions of Data.Map and > wrap/unwrap them in my Constructor G, such as > > singleton :: String -> Value -> G > singleton s v = G $ (Data.Map.singleton s v) > > I think I do not need to limit the scope of G's functionality, I basically > want everything from Data.Map + Bonus , like my Monoid. > Also I want G to be a specific Data.Map, there is never any other case > where it's not a Map String Values. > > However, if I have > > type G2 = Data.Map String Values > > I cannot instance Monoid. > > So, I am very sure that I'm not the first person ever doing this. Is there > a language extension providing what I want? Or is what i want "bad"? > Am I just missing a higher-order base function which does what I want? > > best regards & thanks > Leonhard > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://mail.haskell.org/pipermail/beginners/attachments/20191115/904e640f/attachment-0001.html > > > -------------- next part -------------- > A non-text attachment was scrubbed... > Name: publickey - Leonhard.Applis at protonmail.com - 0x807FDDF3.asc > Type: application/pgp-keys > Size: 1843 bytes > Desc: not available > URL: < > http://mail.haskell.org/pipermail/beginners/attachments/20191115/904e640f/attachment-0001.key > > > -------------- next part -------------- > A non-text attachment was scrubbed... > Name: signature.asc > Type: application/pgp-signature > Size: 477 bytes > Desc: OpenPGP digital signature > URL: < > http://mail.haskell.org/pipermail/beginners/attachments/20191115/904e640f/attachment-0001.sig > > > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > ------------------------------ > > End of Beginners Digest, Vol 137, Issue 2 > ***************************************** > -------------- next part -------------- An HTML attachment was scrubbed... URL: From alexander at chenjia.nl Mon Nov 18 12:30:54 2019 From: alexander at chenjia.nl (Alexander Chen) Date: Mon, 18 Nov 2019 13:30:54 +0100 (CET) Subject: [Haskell-beginners] importing Data.Digits Message-ID: <663503445.269564.1574080254193@ichabod.co-bxl> Hi All, This is my first 'post' not quite sure if I am doing it right. I have a question about the importing of modules that are available on the Hackage.Haskell site: http://hackage.haskell.org/package/digits if I write this in my wordpad and then load it to GCI i get the following error: chapter4.hs:1:1: error:     Could not find module ‘Data.Digits’     Perhaps you meant Data.Bits (from base-4.12.0.0)     Use -v to see a list of the files searched for.   | 1 | import Data.Digits   | ^^^^^^^^^^^^^^^^^^ However if I load Data.Char than it loads fine. What am I doing wrong? best, -------------- next part -------------- An HTML attachment was scrubbed... URL: From toad3k at gmail.com Mon Nov 18 13:11:30 2019 From: toad3k at gmail.com (David McBride) Date: Mon, 18 Nov 2019 08:11:30 -0500 Subject: [Haskell-beginners] importing Data.Digits In-Reply-To: <663503445.269564.1574080254193@ichabod.co-bxl> References: <663503445.269564.1574080254193@ichabod.co-bxl> Message-ID: This particular module comes from a separate package. By default all modules you use happen to be in the base package, which ships with ghc. To use other libraries you must make a proper project which tells ghc which libraries you are using. For example, the digits package uses this cabal file at http://hackage.haskell.org/package/digits-0.3.1/digits.cabal You can find more information about how to start a package from scratch here https://www.haskell.org/cabal/users-guide/developing-packages.html On Mon, Nov 18, 2019 at 7:31 AM Alexander Chen wrote: > Hi All, > > This is my first 'post' not quite sure if I am doing it right. > > I have a question about the importing of modules that are available on the > Hackage.Haskell site: > http://hackage.haskell.org/package/digits > > if I write this in my wordpad and then load it to GCI i get the following > error: > > > chapter4.hs:1:1: error: > Could not find module ‘Data.Digits’ > Perhaps you meant Data.Bits (from base-4.12.0.0) > Use -v to see a list of the files searched for. > | > 1 | import Data.Digits | ^^^^^^^^^^^^^^^^^^ > > > However if I load Data.Char than it loads fine. > > What am I doing wrong? > > best, > _______________________________________________ > 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 Leonhard.Applis at protonmail.com Mon Nov 18 20:42:22 2019 From: Leonhard.Applis at protonmail.com (Leonhard Applis) Date: Mon, 18 Nov 2019 20:42:22 +0000 Subject: [Haskell-beginners] Export two modules from one.hs file? Message-ID: <_QHLN6QYGGGjW3RwH0CJB2tIsuSBrKe3klqLJ45k_Kf-rUpFNV_XkUHLy38_V0e9byfWFK5nUDvfdSJ_xdoqhfx_XOwaeHUfzJz3q8QioSc=@protonmail.com> Hey  All, I currently want to make a module, which "truly" exposes 3 functions. However, there are more functions which I want to test. I would like to export two modules from the same file, "ModuleToUse" and "ModuleOpen". Then I can use ModuleToUse everywhere else, and ModuleOpen in the UnitTests. I know I can declare ModuleOpen, and export only certain functions with ModuleToUse. But I am not sure, if that is a smart / normal thing to do. In my case this would double my modules, and ... hence files? What is the "real world" approach for this? Thanks Leonhard -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: publickey - Leonhard.Applis at protonmail.com - 0x807FDDF3.asc Type: application/pgp-keys Size: 1843 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 477 bytes Desc: OpenPGP digital signature URL: From Leonhard.Applis at protonmail.com Mon Nov 18 22:22:01 2019 From: Leonhard.Applis at protonmail.com (Leonhard Applis) Date: Mon, 18 Nov 2019 22:22:01 +0000 Subject: [Haskell-beginners] How to use the Data.Map inbuild Monoid Message-ID: Hello Francesco, > `Map k v` is already an instance of `Monoid` (when `v` is an instance of `Ord`), are you sure you need to write another one? Thanks for your answer! My "Values" is a Monoid, however it seems that the Graph cannot properly be seen correctly as a Monoid using mconcat does not (properly) work, meaning that <> is not correctly applied to the someMonoidsso instead of type G = Map Text someMonoid mconcat [gs] I have to write: foldr (Map.unionWith (<>)) Map.empty [gs] This passes the tests. Same Problem with g1 <> g2  --(Does not work properly) and Map.unionWith (<>) g1 g2 --(Does work) I have declared someMonoid myself, do I need to declare something special about it? I feel like my G is messing up with <> being about him, or about someMonoid A broken down piece of code is: importData.MapasMap dataSum=SumIntderiving (Eq,Show) instanceSemigroupSumwhere (<>) (Sum a) (Sum b)=Sum(a + b)  instanceMonoidSumwhere     mempty =Sum0 typeG=Map.MapStringSum And to verify my problem: GHCI > v = Map.singleton "A" (Sum 1) GHCI > u = Map.singleton "A" (Sum 1) GHCI> c= v <> u GHCI> Map.lookup "A" c Just (Sum 1) but I want Just (Sum 2) thanks Leonhard -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: publickey - Leonhard.Applis at protonmail.com - 0x807FDDF3.asc Type: application/pgp-keys Size: 1843 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 477 bytes Desc: OpenPGP digital signature URL: From fa-ml at ariis.it Mon Nov 18 22:23:52 2019 From: fa-ml at ariis.it (Francesco Ariis) Date: Mon, 18 Nov 2019 23:23:52 +0100 Subject: [Haskell-beginners] Export two modules from one.hs file? In-Reply-To: <_QHLN6QYGGGjW3RwH0CJB2tIsuSBrKe3klqLJ45k_Kf-rUpFNV_XkUHLy38_V0e9byfWFK5nUDvfdSJ_xdoqhfx_XOwaeHUfzJz3q8QioSc=@protonmail.com> References: <_QHLN6QYGGGjW3RwH0CJB2tIsuSBrKe3klqLJ45k_Kf-rUpFNV_XkUHLy38_V0e9byfWFK5nUDvfdSJ_xdoqhfx_XOwaeHUfzJz3q8QioSc=@protonmail.com> Message-ID: <20191118222039.GA9411@x60s.casa> Hello Leonard, On Mon, Nov 18, 2019 at 08:42:22PM +0000, Leonhard Applis wrote: > I currently want to make a module, which "truly" exposes 3 functions. > However, there are more functions which I want to test. > I would like to export two modules from the same file, "ModuleToUse" > and "ModuleOpen". Unfortunately Haskell (rather, GHC) in its current incarnation does not allow many-modules-per-single-file (which would indeed come quite handy in cases like yours, in writing example code, etc.). > What is the "real world" approach for this? Have two modules, `Prova` and `Prova.Internal` (files: `src/Prova.hs` and `src/Prova/Intenral.hs`).j Does this answer your question? -F From simon.jakobi at googlemail.com Mon Nov 18 22:48:06 2019 From: simon.jakobi at googlemail.com (Simon Jakobi) Date: Mon, 18 Nov 2019 23:48:06 +0100 Subject: [Haskell-beginners] How to use the Data.Map inbuild Monoid In-Reply-To: References: Message-ID: Hi Leonhard, the monoidal-containers package should be interesting to you: http://hackage.haskell.org/package/monoidal-containers Cheers, Simon Am Mo., 18. Nov. 2019 um 23:22 Uhr schrieb Leonhard Applis : > > Hello Francesco, > > > `Map k v` is already an instance of `Monoid` (when `v` is an instance of `Ord`), are you sure you need to write another one? > > Thanks for your answer! > My "Values" is a Monoid, however it seems that the Graph cannot properly be seen correctly as a Monoid > > using mconcat does not (properly) work, meaning that <> is not correctly applied to the someMonoids > so instead of > > type G = Map Text someMonoid > mconcat [gs] > > I have to write: > > foldr (Map.unionWith (<>)) Map.empty [gs] > > This passes the tests. > Same Problem with > g1 <> g2 --(Does not work properly) > and > Map.unionWith (<>) g1 g2 --(Does work) > > I have declared someMonoid myself, do I need to declare something special about it? > I feel like my G is messing up with <> being about him, or about someMonoid > > A broken down piece of code is: > > import Data.Map as Map > > data Sum = Sum Int deriving (Eq,Show) > > instance Semigroup Sum where > (<>) (Sum a) (Sum b)= Sum(a + b) > instance Monoid Sum where > mempty = Sum 0 > > type G = Map.Map String Sum > > And to verify my problem: > GHCI > v = Map.singleton "A" (Sum 1) > GHCI > u = Map.singleton "A" (Sum 1) > GHCI> c= v <> u > GHCI> Map.lookup "A" c > Just (Sum 1) > > but I want > Just (Sum 2) > > thanks > Leonhard > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners From juncheng_hsk at outlook.com Fri Nov 22 11:41:12 2019 From: juncheng_hsk at outlook.com (juncheng_hsk at outlook.com) Date: Fri, 22 Nov 2019 11:41:12 +0000 Subject: [Haskell-beginners] Configuration of Environment Message-ID: Hi All, I’m a newcomer to Haskell and mailing list, so I am not sure if my question is proper. I use notepad++ to learn Haskell now. Are there any suggestions or conventions which can help me learn Haskell? Best regards, Juncheng -------------- next part -------------- An HTML attachment was scrubbed... URL: From Leonhard.Applis at protonmail.com Fri Nov 22 14:13:15 2019 From: Leonhard.Applis at protonmail.com (Leonhard Applis) Date: Fri, 22 Nov 2019 14:13:15 +0000 Subject: [Haskell-beginners] Configuration of Environment Message-ID: > Hi All, > > I’m a newcomer to Haskell and mailing list, so I am not sure if my question is proper. > > I use notepad++ to learn Haskell now. Are there any suggestions or conventions which can help me learn Haskell? > > Best regards, > Juncheng Hi Juncheng, I think for learning "code", as in writing nice code, get yourself the Hlinter [1] running. It really spots great improvements and some very haskelly ways. For Learning purposes I would suggest that you first "try it your way" step by step, and check every step with hlint. So: fun1 -> Hlint -> fun2 -> Hlint Additionally you might want to enable a spell-checker (like, a normal one, for english). Last thing you might find very useful is a local Hoogle [2] install. It's amazingly convenient if you want to know, e.g. the function which gives a length of a list, but you don't remember if it was len, length, size, count ... So you just search for [a] -> Int and voila. Second Hoogle can help you find similar functions to what you are currently building, often you are implementing something that is somewhere as a higher order function already. best regards, Leonhard [1] Hlint: http://hackage.haskell.org/package/hlint [2] Hoogle: http://hackage.haskell.org/package/hoogle -------------- next part -------------- A non-text attachment was scrubbed... Name: publickey - Leonhard.Applis at protonmail.com - 0x807FDDF3.asc Type: application/pgp-keys Size: 1843 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 477 bytes Desc: OpenPGP digital signature URL: From alexander at chenjia.nl Sat Nov 23 18:38:03 2019 From: alexander at chenjia.nl (Alexander Chen) Date: Sat, 23 Nov 2019 19:38:03 +0100 (CET) Subject: [Haskell-beginners] list doesn't end Message-ID: <1722033790.317238.1574534283773@ichabod.co-bxl> Hi, I am doing some further learning with euler now in Haskell instead of Julia. But I am getting something strange. [x+y+z | x <- a2, y <- b3,  z <- c4, (x+y+z) < 50] a2, b3, c4 are all finite lists derived from the lazy list of the primes package. the output is: [28,47,33,49 this is not a typo it is still calculating hence the missing bracket (for the last couple of hours, when to a christmas fair in between). The only thing is that, this should be the answer: [28,47,33,49]  so it should be done but its not. what am I doing wrong? best, -------------- next part -------------- An HTML attachment was scrubbed... URL: From ollie at ocharles.org.uk Sat Nov 23 18:42:05 2019 From: ollie at ocharles.org.uk (Oliver Charles) Date: Sat, 23 Nov 2019 18:42:05 +0000 Subject: [Haskell-beginners] list doesn't end In-Reply-To: <1722033790.317238.1574534283773@ichabod.co-bxl> References: <1722033790.317238.1574534283773@ichabod.co-bxl> Message-ID: How big are those lists? GHC will not be able to work out x+y+z < 50 will never be true again, it will have to exhaustively consider *every* combination. On Sat, 23 Nov 2019, 6:38 pm Alexander Chen, wrote: > Hi, > > I am doing some further learning with euler now in Haskell instead of > Julia. But I am getting something strange. > > [x+y+z | x <- a2, y <- b3, z <- c4, (x+y+z) < 50] > > a2, b3, c4 are all finite lists derived from the lazy list of the primes > package. the output is: > > [28,47,33,49 > > this is not a typo it is still calculating hence the missing bracket (for > the last couple of hours, when to a christmas fair in between). The only > thing is that, this should be the answer: > > [28,47,33,49] > > > so it should be done but its not. what am I doing wrong? > > best, > > > > > > _______________________________________________ > 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 Sat Nov 23 19:05:32 2019 From: fa-ml at ariis.it (Francesco Ariis) Date: Sat, 23 Nov 2019 20:05:32 +0100 Subject: [Haskell-beginners] list doesn't end In-Reply-To: <1722033790.317238.1574534283773@ichabod.co-bxl> References: <1722033790.317238.1574534283773@ichabod.co-bxl> Message-ID: <20191123190532.GA659@x60s.casa> Hello Alexander, On Sat, Nov 23, 2019 at 07:38:03PM +0100, Alexander Chen wrote: > Hi, > > I am doing some further learning with euler now in Haskell instead of Julia. But I am getting something strange. > > [x+y+z | x <- a2, y <- b3,  z <- c4, (x+y+z) < 50] > > a2, b3, c4 are all finite lists derived from the lazy list of the primes package. the output is: > > [28,47,33,49 λ> :m Data.Numbers.Primes λ> let a = take 100 primes λ> length [x+y+x | x <- a, y <- a, z <- a, (x+y+z) < 50] 942 I suspect one in [a2, b3, c4] is infinite (or very very long). Can you paste the whole calculation? -F From alexander at chenjia.nl Sun Nov 24 16:10:17 2019 From: alexander at chenjia.nl (Alexander Chen) Date: Sun, 24 Nov 2019 17:10:17 +0100 (CET) Subject: [Haskell-beginners] list doesn't end In-Reply-To: <20191123190532.GA659@x60s.casa> References: <1722033790.317238.1574534283773@ichabod.co-bxl> <20191123190532.GA659@x60s.casa> Message-ID: <1726437853.349004.1574611817399@ichabod.co-bxl> Hi Francesco, length a2 = 7072 length b3 = 7072 length c4 = 82 I suspect its the first two that get it into trouble. Is is 7072*7072*82 = 41014081088 permutations, 100*3 = 1000000. So I am guessing that this is not the fix to the euler problem.... best. November 23, 2019 8:05:32 PM CET Francesco Ariis wrote:Hello Alexander, On Sat, Nov 23, 2019 at 07:38:03PM +0100, Alexander Chen wrote: > Hi, > > I am doing some further learning with euler now in Haskell instead of Julia. But I am getting something strange. > > [x+y+z | x <- a2, y <- b3,  z <- c4, (x+y+z) < 50] > > a2, b3, c4 are all finite lists derived from the lazy list of the primes package. the output is: > > [28,47,33,49 λ> :m Data.Numbers.Primes λ> let a = take 100 primes λ> length [x+y+x | x <- a, y <- a, z <- a, (x+y+z) < 50] 942 I suspect one in [a2, b3, c4] is infinite (or very very long). Can you paste the whole calculation? -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 Sun Nov 24 18:19:51 2019 From: fa-ml at ariis.it (Francesco Ariis) Date: Sun, 24 Nov 2019 19:19:51 +0100 Subject: [Haskell-beginners] list doesn't end In-Reply-To: <1726437853.349004.1574611817399@ichabod.co-bxl> References: <1722033790.317238.1574534283773@ichabod.co-bxl> <20191123190532.GA659@x60s.casa> <1726437853.349004.1574611817399@ichabod.co-bxl> Message-ID: <20191124181951.GB3552@x60s.casa> On Sun, Nov 24, 2019 at 05:10:17PM +0100, Alexander Chen wrote: > Hi Francesco, > > length a2 = 7072 > length b3 = 7072 > length c4 = 82 > > I suspect its the first two that get it into trouble. Is is 7072*7072*82 = 41014081088 permutations, 100*3 = 1000000. > > So I am guessing that this is not the fix to the euler problem.... If `x+y+z` need to be <50, and the three are primes, I am puzzled to see such lengths! Which problem is it? From alexander at chenjia.nl Mon Nov 25 07:55:17 2019 From: alexander at chenjia.nl (Alexander Chen) Date: Mon, 25 Nov 2019 08:55:17 +0100 (CET) Subject: [Haskell-beginners] list doesn't end In-Reply-To: <20191124181951.GB3552@x60s.casa> References: <1722033790.317238.1574534283773@ichabod.co-bxl> <20191123190532.GA659@x60s.casa> <1726437853.349004.1574611817399@ichabod.co-bxl> <20191124181951.GB3552@x60s.casa> Message-ID: <643030919.375007.1574668517628@ichabod.co-bxl> Hi Francesco, Their is a ^2, ^3, ^4 in the lists, respectively. see https://projecteuler.net/problem=87 best, November 24, 2019 7:19:51 PM CET Francesco Ariis wrote:On Sun, Nov 24, 2019 at 05:10:17PM +0100, Alexander Chen wrote: > Hi Francesco, > > length a2 = 7072 > length b3 = 7072 > length c4 = 82 > > I suspect its the first two that get it into trouble. Is is 7072*7072*82 = 41014081088 permutations, 100*3 = 1000000. > > So I am guessing that this is not the fix to the euler problem.... If `x+y+z` need to be <50, and the three are primes, I am puzzled to see such lengths! Which problem is it? _______________________________________________ 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 Nov 25 13:20:24 2019 From: fa-ml at ariis.it (Francesco Ariis) Date: Mon, 25 Nov 2019 14:20:24 +0100 Subject: [Haskell-beginners] list doesn't end In-Reply-To: <643030919.375007.1574668517628@ichabod.co-bxl> References: <1722033790.317238.1574534283773@ichabod.co-bxl> <20191123190532.GA659@x60s.casa> <1726437853.349004.1574611817399@ichabod.co-bxl> <20191124181951.GB3552@x60s.casa> <643030919.375007.1574668517628@ichabod.co-bxl> Message-ID: <20191125132024.GA16954@x60s.casa> On Mon, Nov 25, 2019 at 08:55:17AM +0100, Alexander Chen wrote: > Hi Francesco, > > Their is a ^2, ^3, ^4 in the lists, respectively. > > see https://projecteuler.net/problem=87 This runs reasonably fast even on my old 32bit machine: import qualified Data.Set as S import Data.Numbers.Primes sol72 :: Integer -> Int sol72 l = S.size . S.fromList $ [(x+y+z) | x <- p2, y <- p3, z <- p4, x+y+z < l] where f :: Integer -> [Integer] f n = takeWhile (< l) $ map (^n) primes p2, p3, p4 :: [Integer] p2 = f 2 p3 = f 3 p4 = f 4 λ> sol72 (50 * 10^6) 1097343 Notice how the lengths for lists p2, p3 and p4 are actually 908, 73 and 23! -F From Leonhard.Applis at protonmail.com Thu Nov 28 14:15:27 2019 From: Leonhard.Applis at protonmail.com (Leonhard Applis) Date: Thu, 28 Nov 2019 14:15:27 +0000 Subject: [Haskell-beginners] Providing Haskell Libraries wrapped for other Languages Message-ID: Hi,  I am currently writing a small library. I will provide a small web-api for it, however I have some colleagues who neither have experience in haskell, nor in web-dev.  Also they maybe want to produce programs using my library without internet / docker / etc.  So in addition I'd like to provide the library "wrapped" for other languages, especially python, but maybe java as well.  These wrappers should do nothing except invoking their pardons on the library, and should somewhat contain the library.  What is the common way to do this?  I've seen "hyphen" as a super heavyweight solution, and I've seen people starting the haskell library listening on system-pipes.  I don't feel that these are the "best" solutions, atleast for my intention.  best regards Leonhard -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: publickey - Leonhard.Applis at protonmail.com - 0x807FDDF3.asc Type: application/pgp-keys Size: 1843 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 477 bytes Desc: OpenPGP digital signature URL: From simon.jakobi at googlemail.com Thu Nov 28 15:43:30 2019 From: simon.jakobi at googlemail.com (Simon Jakobi) Date: Thu, 28 Nov 2019 16:43:30 +0100 Subject: [Haskell-beginners] Providing Haskell Libraries wrapped for other Languages In-Reply-To: References: Message-ID: Hi Leonhard, I don't have any experience with calling Haskell from other languages but I am aware of this project: https://github.com/nh2/call-haskell-from-anything I hope it's useful to you. Cheers, Simon Am Do., 28. Nov. 2019 um 15:15 Uhr schrieb Leonhard Applis : > > Hi, > > I am currently writing a small library. > I will provide a small web-api for it, however I have some colleagues who neither have experience in haskell, nor in web-dev. > Also they maybe want to produce programs using my library without internet / docker / etc. > > So in addition I'd like to provide the library "wrapped" for other languages, especially python, but maybe java as well. > These wrappers should do nothing except invoking their pardons on the library, and should somewhat contain the library. > > What is the common way to do this? > > > > I've seen "hyphen" as a super heavyweight solution, and I've seen people starting the haskell library listening on system-pipes. > I don't feel that these are the "best" solutions, atleast for my intention. > > best regards > Leonhard > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners From frederic-emmanuel.picca at synchrotron-soleil.fr Fri Nov 29 10:55:35 2019 From: frederic-emmanuel.picca at synchrotron-soleil.fr (PICCA Frederic-Emmanuel) Date: Fri, 29 Nov 2019 10:55:35 +0000 Subject: [Haskell-beginners] strange error inside a case Message-ID: Hello, I aheve some code whcih look like this thumbnail' :: (MonadIO m, MonadReader Beamline m, MonadThrow m) => ThumbnailInput -> m () thumbnail' (ThumbnailInput col) = do cwd <- toResultsPath "thumbnail" col let shakeFiles' = cwd $(mkRelDir ".shake/") let shakeReport' = shakeFiles' $(mkRelFile "report.html") liftIO $ shake shakeOptions{ shakeFiles=fromAbsDir shakeFiles' , shakeReport=[fromAbsFile shakeReport'] , shakeVerbosity=Diagnostic } $ do let uploaded = fromAbsFile $ cwd $(mkRelFile "thumbnail.uploaded") want [uploaded] -- (Rule 1) merge the image files uploaded %> \_out -> do -- need [xml] masters <- liftIO $ expectedInputFiles col liftIO $ hdf2mergedcbf' (head masters) 1 1 liftIO $ case col of (SomeDataCollection SCollect SHdf5 _) -> hdf2mergedcbf' (head masters) 1 1 (SomeDataCollection SCollect SHdf5' _) -> undefined -- hdf2mergedcbf' (head masters) 1 1 (SomeDataCollection SCaracterization SHdf5 _) -> undefined (SomeDataCollection SCaracterization SHdf5' _) -> undefined _ -> error "show not arrive here !!!" -- hdf2mergedcbf -- command [] "touch" [uploaded] return () When I try to compile it, it give me this error • Couldn't match type ‘a0’ with ‘()’ ‘a0’ is untouchable inside the constraints: f ~ 'ISPyB.DataCollection.Hdf5 bound by a pattern with constructor: SHdf5 :: SCollectSourceFormat 'ISPyB.DataCollection.Hdf5, in a case alternative at src/Thumbnail.hs:180:38-42 Expected type: IO a0 Actual type: IO () • In the expression: hdf2mergedcbf' (head masters) 1 1 In a case alternative: (SomeDataCollection SCollect SHdf5 _) -> hdf2mergedcbf' (head masters) 1 1 In the second argument of ‘($)’, namely ‘case col of (SomeDataCollection SCollect SHdf5 _) -> hdf2mergedcbf' (head masters) 1 1 (SomeDataCollection SCollect SHdf5' _) -> undefined (SomeDataCollection SCaracterization SHdf5 _) -> undefined (SomeDataCollection SCaracterization SHdf5' _) -> undefined _ -> error "show not arrive here !!!"’ | 180 | (SomeDataCollection SCollect SHdf5 _) -> hdf2mergedcbf' (head masters) 1 1 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ What I do not understand is how to fix this since it seems that liftIO $ hdf2mergedcbf' (head masters) 1 1 works out of the case thanks for your help Frederic From sylvain at haskus.fr Fri Nov 29 11:29:23 2019 From: sylvain at haskus.fr (Sylvain Henry) Date: Fri, 29 Nov 2019 12:29:23 +0100 Subject: [Haskell-beginners] strange error inside a case In-Reply-To: References: Message-ID: <7c062774-ff78-569a-fba5-543eccf7cecd@haskus.fr> Hello, What is the type of hdf2mergedcbf' ? Does it work if you write `void (hdf2mergedcbf' (head masters) 1 1)` ? On 29/11/2019 11:55, PICCA Frederic-Emmanuel wrote: > Hello, I aheve some code whcih look like this > > thumbnail' :: (MonadIO m, MonadReader Beamline m, MonadThrow m) => ThumbnailInput -> m () > thumbnail' (ThumbnailInput col) = do > cwd <- toResultsPath "thumbnail" col > let shakeFiles' = cwd $(mkRelDir ".shake/") > let shakeReport' = shakeFiles' $(mkRelFile "report.html") > > liftIO $ shake shakeOptions{ shakeFiles=fromAbsDir shakeFiles' > , shakeReport=[fromAbsFile shakeReport'] > , shakeVerbosity=Diagnostic > } $ do > let uploaded = fromAbsFile $ cwd $(mkRelFile "thumbnail.uploaded") > > want [uploaded] > > -- (Rule 1) merge the image files > uploaded %> \_out -> do > -- need [xml] > masters <- liftIO $ expectedInputFiles col > liftIO $ hdf2mergedcbf' (head masters) 1 1 > liftIO $ case col of > (SomeDataCollection SCollect SHdf5 _) -> hdf2mergedcbf' (head masters) 1 1 > (SomeDataCollection SCollect SHdf5' _) -> undefined -- hdf2mergedcbf' (head masters) 1 1 > (SomeDataCollection SCaracterization SHdf5 _) -> undefined > (SomeDataCollection SCaracterization SHdf5' _) -> undefined > _ -> error "show not arrive here !!!" > > -- hdf2mergedcbf > -- command [] "touch" [uploaded] > return () > > > When I try to compile it, it give me this error > > • Couldn't match type ‘a0’ with ‘()’ > ‘a0’ is untouchable > inside the constraints: f ~ 'ISPyB.DataCollection.Hdf5 > bound by a pattern with constructor: > SHdf5 :: SCollectSourceFormat 'ISPyB.DataCollection.Hdf5, > in a case alternative > at src/Thumbnail.hs:180:38-42 > Expected type: IO a0 > Actual type: IO () > • In the expression: hdf2mergedcbf' (head masters) 1 1 > In a case alternative: > (SomeDataCollection SCollect SHdf5 _) > -> hdf2mergedcbf' (head masters) 1 1 > In the second argument of ‘($)’, namely > ‘case col of > (SomeDataCollection SCollect SHdf5 _) > -> hdf2mergedcbf' (head masters) 1 1 > (SomeDataCollection SCollect SHdf5' _) -> undefined > (SomeDataCollection SCaracterization SHdf5 _) -> undefined > (SomeDataCollection SCaracterization SHdf5' _) -> undefined > _ -> error "show not arrive here !!!"’ > | > 180 | (SomeDataCollection SCollect SHdf5 _) -> hdf2mergedcbf' (head masters) 1 1 > | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > > What I do not understand is how to fix this since it seems that > > liftIO $ hdf2mergedcbf' (head masters) 1 1 works out of the case > > thanks for your help > > Frederic > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners From traqueofziche at gmail.com Fri Nov 29 15:11:55 2019 From: traqueofziche at gmail.com (=?UTF-8?B?6bKN5Yev5paH?=) Date: Fri, 29 Nov 2019 07:11:55 -0800 Subject: [Haskell-beginners] Providing Haskell Libraries wrapped for other Languages In-Reply-To: References: Message-ID: Hi, Have you looked into Apache thrift ( https://thrift.apache.org )? You’d provide interface definitions and the thrift compiler generates client/server code from those. If the overhead of that is intolerable and you really want to call functions “directly”, you could try exporting haskell functions to c and then writing bindings to that for your language, e.g. using the python c api or JNI. I’m just not sure how one’s supposed to ensure initialization of the haskell runtime in any case. Good luck On Fri, Nov 29, 2019 at 5:00 AM 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. Providing Haskell Libraries wrapped for other Languages > (Leonhard Applis) > 2. Re: Providing Haskell Libraries wrapped for other Languages > (Simon Jakobi) > 3. strange error inside a case (PICCA Frederic-Emmanuel) > 4. Re: strange error inside a case (Sylvain Henry) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 28 Nov 2019 14:15:27 +0000 > From: Leonhard Applis > To: "beginners at haskell.org" > Subject: [Haskell-beginners] Providing Haskell Libraries wrapped for > other Languages > Message-ID: > > protonmail.com> > > Content-Type: text/plain; charset="utf-8" > > Hi, > I am currently writing a small library. I will provide a small web-api for > it, however I have some colleagues who neither have experience in haskell, > nor in web-dev. > Also they maybe want to produce programs using my library without internet > / docker / etc. > > So in addition I'd like to provide the library "wrapped" for other > languages, especially python, but maybe java as well. > These wrappers should do nothing except invoking their pardons on the > library, and should somewhat contain the library. > > What is the common way to do this? > I've seen "hyphen" as a super heavyweight solution, and I've seen people > starting the haskell library listening on system-pipes. > I don't feel that these are the "best" solutions, atleast for my > intention. > > best regards > Leonhard > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://mail.haskell.org/pipermail/beginners/attachments/20191128/38f52f24/attachment-0001.html > > > -------------- next part -------------- > A non-text attachment was scrubbed... > Name: publickey - Leonhard.Applis at protonmail.com - 0x807FDDF3.asc > Type: application/pgp-keys > Size: 1843 bytes > Desc: not available > URL: < > http://mail.haskell.org/pipermail/beginners/attachments/20191128/38f52f24/attachment-0001.key > > > -------------- next part -------------- > A non-text attachment was scrubbed... > Name: signature.asc > Type: application/pgp-signature > Size: 477 bytes > Desc: OpenPGP digital signature > URL: < > http://mail.haskell.org/pipermail/beginners/attachments/20191128/38f52f24/attachment-0001.sig > > > > ------------------------------ > > Message: 2 > Date: Thu, 28 Nov 2019 16:43:30 +0100 > From: Simon Jakobi > To: Leonhard Applis , The > Haskell-Beginners Mailing List - Discussion of primarily > beginner-level topics related to Haskell > Subject: Re: [Haskell-beginners] Providing Haskell Libraries wrapped > for other Languages > Message-ID: > tG7oU3TAtRXTAw at mail.gmail.com> > Content-Type: text/plain; charset="UTF-8" > > Hi Leonhard, > > I don't have any experience with calling Haskell from other languages > but I am aware of this project: > > https://github.com/nh2/call-haskell-from-anything > > I hope it's useful to you. > > Cheers, > Simon > > Am Do., 28. Nov. 2019 um 15:15 Uhr schrieb Leonhard Applis > : > > > > Hi, > > > > I am currently writing a small library. > > I will provide a small web-api for it, however I have some colleagues > who neither have experience in haskell, nor in web-dev. > > Also they maybe want to produce programs using my library without > internet / docker / etc. > > > > So in addition I'd like to provide the library "wrapped" for other > languages, especially python, but maybe java as well. > > These wrappers should do nothing except invoking their pardons on the > library, and should somewhat contain the library. > > > > What is the common way to do this? > > > > > > > > I've seen "hyphen" as a super heavyweight solution, and I've seen people > starting the haskell library listening on system-pipes. > > I don't feel that these are the "best" solutions, atleast for my > intention. > > > > best regards > > Leonhard > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > ------------------------------ > > Message: 3 > Date: Fri, 29 Nov 2019 10:55:35 +0000 > From: PICCA Frederic-Emmanuel > > To: "The Haskell-Beginners Mailing List - Discussion of primarily > beginner-level topics related to Haskell" > Subject: [Haskell-beginners] strange error inside a case > Message-ID: > < > A2A20EC3B8560D408356CAC2FC148E53017D83AB1A at SUN-DAG3.synchrotron-soleil.fr> > > Content-Type: text/plain; charset="Windows-1252" > > Hello, I aheve some code whcih look like this > > thumbnail' :: (MonadIO m, MonadReader Beamline m, MonadThrow m) => > ThumbnailInput -> m () > thumbnail' (ThumbnailInput col) = do > cwd <- toResultsPath "thumbnail" col > let shakeFiles' = cwd $(mkRelDir ".shake/") > let shakeReport' = shakeFiles' $(mkRelFile "report.html") > > liftIO $ shake shakeOptions{ shakeFiles=fromAbsDir shakeFiles' > , shakeReport=[fromAbsFile shakeReport'] > , shakeVerbosity=Diagnostic > } $ do > let uploaded = fromAbsFile $ cwd $(mkRelFile "thumbnail.uploaded") > > want [uploaded] > > -- (Rule 1) merge the image files > uploaded %> \_out -> do > -- need [xml] > masters <- liftIO $ expectedInputFiles col > liftIO $ hdf2mergedcbf' (head masters) 1 1 > liftIO $ case col of > (SomeDataCollection SCollect SHdf5 _) -> hdf2mergedcbf' > (head masters) 1 1 > (SomeDataCollection SCollect SHdf5' _) -> undefined -- > hdf2mergedcbf' (head masters) 1 1 > (SomeDataCollection SCaracterization SHdf5 _) -> undefined > (SomeDataCollection SCaracterization SHdf5' _) -> undefined > _ -> error "show not > arrive here !!!" > > -- hdf2mergedcbf > -- command [] "touch" [uploaded] > return () > > > When I try to compile it, it give me this error > > • Couldn't match type ‘a0’ with ‘()’ > ‘a0’ is untouchable > inside the constraints: f ~ 'ISPyB.DataCollection.Hdf5 > bound by a pattern with constructor: > SHdf5 :: SCollectSourceFormat > 'ISPyB.DataCollection.Hdf5, > in a case alternative > at src/Thumbnail.hs:180:38-42 > Expected type: IO a0 > Actual type: IO () > • In the expression: hdf2mergedcbf' (head masters) 1 1 > In a case alternative: > (SomeDataCollection SCollect SHdf5 _) > -> hdf2mergedcbf' (head masters) 1 1 > In the second argument of ‘($)’, namely > ‘case col of > (SomeDataCollection SCollect SHdf5 _) > -> hdf2mergedcbf' (head masters) 1 1 > (SomeDataCollection SCollect SHdf5' _) -> undefined > (SomeDataCollection SCaracterization SHdf5 _) -> undefined > (SomeDataCollection SCaracterization SHdf5' _) -> undefined > _ -> error "show not arrive here !!!"’ > | > 180 | (SomeDataCollection SCollect SHdf5 _) -> > hdf2mergedcbf' (head masters) 1 1 > | > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > > What I do not understand is how to fix this since it seems that > > liftIO $ hdf2mergedcbf' (head masters) 1 1 works out of the case > > thanks for your help > > Frederic > > ------------------------------ > > Message: 4 > Date: Fri, 29 Nov 2019 12:29:23 +0100 > From: Sylvain Henry > To: > Subject: Re: [Haskell-beginners] strange error inside a case > Message-ID: <7c062774-ff78-569a-fba5-543eccf7cecd at haskus.fr> > Content-Type: text/plain; charset="utf-8"; format=flowed > > Hello, > > What is the type of hdf2mergedcbf' ? > > Does it work if you write `void (hdf2mergedcbf' (head masters) 1 1)` ? > > > On 29/11/2019 11:55, PICCA Frederic-Emmanuel wrote: > > Hello, I aheve some code whcih look like this > > > > thumbnail' :: (MonadIO m, MonadReader Beamline m, MonadThrow m) => > ThumbnailInput -> m () > > thumbnail' (ThumbnailInput col) = do > > cwd <- toResultsPath "thumbnail" col > > let shakeFiles' = cwd $(mkRelDir ".shake/") > > let shakeReport' = shakeFiles' $(mkRelFile "report.html") > > > > liftIO $ shake shakeOptions{ shakeFiles=fromAbsDir shakeFiles' > > , shakeReport=[fromAbsFile shakeReport'] > > , shakeVerbosity=Diagnostic > > } $ do > > let uploaded = fromAbsFile $ cwd $(mkRelFile > "thumbnail.uploaded") > > > > want [uploaded] > > > > -- (Rule 1) merge the image files > > uploaded %> \_out -> do > > -- need [xml] > > masters <- liftIO $ expectedInputFiles col > > liftIO $ hdf2mergedcbf' (head masters) 1 1 > > liftIO $ case col of > > (SomeDataCollection SCollect SHdf5 _) -> > hdf2mergedcbf' (head masters) 1 1 > > (SomeDataCollection SCollect SHdf5' _) -> undefined -- > hdf2mergedcbf' (head masters) 1 1 > > (SomeDataCollection SCaracterization SHdf5 _) -> undefined > > (SomeDataCollection SCaracterization SHdf5' _) -> undefined > > _ -> error "show > not arrive here !!!" > > > > -- hdf2mergedcbf > > -- command [] "touch" [uploaded] > > return () > > > > > > When I try to compile it, it give me this error > > > > • Couldn't match type ‘a0’ with ‘()’ > > ‘a0’ is untouchable > > inside the constraints: f ~ 'ISPyB.DataCollection.Hdf5 > > bound by a pattern with constructor: > > SHdf5 :: SCollectSourceFormat > 'ISPyB.DataCollection.Hdf5, > > in a case alternative > > at src/Thumbnail.hs:180:38-42 > > Expected type: IO a0 > > Actual type: IO () > > • In the expression: hdf2mergedcbf' (head masters) 1 1 > > In a case alternative: > > (SomeDataCollection SCollect SHdf5 _) > > -> hdf2mergedcbf' (head masters) 1 1 > > In the second argument of ‘($)’, namely > > ‘case col of > > (SomeDataCollection SCollect SHdf5 _) > > -> hdf2mergedcbf' (head masters) 1 1 > > (SomeDataCollection SCollect SHdf5' _) -> undefined > > (SomeDataCollection SCaracterization SHdf5 _) -> undefined > > (SomeDataCollection SCaracterization SHdf5' _) -> undefined > > _ -> error "show not arrive here !!!"’ > > | > > 180 | (SomeDataCollection SCollect SHdf5 _) -> > hdf2mergedcbf' (head masters) 1 1 > > | > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > > > > > > What I do not understand is how to fix this since it seems that > > > > liftIO $ hdf2mergedcbf' (head masters) 1 1 works out of the case > > > > thanks for your help > > > > Frederic > > _______________________________________________ > > Beginners mailing list > > Beginners at haskell.org > > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > Beginners mailing list > Beginners at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/beginners > > > ------------------------------ > > End of Beginners Digest, Vol 137, Issue 13 > ****************************************** > -------------- next part -------------- An HTML attachment was scrubbed... URL: From frederic-emmanuel.picca at synchrotron-soleil.fr Fri Nov 29 18:23:45 2019 From: frederic-emmanuel.picca at synchrotron-soleil.fr (PICCA Frederic-Emmanuel) Date: Fri, 29 Nov 2019 18:23:45 +0000 Subject: [Haskell-beginners] strange error inside a case In-Reply-To: <7c062774-ff78-569a-fba5-543eccf7cecd@haskus.fr> References: , <7c062774-ff78-569a-fba5-543eccf7cecd@haskus.fr> Message-ID: > What is the type of hdf2mergedcbf' ? hdf2mergedcbf' :: Path Abs File -> Int -> Int -> IO () > Does it work if you write `void (hdf2mergedcbf' (head masters) 1 1)` ? nop • In the expression: void (hdf2mergedcbf' (head masters) 1 1) In a case alternative: (SomeDataCollection SCollect SHdf5 _) -> void (hdf2mergedcbf' (head masters) 1 1) In the second argument of ‘($)’, namely ‘case col of { (SomeDataCollection SCollect SHdf5 _) -> void (hdf2mergedcbf' (head masters) 1 1) }’ | 184 | (SomeDataCollection SCollect SHdf5 _) -> void (hdf2mergedcbf' (head masters) 1 1) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ HsCompilation exited abnormally with code 1 at Fri Nov 29 19:23:04