From mail at nh2.me Fri Sep 1 10:40:42 2017 From: mail at nh2.me (=?UTF-8?Q?Niklas_Hamb=c3=bcchen?=) Date: Fri, 1 Sep 2017 11:40:42 +0100 Subject: [Haskell-cafe] Crossreferenced codebase for Stackage LTS 9.2 available In-Reply-To: References: <8c4634fe-d8a2-2506-8b71-e7c87ffed04c@nh2.me> Message-ID: <3ba37997-2287-ae3e-580f-d1387f5de863@nh2.me> I consider usages on Hackage an OK estimator of usages outside of Stackage, certainly enough to get a first expression. Also, with haskell-indexer becoming really easy to use, the maintainers of off-Hackage code bases can themselves more easily determine whether they use functions in question and chime into the discussion with real data. On 31/08/17 19:31, Joachim Durchholz wrote: > It does not (and cannot) tell you about caller code that is not on Hackage. > If you have a low-level library then that information is still better > than nothing, but if your code is a public API this information is > almost worse than nothing. From simon at joyful.com Fri Sep 1 15:11:05 2017 From: simon at joyful.com (Simon Michael) Date: Fri, 1 Sep 2017 08:11:05 -0700 Subject: [Haskell-cafe] megaparsec 6 migration In-Reply-To: References: Message-ID: On 8/24/17 8:26 PM, ☂Josh Chia (謝任中) wrote: > Are there examples or tutorials compatible with megaparsec 6? For a start, > what should I do with the above two things that have 'disappeared'? What do > I replace them with? Hi Josh, Here's a Text.Megaparsec.Compat module, useful for supporting megaparsec <6 and >=6. https://github.com/fpco/stackage/issues/2666#issuecomment-318538839 From jkb at jkbsc.co.uk Fri Sep 1 19:49:34 2017 From: jkb at jkbsc.co.uk (John Beattie) Date: Fri, 1 Sep 2017 20:49:34 +0100 Subject: [Haskell-cafe] To merge package documentation with the platform doc tree In-Reply-To: References: <20170829210627.GA27852@pabbay.hignfy.demon.co.uk> <20170829212950.jsvkfgzk6sfbncex@x60s.casa> Message-ID: <20170901194934.GA1397@pabbay.hignfy.demon.co.uk> Thanks for all this. I tried the cabal method of F. (ariis.it) and that works fine. Thanks again, John On 2017-08-30 02:20 +0000, Jake wrote: > Another way of doing this is by using Nix package manager. This section of the > manual explains how to create a shell environment with a set of specified > packages installed that includes a unified haddock documentation directory. > > On Tue, Aug 29, 2017 at 5:32 PM Francesco Ariis wrote: > > On Tue, Aug 29, 2017 at 10:06:27PM +0100, John Beattie wrote: > > Hi, > > > > Suppose I download a package and install it. I would like to be able to > have > > the html documentation for that package and I would like it to be > integrated > > with the local doc tree in the haskell platform. > > > > Is this a recognised usecase and is there a recommended way to do that? > > > > My first thought was to use haddock but I haven't managed to work out if > there > > is a combination of haddock options which would get me there. > > > > As an alternative, I was wondering about cloning the GHC platform source > and > > pasting the new library into the source tree alongside the other > libraries and > > building the documentation.  I might have to tweak a makefile or somesuch > but > > would that work? > > > > Thanks, > > John Beattie > > Hello John, > > ah, my time to spam! > >     http://ariis.it/static/articles/no-docs-hackage/page.html > > I bootstrap cabal (HP minimal?) and it works as written. I did not test > it with HP full but I don't think it should have problems with that. > > Let me know if it does the trick > -F > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. From lam.dev.hs at gmail.com Sat Sep 2 05:10:36 2017 From: lam.dev.hs at gmail.com (Weylin Lam) Date: Sat, 2 Sep 2017 07:10:36 +0200 Subject: [Haskell-cafe] issues with ad-hoc polymorphic typeclass instances Message-ID: Hello ! I'm trying to write a polymorphic class instance in function of another class. So far it's pretty hard, I have trouble with headsizes and so on. I actually had to switch to type families pretty fast, and i'm still not out of the woods. http://lpaste.net/2650337298029215744 The context: It concerns "tagless final interpreters" for EDSLs as described in http://okmij.org/ftp/tagless-final/course/lecture.pdf A comparison with free monads: http://yowconference.com.au/slides/ yowlambdajam2016/Hopkins-StopPayingForFreeMonads.pdf The technique is fairly simple: instead of using ADTs to encode the operations of the language, we use haskell's class system. Languages become type classes, and interpreters are the instances which give various different meanings to the language expressions, which become simple haskell, ad-hoc polymorphic values. It has strong advantages. For example, to write some expression in the composition of two languages (two typeclasses), you only need to combine the constraints: class WriteFile h m where writeFile :: h -> String -> m () class ReadFile h m where readFile :: h -> m String -- we use Monad m to have access to monadic operations, but the language itself -- does not care that m be a monad or not. myExpression :: (WriteFile h m, ReadFile h m, Monad m) => h -> h -> String -> m String myExpression h h2 str = writeFile h str *> readFile h2 The fusion of both languages is utterly seamless, which is the beauty of typeclasses. When writing DSLs, there are at least two basic operations that need to be done: combining DSLs to create richer languages (and as just shown, it's really simple with this technique), and translating one DSL into another. That latter operation between DSLs is a bit more complicated with classes. I haven't found examples of how to do so in the wild (the technique doesn't seem very much used, esp compared with free monads), so if anybody knows how to do it or has references on that, it'd be much appreciated. Theoretical example of what i'm trying to perform: class A a where subtract :: a -> a -> a class B a where add :: a -> a -> a neg :: a -> a -- interpreter from A to B: (doesn't work of course) class (B a) => A a where subtract x y = add x (neg y) -- interpreter for B in terms of Int: instance B Int where add = (+) neg = negate expression :: (A a) => a expression = subtract (subtract 4 5) 6 -- to get it to be interpreted, we need to select the type. usually we use a monomorphic version of id: asInt = identity :: Int -> Int intExp = asInt expression :: Int For the instance B Int to be re-usable as instance/interpreter of (A Int) expressions, we need a way to write an interpretation of A a in terms of any pre-existing interpretation of B b. Usually there are some issues, the need to wrap the types into newtype wrappers among others. But in the case i'm trying to solve, it still doesn't work. To see where i'm stuck, see above my lpaste. Any help or ideas would be very welcome! :) Thanks a lot in advance. -------------- next part -------------- An HTML attachment was scrubbed... URL: From anselm.scholl at tu-harburg.de Sat Sep 2 05:48:16 2017 From: anselm.scholl at tu-harburg.de (Jonas Scholl) Date: Sat, 2 Sep 2017 07:48:16 +0200 Subject: [Haskell-cafe] issues with ad-hoc polymorphic typeclass instances In-Reply-To: References: Message-ID: <3958c5bf-7c22-560a-4957-38b93359c392@tu-harburg.de> Do addWithEnv and mulWithEnv need to be functions in a type class? Couldn't you just define them as normal functions? Then all the problems with undecidable instances are gone. I also don't see how having them in a type class helps you in any way if you want to define such a far reaching instance for it. Are there cases where you would need another instance? If not, then putting it in a plain function is the way to go. If yes, then you can not define Op and Env for the type of your OpEnv instance, which seems counterintuitive. Otherwise you would run into overlapping instances and I don't know if you want that, probably not. On 09/02/2017 07:10 AM, Weylin Lam wrote: > Hello ! > > I'm trying to write a polymorphic class instance in function of another > class. So far it's pretty hard, I have trouble with headsizes and so on. > I actually had to switch to type families pretty fast, and i'm still not > out of the woods. > http://lpaste.net/2650337298029215744 > > > The context: > It concerns "tagless final interpreters" for EDSLs as described > in http://okmij.org/ftp/tagless-final/course/lecture.pdf > > A comparison with free > monads: http://yowconference.com.au/slides/yowlambdajam2016/Hopkins-StopPayingForFreeMonads.pdf > > > The technique is fairly simple: instead of using ADTs to encode the > operations of the language, we use haskell's class system. Languages > become type classes, and interpreters are the instances which give > various different meanings to the language expressions, which become > simple haskell, ad-hoc polymorphic values. > > It has strong advantages. For example, to write some expression in the > composition of two languages (two typeclasses), you only need to combine > the constraints: > class WriteFile h m where >   writeFile :: h -> String -> m () > class ReadFile h m where >   readFile :: h -> m String > > -- we use Monad m to have access to monadic operations, but the language > itself > -- does not care that m be a monad or not. > myExpression :: (WriteFile h m, ReadFile h m, Monad m) => h -> h -> > String -> m String > myExpression h h2 str = writeFile h str *> readFile h2 > > The fusion of both languages is utterly seamless, which is the beauty of > typeclasses. > > When writing DSLs, there are at least two basic operations that need to > be done: combining DSLs to create richer languages (and as just shown, > it's really simple with this technique), and translating one DSL into > another. > > That latter operation between DSLs is a bit more complicated with > classes. I haven't found examples of how to do so in the wild (the > technique doesn't seem very much used, esp compared with free monads), > so if anybody knows how to do it or has references on that, it'd be much > appreciated. > > Theoretical example of what i'm trying to perform: > class A a where >   subtract :: a -> a -> a > class B a where >   add :: a -> a -> a >   neg :: a -> a > > -- interpreter from A to B: (doesn't work of course) > class (B a) => A a where >   subtract x y = add x (neg y) > > -- interpreter for B in terms of Int: > instance B Int where >   add = (+) >   neg = negate > > expression :: (A a) => a > expression = subtract (subtract 4 5) 6 > -- to get it to be interpreted, we need to select the type. usually we > use a monomorphic version of id: > asInt = identity :: Int -> Int > intExp = asInt expression :: Int > > For the instance B Int to be re-usable as instance/interpreter of (A > Int) expressions, we need a way to write an interpretation of A a in > terms of any pre-existing interpretation of B b. > Usually there are some issues, the need to wrap the types into newtype > wrappers among others. > > But in the case i'm trying to solve, it still doesn't work. To see where > i'm stuck, see above my lpaste. > > Any help or ideas would be very welcome! :) Thanks a lot in advance. > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: From lam.dev.hs at gmail.com Sat Sep 2 07:21:17 2017 From: lam.dev.hs at gmail.com (Weylin Lam) Date: Sat, 2 Sep 2017 09:21:17 +0200 Subject: [Haskell-cafe] Fwd: issues with ad-hoc polymorphic typeclass instances In-Reply-To: References: <3958c5bf-7c22-560a-4957-38b93359c392@tu-harburg.de> Message-ID: ---------- Forwarded message ---------- From: Weylin Lam Date: Sat, Sep 2, 2017 at 8:37 AM Subject: Re: [Haskell-cafe] issues with ad-hoc polymorphic typeclass instances To: Jonas Scholl i actually hadn't thought of that! It's an good idea, indeed. The issue is, in terms of DSLs, there'd be no way to prevent a potential mix between the more abstract language and its translation, because expressions are connected to their DSLs via constraints, and here without a class for the language OpEnv, there'd be no way to prevent say the use of ask mixed with addWithEnv, since to use the latter i'd need to put a (Op e, OpEnv e m) constraint... Also, without class i simply couldn't define and use the language OpEnv as is, regardless of the existence of its implementation in terms of Op and Env. Sure for my trivial example it's not very important, but it *is* just a trivial example, it doesn't mean it's always irrelevant... at least i think so. On Sat, Sep 2, 2017 at 7:48 AM, Jonas Scholl wrote: > Do addWithEnv and mulWithEnv need to be functions in a type class? > Couldn't you just define them as normal functions? Then all the problems > with undecidable instances are gone. I also don't see how having them in > a type class helps you in any way if you want to define such a far > reaching instance for it. Are there cases where you would need another > instance? If not, then putting it in a plain function is the way to go. > If yes, then you can not define Op and Env for the type of your OpEnv > instance, which seems counterintuitive. Otherwise you would run into > overlapping instances and I don't know if you want that, probably not. > > On 09/02/2017 07:10 AM, Weylin Lam wrote: > > Hello ! > > > > I'm trying to write a polymorphic class instance in function of another > > class. So far it's pretty hard, I have trouble with headsizes and so on. > > I actually had to switch to type families pretty fast, and i'm still not > > out of the woods. > > http://lpaste.net/2650337298029215744 > > > > > > The context: > > It concerns "tagless final interpreters" for EDSLs as described > > in http://okmij.org/ftp/tagless-final/course/lecture.pdf > > > > A comparison with free > > monads: http://yowconference.com.au/slides/yowlambdajam2016/ > Hopkins-StopPayingForFreeMonads.pdf > > -StopPayingForFreeMonads.pdf> > > > > The technique is fairly simple: instead of using ADTs to encode the > > operations of the language, we use haskell's class system. Languages > > become type classes, and interpreters are the instances which give > > various different meanings to the language expressions, which become > > simple haskell, ad-hoc polymorphic values. > > > > It has strong advantages. For example, to write some expression in the > > composition of two languages (two typeclasses), you only need to combine > > the constraints: > > class WriteFile h m where > > writeFile :: h -> String -> m () > > class ReadFile h m where > > readFile :: h -> m String > > > > -- we use Monad m to have access to monadic operations, but the language > > itself > > -- does not care that m be a monad or not. > > myExpression :: (WriteFile h m, ReadFile h m, Monad m) => h -> h -> > > String -> m String > > myExpression h h2 str = writeFile h str *> readFile h2 > > > > The fusion of both languages is utterly seamless, which is the beauty of > > typeclasses. > > > > When writing DSLs, there are at least two basic operations that need to > > be done: combining DSLs to create richer languages (and as just shown, > > it's really simple with this technique), and translating one DSL into > > another. > > > > That latter operation between DSLs is a bit more complicated with > > classes. I haven't found examples of how to do so in the wild (the > > technique doesn't seem very much used, esp compared with free monads), > > so if anybody knows how to do it or has references on that, it'd be much > > appreciated. > > > > Theoretical example of what i'm trying to perform: > > class A a where > > subtract :: a -> a -> a > > class B a where > > add :: a -> a -> a > > neg :: a -> a > > > > -- interpreter from A to B: (doesn't work of course) > > class (B a) => A a where > > subtract x y = add x (neg y) > > > > -- interpreter for B in terms of Int: > > instance B Int where > > add = (+) > > neg = negate > > > > expression :: (A a) => a > > expression = subtract (subtract 4 5) 6 > > -- to get it to be interpreted, we need to select the type. usually we > > use a monomorphic version of id: > > asInt = identity :: Int -> Int > > intExp = asInt expression :: Int > > > > For the instance B Int to be re-usable as instance/interpreter of (A > > Int) expressions, we need a way to write an interpretation of A a in > > terms of any pre-existing interpretation of B b. > > Usually there are some issues, the need to wrap the types into newtype > > wrappers among others. > > > > But in the case i'm trying to solve, it still doesn't work. To see where > > i'm stuck, see above my lpaste. > > > > Any help or ideas would be very welcome! :) Thanks a lot in advance. > > > > > > _______________________________________________ > > Haskell-Cafe mailing list > > To (un)subscribe, modify options or view archives go to: > > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > Only members subscribed via the mailman list are allowed to post. > > > > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From david.feuer at gmail.com Sun Sep 3 03:50:15 2017 From: david.feuer at gmail.com (David Feuer) Date: Sat, 2 Sep 2017 23:50:15 -0400 Subject: [Haskell-cafe] How to import hidden modules In-Reply-To: <31e52a0a-540b-7988-cebe-c13afbb144f0@sip.ucm.es> References: <31e52a0a-540b-7988-cebe-c13afbb144f0@sip.ucm.es> Message-ID: I'm a little confused. Data.Map.Internal from the containers package isn't hidden at all! What version of containers are you using? On Thu, Aug 31, 2017 at 11:05 AM, Ricardo Peña wrote: > Hi, > > I need to define a class instance for the algebraic datatype Data.Map.Map in > the Hierarchical GCH libraries, but I do not find the way to import > Data.Map.Internal which it is assumed to be hidden. Is there any way to > access to this definition? > > Thanks > -Ricardo > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. From hello at mario.net.au Tue Sep 5 15:01:09 2017 From: hello at mario.net.au (Mario Rogic) Date: Tue, 5 Sep 2017 16:01:09 +0100 Subject: [Haskell-cafe] Archival of community.haskell.org In-Reply-To: References: Message-ID: Hi all In continuation of the work towards shutting down the legacy community.haskell.org server, I have the following updates to share: - The projects.haskell.org, and code.haskell.org sites have now been archived to https://archives.haskell.org/, and redirects have been put in place - http://trac.haskell.org/ has been disabled, but will not be archived due to its long term broken state - We discovered that code/projects domains were still being used for ~user dirs , redirect exceptions have now been put in place for those Next on the list is the personal directories. Thanks to those who have already reached out. If you still use a personal account on community.haskell.org or have data there you would like to retain, *you are encouraged to migrate or backup ASAP*. I can assist with putting in place redirects for a time, please email me if desired. Thanks - Mario On 4 March 2017 at 12:23, Mario Rogic wrote: > Hi all > > As announced back in 2015 > we > have started archiving community.haskell.org services. > > We've created https://archives.haskell.org/, and the old projects mailing > lists have been the first to be archived. > > Next on the list is the remainder of projects.haskell.org, and the > code.haskell.org site. > > As always, you can email admin at h.o or hop on the #haskell-infrastructure > freenode channel to provide feedback / concerns. > > Thanks > > - Mario > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dominic at steinitz.org Tue Sep 5 20:29:20 2017 From: dominic at steinitz.org (dominic at steinitz.org) Date: Tue, 5 Sep 2017 22:29:20 +0200 Subject: [Haskell-cafe] Haskell Numerics / Data Science at ICFP Message-ID: <75F9BE17-04D0-4867-AF12-7F52A4E318D4@steinitz.org> Hello Fellow Haskellers, The organisers of ICFP have very kindly given a room for anyone interested in Haskell Numerics / Data Science on Saturday 9th September 1230-1400. All are welcome and there will be a sign at the reception desk on Saturday morning. I will present a few slides on what we currently have available in our armoury and what might be possible. I plan to spend less than 10 minutes on this. Trevor McDonell has kindly offered to say a few words on accelerate. If anyone wants to give a lightning talk please feel free. Dominic Steinitz dominic at steinitz.org http://idontgetoutmuch.wordpress.com From mgajda at mimuw.edu.pl Wed Sep 6 12:48:44 2017 From: mgajda at mimuw.edu.pl (Michal J Gajda) Date: Wed, 06 Sep 2017 12:48:44 +0000 Subject: [Haskell-cafe] Haskell-Cafe Digest, Vol 169, Issue 4 In-Reply-To: References: Message-ID: Hi I can tell a few words about ETL and ML problems in in practice. -- Best regards Michal -------------- next part -------------- An HTML attachment was scrubbed... URL: From dominic at steinitz.org Wed Sep 6 13:30:16 2017 From: dominic at steinitz.org (dominic at steinitz.org) Date: Wed, 6 Sep 2017 14:30:16 +0100 Subject: [Haskell-cafe] Haskell-Cafe Digest, Vol 169, Issue 4 In-Reply-To: References: Message-ID: <2BC9ACA7-7118-40F5-90BD-BCB8AE78D2E5@steinitz.org> Hi Michal, That would be great :) I look forward to meeting you. > On 6 Sep 2017, at 13:48, Michal J Gajda wrote: > > Hi > I can tell a few words about ETL and ML problems in in practice. > -- > Best regards > Michal Dominic Steinitz dominic at steinitz.org http://idontgetoutmuch.wordpress.com From doug at cs.dartmouth.edu Wed Sep 6 16:22:49 2017 From: doug at cs.dartmouth.edu (Doug McIlroy) Date: Wed, 06 Sep 2017 12:22:49 -0400 Subject: [Haskell-cafe] Haskell Numerics / Data Science at ICFP Message-ID: <201709061622.v86GMnAh104450@tahoe.cs.Dartmouth.EDU> I won't be at ICFP, but would like to put in a reminder about the shabbiness of GHC floating-point output conversion. When I raised this issue once before, I got the surprising reaction that speed was more important than accuracy. Doug McIlroy From romanandreg at gmail.com Wed Sep 6 19:17:14 2017 From: romanandreg at gmail.com (=?UTF-8?B?Um9tw6FuIEdvbnrDoWxleg==?=) Date: Wed, 6 Sep 2017 12:17:14 -0700 Subject: [Haskell-cafe] [ANN] Haskell Workshop in Vancouver, BC Message-ID: `Hello, Is my pleasure to share the news about a new Study Group to learn Haskell using "The Haskell Book". If you live in Vancouver, British Columbia, or know someone that lives here and might be interested in learning Haskell, please share this link with them: https://workshops.vanfp.org/haskell Best Regards. Roman.- -------------- next part -------------- An HTML attachment was scrubbed... URL: From ietf-dane at dukhovni.org Wed Sep 6 19:26:52 2017 From: ietf-dane at dukhovni.org (Viktor Dukhovni) Date: Wed, 6 Sep 2017 15:26:52 -0400 Subject: [Haskell-cafe] optparse-applicative in stack LTS <= 9.3 Message-ID: FYI, the version of optparse-applicative (0.13.2.0) in Stack LTS-9.3 and earlier does not appear to handle the "noIntersperse" info modifier correctly. Instead of stopping parsing flags after the first non-option argument, it instead simply never parses any options. This is fixed in 0.14.0.0, which is in "Stackage Nightly". Perhaps someone else will run into the same issue. And it would of course be nice to see 0.14.0.0 appear in an upcoming LTS version (say 9.4). -- Viktor. Demo program, this fails to even process "--help" with the outdated optparse-applicative, which just reports all arguments as positional: module Main (main) where import Options.Applicative import Data.Monoid ((<>)) data Opts = Opts { bl :: Bool , fl :: Bool , st :: Maybe String , pos :: String , args :: [String] } deriving (Show) main :: IO () main = do let parse = Opts <$> switch ( long "bool" <> short 'b' ) <*> switch ( long "flag" <> short 'f' ) <*> optional ( strOption ( long "string" <> short 's' ) ) <*> strArgument ( metavar "FILE" ) <*> many ( strArgument ( metavar "ARGS..." ) ) i = info (helper <*> parse) $ fullDesc <> noIntersperse <> header "Option parser" <> progDesc "- test POSIX-style options" execParser i >>= print -- Viktor. From andrew.thaddeus at gmail.com Thu Sep 7 15:07:44 2017 From: andrew.thaddeus at gmail.com (Andrew Martin) Date: Thu, 7 Sep 2017 11:07:44 -0400 Subject: [Haskell-cafe] Maintenance of streaming and streaming-bytestring Message-ID: David Feuer brought this up two weeks ago [0]. The maintainer of streaming and streaming-bytestring has been unreachable, and provided his continued absence, I would like to become a maintainer of these two libraries. I have put up PRs fixing issues [1] and I've offered on the issue tracker to become a comaintainer [2]. I use this library a lot at work, so I have an interest in keeping it in good shape. [0] https://mail.haskell.org/pipermail/libraries/2017-August/028141.html [1] https://github.com/michaelt/streaming-bytestring/pull/11 [2] https://github.com/michaelt/streaming-bytestring/issues/19 -- -Andrew Thaddeus Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: From carter.schonwald at gmail.com Thu Sep 7 23:42:19 2017 From: carter.schonwald at gmail.com (Carter Schonwald) Date: Fri, 8 Sep 2017 00:42:19 +0100 Subject: [Haskell-cafe] floating point conversion Message-ID: On Wed, Sep 6, 2017 at 5:22 PM, Doug McIlroy wrote: > I won't be at ICFP, but would like to put in a reminder about > the shabbiness of GHC floating-point output conversion. When I > raised this issue once before, I got the surprising reaction > that speed was more important than accuracy. > @doug: could you point me to the issue ? i'm actually allocating some of my time over the next year to improving floating point matters in ghc and the standard, and specific issues you can point me to that you've previously articulated would be super helpful :) > > Doug McIlroy > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dominic at steinitz.org Fri Sep 8 11:56:01 2017 From: dominic at steinitz.org (dominic at steinitz.org) Date: Fri, 8 Sep 2017 12:56:01 +0100 Subject: [Haskell-cafe] Haskell Numerics / Data Science at ICFP In-Reply-To: <201709061622.v86GMnAh104450@tahoe.cs.Dartmouth.EDU> References: <201709061622.v86GMnAh104450@tahoe.cs.Dartmouth.EDU> Message-ID: <39CE2A2E-4C5C-4288-AFA3-DDD82DEAB6D3@steinitz.org> Hi Doug, Thanks for pointing this out. I will raise it but is there a ticket or reference for this also? > On 6 Sep 2017, at 17:22, Doug McIlroy wrote: > > won't be at ICFP, but would like to put in a reminder about > the shabbiness of GHC floating-point output conversion. When I > raised this issue once before, I got the surprising reaction > that speed was more important than accuracy. Dominic Steinitz dominic at steinitz.org http://idontgetoutmuch.wordpress.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeffbrown.the at gmail.com Sat Sep 9 03:54:38 2017 From: jeffbrown.the at gmail.com (Jeffrey Brown) Date: Fri, 8 Sep 2017 20:54:38 -0700 Subject: [Haskell-cafe] Is this a GHC parser error? A test case compiles from one line but not another. Message-ID: The test suite below[1] does what it's supposed to. The last line of it is a commented-out test case: -- assertBool "broken" $ True If I uncomment that, it fails to compile: > :reload [13 of 13] Compiling TParse ( test/TParse.hs, interpreted ) test/TParse.hs:67:3: error: parse error on input ‘assertBool’ | 67 | assertBool "broken" $ True | ^^^^^^^^^^ Failed, 12 modules loaded. > However, if I move it to somewhere earlier in the code, it works. [1] https://github.com/JeffreyBenjaminBrown/digraphs-with-text/blob/e5afd39b950752ccb65997b89ab625d859299b4a/test/TParse.hs -- Jeff Brown | Jeffrey Benjamin Brown Website | Facebook | LinkedIn (spammy, so I often miss messages here) | Github -------------- next part -------------- An HTML attachment was scrubbed... URL: From lexi.lambda at gmail.com Sat Sep 9 04:05:53 2017 From: lexi.lambda at gmail.com (Alexis King) Date: Fri, 8 Sep 2017 21:05:53 -0700 Subject: [Haskell-cafe] Is this a GHC parser error? A test case compiles from one line but not another. In-Reply-To: References: Message-ID: No, it isn’t a GHC parser error. Your preceding expression ends in a where clause, like this: assertBool "4" $ p == Right a where p = ... That’s fine, but make sure you understand how where works. Where clauses are not attached to individual expressions, they are *always* attached to definitions. In this case, the where clause is not attached to the assertion but to your definition of tHash. GHC parses your program the same way as this one: tHash = TestCase $ do ... assertBool "4" $ p == Right a where p = ... Therefore, the where clause forces the termination of the do block, since it exists syntactically outside the “body” of a definition. It is its own syntactic construct, an optional sequence of definitions in scope within the RHS of a definition. You cannot have any more expression after the where clause because they would be free-floating, outside of any particular definition. If you really want definitions that are scoped to that single assertion, use a let expression instead of a where clause: let p = ... a = ... in assertBool "4" $ p == Right a That works, since let...in blocks serve as completely ordinary expressions, and they are permitted anywhere an expression is permitted (unlike where clauses, which must “belong” to a top-level or let-bound definition). > On Sep 8, 2017, at 20:54, Jeffrey Brown > wrote: > > The test suite below[1] does what it's supposed to. The last line of > it is a commented-out test case: > > -- assertBool "broken" $ True > > If I uncomment that, it fails to compile: > > > :reload > [13 of 13] Compiling TParse ( test/TParse.hs, interpreted ) > > test/TParse.hs:67:3: error: parse error on input ‘assertBool’ > | > 67 | assertBool "broken" $ True > | ^^^^^^^^^^ > Failed, 12 modules loaded. > > > > However, if I move it to somewhere earlier in the code, it works. > > > [1] https://github.com/JeffreyBenjaminBrown/digraphs-with-text/blob/e5afd39b950752ccb65997b89ab625d859299b4a/test/TParse.hs > > Jeff Brown | Jeffrey Benjamin Brown From jeffbrown.the at gmail.com Sat Sep 9 04:53:45 2017 From: jeffbrown.the at gmail.com (Jeffrey Brown) Date: Fri, 8 Sep 2017 21:53:45 -0700 Subject: [Haskell-cafe] Is this a GHC parser error? A test case compiles from one line but not another. In-Reply-To: References: Message-ID: Thanks, Alexis! Your explanation of the distinction between let and where is the first I've understood. On Fri, Sep 8, 2017 at 9:05 PM, Alexis King wrote: > No, it isn’t a GHC parser error. > > Your preceding expression ends in a where clause, like this: > > assertBool "4" $ p == Right a where > p = ... > > That’s fine, but make sure you understand how where works. Where clauses > are not attached to individual expressions, they are *always* attached > to definitions. In this case, the where clause is not attached to the > assertion but to your definition of tHash. GHC parses your program the > same way as this one: > > tHash = TestCase $ do > ... > assertBool "4" $ p == Right a > where > p = ... > > Therefore, the where clause forces the termination of the do block, > since it exists syntactically outside the “body” of a definition. It is > its own syntactic construct, an optional sequence of definitions in > scope within the RHS of a definition. You cannot have any more > expression after the where clause because they would be free-floating, > outside of any particular definition. > > If you really want definitions that are scoped to that single assertion, > use a let expression instead of a where clause: > > let p = ... > a = ... > in assertBool "4" $ p == Right a > > That works, since let...in blocks serve as completely ordinary > expressions, and they are permitted anywhere an expression is permitted > (unlike where clauses, which must “belong” to a top-level or let-bound > definition). > > > On Sep 8, 2017, at 20:54, Jeffrey Brown > > wrote: > > > > The test suite below[1] does what it's supposed to. The last line of > > it is a commented-out test case: > > > > -- assertBool "broken" $ True > > > > If I uncomment that, it fails to compile: > > > > > :reload > > [13 of 13] Compiling TParse ( test/TParse.hs, interpreted ) > > > > test/TParse.hs:67:3: error: parse error on input ‘assertBool’ > > | > > 67 | assertBool "broken" $ True > > | ^^^^^^^^^^ > > Failed, 12 modules loaded. > > > > > > > However, if I move it to somewhere earlier in the code, it works. > > > > > > [1] https://github.com/JeffreyBenjaminBrown/digraphs-with-text/blob/ > e5afd39b950752ccb65997b89ab625d859299b4a/test/TParse.hs > > > > Jeff Brown | Jeffrey Benjamin Brown > > -- Jeff Brown | Jeffrey Benjamin Brown Website | Facebook | LinkedIn (spammy, so I often miss messages here) | Github -------------- next part -------------- An HTML attachment was scrubbed... URL: From david.feuer at gmail.com Sun Sep 10 01:14:30 2017 From: david.feuer at gmail.com (David Feuer) Date: Sat, 9 Sep 2017 21:14:30 -0400 Subject: [Haskell-cafe] Is this a GHC parser error? A test case compiles from one line but not another. In-Reply-To: References: Message-ID: Where clauses are not *always* attached to definitions. They can also be attached to case branches. case z of Just n -> blah where blah = n * 7 What I believe is true is that anywhere a set of guards could occur, they may be followed by a where clause, and vice versa. On Sep 9, 2017 12:08 AM, "Alexis King" wrote: > No, it isn’t a GHC parser error. > > Your preceding expression ends in a where clause, like this: > > assertBool "4" $ p == Right a where > p = ... > > That’s fine, but make sure you understand how where works. Where clauses > are not attached to individual expressions, they are *always* attached > to definitions. In this case, the where clause is not attached to the > assertion but to your definition of tHash. GHC parses your program the > same way as this one: > > tHash = TestCase $ do > ... > assertBool "4" $ p == Right a > where > p = ... > > Therefore, the where clause forces the termination of the do block, > since it exists syntactically outside the “body” of a definition. It is > its own syntactic construct, an optional sequence of definitions in > scope within the RHS of a definition. You cannot have any more > expression after the where clause because they would be free-floating, > outside of any particular definition. > > If you really want definitions that are scoped to that single assertion, > use a let expression instead of a where clause: > > let p = ... > a = ... > in assertBool "4" $ p == Right a > > That works, since let...in blocks serve as completely ordinary > expressions, and they are permitted anywhere an expression is permitted > (unlike where clauses, which must “belong” to a top-level or let-bound > definition). > > > On Sep 8, 2017, at 20:54, Jeffrey Brown > > wrote: > > > > The test suite below[1] does what it's supposed to. The last line of > > it is a commented-out test case: > > > > -- assertBool "broken" $ True > > > > If I uncomment that, it fails to compile: > > > > > :reload > > [13 of 13] Compiling TParse ( test/TParse.hs, interpreted ) > > > > test/TParse.hs:67:3: error: parse error on input ‘assertBool’ > > | > > 67 | assertBool "broken" $ True > > | ^^^^^^^^^^ > > Failed, 12 modules loaded. > > > > > > > However, if I move it to somewhere earlier in the code, it works. > > > > > > [1] https://github.com/JeffreyBenjaminBrown/digraphs-with-text/blob/ > e5afd39b950752ccb65997b89ab625d859299b4a/test/TParse.hs > > > > Jeff Brown | Jeffrey Benjamin Brown > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From lexi.lambda at gmail.com Sun Sep 10 04:54:19 2017 From: lexi.lambda at gmail.com (Alexis King) Date: Sat, 9 Sep 2017 21:54:19 -0700 Subject: [Haskell-cafe] Is this a GHC parser error? A test case compiles from one line but not another. In-Reply-To: References: Message-ID: <0AC2708B-5FA9-433E-9138-DC2CF2169A90@gmail.com> > On Sep 9, 2017, at 18:14, David Feuer wrote: > > Where clauses are not *always* attached to definitions. They can also > be attached to case branches. Ah, you’re right of course, I forgot about this. > What I believe is true is that anywhere a set of guards could occur, > they may be followed by a where clause, and vice versa. This appears to be true in standard Haskell, but interestingly, it seems that where clauses *cannot* be attached to a multi-way if expression. Whether or not that counts as a “set of guards” is debatable, but I usually think of them that way, so it’s potentially worth nothing. From andrew.thaddeus at gmail.com Tue Sep 12 18:18:21 2017 From: andrew.thaddeus at gmail.com (Andrew Martin) Date: Tue, 12 Sep 2017 14:18:21 -0400 Subject: [Haskell-cafe] Maintenance of streaming and streaming-bytestring In-Reply-To: References: Message-ID: Are there any further steps that I can take? On Thu, Sep 7, 2017 at 11:07 AM, Andrew Martin wrote: > David Feuer brought this up two weeks ago [0]. The maintainer of streaming > and streaming-bytestring has been unreachable, and provided his continued > absence, I would like to become a maintainer of these two libraries. I have > put up PRs fixing issues [1] and I've offered on the issue tracker to > become a comaintainer [2]. I use this library a lot at work, so I have an > interest in keeping it in good shape. > > [0] https://mail.haskell.org/pipermail/libraries/2017-August/028141.html > [1] https://github.com/michaelt/streaming-bytestring/pull/11 > [2] https://github.com/michaelt/streaming-bytestring/issues/19 > > -- > -Andrew Thaddeus Martin > -- -Andrew Thaddeus Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: From hesselink at gmail.com Tue Sep 12 19:57:29 2017 From: hesselink at gmail.com (Erik Hesselink) Date: Tue, 12 Sep 2017 21:57:29 +0200 Subject: [Haskell-cafe] Maintenance of streaming and streaming-bytestring In-Reply-To: References: Message-ID: Hi Andrew, We usually allow about 3 weeks for the maintainer to respond. Since that time has now passed I've added you as a maintainer for streaming and streaming-bytestring. Let me know if there's anything else you need. For others looking to take over a package in the future, please CC admin at hackage.haskell.org, there's a higher chance I'll see it there than just on the email lists. Regards, Erik (hackage admin) On 12 September 2017 at 20:18, Andrew Martin wrote: > Are there any further steps that I can take? > > On Thu, Sep 7, 2017 at 11:07 AM, Andrew Martin > wrote: > >> David Feuer brought this up two weeks ago [0]. The maintainer of >> streaming and streaming-bytestring has been unreachable, and provided his >> continued absence, I would like to become a maintainer of these two >> libraries. I have put up PRs fixing issues [1] and I've offered on the >> issue tracker to become a comaintainer [2]. I use this library a lot at >> work, so I have an interest in keeping it in good shape. >> >> [0] https://mail.haskell.org/pipermail/libraries/2017-August/028141.html >> [1] https://github.com/michaelt/streaming-bytestring/pull/11 >> [2] https://github.com/michaelt/streaming-bytestring/issues/19 >> >> -- >> -Andrew Thaddeus Martin >> > > > > -- > -Andrew Thaddeus Martin > > _______________________________________________ > Libraries mailing list > Libraries at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrew.thaddeus at gmail.com Tue Sep 12 20:50:05 2017 From: andrew.thaddeus at gmail.com (Andrew Martin) Date: Tue, 12 Sep 2017 16:50:05 -0400 Subject: [Haskell-cafe] Maintenance of streaming and streaming-bytestring In-Reply-To: References: Message-ID: Thanks adding me as a maintainer. I'm new to this process, so I appreciate the tip about admin at hackage.haskell.org as well. -Andrew Martin On Tue, Sep 12, 2017 at 3:57 PM, Erik Hesselink wrote: > Hi Andrew, > > We usually allow about 3 weeks for the maintainer to respond. Since that > time has now passed I've added you as a maintainer for streaming and > streaming-bytestring. Let me know if there's anything else you need. > > For others looking to take over a package in the future, please CC > admin at hackage.haskell.org, there's a higher chance I'll see it there than > just on the email lists. > > Regards, > > Erik (hackage admin) > > On 12 September 2017 at 20:18, Andrew Martin > wrote: > >> Are there any further steps that I can take? >> >> On Thu, Sep 7, 2017 at 11:07 AM, Andrew Martin > > wrote: >> >>> David Feuer brought this up two weeks ago [0]. The maintainer of >>> streaming and streaming-bytestring has been unreachable, and provided his >>> continued absence, I would like to become a maintainer of these two >>> libraries. I have put up PRs fixing issues [1] and I've offered on the >>> issue tracker to become a comaintainer [2]. I use this library a lot at >>> work, so I have an interest in keeping it in good shape. >>> >>> [0] https://mail.haskell.org/pipermail/libraries/2017-August/028141.html >>> [1] https://github.com/michaelt/streaming-bytestring/pull/11 >>> [2] https://github.com/michaelt/streaming-bytestring/issues/19 >>> >>> -- >>> -Andrew Thaddeus Martin >>> >> >> >> >> -- >> -Andrew Thaddeus Martin >> >> _______________________________________________ >> Libraries mailing list >> Libraries at haskell.org >> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries >> >> > -- -Andrew Thaddeus Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: From aquagnu at gmail.com Wed Sep 13 08:32:59 2017 From: aquagnu at gmail.com (Baa) Date: Wed, 13 Sep 2017 11:32:59 +0300 Subject: [Haskell-cafe] HPC and coverage report Message-ID: <20170913113259.5a39ff4d@Pavel> Hello Everyone. To generate coverage, Haskellers use HPC. HPC has command report [--xml-output] ... which allows to get XML output of coverage. Jenkins CI "understands" Cobertura Coverage XML format, which is shown as code source marked with red/green/etc background lines - uncovered/covered code lines. Also it's possible to mark branches (if/else/etc). It's true for Python, Java, etc. Can HPC (or other Haskell tool) does the same, i.e. generate Cobertura-compatible XML (to be understandable by Jenkins CI) ? What peoples use for coverage reporting under Jenkins CI w/ Haskell ? Is this `hpc report --xml-output` compatible w/ Jenkins CI ? === Best regards, Paul From andrew.thaddeus at gmail.com Wed Sep 13 17:31:49 2017 From: andrew.thaddeus at gmail.com (Andrew Martin) Date: Wed, 13 Sep 2017 13:31:49 -0400 Subject: [Haskell-cafe] Maintenance of streaming and streaming-bytestring In-Reply-To: References: Message-ID: The streaming and streaming-bytestring libraries are now being maintained here: https://github.com/haskell-streaming On Tue, Sep 12, 2017 at 4:50 PM, Andrew Martin wrote: > Thanks adding me as a maintainer. I'm new to this process, so I appreciate > the tip about admin at hackage.haskell.org as well. > > -Andrew Martin > > On Tue, Sep 12, 2017 at 3:57 PM, Erik Hesselink > wrote: > >> Hi Andrew, >> >> We usually allow about 3 weeks for the maintainer to respond. Since that >> time has now passed I've added you as a maintainer for streaming and >> streaming-bytestring. Let me know if there's anything else you need. >> >> For others looking to take over a package in the future, please CC >> admin at hackage.haskell.org, there's a higher chance I'll see it there >> than just on the email lists. >> >> Regards, >> >> Erik (hackage admin) >> >> On 12 September 2017 at 20:18, Andrew Martin >> wrote: >> >>> Are there any further steps that I can take? >>> >>> On Thu, Sep 7, 2017 at 11:07 AM, Andrew Martin < >>> andrew.thaddeus at gmail.com> wrote: >>> >>>> David Feuer brought this up two weeks ago [0]. The maintainer of >>>> streaming and streaming-bytestring has been unreachable, and provided his >>>> continued absence, I would like to become a maintainer of these two >>>> libraries. I have put up PRs fixing issues [1] and I've offered on the >>>> issue tracker to become a comaintainer [2]. I use this library a lot at >>>> work, so I have an interest in keeping it in good shape. >>>> >>>> [0] https://mail.haskell.org/pipermail/libraries/2017-August/028 >>>> 141.html >>>> [1] https://github.com/michaelt/streaming-bytestring/pull/11 >>>> [2] https://github.com/michaelt/streaming-bytestring/issues/19 >>>> >>>> -- >>>> -Andrew Thaddeus Martin >>>> >>> >>> >>> >>> -- >>> -Andrew Thaddeus Martin >>> >>> _______________________________________________ >>> Libraries mailing list >>> Libraries at haskell.org >>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries >>> >>> >> > > > -- > -Andrew Thaddeus Martin > -- -Andrew Thaddeus Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: From hafnersimon at gmail.com Wed Sep 13 18:02:46 2017 From: hafnersimon at gmail.com (Simon Hafner) Date: Wed, 13 Sep 2017 20:02:46 +0200 Subject: [Haskell-cafe] Executing conduit streams in parallel leads to memory leaks Message-ID: When I run my conduit without any additions, it works as expected, with low constant memory usage, as advertised. It's a bit slow, so I tried to speed it up with worker pools (via parallel-io) and staged folding (via stm-conduit). However, then the memory usage indicates all the ByteString from the file readings are being fully allocated and kept in memory, even though they're not being used after a step of conduit. [1] I thought maybe because of the closing IO, the release of the file handle somehow keeps the read string in memory, so I wanted to make absolutely sure that's not the problem. [2] Switch out the `Lib.readFile` with `B.readFile` to undo that specific part. I was not using a worker pool in the beginning, so maybe the `mapConcurrently_` somehow allocated all the threads, but with the pooled solution, that should be solved as well. What else could cause all the ByteStrings to be kept in memory in the parallel version? The example is available on: https://github.com/reactormonk/non-constant-memory [1] https://github.com/reactormonk/non-constant-memory/blob/master/src/Lib.hs#L51 [2] https://github.com/reactormonk/non-constant-memory/blob/master/src/Lib.hs#L62 From ivan.miljenovic at gmail.com Thu Sep 14 05:07:53 2017 From: ivan.miljenovic at gmail.com (Ivan Lazar Miljenovic) Date: Thu, 14 Sep 2017 15:07:53 +1000 Subject: [Haskell-cafe] Maintenance of streaming and streaming-bytestring In-Reply-To: References: Message-ID: Since you've seem to set this up as an organisation, would you be interested in my moving over the various streaming libraries I have there as well? On 14 September 2017 at 03:31, Andrew Martin wrote: > The streaming and streaming-bytestring libraries are now being maintained > here: https://github.com/haskell-streaming > > On Tue, Sep 12, 2017 at 4:50 PM, Andrew Martin > wrote: >> >> Thanks adding me as a maintainer. I'm new to this process, so I appreciate >> the tip about admin at hackage.haskell.org as well. >> >> -Andrew Martin >> >> On Tue, Sep 12, 2017 at 3:57 PM, Erik Hesselink >> wrote: >>> >>> Hi Andrew, >>> >>> We usually allow about 3 weeks for the maintainer to respond. Since that >>> time has now passed I've added you as a maintainer for streaming and >>> streaming-bytestring. Let me know if there's anything else you need. >>> >>> For others looking to take over a package in the future, please CC >>> admin at hackage.haskell.org, there's a higher chance I'll see it there than >>> just on the email lists. >>> >>> Regards, >>> >>> Erik (hackage admin) >>> >>> On 12 September 2017 at 20:18, Andrew Martin >>> wrote: >>>> >>>> Are there any further steps that I can take? >>>> >>>> On Thu, Sep 7, 2017 at 11:07 AM, Andrew Martin >>>> wrote: >>>>> >>>>> David Feuer brought this up two weeks ago [0]. The maintainer of >>>>> streaming and streaming-bytestring has been unreachable, and provided his >>>>> continued absence, I would like to become a maintainer of these two >>>>> libraries. I have put up PRs fixing issues [1] and I've offered on the issue >>>>> tracker to become a comaintainer [2]. I use this library a lot at work, so I >>>>> have an interest in keeping it in good shape. >>>>> >>>>> [0] >>>>> https://mail.haskell.org/pipermail/libraries/2017-August/028141.html >>>>> [1] https://github.com/michaelt/streaming-bytestring/pull/11 >>>>> [2] https://github.com/michaelt/streaming-bytestring/issues/19 >>>>> >>>>> -- >>>>> -Andrew Thaddeus Martin >>>> >>>> >>>> >>>> >>>> -- >>>> -Andrew Thaddeus Martin >>>> >>>> _______________________________________________ >>>> Libraries mailing list >>>> Libraries at haskell.org >>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries >>>> >>> >> >> >> >> -- >> -Andrew Thaddeus Martin > > > > > -- > -Andrew Thaddeus Martin > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.wordpress.com From spam at scientician.net Thu Sep 14 22:08:27 2017 From: spam at scientician.net (Bardur Arantsson) Date: Fri, 15 Sep 2017 00:08:27 +0200 Subject: [Haskell-cafe] Maintenance of streaming and streaming-bytestring In-Reply-To: References: Message-ID: On 2017-09-13 19:31, Andrew Martin wrote: > The streaming and streaming-bytestring libraries are now being > maintained here: https://github.com/haskell-streaming > You might want to upload a new package to Hackage with a change of URL :). The Hackage package currently points to the old GitHub. From andrew.thaddeus at gmail.com Thu Sep 14 22:30:57 2017 From: andrew.thaddeus at gmail.com (Andrew Martin) Date: Thu, 14 Sep 2017 18:30:57 -0400 Subject: [Haskell-cafe] Maintenance of streaming and streaming-bytestring In-Reply-To: References: Message-ID: <99DD984F-82A7-4115-AFE8-4BAA8847014F@gmail.com> If I can do that with a hackage revision, i'll go ahead and do that tonight. If not, there will probably be a new release for both of them in the next week anyway, so I would just wait until then to do it. Sent from my iPhone > On Sep 14, 2017, at 6:08 PM, Bardur Arantsson wrote: > >> On 2017-09-13 19:31, Andrew Martin wrote: >> The streaming and streaming-bytestring libraries are now being >> maintained here: https://github.com/haskell-streaming >> > > You might want to upload a new package to Hackage with a change of URL > :). The Hackage package currently points to the old GitHub. > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. From ietf-dane at dukhovni.org Fri Sep 15 07:20:03 2017 From: ietf-dane at dukhovni.org (Viktor Dukhovni) Date: Fri, 15 Sep 2017 07:20:03 +0000 Subject: [Haskell-cafe] How to write a polymorphic serializer? Message-ID: <20170915072003.GW3322@mournblade.imrryr.org> I tried to implement a polymorphic serializer that uses a enclosed MVar () to serialize an action in an arbitrary IO monad, without a need for its user to resort to explicit liftIO calls. So, as a first step I create a typeclass that has a natural default implementation, and some instances for the Monads of interest that just use the natural default: type Serially m = (MonadIO m) => forall a. IO a -> m a class (MonadIO m) => Serializable m where serialize :: MVar () -> Serially m serialize lock = liftIO . withMVar lock . const instance Serializable IO instance Serializable (StateT Int IO) ... With this, given: foo :: Serially IO -> ... -> IO () foo serially ... = do ... serially $ ... ... bar :: Serially (StateT Int IO) -> ... -> StateT Int IO () bar serially ... = do ... serially $ ... ... I can write: lock <- newMVar () foo (serialize lock) ... bar (serialize lock) and the type system figures out the correct version of serialize for foo's and bar's actual monad. Is it possible to create a single "serialize lock" closure that works for both "foo" and "bar"? Something that works along the lines of: let x = liftIO . withMVar lock . const :: ??? foo x ... bar x ... If I leave out the "liftIO", then I can of course use: x :: forall a. IO a -> IO a and the "liftIO" can be put explicitly into "foo" and "bar". foo x ... = liftIO $ x $ ... bar x ... = liftIO $ x $ ... but is it possible for "x" to both be polymorphic with respect to its user's monad and at the same time to be a *closure* around some MVar, and thus not directly a method of a type class. Of course needing to add an extra "liftI0" here and there is not onerous, I'm mostly just curious whether I'm missing something that can hide that boilerplate call in the serializer implementation. -- Viktor. From andrew.thaddeus at gmail.com Fri Sep 15 13:35:41 2017 From: andrew.thaddeus at gmail.com (Andrew Martin) Date: Fri, 15 Sep 2017 09:35:41 -0400 Subject: [Haskell-cafe] Maintenance of streaming and streaming-bytestring In-Reply-To: References: Message-ID: Oh my, you seem to have quite a few of these. Yes, if you would like to move them over to the umbrella organization, that would be great. On Thu, Sep 14, 2017 at 1:07 AM, Ivan Lazar Miljenovic < ivan.miljenovic at gmail.com> wrote: > Since you've seem to set this up as an organisation, would you be > interested in my moving over the various streaming libraries I have > there as well? > > On 14 September 2017 at 03:31, Andrew Martin > wrote: > > The streaming and streaming-bytestring libraries are now being maintained > > here: https://github.com/haskell-streaming > > > > On Tue, Sep 12, 2017 at 4:50 PM, Andrew Martin < > andrew.thaddeus at gmail.com> > > wrote: > >> > >> Thanks adding me as a maintainer. I'm new to this process, so I > appreciate > >> the tip about admin at hackage.haskell.org as well. > >> > >> -Andrew Martin > >> > >> On Tue, Sep 12, 2017 at 3:57 PM, Erik Hesselink > >> wrote: > >>> > >>> Hi Andrew, > >>> > >>> We usually allow about 3 weeks for the maintainer to respond. Since > that > >>> time has now passed I've added you as a maintainer for streaming and > >>> streaming-bytestring. Let me know if there's anything else you need. > >>> > >>> For others looking to take over a package in the future, please CC > >>> admin at hackage.haskell.org, there's a higher chance I'll see it there > than > >>> just on the email lists. > >>> > >>> Regards, > >>> > >>> Erik (hackage admin) > >>> > >>> On 12 September 2017 at 20:18, Andrew Martin < > andrew.thaddeus at gmail.com> > >>> wrote: > >>>> > >>>> Are there any further steps that I can take? > >>>> > >>>> On Thu, Sep 7, 2017 at 11:07 AM, Andrew Martin > >>>> wrote: > >>>>> > >>>>> David Feuer brought this up two weeks ago [0]. The maintainer of > >>>>> streaming and streaming-bytestring has been unreachable, and > provided his > >>>>> continued absence, I would like to become a maintainer of these two > >>>>> libraries. I have put up PRs fixing issues [1] and I've offered on > the issue > >>>>> tracker to become a comaintainer [2]. I use this library a lot at > work, so I > >>>>> have an interest in keeping it in good shape. > >>>>> > >>>>> [0] > >>>>> https://mail.haskell.org/pipermail/libraries/2017-August/028141.html > >>>>> [1] https://github.com/michaelt/streaming-bytestring/pull/11 > >>>>> [2] https://github.com/michaelt/streaming-bytestring/issues/19 > >>>>> > >>>>> -- > >>>>> -Andrew Thaddeus Martin > >>>> > >>>> > >>>> > >>>> > >>>> -- > >>>> -Andrew Thaddeus Martin > >>>> > >>>> _______________________________________________ > >>>> Libraries mailing list > >>>> Libraries at haskell.org > >>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries > >>>> > >>> > >> > >> > >> > >> -- > >> -Andrew Thaddeus Martin > > > > > > > > > > -- > > -Andrew Thaddeus Martin > > > > _______________________________________________ > > Haskell-Cafe mailing list > > To (un)subscribe, modify options or view archives go to: > > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > Only members subscribed via the mailman list are allowed to post. > > > > -- > Ivan Lazar Miljenovic > Ivan.Miljenovic at gmail.com > http://IvanMiljenovic.wordpress.com > -- -Andrew Thaddeus Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: From lysxia at gmail.com Fri Sep 15 14:12:43 2017 From: lysxia at gmail.com (Li-yao Xia) Date: Fri, 15 Sep 2017 10:12:43 -0400 Subject: [Haskell-cafe] How to write a polymorphic serializer? In-Reply-To: <20170915072003.GW3322@mournblade.imrryr.org> References: <20170915072003.GW3322@mournblade.imrryr.org> Message-ID: Hi Viktor, This example is odd because it doesn't seem like the lock is doing anything. Probably, the details that would make it more interesting have just been abstracted away, and I would guess that you do want a way to work with a single global lock. A common pattern is that every MonadSomething type class (like Serializable here) comes with a SomethingT transformer providing the required environment. In fact, this is a specialization of ReaderT/MonadReader.     class Monad m => Serializable m where       serially :: IO a -> m a       default serially :: (m ~ t n, MonadTrans t, Serializable n) => IO a -> m a       serially io = lift (serialize io)     newtype SerializeT m a = SerializeT { runSerializeT :: MVar () -> m a }     -- Monad instance     instance MonadIO m => Serializable (SerializeT m) where       serialize io = SerializeT (\lock -> liftIO (withMVar lock (const io)))     instance Serializable m => Serializable (StateT s m)     -- every other monad transformer where this makes sense Keep foo and bar polymorphic, with MonadSomething constraints:     -- No 'serially' argument     foo :: (Serializable m, MonadIO m) => ... -> m ()     foo ... = do       ...       serially $ ...     bar :: (Serializable m, MonadState Int m) => ... -> m () You can compose foo and bar together so they are guaranteed to run under the same lock.   baz :: (Serializable m, MonadState Int m, MonadIO m) => ... -> m ()   baz ... ...  = do     foo ...     bar ... To run an SerializeT action you still need to unwrap it explicitly, but just once, ensuring only one lock is used throughout the given action, and no user can mess with it as long as your types are abstract to them.     serialize :: MonadIO m => SerializeT m a -> m a     serialize m = do       lock <- liftIO (newMVar ())       runSerializeT m lock     main :: IO ()     main = evalStateT (serialize baz) 42 Now, if you are positive that you will only ever need a single lock, or you need synchronization even among distinct calls to `serialize` (which currently each generate a fresh lock), you can do this:     -- Keep this out of the API. -- Also notice this is *not* unsafeDupablePerformIO. We prevent a race condition on initialization.     globalLock :: MVar ()     globalLock = unsafePerformIO (newMVar ()) It is well known that unsafePerformIO requires extra care, but I believe that this situation is safe. The main wart of unsafePerformIO is *unsoundness*: it allows you to derive unsafeCoerce :: forall a b. a -> b, and more generally it makes programs "go wrong". However, as far as I can recall, this relies on an interaction between polymorphism and effects, the simplest example being to use unsafePerformIO to create a polymorphic MVar, put in a value of type a, take it out with type b. Here it is being used at a single not-too-fancy ground type (MVar ()), so this doesn't seem to cause such problems.     globalSerialize :: SerializeT m a -> m a     globalSerialize m = runSerializeT m globalLock Now that we have a global variable though, we might as well make a Serialize instance for IO.     instance Serialize IO where       serially io = withMVar globalLock (const io)     main = flip evalStateT 42 $ do       foo ...       bar ... :: StateT Int IO () Regards, Li-yao On 09/15/2017 03:20 AM, Viktor Dukhovni wrote: > I tried to implement a polymorphic serializer that uses a enclosed > MVar () to serialize an action in an arbitrary IO monad, without > a need for its user to resort to explicit liftIO calls. > > So, as a first step I create a typeclass that has a natural default > implementation, and some instances for the Monads of interest that > just use the natural default: > > type Serially m = (MonadIO m) => forall a. IO a -> m a > > class (MonadIO m) => Serializable m where > serialize :: MVar () -> Serially m > serialize lock = liftIO . withMVar lock . const > > instance Serializable IO > instance Serializable (StateT Int IO) > ... > > With this, given: > > foo :: Serially IO -> ... -> IO () > foo serially ... = do > ... > serially $ ... > ... > > bar :: Serially (StateT Int IO) -> ... -> StateT Int IO () > bar serially ... = do > ... > serially $ ... > ... > > I can write: > > lock <- newMVar () > foo (serialize lock) ... > bar (serialize lock) > > and the type system figures out the correct version of serialize > for foo's and bar's actual monad. > > Is it possible to create a single "serialize lock" closure that > works for both "foo" and "bar"? Something that works along the > lines of: > > let x = liftIO . withMVar lock . const :: ??? > foo x ... > bar x ... > > If I leave out the "liftIO", then I can of course use: > > x :: forall a. IO a -> IO a > > and the "liftIO" can be put explicitly into "foo" and "bar". > > foo x ... = liftIO $ x $ ... > bar x ... = liftIO $ x $ ... > > but is it possible for "x" to both be polymorphic with respect to > its user's monad and at the same time to be a *closure* around some > MVar, and thus not directly a method of a type class. > > Of course needing to add an extra "liftI0" here and there is not > onerous, I'm mostly just curious whether I'm missing something that > can hide that boilerplate call in the serializer implementation. > From david.feuer at gmail.com Fri Sep 15 17:01:38 2017 From: david.feuer at gmail.com (David Feuer) Date: Fri, 15 Sep 2017 13:01:38 -0400 Subject: [Haskell-cafe] Maintenance of streaming and streaming-bytestring In-Reply-To: References: Message-ID: Having an organization (with multiple owners and members) makes for much smoother transitions when maintainers change. That goes triple for unexpected changes. There's (still!) no really good way to migrate an issue tracker or PRs from one repository to another. Unfortunately, for that same reason, I believe that actually moving your project to the organization will be quite unpleasant if there are more than a few open tickets. And if there are more than a few closed tickets, then preserving history in a useful history seems hard too. Maybe someone else knows a reason this isn't actually terrible. David On Sep 14, 2017 1:10 AM, "Ivan Lazar Miljenovic" wrote: Since you've seem to set this up as an organisation, would you be interested in my moving over the various streaming libraries I have there as well? On 14 September 2017 at 03:31, Andrew Martin wrote: > The streaming and streaming-bytestring libraries are now being maintained > here: https://github.com/haskell-streaming > > On Tue, Sep 12, 2017 at 4:50 PM, Andrew Martin > wrote: >> >> Thanks adding me as a maintainer. I'm new to this process, so I appreciate >> the tip about admin at hackage.haskell.org as well. >> >> -Andrew Martin >> >> On Tue, Sep 12, 2017 at 3:57 PM, Erik Hesselink >> wrote: >>> >>> Hi Andrew, >>> >>> We usually allow about 3 weeks for the maintainer to respond. Since that >>> time has now passed I've added you as a maintainer for streaming and >>> streaming-bytestring. Let me know if there's anything else you need. >>> >>> For others looking to take over a package in the future, please CC >>> admin at hackage.haskell.org, there's a higher chance I'll see it there than >>> just on the email lists. >>> >>> Regards, >>> >>> Erik (hackage admin) >>> >>> On 12 September 2017 at 20:18, Andrew Martin >>> wrote: >>>> >>>> Are there any further steps that I can take? >>>> >>>> On Thu, Sep 7, 2017 at 11:07 AM, Andrew Martin >>>> wrote: >>>>> >>>>> David Feuer brought this up two weeks ago [0]. The maintainer of >>>>> streaming and streaming-bytestring has been unreachable, and provided his >>>>> continued absence, I would like to become a maintainer of these two >>>>> libraries. I have put up PRs fixing issues [1] and I've offered on the issue >>>>> tracker to become a comaintainer [2]. I use this library a lot at work, so I >>>>> have an interest in keeping it in good shape. >>>>> >>>>> [0] >>>>> https://mail.haskell.org/pipermail/libraries/2017-August/028141.html >>>>> [1] https://github.com/michaelt/streaming-bytestring/pull/11 >>>>> [2] https://github.com/michaelt/streaming-bytestring/issues/19 >>>>> >>>>> -- >>>>> -Andrew Thaddeus Martin >>>> >>>> >>>> >>>> >>>> -- >>>> -Andrew Thaddeus Martin >>>> >>>> _______________________________________________ >>>> Libraries mailing list >>>> Libraries at haskell.org >>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries >>>> >>> >> >> >> >> -- >> -Andrew Thaddeus Martin > > > > > -- > -Andrew Thaddeus Martin > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -- Ivan Lazar Miljenovic Ivan.Miljenovic at gmail.com http://IvanMiljenovic.wordpress.com _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From carter.schonwald at gmail.com Fri Sep 15 17:23:27 2017 From: carter.schonwald at gmail.com (Carter Schonwald) Date: Fri, 15 Sep 2017 17:23:27 +0000 Subject: [Haskell-cafe] Maintenance of streaming and streaming-bytestring In-Reply-To: References: Message-ID: GitHub has a transfer repo ownership toggle you can do to move the main repo and it's assets On Fri, Sep 15, 2017 at 1:05 PM David Feuer wrote: > Having an organization (with multiple owners and members) makes for much > smoother transitions when maintainers change. That goes triple for > unexpected changes. There's (still!) no really good way to migrate an issue > tracker or PRs from one repository to another. Unfortunately, for that same > reason, I believe that actually moving your project to the organization > will be quite unpleasant if there are more than a few open tickets. And if > there are more than a few closed tickets, then preserving history in a > useful history seems hard too. Maybe someone else knows a reason this isn't > actually terrible. > > David > > On Sep 14, 2017 1:10 AM, "Ivan Lazar Miljenovic" < > ivan.miljenovic at gmail.com> wrote: > > Since you've seem to set this up as an organisation, would you be > interested in my moving over the various streaming libraries I have > there as well? > > On 14 September 2017 at 03:31, Andrew Martin > wrote: > > The streaming and streaming-bytestring libraries are now being maintained > > here: https://github.com/haskell-streaming > > > > On Tue, Sep 12, 2017 at 4:50 PM, Andrew Martin < > andrew.thaddeus at gmail.com> > > wrote: > >> > >> Thanks adding me as a maintainer. I'm new to this process, so I > appreciate > >> the tip about admin at hackage.haskell.org as well. > >> > >> -Andrew Martin > >> > >> On Tue, Sep 12, 2017 at 3:57 PM, Erik Hesselink > >> wrote: > >>> > >>> Hi Andrew, > >>> > >>> We usually allow about 3 weeks for the maintainer to respond. Since > that > >>> time has now passed I've added you as a maintainer for streaming and > >>> streaming-bytestring. Let me know if there's anything else you need. > >>> > >>> For others looking to take over a package in the future, please CC > >>> admin at hackage.haskell.org, there's a higher chance I'll see it there > than > >>> just on the email lists. > >>> > >>> Regards, > >>> > >>> Erik (hackage admin) > >>> > >>> On 12 September 2017 at 20:18, Andrew Martin < > andrew.thaddeus at gmail.com> > >>> wrote: > >>>> > >>>> Are there any further steps that I can take? > >>>> > >>>> On Thu, Sep 7, 2017 at 11:07 AM, Andrew Martin > >>>> wrote: > >>>>> > >>>>> David Feuer brought this up two weeks ago [0]. The maintainer of > >>>>> streaming and streaming-bytestring has been unreachable, and > provided his > >>>>> continued absence, I would like to become a maintainer of these two > >>>>> libraries. I have put up PRs fixing issues [1] and I've offered on > the issue > >>>>> tracker to become a comaintainer [2]. I use this library a lot at > work, so I > >>>>> have an interest in keeping it in good shape. > >>>>> > >>>>> [0] > >>>>> https://mail.haskell.org/pipermail/libraries/2017-August/028141.html > >>>>> [1] https://github.com/michaelt/streaming-bytestring/pull/11 > >>>>> [2] https://github.com/michaelt/streaming-bytestring/issues/19 > >>>>> > >>>>> -- > >>>>> -Andrew Thaddeus Martin > >>>> > >>>> > >>>> > >>>> > >>>> -- > >>>> -Andrew Thaddeus Martin > >>>> > >>>> _______________________________________________ > >>>> Libraries mailing list > >>>> Libraries at haskell.org > >>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries > >>>> > >>> > >> > >> > >> > >> -- > >> -Andrew Thaddeus Martin > > > > > > > > > > -- > > -Andrew Thaddeus Martin > > > > _______________________________________________ > > Haskell-Cafe mailing list > > To (un)subscribe, modify options or view archives go to: > > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > Only members subscribed via the mailman list are allowed to post. > > > > -- > Ivan Lazar Miljenovic > Ivan.Miljenovic at gmail.com > http://IvanMiljenovic.wordpress.com > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From andrew.thaddeus at gmail.com Fri Sep 15 19:14:58 2017 From: andrew.thaddeus at gmail.com (Andrew Martin) Date: Fri, 15 Sep 2017 15:14:58 -0400 Subject: [Haskell-cafe] Maintenance of streaming and streaming-bytestring In-Reply-To: References: Message-ID: Yes. Carter's suggestion is what I just thinking of. The transfer completely preserves everything. On Fri, Sep 15, 2017 at 1:23 PM, Carter Schonwald < carter.schonwald at gmail.com> wrote: > GitHub has a transfer repo ownership toggle you can do to move the main > repo and it's assets > > On Fri, Sep 15, 2017 at 1:05 PM David Feuer wrote: > >> Having an organization (with multiple owners and members) makes for much >> smoother transitions when maintainers change. That goes triple for >> unexpected changes. There's (still!) no really good way to migrate an issue >> tracker or PRs from one repository to another. Unfortunately, for that same >> reason, I believe that actually moving your project to the organization >> will be quite unpleasant if there are more than a few open tickets. And if >> there are more than a few closed tickets, then preserving history in a >> useful history seems hard too. Maybe someone else knows a reason this isn't >> actually terrible. >> >> David >> >> On Sep 14, 2017 1:10 AM, "Ivan Lazar Miljenovic" < >> ivan.miljenovic at gmail.com> wrote: >> >> Since you've seem to set this up as an organisation, would you be >> interested in my moving over the various streaming libraries I have >> there as well? >> >> On 14 September 2017 at 03:31, Andrew Martin >> wrote: >> > The streaming and streaming-bytestring libraries are now being >> maintained >> > here: https://github.com/haskell-streaming >> > >> > On Tue, Sep 12, 2017 at 4:50 PM, Andrew Martin < >> andrew.thaddeus at gmail.com> >> > wrote: >> >> >> >> Thanks adding me as a maintainer. I'm new to this process, so I >> appreciate >> >> the tip about admin at hackage.haskell.org as well. >> >> >> >> -Andrew Martin >> >> >> >> On Tue, Sep 12, 2017 at 3:57 PM, Erik Hesselink >> >> wrote: >> >>> >> >>> Hi Andrew, >> >>> >> >>> We usually allow about 3 weeks for the maintainer to respond. Since >> that >> >>> time has now passed I've added you as a maintainer for streaming and >> >>> streaming-bytestring. Let me know if there's anything else you need. >> >>> >> >>> For others looking to take over a package in the future, please CC >> >>> admin at hackage.haskell.org, there's a higher chance I'll see it there >> than >> >>> just on the email lists. >> >>> >> >>> Regards, >> >>> >> >>> Erik (hackage admin) >> >>> >> >>> On 12 September 2017 at 20:18, Andrew Martin < >> andrew.thaddeus at gmail.com> >> >>> wrote: >> >>>> >> >>>> Are there any further steps that I can take? >> >>>> >> >>>> On Thu, Sep 7, 2017 at 11:07 AM, Andrew Martin >> >>>> wrote: >> >>>>> >> >>>>> David Feuer brought this up two weeks ago [0]. The maintainer of >> >>>>> streaming and streaming-bytestring has been unreachable, and >> provided his >> >>>>> continued absence, I would like to become a maintainer of these two >> >>>>> libraries. I have put up PRs fixing issues [1] and I've offered on >> the issue >> >>>>> tracker to become a comaintainer [2]. I use this library a lot at >> work, so I >> >>>>> have an interest in keeping it in good shape. >> >>>>> >> >>>>> [0] >> >>>>> https://mail.haskell.org/pipermail/libraries/2017- >> August/028141.html >> >>>>> [1] https://github.com/michaelt/streaming-bytestring/pull/11 >> >>>>> [2] https://github.com/michaelt/streaming-bytestring/issues/19 >> >>>>> >> >>>>> -- >> >>>>> -Andrew Thaddeus Martin >> >>>> >> >>>> >> >>>> >> >>>> >> >>>> -- >> >>>> -Andrew Thaddeus Martin >> >>>> >> >>>> _______________________________________________ >> >>>> Libraries mailing list >> >>>> Libraries at haskell.org >> >>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries >> >>>> >> >>> >> >> >> >> >> >> >> >> -- >> >> -Andrew Thaddeus Martin >> > >> > >> > >> > >> > -- >> > -Andrew Thaddeus Martin >> > >> > _______________________________________________ >> > Haskell-Cafe mailing list >> > To (un)subscribe, modify options or view archives go to: >> > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> > Only members subscribed via the mailman list are allowed to post. >> >> >> >> -- >> Ivan Lazar Miljenovic >> Ivan.Miljenovic at gmail.com >> http://IvanMiljenovic.wordpress.com >> _______________________________________________ >> Haskell-Cafe mailing list >> To (un)subscribe, modify options or view archives go to: >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> Only members subscribed via the mailman list are allowed to post. >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> To (un)subscribe, modify options or view archives go to: >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> Only members subscribed via the mailman list are allowed to post. > > > _______________________________________________ > Libraries mailing list > Libraries at haskell.org > http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries > > -- -Andrew Thaddeus Martin -------------- next part -------------- An HTML attachment was scrubbed... URL: From ietf-dane at dukhovni.org Sat Sep 16 05:55:49 2017 From: ietf-dane at dukhovni.org (Viktor Dukhovni) Date: Sat, 16 Sep 2017 05:55:49 +0000 Subject: [Haskell-cafe] How to write a polymorphic serializer? In-Reply-To: References: <20170915072003.GW3322@mournblade.imrryr.org> Message-ID: <20170916055548.GB3322@mournblade.imrryr.org> On Fri, Sep 15, 2017 at 10:12:43AM -0400, Li-yao Xia wrote: > This example is odd because it doesn't seem like the lock is doing anything. > Probably, the details that would make it more interesting have just been > abstracted away, and I would guess that you do want a way to work with a > single global lock. In a bit more detail I have a small number of locks (currently two) that are used to serialize access to the stdout file handle and an SQLite database respectively. Though I know about "unsafePerformIO", and understand that it is safe to use to create a global MVar (), my locks are created on the fly in "main". I was trying to avoid sprinkling the internal APIs and/or context structures with explicit MVar-related types. While implementing the typeclass idea that you helped me flesh out (it works), I stumbled into a simpler alternative that meets my needs and that I thought would not work, but does, and it helps me to better underand and appreciate the semantic power of lazy evaluation. Full program below. When compiled and run:as follows: $ ./locktest $(seq 100 199) | uniq -c | awk '{print $1}' | fmt Correct output: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 shows the numbers from 1 to 100 (not necessarily in that order), which means that the $n^{th}$ thread managed to output $n$ long lines without other threads getting in the way. Without locking I get radically different results. -- Viktor. ---------------- Cut below ---------------- {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE Rank2Types #-} module Main (main) where import Control.Concurrent (forkFinally) import Control.Concurrent.MVar (newMVar, withMVar) import Control.Concurrent.STM ( TVar , newTVar , readTVar , writeTVar , atomically , retry ) import Control.Monad (mapM_, void, when) import Control.Monad.IO.Class (MonadIO, liftIO) import Control.Monad.Trans.Resource (runResourceT) import Control.Monad.Trans.State.Strict import Data.Conduit (await, ($$)) import Data.Conduit.List (sourceList) import Data.List (concat, replicate) import System.Environment (getArgs) import System.IO (hFlush, hPutStrLn, stdout, stderr) -- | Hide polymorphic lock closure inside a fixed existentially qualified -- wrapper type. The magic of lazy evaluation lets Haskell defer the -- type resolution of the @serially@ method inside the Lockbox until -- it is used, and so its polymorphism is retained. -- type Serializer = forall a m. MonadIO m => IO a -> m a newtype Lockbox = Lockbox { serially :: Serializer } locksmith :: IO Lockbox locksmith = (\ lock -> Lockbox (liftIO . withMVar lock . const)) <$> newMVar () -- | Stutter each input string enough times to cause unlocked writes to split -- Only by locking do we reliably get the long lines to be written in their -- entirety, otherwise the output is typically a mess of interleaved partial -- outputs. -- amplification :: Int amplification = 8000 main :: IO () main = do args <- getArgs tc <- atomically $ newTVar 0 lockbox <- locksmith spawn args tc 99 (\ n s -> evalStateT (worker n s) lockbox) where -- | We could equally have used ReaderT here, our state is read-only worker :: Int -> String -> StateT Lockbox IO () worker num s = do dolocked <- gets serially dolocked $ do let bigs = concat $ replicate amplification s mapM_ (\_ -> putStrLn bigs) $ [1..num] hFlush stdout type Worker = Int -> String -> IO () -- | Spawn worker thread up to designated thread count limit. When the limit is -- reached, wait an existing thread to finish. Once all the work has been -- dispatched, wait for the final threads to finish. -- spawn :: [String] -- ^ Strings to amplify -> TVar Int -- ^ Active thread count -> Int -- ^ Thread count limit -> Worker -- ^ Per-thread worker function -> IO () spawn args threadCount threadMax worker = runResourceT $ sourceList args $$ sink 1 where sink num = do next <- await case next of Nothing -> liftIO waitDone Just a -> liftIO (waitTurn num a) >> sink (num + 1) -- | Wait for remaining threads to finish waitDone = atomically $ do tc <- readTVar threadCount when (tc > 0) retry -- | Increment busy thread-count if not maxed-out, else wait and retry waitTurn n s = do atomically $ do count <- readTVar threadCount if (count < threadMax) then writeTVar threadCount (count + 1) else retry void $ forkFinally (worker n s) finalize -- | Decrement busy thread-count and warn of any exceptions finalize res = do atomically $ readTVar threadCount >>= writeTVar threadCount . pred either warn (\_ -> return ()) res where warn err = hPutStrLn stderr $ "Exception: " ++ show err From david.feuer at gmail.com Sat Sep 16 23:24:11 2017 From: david.feuer at gmail.com (David Feuer) Date: Sat, 16 Sep 2017 19:24:11 -0400 Subject: [Haskell-cafe] Maintenance of streaming and streaming-bytestring In-Reply-To: References: Message-ID: Ah, right. Then yes, that sounds like a great approach. On Sep 15, 2017 1:23 PM, "Carter Schonwald" wrote: > GitHub has a transfer repo ownership toggle you can do to move the main > repo and it's assets > > On Fri, Sep 15, 2017 at 1:05 PM David Feuer wrote: > >> Having an organization (with multiple owners and members) makes for much >> smoother transitions when maintainers change. That goes triple for >> unexpected changes. There's (still!) no really good way to migrate an issue >> tracker or PRs from one repository to another. Unfortunately, for that same >> reason, I believe that actually moving your project to the organization >> will be quite unpleasant if there are more than a few open tickets. And if >> there are more than a few closed tickets, then preserving history in a >> useful history seems hard too. Maybe someone else knows a reason this isn't >> actually terrible. >> >> David >> >> On Sep 14, 2017 1:10 AM, "Ivan Lazar Miljenovic" < >> ivan.miljenovic at gmail.com> wrote: >> >> Since you've seem to set this up as an organisation, would you be >> interested in my moving over the various streaming libraries I have >> there as well? >> >> On 14 September 2017 at 03:31, Andrew Martin >> wrote: >> > The streaming and streaming-bytestring libraries are now being >> maintained >> > here: https://github.com/haskell-streaming >> > >> > On Tue, Sep 12, 2017 at 4:50 PM, Andrew Martin < >> andrew.thaddeus at gmail.com> >> > wrote: >> >> >> >> Thanks adding me as a maintainer. I'm new to this process, so I >> appreciate >> >> the tip about admin at hackage.haskell.org as well. >> >> >> >> -Andrew Martin >> >> >> >> On Tue, Sep 12, 2017 at 3:57 PM, Erik Hesselink >> >> wrote: >> >>> >> >>> Hi Andrew, >> >>> >> >>> We usually allow about 3 weeks for the maintainer to respond. Since >> that >> >>> time has now passed I've added you as a maintainer for streaming and >> >>> streaming-bytestring. Let me know if there's anything else you need. >> >>> >> >>> For others looking to take over a package in the future, please CC >> >>> admin at hackage.haskell.org, there's a higher chance I'll see it there >> than >> >>> just on the email lists. >> >>> >> >>> Regards, >> >>> >> >>> Erik (hackage admin) >> >>> >> >>> On 12 September 2017 at 20:18, Andrew Martin < >> andrew.thaddeus at gmail.com> >> >>> wrote: >> >>>> >> >>>> Are there any further steps that I can take? >> >>>> >> >>>> On Thu, Sep 7, 2017 at 11:07 AM, Andrew Martin >> >>>> wrote: >> >>>>> >> >>>>> David Feuer brought this up two weeks ago [0]. The maintainer of >> >>>>> streaming and streaming-bytestring has been unreachable, and >> provided his >> >>>>> continued absence, I would like to become a maintainer of these two >> >>>>> libraries. I have put up PRs fixing issues [1] and I've offered on >> the issue >> >>>>> tracker to become a comaintainer [2]. I use this library a lot at >> work, so I >> >>>>> have an interest in keeping it in good shape. >> >>>>> >> >>>>> [0] >> >>>>> https://mail.haskell.org/pipermail/libraries/2017- >> August/028141.html >> >>>>> [1] https://github.com/michaelt/streaming-bytestring/pull/11 >> >>>>> [2] https://github.com/michaelt/streaming-bytestring/issues/19 >> >>>>> >> >>>>> -- >> >>>>> -Andrew Thaddeus Martin >> >>>> >> >>>> >> >>>> >> >>>> >> >>>> -- >> >>>> -Andrew Thaddeus Martin >> >>>> >> >>>> _______________________________________________ >> >>>> Libraries mailing list >> >>>> Libraries at haskell.org >> >>>> http://mail.haskell.org/cgi-bin/mailman/listinfo/libraries >> >>>> >> >>> >> >> >> >> >> >> >> >> -- >> >> -Andrew Thaddeus Martin >> > >> > >> > >> > >> > -- >> > -Andrew Thaddeus Martin >> > >> > _______________________________________________ >> > Haskell-Cafe mailing list >> > To (un)subscribe, modify options or view archives go to: >> > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> > Only members subscribed via the mailman list are allowed to post. >> >> >> >> -- >> Ivan Lazar Miljenovic >> Ivan.Miljenovic at gmail.com >> http://IvanMiljenovic.wordpress.com >> _______________________________________________ >> Haskell-Cafe mailing list >> To (un)subscribe, modify options or view archives go to: >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> Only members subscribed via the mailman list are allowed to post. >> >> >> _______________________________________________ >> Haskell-Cafe mailing list >> To (un)subscribe, modify options or view archives go to: >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> Only members subscribed via the mailman list are allowed to post. > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From aditya.siram at gmail.com Sun Sep 17 00:21:41 2017 From: aditya.siram at gmail.com (aditya siram) Date: Sat, 16 Sep 2017 19:21:41 -0500 Subject: [Haskell-cafe] Cabal: updating environment variable in a dependency Message-ID: Hi all, I have two separate packages, a library and an app. In the library's Setup.hs I set the LIBRARY_PATH environment variable to a place where I install a custom C shared library, but when the app is built LIBRARY_PATH is empty. I realize that GHC can build and link C code but for the purposes of this project that wasn't workable. So is there a way to make this environment variable hack work or, even better, a good way a dependency can pass custom information to its dependents? Thanks! -deech -------------- next part -------------- An HTML attachment was scrubbed... URL: From wolfgang-it at jeltsch.info Mon Sep 18 22:27:32 2017 From: wolfgang-it at jeltsch.info (Wolfgang Jeltsch) Date: Tue, 19 Sep 2017 01:27:32 +0300 Subject: [Haskell-cafe] Haskell in Leipzig 2017: 1st call for participation Message-ID: <1505773652.6842.7.camel@jeltsch.info> Event:    Haskell in Leipzig 2017 Time:     October 26–28, 2017 Place:    HTWK Leipzig, Germany Homepage: https://hal2017.softbase.org/ About ===== Haskell is a modern functional programming language that allows rapid development of robust and correct software. It is renowned for its expressive type system, its unique approaches to concurrency and parallelism, and its excellent refactoring capabilities. Haskell is both the playing field of cutting-edge programming language research and a reliable base for commercial software development. The workshop series Haskell in Leipzig (HaL), now in its 12th year, brings together Haskell developers, Haskell researchers, Haskell enthusiasts, and Haskell beginners to listen to talks, take part in tutorials, join in interesting conversations, and hack together. To support the latter, HaL will include a one-day hackathon this year. The workshop will have a focus on functional reactive programming (FRP) this time, while continuing to be open to all aspects of Haskell. As in the previous year, the workshop will be in English. Invited Speaker ===============   * Ivan Perez, University of Nottingham, UK Invited Performer =================   * Lennart Melzer, Robert-Schumann-Hochschule Düsseldorf, Germany Registration ============ Registration information is available on the web page of the local organizers at http://nfa.imn.htwk-leipzig.de/HAL2017/. Program Committee =================   * Edward Amsden, Plow Technologies, USA   * Heinrich Apfelmus, Germany   * Jurriaan Hage, Utrecht University, The Netherlands   * Petra Hofstedt, BTU Cottbus-Senftenberg, Germany   * Wolfgang Jeltsch, Tallinn University of Technology, Estonia (chair)   * Andres Löh, Well-Typed LLP, Germany   * Keiko Nakata, SAP SE, Germany   * Henrik Nilsson, University of Nottingham, UK   * Ertuğrul Söylemez, Intelego GmbH, Germany   * Henning Thielemann, Germany   * Niki Vazou, University of Maryland, USA   * Johannes Waldmann, HTWK Leipzig, Germany Questions ========= If you have any questions, please do not hesitate to contact Wolfgang Jeltsch at wolfgang-it at jeltsch.info. From palotai.robin at gmail.com Tue Sep 19 05:36:01 2017 From: palotai.robin at gmail.com (Robin Palotai) Date: Tue, 19 Sep 2017 07:36:01 +0200 Subject: [Haskell-cafe] ghc-devs@haskell.org Message-ID: Hello GHC devs, Before inventing the wheel, want to check if there is a GHC API way to look up the (fully) resolved instance method from a class method. For example, given a code data Foo Int deriving Show bar = show (Foo 3) when inspecting the Typechecked AST for bar's show call, I would like to get to the Name / Id of 'show' of the 'Show' typeclass. I believe I could use splitHsSigmaTy on the HsType of the function call to get the context, and then evaluate the HsWrapper somehow to find out what instance dictionary is applied to the class restriction in the context, and then look up the instance method from the dictionary.. Two questions: 1) Is there maybe functionality for this? 2) If not, is there any guarantee about the constraint order in the context, at the method call? So I could more easily determine which constraint's application to look for.. Any hints welcome && Thank you! Robin -------------- next part -------------- An HTML attachment was scrubbed... URL: From palotai.robin at gmail.com Tue Sep 19 05:38:33 2017 From: palotai.robin at gmail.com (Robin Palotai) Date: Tue, 19 Sep 2017 07:38:33 +0200 Subject: [Haskell-cafe] Determine instance method from class method callsite Message-ID: Sorry, I messed up subject and mailing list. Copying to both list now after the mistake (wanted only ghc-devs for specificity). Thanks! 2017-09-19 7:36 GMT+02:00 Robin Palotai : > Hello GHC devs, > > Before inventing the wheel, want to check if there is a GHC API way to > look up the (fully) resolved instance method from a class method. > > For example, given a code > > data Foo Int deriving Show > > bar = show (Foo 3) > > when inspecting the Typechecked AST for bar's show call, I would like to > get to the Name / Id of 'show' of the 'Show' typeclass. > > I believe I could use splitHsSigmaTy on the HsType of the function call to > get the context, and then evaluate the HsWrapper somehow to find out what > instance dictionary is applied to the class restriction in the context, and > then look up the instance method from the dictionary.. > > Two questions: > > 1) Is there maybe functionality for this? > > 2) If not, is there any guarantee about the constraint order in the > context, at the method call? So I could more easily determine which > constraint's application to look for.. > > Any hints welcome && Thank you! > Robin > -------------- next part -------------- An HTML attachment was scrubbed... URL: From bhurt at spnz.org Tue Sep 19 13:21:18 2017 From: bhurt at spnz.org (Brian Hurt) Date: Tue, 19 Sep 2017 13:21:18 +0000 Subject: [Haskell-cafe] Haskell Programmers Wanted Message-ID: Code Haskell. Build great things. We’re Wrinkl, a well-funded startup working closely with Obsidian Systems to build a powerful new communications platform. We use Haskell on both the backend and the frontend (using GHCJS and Reflex). And we’re looking to hire Haskell developers, preferably in the Philly area or willing to relocate to Philly. If this sounds interesting, visit https://www.wrinkl.com/jobs/ for more info. Women and minorities strongly encouraged to apply. Brian -------------- next part -------------- An HTML attachment was scrubbed... URL: From damian.nadales at gmail.com Tue Sep 19 16:00:02 2017 From: damian.nadales at gmail.com (Damian Nadales) Date: Tue, 19 Sep 2017 18:00:02 +0200 Subject: [Haskell-cafe] Eindhoven Haskell Meetup session - Oct 3, 2017 Message-ID: Dear All, A new edition of our Haskell meetup will be held in Eindhoven: https://www.meetup.com/preview/Eindhoven-Haskell-Meetup/events/243342181 I would like to invite all the people that might be around this area. Also if you don't live close by, but you're visiting and want to give a talk please let me know, as we can always use a speaker. And at the same time I want to thank to the speakers that came (and will come) from far away to support his meetup (the Haskell community is -in my experience- great!). Kind regards, Damian. From samuli.thomasson at paivola.fi Tue Sep 19 21:03:03 2017 From: samuli.thomasson at paivola.fi (samuli.thomasson at paivola.fi) Date: Wed, 20 Sep 2017 00:03:03 +0300 Subject: [Haskell-cafe] Haskell job opportunity at RELEX Solutions in Helsinki, Finland Message-ID: <20170919210303.GA7668@applicative> Would you like to get paid for writing Haskell? And do you live in Helsinki, Finland area (or could re-locate)? If yes, please read on. RELEX Solutions is Europe’s fastest growing provider of integrated retail and supply chain planning solutions. We are now hiring one or two Haskell programmers in Helsinki, Finland to join our small but impactful group of Haskellers to develop our internal tools. You would be working pretty much exclusively in Haskell and Elm. Exact role is somewhat flexible, depending on what other skills you might bring to the table. Read more and apply now here: https://www.relexsolutions.com/open-positions/#op-209192-haskell-and-elm-enthusiast A good working knowledge of general Haskell programming is preferred, although eager learners can and should apply as well - if it's a good match, you just pick up the skills on the job. Unfortunately, we can't accept full remote for this position, so you should be able to be be present at the Helsinki office at least some days every week. Other details are largely negotiable. Note that the deadline for applications is quite soon, by October 2nd. Regards, Samuli Thomasson From fis at etc-network.de Wed Sep 20 10:17:13 2017 From: fis at etc-network.de (Matthias Fischmann) Date: Wed, 20 Sep 2017 12:17:13 +0200 Subject: [Haskell-cafe] Call for Contributions: BOB 2018 - Berlin, Feb 23, 2018 Message-ID: <20170920101713.t73tvpraiaor3zvk@localhost.localdomain> BOB Conference 2018 "What happens when we use what's best for a change?" http://bobkonf.de/2018/en/cfp.html Berlin, February 23 Call for Contributions Deadline: October 29, 2017 You are actively engaged in advanced software engineering methods, implement ambitious architectures and are open to cutting-edge innovation? Attend this conference, meet people that share your goals, and get to know the best software tools and technologies available today. We strive to offer a day full of new experiences and impressions that you can use to immediately improve your daily life as a software developer. If you share our vision and want to contribute, submit a proposal for a talk or tutorial! Topics ------ We are looking for talks about best-of-breed software technology, e.g.: - functional programming - persistent data structures and databases - types - formal methods for correctness and robustness - abstractions for concurrency and parallelism - metaprogramming - probabilistic programming - math and programming - controlled side effects - beyond REST and SOAP - effective abstractions for data analytics - ... everything really that isn’t mainstream, but you think should be. Presenters should provide the audience with information that is practically useful for software developers. We’re especially interested in experience reports. But this could also take other forms, e.g.: - introductory talks on technical background - overviews of a given field - demos and how-tos Requirements ------------ We accept proposals for presentations of 45 minutes (40 minutes talk + 5 minutes questions), as well as 90 minute tutorials for beginners. The language of presentation should be either English or German. Your proposal should include (in your presentation language of choice): - an abstract of max. 1500 characters. - a short bio/cv - contact information (including at least email address) - a list of 3-5 concrete ideas of how your work can be applied in a developer’s daily life - additional material (websites, blogs, slides, videos of past presentations, ...) Submit here: https://docs.google.com/forms/d/e/1FAIpQLSdjgwulSMpaITJ6q6cK_ndrfR1FlEs_HQlZy04LnUKC-ArCaQ/viewform?usp=sf_link Organisation - direct questions to contact at bobkonf dot de - proposal deadline: October 29, 2017 - notification: November 13, 2017 - program: December 1, 2017 NOTE: The conference fee will be waived for presenters, but travel expenses will not be covered. Speaker Grants -------------- BOB has Speaker Grants available to support speakers from groups under-represented in technology. We specifically seek women speakers and speakers who are not be able to attend the conference for financial reasons. Details are here: http://bobkonf.de/2018/en/speaker-grants.html Shepherding ----------- The program committee offers shepherding to all speakers. Shepherding provides speakers assistance with preparing their sessions, as well as a review of the talk slides. Program Committee ----------------- (more information here: http://bobkonf.de/2018/en/programmkomitee.html) - Matthias Fischmann, zerobuzz UG - Matthias Neubauer, SICK AG - Nicole Rauch, Softwareentwicklung und Entwicklungscoaching - Michael Sperber, Active Group - Stefan Wehr, factis research Scientific Advisory Board - Annette Bieniusa, TU Kaiserslautern - Torsten Grust, Uni Tübingen - Peter Thiemann, Uni Freiburg From schernichkin at gmail.com Wed Sep 20 14:27:54 2017 From: schernichkin at gmail.com (=?UTF-8?B?0KHRgtCw0L3QuNGB0LvQsNCyINCn0LXRgNC90LjRh9C60LjQvQ==?=) Date: Wed, 20 Sep 2017 17:27:54 +0300 Subject: [Haskell-cafe] Why is Haskell so slow (comparing to Java/Scala)? Message-ID: I've wrote simple Haskell benchmark program, which populated primitive vector from vector package: import Data.Vector.Primitive.Mutable as P vectorBench :: Benchmark vectorBench = bgroup "vector" [ primitive ] where primitive = bgroup "primitive" [ write1M ] where write1M = bench "write1M" $ nfIO $ do v <- P.unsafeNew 1000000 void $ for [0..1000000 - 1] $ flip (P.unsafeWrite v) (1 :: Int) return () I use `unsafeNew` to skip memory initialization and `unsafeWrite` to skip boundary checks, I guess it's fastest possible way to write something to vector. My result was about 40 ms. I wrote similar program in Scala: for (_ <- 1 to 5) { val start = System.currentTimeMillis() val a = new Array[Long](1000000) for (i <- 0 until 1000000) { a(i) = 1L } val end = System.currentTimeMillis() println(s"${end - start} ms") } I skip neither boundary checks nor memory initialization, I also used generic array here (suitable for any types of objects, not just for primitive types), so I expected longer run time. But what I got was shocking: 7 ms 3 ms 2 ms 1 ms 2 ms This program runs 20-40 times faster than Haskell after warm-up. 20-40 times, Carl! Why is Haskell soo slooooow? How can it be? -- Sincerely, Stanislav Chernichkin. -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at smallbone.se Wed Sep 20 16:05:12 2017 From: nick at smallbone.se (Nick Smallbone) Date: Wed, 20 Sep 2017 18:05:12 +0200 Subject: [Haskell-cafe] Why is Haskell so slow (comparing to Java/Scala)? References: Message-ID: <8760cdwe2v.fsf@smallbone.se> Hi Stanislav, Станислав Черничкин writes: > I've wrote simple Haskell benchmark program, which populated primitive vector > from vector package: > > ... > void $ for [0..1000000 - 1] $ flip (P.unsafeWrite v) (1 :: Int) 'for' is a variant of 'map' - it returns a list of results (in this case a list of a million () values). Instead you should use 'forM_' (note the underscore) from Control.Monad, which discards the result - that cuts the runtime by a huge amount when I try it. (And make sure to compile with -O too.) Nick From saurabhnanda at gmail.com Wed Sep 20 16:12:51 2017 From: saurabhnanda at gmail.com (Saurabh Nanda) Date: Wed, 20 Sep 2017 21:42:51 +0530 Subject: [Haskell-cafe] Why is Haskell so slow (comparing to Java/Scala)? In-Reply-To: References: <8760cdwe2v.fsf@smallbone.se> Message-ID: Intresting. Wont using "void" or "_ <- forM blah" have the same effect? Why not? On 20-Sep-2017 9:37 PM, "Nick Smallbone" wrote: Hi Stanislav, Станислав Черничкин writes: > I've wrote simple Haskell benchmark program, which populated primitive vector > from vector package: > > ... > void $ for [0..1000000 - 1] $ flip (P.unsafeWrite v) (1 :: Int) 'for' is a variant of 'map' - it returns a list of results (in this case a list of a million () values). Instead you should use 'forM_' (note the underscore) from Control.Monad, which discards the result - that cuts the runtime by a huge amount when I try it. (And make sure to compile with -O too.) Nick _______________________________________________ Haskell-Cafe mailing list To (un)subscribe, modify options or view archives go to: http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From nick at smallbone.se Wed Sep 20 16:21:50 2017 From: nick at smallbone.se (Nick Smallbone) Date: Wed, 20 Sep 2017 18:21:50 +0200 Subject: [Haskell-cafe] Why is Haskell so slow (comparing to Java/Scala)? References: <8760cdwe2v.fsf@smallbone.se> Message-ID: <87r2v1uyqp.fsf@smallbone.se> Saurabh Nanda writes: > Intresting. Wont using "void" or "_ <- forM blah" have the same effect? Why not? It has the same behaviour as using forM_, but the performance is worse, as the program still builds the result list before eventually discarding it. Whether this is something that could be optimised away in theory, I'm not sure - but it doesn't seem to be at the moment. Nick From jo at durchholz.org Wed Sep 20 16:38:49 2017 From: jo at durchholz.org (Joachim Durchholz) Date: Wed, 20 Sep 2017 18:38:49 +0200 Subject: [Haskell-cafe] Why is Haskell so slow (comparing to Java/Scala)? In-Reply-To: References: Message-ID: Am 20.09.2017 um 16:27 schrieb Станислав Черничкин: > I've wrote simple Haskell benchmark program, ... which means that the result is not really meaningful. Large programs have their inefficiencies in needless recomputations, which happen as soon as no single programmer knows everything anymore and people start reinventing the wheel. Small programs do not need to be particularly efficient. Well, usually - sometimes they need to be, but these cases are very rare. In your particular case, the base cause was that your mental model of what Haskell was doing did not match what was really happening. This misdirected you to the wrong function and gave you surprising results. This is not your fault. Haskell's execution model is fundamentally different from that of most other languages, and it takes time and experience to explore all the consequences. It is not Haskell's fault either, either - Haskell was built to explore specifically this execution model. My impression is that it makes Haskell's performance somewhat less predictable, but allows you to build larger systems that "just work" - millions of line of code, instead of the few thousands that you get with typical imperative code. Of course, these things become noticeable only if you (a) have worked on software that is substantially larger than a few thousand lines of code, and (b) at least one of these projects was in Haskell, or any other language with good support for referentially transparent functions. I wouldn't concentrate on getting that benchmark fast. It's too early to get any meaningful data out of that. Essentially, while you can speed up Haskell that way, you are going towards a more imperative style, and you'll lose the real advantages of Haskell. For this reason, I wouldn't pursue those monad library functions. Not right now, anyway; they are pretty specialized, and you should have a better reason than performance to get back to them. If you wish to explore performance, try to make your code faster without too much library function use. You will get more surprising results, but you will get a better understanding of what happens. HTH Jo From thomas.dubuisson at gmail.com Wed Sep 20 17:32:29 2017 From: thomas.dubuisson at gmail.com (Thomas DuBuisson) Date: Wed, 20 Sep 2017 10:32:29 -0700 Subject: [Haskell-cafe] Why is Haskell so slow (comparing to Java/Scala)? In-Reply-To: References: Message-ID: To recap You claimed a 40ms measurement. If we use `for_` instead of `void $ for` (for reasons mentioned earlier in the thread) and `-O2` when compiling we get just under 1 ms: ``` time 876.2 μs (852.8 μs .. 896.9 μs) 0.994 R² (0.989 R² .. 0.998 R²) mean 838.4 μs (825.0 μs .. 855.5 μs) std dev 48.21 μs (36.91 μs .. 74.18 μs) variance introduced by outliers: 48% (moderately inflated) ``` Cheers, Thomas On Wed, Sep 20, 2017 at 7:27 AM, Станислав Черничкин wrote: > I've wrote simple Haskell benchmark program, which populated primitive > vector from vector package: > > import Data.Vector.Primitive.Mutable as P > > vectorBench :: Benchmark > vectorBench = bgroup "vector" [ primitive ] > where > primitive = bgroup "primitive" [ write1M ] > where > write1M = bench "write1M" $ nfIO $ do > v <- P.unsafeNew 1000000 > void $ for [0..1000000 - 1] $ flip (P.unsafeWrite v) (1 :: Int) > return () > > I use `unsafeNew` to skip memory initialization and `unsafeWrite` to skip > boundary checks, I guess it's fastest possible way to write something to > vector. My result was about 40 ms. > > I wrote similar program in Scala: > > for (_ <- 1 to 5) { > val start = System.currentTimeMillis() > val a = new Array[Long](1000000) > for (i <- 0 until 1000000) { > a(i) = 1L > } > val end = System.currentTimeMillis() > println(s"${end - start} ms") > } > > I skip neither boundary checks nor memory initialization, I also used > generic array here (suitable for any types of objects, not just for > primitive types), so I expected longer run time. But what I got was > shocking: > > 7 ms > 3 ms > 2 ms > 1 ms > 2 ms > > This program runs 20-40 times faster than Haskell after warm-up. 20-40 > times, Carl! Why is Haskell soo slooooow? How can it be? > > > -- > Sincerely, Stanislav Chernichkin. > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. From capn.freako at gmail.com Wed Sep 20 17:33:02 2017 From: capn.freako at gmail.com (David Banas) Date: Wed, 20 Sep 2017 10:33:02 -0700 Subject: [Haskell-cafe] Traversable instance for ((->) a)? Message-ID: Is there a Traversable instance for ((->) a)? -db From allbery.b at gmail.com Wed Sep 20 18:49:29 2017 From: allbery.b at gmail.com (Brandon Allbery) Date: Wed, 20 Sep 2017 14:49:29 -0400 Subject: [Haskell-cafe] Why is Haskell so slow (comparing to Java/Scala)? In-Reply-To: References: <8760cdwe2v.fsf@smallbone.se> Message-ID: Briefly, because the 'spine' of IO (and indeed most monads) imposes a boundary on laziness, so when the IO action happens, the list *will* be built. It can only be bypassed by laziness if the IO action itself is. Hypothetically one could have RULES that rewrite to the non-list-building variants (trailing _) if the result is seen to be discarded --- but it would probably be unreliable, much as stream fusion can only happen if things go just right. On Wed, Sep 20, 2017 at 12:12 PM, Saurabh Nanda wrote: > Intresting. Wont using "void" or "_ <- forM blah" have the same effect? > Why not? > > On 20-Sep-2017 9:37 PM, "Nick Smallbone" wrote: > > > Hi Stanislav, > > Станислав Черничкин writes: > > I've wrote simple Haskell benchmark program, which populated primitive > vector > > from vector package: > > > > ... > > void $ for [0..1000000 - 1] $ flip (P.unsafeWrite v) (1 :: Int) > > 'for' is a variant of 'map' - it returns a list of results (in this case > a list of a million () values). Instead you should use 'forM_' (note the > underscore) from Control.Monad, which discards the result - that cuts > the runtime by a huge amount when I try it. (And make sure to compile > with -O too.) > > Nick > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -- brandon s allbery kf8nh sine nomine associates allbery.b at gmail.com ballbery at sinenomine.net unix, openafs, kerberos, infrastructure, xmonad http://sinenomine.net -------------- next part -------------- An HTML attachment was scrubbed... URL: From meburke at rocomai.com Wed Sep 20 19:46:32 2017 From: meburke at rocomai.com (meburke at rocomai.com) Date: Wed, 20 Sep 2017 14:46:32 -0500 Subject: [Haskell-cafe] Why is Haskell so slow (comparing to Java/Scala)? In-Reply-To: References: Message-ID: <20170920144632.Horde.O8ZvFxFbBe2xNHsdWfczVNS@www.rocomai.com> Thomas- You and Nick have been very helpful. I tried to post this in reply to another post, but I got an error, so I don't know if it went through. If this ends up as a double post, please forgive me. Now, the challenge is, given a set of objectives, how do you design a system or program to get the same results as c/c++ in roughly the same execution time. If there was a modeling process (like UML for imperative OO languages) for Haskell, we could compare models and see the differences. NOTE: I typically use LISP or Racket, so Haskell is not my strong suite. A good resource is "Everything That Linguists Have Always Wanted To Know About Logic *But Were Ashamed to Ask" by McCawley. This has such as good explanation of Lambda Calculus that it is worth wading through the whole book. Another NOTE: When using Symbolic Logic I use the Lukasiewicz notation instead of the Principia notation. This made LISP, Racket and Scheme really easy for me to think about. Haskell is still a little different, but it helps there, too. Mike Burke Quoting Thomas DuBuisson : > To recap > > You claimed a 40ms measurement. If we use `for_` instead of `void $ > for` (for reasons mentioned earlier in the thread) and `-O2` when > compiling we get just under 1 ms: > > ``` > time 876.2 μs (852.8 μs .. 896.9 μs) > 0.994 R² (0.989 R² .. 0.998 R²) > mean 838.4 μs (825.0 μs .. 855.5 μs) > std dev 48.21 μs (36.91 μs .. 74.18 μs) > variance introduced by outliers: 48% (moderately inflated) > ``` > > Cheers, > Thomas > > > > > On Wed, Sep 20, 2017 at 7:27 AM, Станислав Черничкин > wrote: >> I've wrote simple Haskell benchmark program, which populated primitive >> vector from vector package: >> >> import Data.Vector.Primitive.Mutable as P >> >> vectorBench :: Benchmark >> vectorBench = bgroup "vector" [ primitive ] >> where >> primitive = bgroup "primitive" [ write1M ] >> where >> write1M = bench "write1M" $ nfIO $ do >> v <- P.unsafeNew 1000000 >> void $ for [0..1000000 - 1] $ flip (P.unsafeWrite v) (1 :: Int) >> return () >> >> I use `unsafeNew` to skip memory initialization and `unsafeWrite` to skip >> boundary checks, I guess it's fastest possible way to write something to >> vector. My result was about 40 ms. >> >> I wrote similar program in Scala: >> >> for (_ <- 1 to 5) { >> val start = System.currentTimeMillis() >> val a = new Array[Long](1000000) >> for (i <- 0 until 1000000) { >> a(i) = 1L >> } >> val end = System.currentTimeMillis() >> println(s"${end - start} ms") >> } >> >> I skip neither boundary checks nor memory initialization, I also used >> generic array here (suitable for any types of objects, not just for >> primitive types), so I expected longer run time. But what I got was >> shocking: >> >> 7 ms >> 3 ms >> 2 ms >> 1 ms >> 2 ms >> >> This program runs 20-40 times faster than Haskell after warm-up. 20-40 >> times, Carl! Why is Haskell soo slooooow? How can it be? >> >> >> -- >> Sincerely, Stanislav Chernichkin. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> To (un)subscribe, modify options or view archives go to: >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> Only members subscribed via the mailman list are allowed to post. > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. From mgsloan at gmail.com Wed Sep 20 21:18:44 2017 From: mgsloan at gmail.com (Michael Sloan) Date: Wed, 20 Sep 2017 14:18:44 -0700 Subject: [Haskell-cafe] Traversable instance for ((->) a)? In-Reply-To: References: Message-ID: It isn't, in ghci try ":m + Data.Traversable" and ":info (->)". It should be possible to define an "instance Bounded a, Enum a, Eq a) => Traversable ((->) a)", it would only work on total functions with finitely enumerable inputs. It would be exactly like "Ord a => Traversable (Map a)", except it also needs to convert the function into this map representation by enumerating all inputs. With just the Eq constraint, the resulting function would be very inefficient as it would need to scan all (input, output) pairs to find the matching one. So you'd probably want an Ord or Hashable constraint and use Map or HashMap. Since this process is so slow, it doesn't make much sense to have this instance defined, it is not a very normal thing to do with functions. More likely to cause confusing type errors when the user intended to use traverse with some other type. -Michael On Wed, Sep 20, 2017 at 10:33 AM, David Banas wrote: > Is there a Traversable instance for ((->) a)? > -db > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. From ietf-dane at dukhovni.org Thu Sep 21 16:17:33 2017 From: ietf-dane at dukhovni.org (Viktor Dukhovni) Date: Thu, 21 Sep 2017 12:17:33 -0400 Subject: [Haskell-cafe] Curious why there's no ioe_description accessor in System.IO.Error? Message-ID: The IOError type re-exported from GHC.IO.Exception by System.IO.Error has accessors for some of the error elements fields, but is notably missing an accessor for ioe_description, which is only available as "ioeGetErrorString" for UserError, for all other errors you just get the string form of the error type: ioeGetErrorType :: IOError -> IOErrorType ioeGetErrorString :: IOError -> String ioeGetLocation :: IOError -> String ioeGetHandle :: IOError -> Maybe Handle ioeGetFileName :: IOError -> Maybe FilePath ioeGetErrorString ioe | isUserErrorType (ioe_type ioe) = ioe_description ioe | otherwise = show (ioe_type ioe) the real ioe_description for other error types can only be brought into scope by importing GHC.IO.Exception instead, or alternatively via the System.IO.Error.Lens: -- | Error type specific information. description :: Lens' IOException String description f s = f (ioe_description s) <&> \e -> s { ioe_description = e } {-# INLINE description #-} I am curious why ioeGetDescription was left out of System.IO.Error, and/or why it should not be added? Somehow it feels "wrong" to import GHC.IO.Exception instead of System.IO.Error just to get at the specific error text... Is it the case that, given all the other language extensions my code depends on, I should not have any qualms about importing GHC.* modules? Or perhaps is it the case that one should just start using lens, and so adding "missing" record accessors just delays migration to the right way and is no longer a priority? -- Viktor. From palotai.robin at gmail.com Thu Sep 21 22:38:28 2017 From: palotai.robin at gmail.com (Robin Palotai) Date: Fri, 22 Sep 2017 00:38:28 +0200 Subject: [Haskell-cafe] Determine instance method from class method callsite In-Reply-To: References: Message-ID: My conclusion so far: there's no royal way. One can get the instance dictionary DFunId pretty easy, but then access to the Typechecked AST of the instance declaration is really needed to find all the method bindings $c... (that get applied when constructing the dictionary $d...). 2017-09-19 7:38 GMT+02:00 Robin Palotai : > Sorry, I messed up subject and mailing list. Copying to both list now > after the mistake (wanted only ghc-devs for specificity). > > Thanks! > > 2017-09-19 7:36 GMT+02:00 Robin Palotai : > >> Hello GHC devs, >> >> Before inventing the wheel, want to check if there is a GHC API way to >> look up the (fully) resolved instance method from a class method. >> >> For example, given a code >> >> data Foo Int deriving Show >> >> bar = show (Foo 3) >> >> when inspecting the Typechecked AST for bar's show call, I would like to >> get to the Name / Id of 'show' of the 'Show' typeclass. >> >> I believe I could use splitHsSigmaTy on the HsType of the function call >> to get the context, and then evaluate the HsWrapper somehow to find out >> what instance dictionary is applied to the class restriction in the >> context, and then look up the instance method from the dictionary.. >> >> Two questions: >> >> 1) Is there maybe functionality for this? >> >> 2) If not, is there any guarantee about the constraint order in the >> context, at the method call? So I could more easily determine which >> constraint's application to look for.. >> >> Any hints welcome && Thank you! >> Robin >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From chneukirchen at gmail.com Fri Sep 22 13:31:01 2017 From: chneukirchen at gmail.com (Christian Neukirchen) Date: Fri, 22 Sep 2017 15:31:01 +0200 Subject: [Haskell-cafe] Munich Haskell Meeting, 2017-09-25 @ 19:30 Message-ID: <87377e97xm.fsf@gmail.com> Dear all, Next week, our monthly Munich Haskell Meeting will take place again on Monday, September 25 at Max Emanuel Brauerei at 19h30. For details see here: http://muenchen.haskell.bayern/dates.html If you plan to join, please add yourself to this dudle so we can reserve enough seats! It is OK to add yourself to the dudle anonymously or pseudonymously. https://dudle.inf.tu-dresden.de/haskell-munich-sep-2017/ Everybody is welcome! cu, -- Christian Neukirchen http://chneukirchen.org From olf at aatal-apotheke.de Fri Sep 22 14:39:57 2017 From: olf at aatal-apotheke.de (Olaf Klinke) Date: Fri, 22 Sep 2017 16:39:57 +0200 (CEST) Subject: [Haskell-cafe] deploy wxHaskell app on Windows Message-ID: <1506933474.183820.1506091197673@webmail.strato.de> Dear Cafe, I need help deploying a wxHaskell application on Windows. (The gui at haskell.org list seems to be dormant, as is wxhaskell-users on sourceforge.) I am explicitly CC-ing some people who recently posted about wxHaskell on this list. TL;DR: How to deploy a wxHaskell application on several Windows machines? Option (a): Automate the installation of DLLs and tweaking of PATH Option (b): Build static libs of wxWidgets to be linked into a static binary. I don't know how to do either. I developed a GUI application based on wxWidgets. I love the wx package, since wxWidgets provides all the high-level dialogs I need, like file and date pickers. The necessary installations on my Linux development machine went like a charm. Next I tried a Windows 10 machine. I installed stack, which installed a ghc.exe in %HOME%/AppData/Local/Programs/.../bin/ and cabal and stack binaries in %HOME%/AppData/Roaming/local/bin/. I downloaded a wx-config.exe binary and placed it in the latter directory and added that to the PATH. I downloaded wxInstall-Achelanne-64.0.1 and after adding the above path to ghc.exe to it's Install.bat, the Installation completed. Install.bat suggested to add two directories to the PATH, which I did. I set WXWIN to wxInstall-Achelanne-64.0.1/wxWidgets and WXCFG to gcc_dll/mswu With this, wx-config outputs some flags if requested. Next, I added %WXWIN%/include to extra-include-dirs and %WXWIN%/lib/gcc_dll to extra-lib-dirs in my stack.yaml. I also added %WXWIN%/DLLs to the extra-lib-dirs in the .cabal file. %WXWIN%/include/wx/platform.h mentions wx/setup.h which is not there. Remedy: Copy %WXWIN%/include/wx/msw/setup.h to %WXWIN%/include/wx/setup.h I believe I did set SHARED=0 in the wxWidgets config but there are no .lib, only .dll files in %WXWIN%, so I can not use ghc -optl-static. Hence the binaries produced by stack need to be told the place of the DLLs via the PATH environment variable. This is something I'd like to avoid on all the machines. Any suggestions welcome. Olaf From robstewart57 at gmail.com Fri Sep 22 15:55:09 2017 From: robstewart57 at gmail.com (Rob Stewart) Date: Fri, 22 Sep 2017 15:55:09 +0000 Subject: [Haskell-cafe] 3rd International Workshop on Real World Domain Specific Languages (RWDSL'18) Message-ID: CALL FOR PAPERS ================================= 3rd International Workshop on Real World Domain Specific Languages https://sites.google.com/site/realworlddsl In conjunction with The International Symposium on Code Generation and Optimisation 2018. http://cgo.org/cgo2018/ Vienna, Austria, 24 February, 2018 ==================================== As the use of computers proliferates, the complexity and variety of systems continues to grow. As a result, it is becoming increasingly inflexible to "hard wire" behaviours into software. Software developers can enable more control over their software configurations by exploiting Domain Specific Languages (DSLs). Such DSLs provide a systematic way to structure the underlying computational components: to coin a phrase, a DSL is a library with syntax. There is an enormous variety of DSLs for a very wide range of domains. Most DSLs are highly idiosyncratic, reflecting both the specific natures of their application domains and their designers' own preferences. This workshop will bring together constructors of DSLs for "real world" domains; that is, DSLs intended primarily to aid in building software to solve real world problems rather than to explore the more theoretical aspects of language design and implementation. We are looking for submissions that present the motivation, design, implementation, use and evaluation of such DSLs. ================================= Key Dates: ---------------- Paper submission deadline : 15th December2017 Author notification: 26th January 2018 Final manuscript due: 9th February 2018 Workshop: 24th February 2018 ---------------- Submission Instructions: The EasyChair submission page for this workshop is: https://easychair.org/conferences/?conf=rwdsl18 We anticipate that accepted submissions will be published in the ACM Digital Library within its International Conference Proceedings Series, as were RWSDL'16 and RWDSL'17. Submissions should be 8-10 pages in ACM double-column format. Authors should follow the information for formatting ACM SIGPLAN conference papers, which can be found at http://www.acm.org/publications/proceedings-template. Full submission details are on the workshop web page. ================================= Program Chairs Rob Stewart, Heriot-Watt University, UK Greg Michaelson, Heriot-Watt University, UK PC Members Riyadh Baghdadi, MIT, USA Allin Cottrell, Wake Forest University, USA Nina Dethlefs, University of Hull, UK And Gill, X - The Moonshot Factory, USA Kevin Hammond, University of St Andrews, UK Patrick Maier, University of Glasgow, UK Mathijs Schuts, Phillips Healthcare, Netherlands Simon Thompson, University of Kent, UK Phil Trinder, University of Glasgow, UK Contact Please email inquiries concerning the workshop to: R.Stewart at hw.ac.uk -------------- next part -------------- An HTML attachment was scrubbed... URL: From mad+haskell at unserver.de Fri Sep 22 18:45:26 2017 From: mad+haskell at unserver.de (Matthias =?utf-8?Q?K=C3=BChlke?=) Date: Fri, 22 Sep 2017 20:45:26 +0200 Subject: [Haskell-cafe] deploy wxHaskell app on Windows In-Reply-To: <1506933474.183820.1506091197673@webmail.strato.de> References: <1506933474.183820.1506091197673@webmail.strato.de> Message-ID: <87k20qa7y1.fsf@unserver.de> Hello, the easy solution would be to place the DLLs into the same directory as the .exe file. Windows looks there first: https://docs.microsoft.com/en-us/cpp/build/search-path-used-by-windows-to-locate-a-dll We did that with GTK, and it worked perfectly. HTH, Matthias From ivanperezdominguez at gmail.com Fri Sep 22 22:22:10 2017 From: ivanperezdominguez at gmail.com (Ivan Perez) Date: Fri, 22 Sep 2017 23:22:10 +0100 Subject: [Haskell-cafe] deploy wxHaskell app on Windows In-Reply-To: <87k20qa7y1.fsf@unserver.de> References: <1506933474.183820.1506091197673@webmail.strato.de> <87k20qa7y1.fsf@unserver.de> Message-ID: Hi On 22 September 2017 at 19:45, Matthias Kühlke wrote: > [T]he easy solution would be to place the DLLs into the same directory as > the .exe file. I also do this. I wrote a GTK Haskell program for a company in 2011 that placed the DLLs with the executable. It's been in use ever since on machines, up to windows 7 I believe, without changing that. Ivan -------------- next part -------------- An HTML attachment was scrubbed... URL: From erwig at oregonstate.edu Sun Sep 24 01:02:33 2017 From: erwig at oregonstate.edu (erwig) Date: Sat, 23 Sep 2017 18:02:33 -0700 Subject: [Haskell-cafe] EduHaskell Message-ID: <1E41D48D-AD5B-4C5F-9595-721392525C50@oregonstate.edu> Dear Haskell aficionados, We will be using Haskell in an introductory course to computer science for college freshmen. From my past experience in using Haskell for students, the biggest hurdle and source of frustration is the type checker, or more precisely, the error messages generated. I see three major kinds of errors that get in the way of a smoother programming experience: * Errors resulting from overloading * Errors due to undefined type class instances (specifically, Eq and Show) * Errors in the context of parametric polymorphism While these problems are not unsurmountable, having to talk about these errors is a distraction from the major goal of explaining basics of (functional) programming. It would be great to have a Haskell compiler that offers the following features (and maybe others): * Type classes and overloading could be turned off * Eq and Show (and maybe Ord) instances would be automatically defined for any data type definition (when type classes are enabled) My questions are: (1) Does there exist a good solution to this problem already? Should one use Helium? I haven't checked lately, but it used to avoid type classes. This might have the disadvantage of having to switch to GHC in case one wants to use overloading. (I have used Helium in the past, and while I admire the effort, I am not sure it's the best option.) Are there versions of the Prelude available that accomplish some of this? (2) Are there other Haskellers out there who also want a simpler, more educationally suited version of GHCi? (3) If the answer to (1) is NO and to (2) is YES, is there any interest in forming a group for creating something like "EduHaskell"? I'd be grateful for any comments or suggestions! Thanks, Martin From hafnersimon at gmail.com Sun Sep 24 01:20:31 2017 From: hafnersimon at gmail.com (Simon Hafner) Date: Sun, 24 Sep 2017 03:20:31 +0200 Subject: [Haskell-cafe] EduHaskell In-Reply-To: <1E41D48D-AD5B-4C5F-9595-721392525C50@oregonstate.edu> References: <1E41D48D-AD5B-4C5F-9595-721392525C50@oregonstate.edu> Message-ID: Hello Erwig >From what I understand, you want a Haskell without typeclasses. Elm [1] would fit that bill nicely. > * Type classes and overloading could be turned off These don't exist in Elm. > * Eq and Show (and maybe Ord) instances would be automatically defined for any data type definition (when type classes are enabled) Eq and Show are implemented by compiler magic, no Ord though. You could later move the students towards Haskell, after you spoiled them with the Elm compiler messages :-) Cheers, Simon [1] http://elm-lang.org/examples 2017-09-24 3:02 GMT+02:00 erwig : > Dear Haskell aficionados, > > We will be using Haskell in an introductory course to computer science for college freshmen. From my past experience in using Haskell for students, the biggest hurdle and source of frustration is the type checker, or more precisely, the error messages generated. I see three major kinds of errors that get in the way of a smoother programming experience: > > * Errors resulting from overloading > * Errors due to undefined type class instances (specifically, Eq and Show) > * Errors in the context of parametric polymorphism > > While these problems are not unsurmountable, having to talk about these errors is a distraction from the major goal of explaining basics of (functional) programming. It would be great to have a Haskell compiler that offers the following features (and maybe others): > > * Type classes and overloading could be turned off > * Eq and Show (and maybe Ord) instances would be automatically defined for any data type definition (when type classes are enabled) > > My questions are: > > (1) Does there exist a good solution to this problem already? > > Should one use Helium? I haven't checked lately, but it used to avoid type classes. This might have the disadvantage of having to switch to GHC in case one wants to use overloading. (I have used Helium in the past, and while I admire the effort, I am not sure it's the best option.) > > Are there versions of the Prelude available that accomplish some of this? > > (2) Are there other Haskellers out there who also want a simpler, more educationally suited version of GHCi? > > (3) If the answer to (1) is NO and to (2) is YES, is there any interest in forming a group for creating something like "EduHaskell"? > > > I'd be grateful for any comments or suggestions! > > > Thanks, > Martin > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. From cdsmith at gmail.com Sun Sep 24 01:22:31 2017 From: cdsmith at gmail.com (Chris Smith) Date: Sat, 23 Sep 2017 18:22:31 -0700 Subject: [Haskell-cafe] EduHaskell In-Reply-To: <1E41D48D-AD5B-4C5F-9595-721392525C50@oregonstate.edu> References: <1E41D48D-AD5B-4C5F-9595-721392525C50@oregonstate.edu> Message-ID: Hi! For some of your ideas, let me suggest looking at CodeWorld, at http://code.world. I use it to teach middle school students, ages around 11 to 14. It has some of the properties you are looking for. Notably: - No type classes are defined in the standard library. - It offers a fully polymorphic equality operator, with no type class constraint. (This is implemented with runtime-aware logic specific to GHCJS.) - It avoids the need for many other type classes by simplifying the available types. For instance, there is one Number type so that math operators are monomorphic. Comparison operators only work on Number, and there are separate monomorphic "Show"-like functions for different types. - The prelude is uncurried, because accidentally partially applying a function is another mistake that new programmers make that can lead to poor error messages. - A pre-compile step enforces that function application should use parentheses around arguments. CodeWorld is designed to be used with a math-like notation -- such as "f(x)" -- rather than just "f x". - There are post-processing rules that rewrite some error messages to be beginner-friendly. This is likely not *exactly* what you want. For instance, there is no REPL at all, and programs are designed to be run in a web browser panel (and soon exported to Android) rather than used from the command line. But it might be a source of ideas for what is possible to accomplish on top of GHC. Hope that helps, Chris On Sat, Sep 23, 2017 at 6:02 PM, erwig wrote: > Dear Haskell aficionados, > > We will be using Haskell in an introductory course to computer science for > college freshmen. From my past experience in using Haskell for students, > the biggest hurdle and source of frustration is the type checker, or more > precisely, the error messages generated. I see three major kinds of errors > that get in the way of a smoother programming experience: > > * Errors resulting from overloading > * Errors due to undefined type class instances (specifically, Eq and Show) > * Errors in the context of parametric polymorphism > > While these problems are not unsurmountable, having to talk about these > errors is a distraction from the major goal of explaining basics of > (functional) programming. It would be great to have a Haskell compiler that > offers the following features (and maybe others): > > * Type classes and overloading could be turned off > * Eq and Show (and maybe Ord) instances would be automatically defined for > any data type definition (when type classes are enabled) > > My questions are: > > (1) Does there exist a good solution to this problem already? > > Should one use Helium? I haven't checked lately, but it used to avoid type > classes. This might have the disadvantage of having to switch to GHC in > case one wants to use overloading. (I have used Helium in the past, and > while I admire the effort, I am not sure it's the best option.) > > Are there versions of the Prelude available that accomplish some of this? > > (2) Are there other Haskellers out there who also want a simpler, more > educationally suited version of GHCi? > > (3) If the answer to (1) is NO and to (2) is YES, is there any interest in > forming a group for creating something like "EduHaskell"? > > > I'd be grateful for any comments or suggestions! > > > Thanks, > Martin > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ruben.astud at gmail.com Sun Sep 24 04:16:06 2017 From: ruben.astud at gmail.com (Ruben Astudillo) Date: Sun, 24 Sep 2017 01:16:06 -0300 Subject: [Haskell-cafe] EduHaskell In-Reply-To: <1E41D48D-AD5B-4C5F-9595-721392525C50@oregonstate.edu> References: <1E41D48D-AD5B-4C5F-9595-721392525C50@oregonstate.edu> Message-ID: I just have passing commentary on your issues. For the bigger questions at the end of the mail I don't have good answers sadly, although just by convenience on question from SO/reddit/web in general I would stay on GHC/base so they can search their questions. On 23/09/17 22:02, erwig wrote: > * Errors resulting from overloading On GHC 8.2.1 there is a new flag for `:type +d` which uses type-defaulting for giving non-overloaded versions for functions. Prelude> :type +d foldr foldr :: (a -> b -> b) -> b -> [a] -> b Prelude> :type foldr foldr :: Foldable t => (a -> b -> b) -> b -> t a -> b That help to return some of the convenience from before Foldable was in the Prelude. There also -XTypeApplications which lets you play with the signatures Prelude> :set -XTypeApplications Prelude> import Data.Monoid Prelude> import Data.Set Prelude> :type +v foldMap foldMap :: Foldable t => forall m a. Monoid m => (a -> m) -> t a -> m Prelude> :type foldMap @Set foldMap @Set :: Monoid m => (a -> m) -> Set a -> m Prelude> :type foldMap @Set @(Sum _) foldMap @Set @(Sum _) :: Num w => (a -> Sum w) -> Set a -> Sum w Prelude> :type foldMap @Set @(Sum Int) foldMap @Set @(Sum Int) :: (a -> Sum Int) -> Set a -> Sum Int type +v is to see the explicit forall and thus how the TypeApplications get applied. Lastly there is more help to see what instances are available in the form of link in the haddock pages of the classes. > * Errors due to undefined type class instances (specifically, Eq and Show) I would teach to define instances for those clases because they are easy to do. They work on types of kind * thus are very down to earth. I remember doing this with LYAH. That way they won't see them as magic and actually understand why the compiler is barfing. > * Errors in the context of parametric polymorphism Those are actually hard. Classes of working on kinds * -> * are what gives haskell the feeling that the class/instances are hard and magical. Playing with them is the only to get comfortable though. -- -- Ruben -- pgp: 4EE9 28F7 932E F4AD From johannes.waldmann at htwk-leipzig.de Sun Sep 24 15:05:03 2017 From: johannes.waldmann at htwk-leipzig.de (Johannes Waldmann) Date: Sun, 24 Sep 2017 17:05:03 +0200 Subject: [Haskell-cafe] EduHaskell Message-ID: <12e68467-fe9f-1b14-dada-82897170cc11@htwk-leipzig.de> Dear Martin, I use Haskell for teaching as well (not for beginners) [1]. I do use ghci in lab classes. For the problems you mention, I have these sort-of work-arounds: > Errors resulting from overloading numerical literals, arithmetical operators? avoid built-in (Prelude) numbers and the Num class. stuff that's been generalized from list to Foldable (e.g., length)? avoid built-in (Prelude) lists [2] > Errors due to undefined type class instances > (specifically, Eq and Show) I think these classes are somewhat easy to motivate - at least Eq is (we need "==" to notate and test properties of programs, not every type has decidable equality (functions have not), so we need to mark the types that do) For Show, it's not that nice (ghci uses "show" but implicitly - then why do we need to write the Show instance explicitly) Still, adding "deriving (Eq, Show)" after each data declaration is not too much of a burden. I agree it is a distraction. > Errors in the context of parametric polymorphism Well, it's an important concept to teach, so it is natural that it takes some time and work. (slightly tangential - I think it would already help if it would be easier to declare types of identifiers - to remove unwanted polymorphism. E.g., "\ (x::Bool) (y::Bool) -> x || y" currently requires a language pragma (!) whose name mentions type variables (!!) ) - Johannes. [1] https://www.imn.htwk-leipzig.de/~waldmann/talk/17/wflp [2] https://www.imn.htwk-leipzig.de/~waldmann/etc/untutorial/list-or-not-list/ From stuart at cs.uchicago.edu Sun Sep 24 15:52:03 2017 From: stuart at cs.uchicago.edu (Stuart A. Kurtz) Date: Sun, 24 Sep 2017 10:52:03 -0500 Subject: [Haskell-cafe] EduHaskell In-Reply-To: <1E41D48D-AD5B-4C5F-9595-721392525C50@oregonstate.edu> References: <1E41D48D-AD5B-4C5F-9595-721392525C50@oregonstate.edu> Message-ID: Dear Martin, I also teach Haskell to college freshmen, albeit in a self-selected "honors" class. My typical student has some programming background, and a high level of mathematical aptitude. The first few weeks were a bit easier in the days before burning bridges, but my sense is the things are starting to improve again. Certainly, I think the benefits of the improved Prelude far outweigh the pedagogical costs imposed on the proud few, who like us, are crazy enough to teach Haskell to 18 year olds. 1. The error messages in ghc 8.2.1 strike me as clearer and more concise. 2. I'm changing the way I teach. My experience in teaching Haskell is that have to introduce types early, and the only real question is "how early." We're experimenting with introducing types (including simple parametric types and typeclasses) in Lecture 1 (tomorrow) this year, in what my colleague Ravi Chugh and I refer to as the "types earliest" approach. What we're aiming for in Lecture 1 is an overview, not a deep understanding of Haskell's type system. Still, we *are* introducing typeclasses (albeit without talking about how they're implemented), and we are sketching out how type inference works, so students can see how conflicts arise. I'd send a URL, but it won't be stable until tomorrow. Peace, Stu --------------- Stuart A. Kurtz Professor, Department of Computer Science and the College Director of Undergraduate Studies for Computer Science The University of Chicago From stuart at cs.uchicago.edu Mon Sep 25 00:19:24 2017 From: stuart at cs.uchicago.edu (Stuart A. Kurtz) Date: Sun, 24 Sep 2017 19:19:24 -0500 Subject: [Haskell-cafe] EduHaskell In-Reply-To: <1E41D48D-AD5B-4C5F-9595-721392525C50@oregonstate.edu> References: <1E41D48D-AD5B-4C5F-9595-721392525C50@oregonstate.edu> Message-ID: Dear Martin, Here's the URL for our first lecture: http://cmsc-16100.cs.uchicago.edu/2017/Lectures/01/intro.php It is idiosyncratic, but then, so am I ;-). My experience is that Chicago students love little bits of history that help contextualize what they're learning, and these notes reflect that. We'll be putting up additional lectures as we go. It's pretty easy to find the 2016 version of the class, but it looks like we'll be reworking much of the material. Peace, Stu --------------- Stuart A. Kurtz Professor, Department of Computer Science and the College Director of Undergraduate Studies for Computer Science The University of Chicago From J.Hage at uu.nl Mon Sep 25 09:35:48 2017 From: J.Hage at uu.nl (Jurriaan Hage) Date: Mon, 25 Sep 2017 11:35:48 +0200 Subject: [Haskell-cafe] EduHaskell In-Reply-To: <1E41D48D-AD5B-4C5F-9595-721392525C50@oregonstate.edu> References: <1E41D48D-AD5B-4C5F-9595-721392525C50@oregonstate.edu> Message-ID: <84893A1C-091E-40D5-9078-74253241C756@uu.nl> Hi Martin, Helium does support overloading, depending on your choice of flags. If you turn it on, it provides a number of built-in type classes, like Eq and Old. It is just that you cannot define your own classes and instances (work is on the way in this respect). All instances are derived, as you ask. I will be working on extending Helium this (course) year in various directions to make it * suitable as a study object for a course on compiler construction and * adding code generation and type checking for type classes * add import/export facilities (these are currently very straightforward) Helium can be easily installed from Cabal for you to check out and play with. See the website at http://foswiki.cs.uu.nl/foswiki/Helium/WebHome As to your general question on EduHaskell, I’d be interested in such a group, and would like Helium to be that teaching-oriented Haskell compiler. best, Jur > On 24Sep, 2017, at 03:02, erwig wrote: > > Dear Haskell aficionados, > > We will be using Haskell in an introductory course to computer science for college freshmen. From my past experience in using Haskell for students, the biggest hurdle and source of frustration is the type checker, or more precisely, the error messages generated. I see three major kinds of errors that get in the way of a smoother programming experience: > > * Errors resulting from overloading > * Errors due to undefined type class instances (specifically, Eq and Show) > * Errors in the context of parametric polymorphism > > While these problems are not unsurmountable, having to talk about these errors is a distraction from the major goal of explaining basics of (functional) programming. It would be great to have a Haskell compiler that offers the following features (and maybe others): > > * Type classes and overloading could be turned off > * Eq and Show (and maybe Ord) instances would be automatically defined for any data type definition (when type classes are enabled) > > My questions are: > > (1) Does there exist a good solution to this problem already? > > Should one use Helium? I haven't checked lately, but it used to avoid type classes. This might have the disadvantage of having to switch to GHC in case one wants to use overloading. (I have used Helium in the past, and while I admire the effort, I am not sure it's the best option.) > > Are there versions of the Prelude available that accomplish some of this? > > (2) Are there other Haskellers out there who also want a simpler, more educationally suited version of GHCi? > > (3) If the answer to (1) is NO and to (2) is YES, is there any interest in forming a group for creating something like "EduHaskell"? > > > I'd be grateful for any comments or suggestions! > > > Thanks, > Martin > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. From olf at aatal-apotheke.de Mon Sep 25 18:44:33 2017 From: olf at aatal-apotheke.de (Olaf Klinke) Date: Mon, 25 Sep 2017 20:44:33 +0200 Subject: [Haskell-cafe] Solved: deploy wxHaskell app on Windows In-Reply-To: References: <1506933474.183820.1506091197673@webmail.strato.de> <87k20qa7y1.fsf@unserver.de> Message-ID: <2D34235E-DA8D-4C58-9711-ACF2116178CB@aatal-apotheke.de> Thanks all for the hint! The DLLs and executable even work on both Windows 10 and Windows 7, which I feared would require yet another setup of stack. Now I have got only one cosmetic problem to solve: Static text in wxWidgets seems to accept bgcolor attributes, but the background itself seems to be transparent (or equal to the parent's). Graphics.UI.WXCore.WxcDefs exports far fewer constants than there could be. I'd like to color cells of a table composed as a grid of static text elements. Cheers, Olaf > Am 23.09.2017 um 00:22 schrieb Ivan Perez : > > Hi > > On 22 September 2017 at 19:45, Matthias Kühlke wrote: > [T]he easy solution would be to place the DLLs into the same directory as > the .exe file. > > I also do this. I wrote a GTK Haskell program for a company in 2011 that placed the DLLs with the executable. It's been in use ever since on machines, up to windows 7 I believe, without changing that. > > Ivan > From ischenkovn at gmail.com Mon Sep 25 19:18:03 2017 From: ischenkovn at gmail.com (Vladyslav Nikolayevich) Date: Mon, 25 Sep 2017 22:18:03 +0300 Subject: [Haskell-cafe] =?utf-8?q?=28no_subject=29?= Message-ID: <57973BF2-6FA3-4E91-AF47-5401C1CB0464@gmail.com> From erwig at oregonstate.edu Mon Sep 25 21:11:20 2017 From: erwig at oregonstate.edu (erwig) Date: Mon, 25 Sep 2017 14:11:20 -0700 Subject: [Haskell-cafe] EduHaskell In-Reply-To: <971c589553cc44648517b49e121ab77b@EX1.oregonstate.edu> References: <1E41D48D-AD5B-4C5F-9595-721392525C50@oregonstate.edu> <971c589553cc44648517b49e121ab77b@EX1.oregonstate.edu> Message-ID: Thanks for all the useful hints and suggestions! Maybe I should have explained the constraints (and where they come from) in more detail. First, the course is NOT an introduction to programming, but an introduction to computer science more generally and thus also discusses several topics not typically addressed by a programming course. Second, computing concepts are introduced with the help of stories, and programming will only take place in the second half of the course (more details about the approach can be found at web.engr.oregonstate.edu/~erwig/SBT). Thus the goal of minimizing the need for explaining advanced type system features. Also, we have already created Haskell code, so that's why Elm, although a really nice language, is currently not an option because of its different syntax. Code.world is also a cool system, but we do currently require a REPL. I definitely will take another look a Helium. Again, thanks for all the responses so far! I'm still wondering which, if any, of the existing alternative preludes would potentially be a good substitute for educational purposes. -- Martin From ietf-dane at dukhovni.org Mon Sep 25 23:48:14 2017 From: ietf-dane at dukhovni.org (Viktor Dukhovni) Date: Mon, 25 Sep 2017 23:48:14 +0000 Subject: [Haskell-cafe] EduHaskell In-Reply-To: References: <1E41D48D-AD5B-4C5F-9595-721392525C50@oregonstate.edu> <971c589553cc44648517b49e121ab77b@EX1.oregonstate.edu> Message-ID: <20170925234814.GO3322@mournblade.imrryr.org> On Mon, Sep 25, 2017 at 02:11:20PM -0700, erwig wrote: > Again, thanks for all the responses so far! I'm still wondering > which, if any, of the existing alternative preludes would potentially > be a good substitute for educational purposes. A small comment, for what it is worth: as a still learning novice, I find the error messages in GHC 8.2 to be significantly easier to understand than in previous releases. Perhaps students will also find that to be the case. As to having or not having "Eq" by default, I have a brief anecdote: I just did some work to improve performance in the HDBC Sqlite driver, and had to deal with bit-rot in the tests. I moved the time conversion tests from the deprecated System.Time interface to the preferred Data.Time interface, but found an obstacle in that ZonedTime has no Eq instance. This makes sense, because equality of time with a time zone is ambiguous, are two such times equal when they refer to the same UTC time, or should the Time Zone name and summer only flags also be required to be equal? So choosing a suitable Eq implementation can be a subtle issue. For the purpose of the tests, full equality was previously chosen for System.Time, and I let that stand, so I needed to define an equivalent Eq instance for Data.Time's ZonedTIme, and wanted to avoid compiler warnings from creation of orphan instances. So I wrapped ZonedTime in a newtype ZonedTimeEq and created an Eq instance for that, but the tests also wanted this to be "Convertible" to various related types. So I engaged some rather fancy machinery: {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE UndecidableInstances #-} newtype ZonedTimeEq = ZonedTimeEq { _zt :: ZonedTime } instance Show ZonedTimeEq where show = show . _zt instance Eq ZonedTimeEq where a == b = let a' = _zt a b' = _zt b in zonedTimeToUTC a' == zonedTimeToUTC b' && zonedTimeZone a' == zonedTimeZone b' instance (Convertible a ZonedTime) => (Convertible a ZonedTimeEq) where safeConvert v = ZonedTimeEq <$> (safeConvert v) instance (Convertible ZonedTime b) => (Convertible ZonedTimeEq b) where safeConvert (ZonedTimeEq v) = safeConvert v I just wrote the definitions I wanted to write, and each time the compiler produced warnings, it helpfully told me that the definitions were illegal without an extension to make it go. So it took three iterations to add FlexibleInstances, MultiParamTypeClasses and finally UndecidableInstances to make the compiler happy. The moral of the story is that Eq can be subtle, and sometimes lack of an Eq instance is not an oversight, but is a hint that there be dragons with deciding equality for the type in question. And it is in such cases that the instance machinery comes into play to let one make the appropriate choice for the problem at hand. -- Viktor. P.S. Perhaps my ZonedTimeEq "solution" is suboptimal, if there's a better way, please drop me a note. From ietf-dane at dukhovni.org Thu Sep 28 08:55:09 2017 From: ietf-dane at dukhovni.org (Viktor Dukhovni) Date: Thu, 28 Sep 2017 04:55:09 -0400 Subject: [Haskell-cafe] Reinventing the wheel? Does any existing package provide an applicatively lifted (>>) ? Message-ID: <887DDF83-B72C-4EE0-BE78-A2A78E880F10@dukhovni.org> When generating a report file from a database I found it much more efficient (significantly shorter runtime) to represent each row by an I/O action that prints the row, rather than to construct a Row object that to print and throw away. But the naive way to construct the I/O action can be tedious to maintain once the column count gets appreciably high: newtype Foo = Foo { _foo :: IO () } instance FromRow Foo where fromRow = Foo <$> (rowPrinter <$> field <*> field <*> field <*> ... <*> field) where rowPrinter :: Type1 -> Type2 -> Type3 -> ... -> TypeN -> IO () rowPrinter p1 p2 p3 ... pN = do printP1 printP2 printP3 ... printPN So I decided to applicatively decompose the rowPrinter function (with the actual name of "andthen" to be determined later) as: rowPrinter = (printP1 <$> field) `andthen` (printP2 <$> field) `andthen` (printP3 <$> field) `andthen` ... (printPN <$> field) which avoids the need to package the column printers explicitly into a single function, and may be somewhat more efficient a well. What was not immediately obvious to me was whether there's an "off the shelf" implementation of "andthen" I could just reuse. The necessary operator satisfies: andthen (f (m a)) (f (m b)) = f (ma >> mb) or, equivalently: a `andthen` b = (>>) <$> a <*> b for which http://pointree.io dutifully gives me: andthen = (<*>) . ((>>) <$>) Its type signature is: Prelude> :set prompt "l> " l> :m + Control.Applicative l> :m + Control.Monad l> :t ((<*>) . ((>>) <$>)) ((<*>) . ((>>) <$>)) :: (Monad m, Applicative f) => f (m a) -> f (m b) -> f (m b) l> It seems to me that this would have been done before, and the operator would already be present in some package, but I'm having trouble finding it. (Due to the hidden constructors of FromRow defining a Semigroup does not work out here, so I can't use (<>), which also inconveniently conflicts with Monoid (<>)). So my question is whether the operator in question is already available, under some name in some package, or else suggested names for it if new. -- Viktor. From isaace71295 at gmail.com Thu Sep 28 09:44:13 2017 From: isaace71295 at gmail.com (Isaac Elliott) Date: Thu, 28 Sep 2017 09:44:13 +0000 Subject: [Haskell-cafe] Reinventing the wheel? Does any existing package provide an applicatively lifted (>>) ? In-Reply-To: <887DDF83-B72C-4EE0-BE78-A2A78E880F10@dukhovni.org> References: <887DDF83-B72C-4EE0-BE78-A2A78E880F10@dukhovni.org> Message-ID: Hey Victor, If you're not actually the Monad instance of IO, then `andThen` is (*>) for `Compose RowParser IO a` ( https://hackage.haskell.org/package/base-4.10.0.0/docs/Data-Functor-Compose.html ). So `rowPrinter` would be rowPrinter = getCompose $ Compose (printP1 <$> field) *> Compose (printP2 <$> field) *> ... Compose (printPn <$> field) It's a bit more verbose, but I think it's the best answer. On Thu, 28 Sep. 2017, 6:54 pm Viktor Dukhovni, wrote: > > When generating a report file from a database I found it much more > efficient (significantly shorter runtime) to represent each row > by an I/O action that prints the row, rather than to construct a > Row object that to print and throw away. > > But the naive way to construct the I/O action can be tedious to > maintain once the column count gets appreciably high: > > newtype Foo = Foo { _foo :: IO () } > instance FromRow Foo where > fromRow = Foo <$> (rowPrinter <$> field <*> field <*> field <*> ... > <*> field) > where > rowPrinter :: Type1 -> Type2 -> Type3 -> ... -> TypeN -> IO () > rowPrinter p1 p2 p3 ... pN = do > printP1 > printP2 > printP3 > ... > printPN > > So I decided to applicatively decompose the rowPrinter function > (with the actual name of "andthen" to be determined later) as: > > rowPrinter = (printP1 <$> field) `andthen` > (printP2 <$> field) `andthen` > (printP3 <$> field) `andthen` > ... > (printPN <$> field) > > which avoids the need to package the column printers explicitly into > a single function, and may be somewhat more efficient a well. > > What was not immediately obvious to me was whether there's an "off the > shelf" implementation of "andthen" I could just reuse. The necessary > operator satisfies: > > andthen (f (m a)) (f (m b)) = f (ma >> mb) > > or, equivalently: > > a `andthen` b = (>>) <$> a <*> b > > for which http://pointree.io dutifully gives me: > > andthen = (<*>) . ((>>) <$>) > > Its type signature is: > > Prelude> :set prompt "l> " > l> :m + Control.Applicative > l> :m + Control.Monad > l> :t ((<*>) . ((>>) <$>)) > ((<*>) . ((>>) <$>)) > :: (Monad m, Applicative f) => f (m a) -> f (m b) -> f (m b) > l> > > It seems to me that this would have been done before, and the operator > would already be present in some package, but I'm having trouble finding > it. > > (Due to the hidden constructors of FromRow defining a Semigroup does not > work out here, so I can't use (<>), which also inconveniently conflicts > with Monoid (<>)). > > So my question is whether the operator in question is already available, > under some name in some package, or else suggested names for it if new. > > -- > Viktor. > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -------------- next part -------------- An HTML attachment was scrubbed... URL: From jeffbrown.the at gmail.com Thu Sep 28 10:57:11 2017 From: jeffbrown.the at gmail.com (Jeffrey Brown) Date: Thu, 28 Sep 2017 03:57:11 -0700 Subject: [Haskell-cafe] Reinventing the wheel? Does any existing package provide an applicatively lifted (>>) ? In-Reply-To: <887DDF83-B72C-4EE0-BE78-A2A78E880F10@dukhovni.org> References: <887DDF83-B72C-4EE0-BE78-A2A78E880F10@dukhovni.org> Message-ID: > or, equivalently: > > a `andthen` b = (>>) <$> a <*> b > > for which http://pointree.io dutifully gives me: > > andthen = (<*>) . ((>>) <$>) That link is not working for me, and Google isn't finding it, and it sounds like a useful thing. On Thu, Sep 28, 2017 at 1:55 AM, Viktor Dukhovni wrote: > > When generating a report file from a database I found it much more > efficient (significantly shorter runtime) to represent each row > by an I/O action that prints the row, rather than to construct a > Row object that to print and throw away. > > But the naive way to construct the I/O action can be tedious to > maintain once the column count gets appreciably high: > > newtype Foo = Foo { _foo :: IO () } > instance FromRow Foo where > fromRow = Foo <$> (rowPrinter <$> field <*> field <*> field <*> ... > <*> field) > where > rowPrinter :: Type1 -> Type2 -> Type3 -> ... -> TypeN -> IO () > rowPrinter p1 p2 p3 ... pN = do > printP1 > printP2 > printP3 > ... > printPN > > So I decided to applicatively decompose the rowPrinter function > (with the actual name of "andthen" to be determined later) as: > > rowPrinter = (printP1 <$> field) `andthen` > (printP2 <$> field) `andthen` > (printP3 <$> field) `andthen` > ... > (printPN <$> field) > > which avoids the need to package the column printers explicitly into > a single function, and may be somewhat more efficient a well. > > What was not immediately obvious to me was whether there's an "off the > shelf" implementation of "andthen" I could just reuse. The necessary > operator satisfies: > > andthen (f (m a)) (f (m b)) = f (ma >> mb) > > or, equivalently: > > a `andthen` b = (>>) <$> a <*> b > > for which http://pointree.io dutifully gives me: > > andthen = (<*>) . ((>>) <$>) > > Its type signature is: > > Prelude> :set prompt "l> " > l> :m + Control.Applicative > l> :m + Control.Monad > l> :t ((<*>) . ((>>) <$>)) > ((<*>) . ((>>) <$>)) > :: (Monad m, Applicative f) => f (m a) -> f (m b) -> f (m b) > l> > > It seems to me that this would have been done before, and the operator > would already be present in some package, but I'm having trouble finding > it. > > (Due to the hidden constructors of FromRow defining a Semigroup does not > work out here, so I can't use (<>), which also inconveniently conflicts > with Monoid (<>)). > > So my question is whether the operator in question is already available, > under some name in some package, or else suggested names for it if new. > > -- > Viktor. > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. -- Jeff Brown | Jeffrey Benjamin Brown Website | Facebook | LinkedIn (spammy, so I often miss messages here) | Github -------------- next part -------------- An HTML attachment was scrubbed... URL: From schernichkin at gmail.com Thu Sep 28 11:00:37 2017 From: schernichkin at gmail.com (=?UTF-8?B?0KHRgtCw0L3QuNGB0LvQsNCyINCn0LXRgNC90LjRh9C60LjQvQ==?=) Date: Thu, 28 Sep 2017 14:00:37 +0300 Subject: [Haskell-cafe] Mutable data structures and asynchronous exceptions Message-ID: It's quite hard to implement mutable data structures in presence of asynchronous exceptions. Since exception can arise at any point, it is not possible to guarantee atomicity of operation, hence mutable data structure may remain in incorrect state in case of interruption. One can certainly use maskAsyncExceptions# and friends to protect critical regions, but masking function are living in IO, mutable data structures on other hand trend to be state-polymorphic (to allow it usage in ST). This lead to conflicting requirements: - One should not care about asynchronous exceptions inside ST (it is not possible to catch exception in ST, hence not possible to use something in invalid state). More over, it is not even possible to do write “exception-safe” code, because masking functions not available. - One should provide accurate masking then using same data structures in IO. So I want do discuss several questions topics on this case. 1. Impact. Are async exceptions really common? Would not be easier to say: “ok, things can go bad if you combine async exceptions with mutable data structures, just don't do it”. 2. Documentation. Should library authors explicitly mention async exceptions safety? For example https://hackage.haskell.org/package/hashtables – is it async exceptions safe when used in IO? Or even worse https://hackage.haskell.org/package/ghc-prim-0.5.1.0/docs/GHC-Prim.html#v:resizeMutableByteArray-35- - what will happened in case of async exception? This functions is sate-polimorphic, will it implicitly mask exceptions if used from IO? 3. Best practices. How should we deal with problem? Is creating separate versions of code for ST and IO is the only way? Probably it is possible to add “mask” to something like https://hackage.haskell.org/package/primitive-0.6.2.0/docs/Control-Monad-Primitive.html#t:PrimMonad emit mask in IO instance and NOOP in ST version? Or maybe somebody know better patterns for async exeption safe code? -- Sincerely, Stanislav Chernichkin. -------------- next part -------------- An HTML attachment was scrubbed... URL: From timmelzer at gmail.com Thu Sep 28 11:02:12 2017 From: timmelzer at gmail.com (Norbert Melzer) Date: Thu, 28 Sep 2017 13:02:12 +0200 Subject: [Haskell-cafe] Reinventing the wheel? Does any existing package provide an applicatively lifted (>>) ? In-Reply-To: References: <887DDF83-B72C-4EE0-BE78-A2A78E880F10@dukhovni.org> Message-ID: Am 28.09.2017 um 12:57 schrieb Jeffrey Brown: >> or, equivalently: >> >>        a `andthen` b = (>>) <$> a <*> b >> >> for which http://pointree.io  dutifully gives me: >> >>      andthen = (<*>) . ((>>) <$>) > > That link is not working for me, and Google isn't finding it, and it > sounds like a useful thing. Theres just an `f` missing. Correct link is probably http://pointfree.io/ -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: OpenPGP digital signature URL: From sibi at psibi.in Thu Sep 28 11:03:47 2017 From: sibi at psibi.in (Sibi) Date: Thu, 28 Sep 2017 16:33:47 +0530 Subject: [Haskell-cafe] Reinventing the wheel? Does any existing package provide an applicatively lifted (>>) ? In-Reply-To: References: <887DDF83-B72C-4EE0-BE78-A2A78E880F10@dukhovni.org> Message-ID: It should be free instead of tree: http://pointfree.io/ Regards, On Thu, Sep 28, 2017 at 4:27 PM, Jeffrey Brown wrote: > > or, equivalently: > > > > a `andthen` b = (>>) <$> a <*> b > > > > for which http://pointree.io dutifully gives me: > > > > andthen = (<*>) . ((>>) <$>) > > That link is not working for me, and Google isn't finding it, and it > sounds like a useful thing. > > > On Thu, Sep 28, 2017 at 1:55 AM, Viktor Dukhovni > wrote: > >> >> When generating a report file from a database I found it much more >> efficient (significantly shorter runtime) to represent each row >> by an I/O action that prints the row, rather than to construct a >> Row object that to print and throw away. >> >> But the naive way to construct the I/O action can be tedious to >> maintain once the column count gets appreciably high: >> >> newtype Foo = Foo { _foo :: IO () } >> instance FromRow Foo where >> fromRow = Foo <$> (rowPrinter <$> field <*> field <*> field <*> ... >> <*> field) >> where >> rowPrinter :: Type1 -> Type2 -> Type3 -> ... -> TypeN -> IO () >> rowPrinter p1 p2 p3 ... pN = do >> printP1 >> printP2 >> printP3 >> ... >> printPN >> >> So I decided to applicatively decompose the rowPrinter function >> (with the actual name of "andthen" to be determined later) as: >> >> rowPrinter = (printP1 <$> field) `andthen` >> (printP2 <$> field) `andthen` >> (printP3 <$> field) `andthen` >> ... >> (printPN <$> field) >> >> which avoids the need to package the column printers explicitly into >> a single function, and may be somewhat more efficient a well. >> >> What was not immediately obvious to me was whether there's an "off the >> shelf" implementation of "andthen" I could just reuse. The necessary >> operator satisfies: >> >> andthen (f (m a)) (f (m b)) = f (ma >> mb) >> >> or, equivalently: >> >> a `andthen` b = (>>) <$> a <*> b >> >> for which http://pointree.io dutifully gives me: >> >> andthen = (<*>) . ((>>) <$>) >> >> Its type signature is: >> >> Prelude> :set prompt "l> " >> l> :m + Control.Applicative >> l> :m + Control.Monad >> l> :t ((<*>) . ((>>) <$>)) >> ((<*>) . ((>>) <$>)) >> :: (Monad m, Applicative f) => f (m a) -> f (m b) -> f (m b) >> l> >> >> It seems to me that this would have been done before, and the operator >> would already be present in some package, but I'm having trouble finding >> it. >> >> (Due to the hidden constructors of FromRow defining a Semigroup does not >> work out here, so I can't use (<>), which also inconveniently conflicts >> with Monoid (<>)). >> >> So my question is whether the operator in question is already available, >> under some name in some package, or else suggested names for it if new. >> >> -- >> Viktor. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> To (un)subscribe, modify options or view archives go to: >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> Only members subscribed via the mailman list are allowed to post. > > > > > -- > Jeff Brown | Jeffrey Benjamin Brown > Website | Facebook > | LinkedIn > (spammy, so I often > miss messages here) | Github > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -- Sibi, sibi at psibi.in WWW: psibi.in Twitter/github/identi.ca: psibi GPG Fingerpint: A241 B3D6 F4FD D40D D7DE B1C6 D19E 3E0E BB55 7613 Registered Linux User ID: 534664 -------------- next part -------------- An HTML attachment was scrubbed... URL: From info at maximka.de Thu Sep 28 11:31:55 2017 From: info at maximka.de (info at maximka.de) Date: Thu, 28 Sep 2017 13:31:55 +0200 (CEST) Subject: [Haskell-cafe] Mutable data structures and asynchronous exceptions In-Reply-To: References: Message-ID: <1836117529.307629.1506598315656@communicator.strato.de> I hope you'll find some answers to you questions in the "Asynchronous Exceptions" chapter http://chimera.labs.oreilly.com/books/1230000000929/ch09.html Regards, Alexei > On 28 September 2017 at 13:00 Станислав Черничкин wrote: > > > It's quite hard to implement mutable data structures in presence of > asynchronous exceptions. Since exception can arise at any point, it is not > possible to guarantee atomicity of operation, hence mutable data structure > may remain in incorrect state in case of interruption. One can certainly > use maskAsyncExceptions# and friends to protect critical regions, but > masking function are living in IO, mutable data structures on other hand > trend to be state-polymorphic (to allow it usage in ST). > > This lead to conflicting requirements: > - One should not care about asynchronous exceptions inside ST (it is not > possible to catch exception in ST, hence not possible to use something in > invalid state). More over, it is not even possible to do write > “exception-safe” code, because masking functions not available. > - One should provide accurate masking then using same data structures in IO. > > So I want do discuss several questions topics on this case. > > 1. Impact. Are async exceptions really common? Would not be easier to say: > “ok, things can go bad if you combine async exceptions with mutable data > structures, just don't do it”. > > 2. Documentation. Should library authors explicitly mention async > exceptions safety? For example > https://hackage.haskell.org/package/hashtables – is it async exceptions > safe when used in IO? Or even worse > https://hackage.haskell.org/package/ghc-prim-0.5.1.0/docs/GHC-Prim.html#v:resizeMutableByteArray-35- > - what will happened in case of async exception? This functions is > sate-polimorphic, will it implicitly mask exceptions if used from IO? > > 3. Best practices. How should we deal with problem? Is creating separate > versions of code for ST and IO is the only way? Probably it is possible to > add “mask” to something like > https://hackage.haskell.org/package/primitive-0.6.2.0/docs/Control-Monad-Primitive.html#t:PrimMonad > emit mask in IO instance and NOOP in ST version? Or maybe somebody know > better patterns for async exeption safe code? > > -- > Sincerely, Stanislav Chernichkin. > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. From vhaisman at gmail.com Thu Sep 28 12:21:19 2017 From: vhaisman at gmail.com (=?UTF-8?Q?V=C3=A1clav_Haisman?=) Date: Thu, 28 Sep 2017 14:21:19 +0200 Subject: [Haskell-cafe] [hs-bibutils] intention to take over package In-Reply-To: References: Message-ID: On 23 July 2017 at 23:10, Václav Haisman wrote: > > Hi. > > I would like to take over the hs-bibutils Hackage package. It has not > been updated since 2014, the listed maintainer is not responsive to > emails, and listed home page is 404 page. > I have updated hs-bibutils to version of Bibutils 6.2 in new GitHub repository https://github.com/wilx/hs-bibutils. I have used this updated hs-bibutils to build pandoc-citeproc and I have run cabal test with 1 of 1 test suites (1 of 1 test cases) passed. I would like to take over the maintenance of the package, if it possible. -- VH From michael at snoyman.com Thu Sep 28 12:45:51 2017 From: michael at snoyman.com (Michael Snoyman) Date: Thu, 28 Sep 2017 15:45:51 +0300 Subject: [Haskell-cafe] Mutable data structures and asynchronous exceptions In-Reply-To: References: Message-ID: > Since exception can arise at any point, it is not possible to guarantee atomicity of operation, hence mutable data structure may remain in incorrect state in case of interruption. Even if async exceptions didn't exist, we couldn't guarantee atomicity in general without specifically atomic functions (like atomicModifyIORef or STM), since another thread may access the data concurrently and create a data race. If you're only talking about single-threaded cases—of which ST is _basically_ a subset[1]—I don't think you're really worried about _atomicity_, but about exception safety. Exception safety goes beyond async exceptions, since almost all IO actions can throw some form of synchronous exception. For those cases, you can use one of the many exception-cleanup functions, like finally, onException, bracket, or bracketOnError. It's true that those functions don't work inside ST, but I'd argue you don't need them to. The expected behavior of code that receives an async exception is to (1) clean up after itself and (2) rethrow the exception. But as ST blocks are supposed to be free of externally-visible side effects, worrying about putting its variables back into some safe state is unnecessary[2]. To summarize: * If you need true atomicity, you're in IO and dealing with multiple threads. I'd recommend sticking with STM unless you have a strong reason to do otherwise. * If you are single threaded and in IO, you can get away with non-STM stuff more easily, and need to make sure you're using exception-aware functions. * If you're inside ST, make sure any resources you acquire are cleaned up correctly, but otherwise you needn't worry about exceptions. Also, you may be interested in reading the documentation for safe-exceptions[3], which talks more about async exception safety. [1] I say basically since you'd have to pull out unsafe functions to fork a thread that has access to an STVar or similar, though it could be done. [2] If you're doing something like binding to a C library inside ST, you may have some memory cleanup to perform, but the STVars and other data structures should never be visible again. [3] https://haskell-lang.org/library/safe-exceptions On Thu, Sep 28, 2017 at 2:00 PM, Станислав Черничкин wrote: > It's quite hard to implement mutable data structures in presence of > asynchronous exceptions. Since exception can arise at any point, it is not > possible to guarantee atomicity of operation, hence mutable data structure > may remain in incorrect state in case of interruption. One can certainly > use maskAsyncExceptions# and friends to protect critical regions, but > masking function are living in IO, mutable data structures on other hand > trend to be state-polymorphic (to allow it usage in ST). > > This lead to conflicting requirements: > - One should not care about asynchronous exceptions inside ST (it is not > possible to catch exception in ST, hence not possible to use something in > invalid state). More over, it is not even possible to do write > “exception-safe” code, because masking functions not available. > - One should provide accurate masking then using same data structures in > IO. > > So I want do discuss several questions topics on this case. > > 1. Impact. Are async exceptions really common? Would not be easier to say: > “ok, things can go bad if you combine async exceptions with mutable data > structures, just don't do it”. > > 2. Documentation. Should library authors explicitly mention async > exceptions safety? For example https://hackage.haskell.org/ > package/hashtables – is it async exceptions safe when used in IO? Or even > worse https://hackage.haskell.org/package/ghc-prim-0.5.1.0/docs/ > GHC-Prim.html#v:resizeMutableByteArray-35- - what will happened in case > of async exception? This functions is sate-polimorphic, will it implicitly > mask exceptions if used from IO? > > 3. Best practices. How should we deal with problem? Is creating separate > versions of code for ST and IO is the only way? Probably it is possible to > add “mask” to something like https://hackage.haskell.org/ > package/primitive-0.6.2.0/docs/Control-Monad-Primitive.html#t:PrimMonad > emit mask in IO instance and NOOP in ST version? Or maybe somebody know > better patterns for async exeption safe code? > > -- > Sincerely, Stanislav Chernichkin. > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- An HTML attachment was scrubbed... URL: From schernichkin at gmail.com Thu Sep 28 15:51:47 2017 From: schernichkin at gmail.com (=?UTF-8?B?0KHRgtCw0L3QuNGB0LvQsNCyINCn0LXRgNC90LjRh9C60LjQvQ==?=) Date: Thu, 28 Sep 2017 18:51:47 +0300 Subject: [Haskell-cafe] Mutable data structures and asynchronous exceptions In-Reply-To: References: Message-ID: Thank your for reply. I think I should clarify what exactly I'd like to discuss. The “data structures” I'm talking about are in general single-threaded mutable containers (like mentioned hashtables, or like ArrayList in Java). Such structures are not thread safe, yet it would be nice to have async exception safety. The word “atomicity” I used in a sense mentioned here https://en.wikipedia.org/wiki/Atomicity_(database_systems) : operation either occurs or fails and data structure remains in previous state. In many cases such behavior can be achieved without complex exception clean-up routines. Let me give an example. Consider something like ArrayList from Java (an vector which can grow while elements added). I want to implement 'add' action. The contract is straightforward – the action may either add element to structure, possibly reallocating underlying memory buffer, writing element at last position, incrementing element counter, or it may throw OutOfMemory exception. But in the latter case the structure should stay “undamaged”. This could be implemented as following: if count_equals_capacity thenallocate_new_buffer (let's suppose it garbage-collected) copy_elements update_buffer_pointer update_capacity_variable write_new_element_to_buffer update_count_variable This code does not contains any explicit exception handling but it satisfies the contract. The only place there exception can occur is allocate_new_buffer. In this case action will be interrupted before any state modifications. All other operations are basically memory writes and completely safe (assuming code correct and will not segfault). Things become complicated in presence of async exceptions. Suppose async exception raised between write_new_element_to_buffer and update_count_variable. At first glance nothing wrong happed, but if the buffer holds references, it will now contain a reference to some object, preventing it from being GC-d, and this reference will be beyond buffer's count value, because exception occurred before updating count variable, so programmer will be completely unaware of it. But this still can be fixed by masking exceptions in critical blocks. And we can defenelly implement all of this in the IO monad. The question is how to write “monad polymorhic” code. i.e. code, which can run both in IO and ST. Mutable data structures benefit from being “monad polymorhic”. Most Haskell mutable containers (vectors, hashtables, impure-containers) are build on PrimState monad allowing them run both in IO and ST. But they seems just ignore the fact that async exception may corrupt state. Some of them ( e.g. https://hackage.haskell.org/package/impure-containers-0.4.0/docs/src/Data-ArrayList-Generic.html#ArrayList ) seem even ignore that unsafeGrow may throw OutOfMemory (though attempting to recover from OutOfMemory may be bad idea itself). 2017-09-28 15:45 GMT+03:00 Michael Snoyman : > > Since exception can arise at any point, it is not possible to guarantee > atomicity of operation, hence mutable data structure may remain in > incorrect state in case of interruption. > > Even if async exceptions didn't exist, we couldn't guarantee atomicity in > general without specifically atomic functions (like atomicModifyIORef or > STM), since another thread may access the data concurrently and create a > data race. > > If you're only talking about single-threaded cases—of which ST is > _basically_ a subset[1]—I don't think you're really worried about > _atomicity_, but about exception safety. Exception safety goes beyond async > exceptions, since almost all IO actions can throw some form of synchronous > exception. For those cases, you can use one of the many exception-cleanup > functions, like finally, onException, bracket, or bracketOnError. > > It's true that those functions don't work inside ST, but I'd argue you > don't need them to. The expected behavior of code that receives an async > exception is to (1) clean up after itself and (2) rethrow the exception. > But as ST blocks are supposed to be free of externally-visible side > effects, worrying about putting its variables back into some safe state is > unnecessary[2]. > > To summarize: > > * If you need true atomicity, you're in IO and dealing with multiple > threads. I'd recommend sticking with STM unless you have a strong reason to > do otherwise. > * If you are single threaded and in IO, you can get away with non-STM > stuff more easily, and need to make sure you're using exception-aware > functions. > * If you're inside ST, make sure any resources you acquire are cleaned up > correctly, but otherwise you needn't worry about exceptions. > > Also, you may be interested in reading the documentation for > safe-exceptions[3], which talks more about async exception safety. > > [1] I say basically since you'd have to pull out unsafe functions to fork > a thread that has access to an STVar or similar, though it could be done. > [2] If you're doing something like binding to a C library inside ST, you > may have some memory cleanup to perform, but the STVars and other data > structures should never be visible again. > [3] https://haskell-lang.org/library/safe-exceptions > > On Thu, Sep 28, 2017 at 2:00 PM, Станислав Черничкин < > schernichkin at gmail.com> wrote: > >> It's quite hard to implement mutable data structures in presence of >> asynchronous exceptions. Since exception can arise at any point, it is not >> possible to guarantee atomicity of operation, hence mutable data structure >> may remain in incorrect state in case of interruption. One can certainly >> use maskAsyncExceptions# and friends to protect critical regions, but >> masking function are living in IO, mutable data structures on other hand >> trend to be state-polymorphic (to allow it usage in ST). >> >> This lead to conflicting requirements: >> - One should not care about asynchronous exceptions inside ST (it is not >> possible to catch exception in ST, hence not possible to use something in >> invalid state). More over, it is not even possible to do write >> “exception-safe” code, because masking functions not available. >> - One should provide accurate masking then using same data structures in >> IO. >> >> So I want do discuss several questions topics on this case. >> >> 1. Impact. Are async exceptions really common? Would not be easier to >> say: “ok, things can go bad if you combine async exceptions with mutable >> data structures, just don't do it”. >> >> 2. Documentation. Should library authors explicitly mention async >> exceptions safety? For example https://hackage.haskell.org/pa >> ckage/hashtables – is it async exceptions safe when used in IO? Or even >> worse https://hackage.haskell.org/package/ghc-prim-0.5.1.0/docs/GH >> C-Prim.html#v:resizeMutableByteArray-35- - what will happened in case of >> async exception? This functions is sate-polimorphic, will it implicitly >> mask exceptions if used from IO? >> >> 3. Best practices. How should we deal with problem? Is creating separate >> versions of code for ST and IO is the only way? Probably it is possible to >> add “mask” to something like https://hackage.haskell.org/pa >> ckage/primitive-0.6.2.0/docs/Control-Monad-Primitive.html#t:PrimMonad >> emit mask in IO instance and NOOP in ST version? Or maybe somebody know >> better patterns for async exeption safe code? >> >> -- >> Sincerely, Stanislav Chernichkin. >> >> _______________________________________________ >> Haskell-Cafe mailing list >> To (un)subscribe, modify options or view archives go to: >> http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe >> Only members subscribed via the mailman list are allowed to post. >> > > -- Sincerely, Stanislav Chernichkin. -------------- next part -------------- An HTML attachment was scrubbed... URL: From ietf-dane at dukhovni.org Thu Sep 28 16:56:48 2017 From: ietf-dane at dukhovni.org (Viktor Dukhovni) Date: Thu, 28 Sep 2017 12:56:48 -0400 Subject: [Haskell-cafe] Reinventing the wheel? Does any existing package provide an applicatively lifted (>>) ? In-Reply-To: References: <887DDF83-B72C-4EE0-BE78-A2A78E880F10@dukhovni.org> Message-ID: <53F3CB16-922A-4A5E-AA3F-64E583D5A1F3@dukhovni.org> > On Sep 28, 2017, at 5:44 AM, Isaac Elliott wrote: > > If you're not actually the Monad instance of IO, Can you explain that qualification? > then `andThen` is (*>) for `Compose RowParser IO a` (https://hackage.haskell.org/package/base-4.10.0.0/docs/Data-Functor-Compose.html). > > So `rowPrinter` would be > > rowPrinter = > getCompose $ > Compose (printP1 <$> field) *> > Compose (printP2 <$> field) *> > ... > Compose (printPn <$> field) > > It's a bit more verbose, but I think it's the best answer. Indeed this works, and looks more clear than some new unfamiliar operator. This seems to have no measurable run-time cost. Is it reasonable to expect that under the covers no objects boxed as (Compose _) are ever created, and that Compose here is just compile-time syntactic sugar for applying (*>) at the desired layer, so that: getCompose $ Compose (Foo Bar a) *> Compose (Foo Bar b) *> Compose (Foo Bar c) ... *> Compose (Foo Bar z) just compiles down to Foo (Bar a *> Bar b *> Bar c *> ... *> Bar z)? Where, in my case, Foo is "RowParser" and Bar is IO? -- Viktor. From anselm.scholl at tu-harburg.de Thu Sep 28 19:55:48 2017 From: anselm.scholl at tu-harburg.de (Jonas Scholl) Date: Thu, 28 Sep 2017 21:55:48 +0200 Subject: [Haskell-cafe] Mutable data structures and asynchronous exceptions In-Reply-To: References: Message-ID: <248b0822-9668-89c4-c3ae-1510a8b67738@tu-harburg.de> If you are in ST, you can not modify anything externally visible without using unsafe functions. If an exception occurs at any point, your changes would remain in some broken state, but there would be no reference to it, so they are just garbage collected and nothing bad happens. If you need externally visible changes, you have to use IO, but then you also have the full arsenal of exception handling functions at your disposal. If you write code which is polymorphic and can either work in IO or ST, it can not have any visible side effects and thus you can ignore any exceptions in it (because you could runST it in completely pure code). If you think of your array list, lets look at possible signatures for adding an element: addPure :: ArrayList a -> a -> ArrayList a Clearly this just copies the whole array every time, there is nothing mutable here. addST :: ArrayList s a -> a -> ST s () This one is mutable, but you can never get out of ST with this ArrayList. While you are in ST, it doesn't matter if an async exception interrupts you, because you will throw away the result of the ST action anyway (and thus your broken ArrayList). addST' :: ArrayList a -> a -> ST s (ArrayList a) Has to copy the whole array because you can implement addPure with this and runST. addIO :: ArrayList a -> a -> IO () This can modify the list, but it can (and has to) also handle exceptions. This is the only one which Java provides. Regarding the monadic polymorphic (you are talking about MonadPrim, right?) functions: They can not handle exceptions, because they might be used in an ST context. But as stated earlier, if you compose them to another action in some MonadPrim, it will be exception safe because you can just apply runST to it, constraining MonadPrim to ST and getting a pure value out of it (and such a value never needs to handle exceptions). Of course, all this changes as soon as you use unsafeThaw in ST without proving that you have the ONLY reference to that buffer/array/... On 09/28/2017 05:51 PM, Станислав Черничкин wrote: > Thank your for reply. I think I should clarify what exactly I'd like to > discuss. > > The “data structures” I'm talking about are in general single-threaded > mutable containers (like mentioned hashtables, or like ArrayList in > Java). Such structures are not thread safe, yet it would be nice to have > async exception safety. The word “atomicity” I used in a sense mentioned > here https://en.wikipedia.org/wiki/Atomicity_(database_systems) : > operation either occurs or fails and data structure remains in previous > state. In many cases such behavior can be achieved without complex > exception clean-up routines. > > Let me give an example. Consider something like ArrayList from Java (an > vector which can grow while elements added). I want to implement 'add' > action. The contract is straightforward – the action may either add > element to structure, possibly reallocating underlying memory buffer, > writing element at last position, incrementing element counter, or it > may throw OutOfMemory exception. But in the latter case the structure > should stay “undamaged”. This could be implemented as following: > > if count_equals_capacity thenallocate_new_buffer (let's suppose it > garbage-collected) > > copy_elements > > update_buffer_pointer > > update_capacity_variable > > write_new_element_to_buffer > > update_count_variable > > > This code does not contains any explicit exception handling but it > satisfies the contract. The only place there exception can occur is > allocate_new_buffer. In this case action will be interrupted before any > state modifications. All other operations are basically memory writes > and completely safe (assuming code correct and will not segfault). > > Things become complicated in presence of async exceptions. Suppose async > exception raised between write_new_element_to_buffer and > update_count_variable. At first glance nothing wrong happed, but if the > buffer holds references, it will now contain a reference to some object, > preventing it from being GC-d, and this reference will be beyond > buffer's count value, because exception occurred before updating count > variable, so programmer will be completely unaware of it. But this still > can be fixed by masking exceptions in critical blocks. And we can > defenelly implement all of this in the IO monad. > > The question is how to write “monad polymorhic” code. i.e. code, which > can run both in IO and ST. Mutable data structures benefit from being > “monad polymorhic”. Most Haskell mutable containers (vectors, > hashtables, impure-containers) are build on PrimState monad allowing > them run both in IO and ST. But they seems just ignore the fact that > async exception may corrupt state. Some of them ( e.g. > https://hackage.haskell.org/package/impure-containers-0.4.0/docs/src/Data-ArrayList-Generic.html#ArrayList > ) seem even ignore that unsafeGrow may throw OutOfMemory (though > attempting to recover from OutOfMemory may be bad idea itself). > > > 2017-09-28 15:45 GMT+03:00 Michael Snoyman >: > > > Since exception can arise at any point, it is not possible to guarantee atomicity of operation, hence mutable data structure may remain in > incorrect state in case of interruption. > > Even if async exceptions didn't exist, we couldn't guarantee > atomicity in general without specifically atomic functions (like > atomicModifyIORef or STM), since another thread may access the data > concurrently and create a data race. > > If you're only talking about single-threaded cases—of which ST is > _basically_ a subset[1]—I don't think you're really worried about > _atomicity_, but about exception safety. Exception safety goes > beyond async exceptions, since almost all IO actions can throw some > form of synchronous exception. For those cases, you can use one of > the many exception-cleanup functions, like finally, onException, > bracket, or bracketOnError. > > It's true that those functions don't work inside ST, but I'd argue > you don't need them to. The expected behavior of code that receives > an async exception is to (1) clean up after itself and (2) rethrow > the exception. But as ST blocks are supposed to be free of > externally-visible side effects, worrying about putting its > variables back into some safe state is unnecessary[2]. > > To summarize: > > * If you need true atomicity, you're in IO and dealing with multiple > threads. I'd recommend sticking with STM unless you have a strong > reason to do otherwise. > * If you are single threaded and in IO, you can get away with > non-STM stuff more easily, and need to make sure you're using > exception-aware functions. > * If you're inside ST, make sure any resources you acquire are > cleaned up correctly, but otherwise you needn't worry about exceptions. > > Also, you may be interested in reading the documentation for > safe-exceptions[3], which talks more about async exception safety. > > [1] I say basically since you'd have to pull out unsafe functions to > fork a thread that has access to an STVar or similar, though it > could be done. > [2] If you're doing something like binding to a C library inside ST, > you may have some memory cleanup to perform, but the STVars and > other data structures should never be visible again. > [3] https://haskell-lang.org/library/safe-exceptions > > > On Thu, Sep 28, 2017 at 2:00 PM, Станислав Черничкин > > wrote: > > It's quite hard to implement mutable data structures in presence > of asynchronous exceptions. Since exception can arise at any > point, it is not possible to guarantee atomicity of operation, > hence mutable data structure may remain in incorrect state in > case of interruption. One can certainly use maskAsyncExceptions# > and friends to protect critical regions, but masking function > are living in IO, mutable data structures on other hand trend to > be state-polymorphic (to allow it usage in ST). > > This lead to conflicting requirements:  > - One should not care about asynchronous exceptions inside ST > (it is not possible to catch exception in ST, hence not possible > to use something in invalid state). More over, it is not even > possible to do write “exception-safe” code, because masking > functions not available. > - One should provide accurate masking then using same data > structures in IO. > > So I want do discuss several questions topics on this case. > > 1. Impact. Are async exceptions really common? Would not be > easier to say: “ok, things can go bad if you combine async > exceptions with mutable data structures, just don't do it”.  > > 2. Documentation. Should library authors explicitly mention > async exceptions safety? For example > https://hackage.haskell.org/package/hashtables > – is it async > exceptions safe when used in IO? Or even worse > https://hackage.haskell.org/package/ghc-prim-0.5.1.0/docs/GHC-Prim.html#v:resizeMutableByteArray-35- > > - what will happened in case of async exception? This functions > is sate-polimorphic, will it implicitly mask exceptions if used > from IO? > > 3. Best practices. How should we deal with problem? Is creating > separate versions of  code for ST and IO is the only way? > Probably it is possible to add “mask” to something like > https://hackage.haskell.org/package/primitive-0.6.2.0/docs/Control-Monad-Primitive.html#t:PrimMonad > > emit mask in IO instance and NOOP in ST version? Or maybe > somebody know better patterns for async exeption safe code? > > -- > Sincerely, Stanislav Chernichkin. > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > > Only members subscribed via the mailman list are allowed to post. > > > > > > -- > Sincerely, Stanislav Chernichkin. > > > _______________________________________________ > Haskell-Cafe mailing list > To (un)subscribe, modify options or view archives go to: > http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe > Only members subscribed via the mailman list are allowed to post. > -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 488 bytes Desc: OpenPGP digital signature URL: From hexagoxel at hexagoxel.de Thu Sep 28 21:34:51 2017 From: hexagoxel at hexagoxel.de (lennart spitzner) Date: Thu, 28 Sep 2017 23:34:51 +0200 Subject: [Haskell-cafe] [ANN] brittany-0.8.0.3 Message-ID: <3b0da65f-f000-7e29-a09b-71e54399d9a2@hexagoxel.de> - Support for ghc-8.2.1 - Fix quadratic performance bug full changelog at https://hackage.haskell.org/package/brittany-0.8.0.3/changelog -- lennart From isaace71295 at gmail.com Thu Sep 28 22:46:39 2017 From: isaace71295 at gmail.com (Isaac Elliott) Date: Fri, 29 Sep 2017 08:46:39 +1000 Subject: [Haskell-cafe] Reinventing the wheel? Does any existing package provide an applicatively lifted (>>) ? In-Reply-To: <53F3CB16-922A-4A5E-AA3F-64E583D5A1F3@dukhovni.org> References: <887DDF83-B72C-4EE0-BE78-A2A78E880F10@dukhovni.org> <53F3CB16-922A-4A5E-AA3F-64E583D5A1F3@dukhovni.org> Message-ID: On Fri, Sep 29, 2017 at 2:56 AM Viktor Dukhovni wrote: > > Can you explain that qualification? > I mean that you don't need to use (>>=) on the IO inside the RowParser. The composition of two Applicatives is also an Applicative. If you upgrade one to Monad this is no longer true. Since you're only using (>>) (which is really an Applicative operation in disguise), we don't need to worry here. > Indeed this works, and looks more clear than some new unfamiliar operator. > This seems to have no measurable run-time cost. Is it reasonable to expect > that under the covers no objects boxed as (Compose _) are ever created, and > that Compose here is just compile-time syntactic sugar for applying (*>) at > the desired layer, so that: > > getCompose $ Compose (Foo Bar a) > *> Compose (Foo Bar b) > *> Compose (Foo Bar c) > ... > *> Compose (Foo Bar z) > > just compiles down to Foo (Bar a *> Bar b *> Bar c *> ... *> Bar z)? > Where, in my case, Foo is "RowParser" and Bar is IO? > If we tried to write a typeclass instance for "composition of applicatives", it might look something like this: instance (Applicative f, Applicative g) => forall a. Applicative (f (g a)) where ... But we're not allowed to write such an instance. To get around this, a newtype is created: newtype Compose f g a = Compose { getCompose :: f (g a) } and a valid instance can be written: instance (Applicative f, Applicative g) => Applicative (Compose f g) where pure = Compose . pure . pure a <*> b = Compose $ liftA2 (<*>) a b You are correct in assuming it has no runtime cost- at runtime the `f (g a)` is passed around as normal, but at compile time, `Compose f g a` is considered distinct to `f (g a)`. Due to this typeclass instance, getCompose $ Compose a *> Compose b *> Compose c is equivalent to liftA2 (*>) (liftA2 (*>) a b) c -------------- next part -------------- An HTML attachment was scrubbed... URL: From greg at gregorycollins.net Sat Sep 30 05:54:03 2017 From: greg at gregorycollins.net (Gregory Collins) Date: Sat, 30 Sep 2017 01:54:03 -0400 Subject: [Haskell-cafe] Mutable data structures and asynchronous exceptions In-Reply-To: References: Message-ID: Hi Stanislav, On Thu, Sep 28, 2017 at 7:00 AM, Станислав Черничкин wrote: > > This lead to conflicting requirements: > - One should not care about asynchronous exceptions inside ST (it is not > possible to catch exception in ST, hence not possible to use something in > invalid state). More over, it is not even possible to do write > “exception-safe” code, because masking functions not available. > You can't fork in ST :). So there's no need to mask there - values created during the execution will be discarded and cannot be reused unless you use unsafe* 2. Documentation. Should library authors explicitly mention async > exceptions safety? For example https://hackage.haskell.org/ > package/hashtables – is it async exceptions safe when used in IO? > The hashtables library is not safe for concurrent modification, you need locking for that. No masking is done right now either, which is probably a mistake. We should mask when we stToIO. -------------- next part -------------- An HTML attachment was scrubbed... URL: