[Haskell] LumiGuide is hiring
Dear Haskellers, We're hiring a Haskell engineer to join our software engineering team. LumiGuide develops parking guidance systems for cars and bicycles. Our technology is based on optical detection techniques (Computer Vision). A nice example of one of our projects is the P-route Bicycle <https://bicycledutch.wordpress.com/2015/06/09/bicycle-parking-guidance-system-in-utrecht/> in Utrecht City. Functional Programming is used extensively at LumiGuide. Haskell, GHCJS and the Nix stack (Nix, NixOS, hydra and nixops) are some of the technologies we're using. I recently gave a talk <http://foswiki.cs.uu.nl/foswiki/pub/NlFpDay2016/WebHome/LumiGuide_FP-Dag-2016-b.pdf> at the Dutch Functional Programming Day that highlights some of the products and tools we're developing. We're looking for an experienced Haskell developer who wants to join our team full-time and will work from our office in Nijmegen, The Netherlands. As one of the first engineers you'll have a big impact on the culture and the technological direction of the company. If you're interested, please send a mail to b...@lumiguide.nl and tell me a bit about your experience (previous jobs, open source projects, things that you made that you're proud of, etc.). Best Regards, Bas van Dijk CTO LumiGuide ___ Haskell mailing list Haskell@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell
Re: ANNOUNCE: GHC 7.10.1 Release Candidate 3
On 16 March 2015 at 21:30, Austin Seipp aus...@well-typed.com wrote: We are pleased to announce the third release candidate for GHC 7.10.1: https://downloads.haskell.org/~ghc/7.10.1-rc3 https://downloads.haskell.org/~ghc/7.10.1-rc3/docs/html/ I noticed that the Haddock docs return 404s: https://downloads.haskell.org/~ghc/7.10.1-rc3/docs/html/libraries/Prelude.html ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://mail.haskell.org/cgi-bin/mailman/listinfo/glasgow-haskell-users
Re: Thread behavior in 7.8.3
Hi Michael, Are you already using usb-1.3.0.0? If not, could you upgrade and test again? That release fixed the deadlock that Ben and Carter where talking about. Good luck, Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Proving properties of type-level natural numbers obtained from user input
Hi Alexander, Thanks for your answer! This provides a lot of ideas how to proceed. I'm unsure about the following though: lessThen :: KnownNat m = SomeNat - Proxy m - Maybe (Proof (n = m) (Proxy n)) lessThen (SomeNat p) k | natVal p = natVal k = Just (Proof $ Tagged (Proxy :: Proxy n)) | otherwise = Nothing Doesn't this mean lessThen returns a Proxy n for all (n :: Nat) and not just the Nat inside the SomeNat? I also see that p is only used for comparing it to k. It's not used to produce the return value. Cheers, Bas On 25 November 2014 at 19:55, Alexander V Vershilov alexander.vershi...@gmail.com wrote: Hi, Richard, Bas. Maybe I didn't spell it properly but my point was to create a data type that carry a proof without exposing it's constructor and having clever constructor only, then the only place where you need to check will be that constructor. Also it's possible to write in slightly clearer, but again it's possible to make a mistake here and it will be a false proof. lessThen :: KnownNat m = SomeNat - Proxy m - Maybe (Proof (n = m) (Proxy n)) lessThen (SomeNat p) k | natVal p = natVal k = Just (Proof $ Tagged (Proxy :: Proxy n)) | otherwise = Nothing Of cause solution using singletons could solve this problem much better. -- Alexander On 25 November 2014 at 21:34, Richard Eisenberg e...@cis.upenn.edu wrote: Hi Bas, I believe to do this right, you would need singleton types. Then, when you discover that the number is bounded by 255, you would also discover that the type is bounded by 255, and you'd be home free. Unfortunately, I there isn't currently a way to do comparison on GHC.TypeLits Nats with singletons. (There is a module Data.Singletons.TypeLits in the `singletons` package, but there's a comment telling me TODO in the part where comparison should be implemented.) If it were implemented, it would have to use unsafeCoerce, as there's no built-in mechanism connecting runtime numbers with TypeLits. If I were you, I would just write `g` using unsafeCoerce in the right spot, instead of bothering with all the singletons, which would have to use unsafety anyway. The solution Alexander provides below doesn't quite build a proof, I think. Tellingly, if we omit the `natVal p = 255` check, everything else still compiles. Thus, the `Proof` type he uses can be built even if the fact proven is false. That said, I don't know if my solution is any better, crucially relying on unsafeCoerce. Richard On Nov 25, 2014, at 4:52 AM, Alexander V Vershilov alexander.vershi...@gmail.com wrote: Hi, Following approach can work, the idea is to define a type that will carry a proof (constraint) that we want to check. Here I have reused Data.Tagged, but it's possible to introduce your own with concrete constraints. {-# LANGUAGE DataKinds #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE KindSignatures #-} {-# LANGUAGE PolyKinds #-} {-# LANGUAGE UndecidableInstances #-} import GHC.TypeLits import GHC.Exts import Data.Proxy import Data.Tagged import System.Environment New constraint carrying data type newtype Proof a b = Proof { unProof :: Tagged a b } Runtime check for unknown naturals fromSome :: SomeNat - Maybe (Proof (n = 255) (Proxy n)) fromSome (SomeNat p) | natVal p = 255 = Just (Proof $ Tagged (Proxy :: Proxy n)) | otherwise = Nothing Compiletime converter for known naturals fromKnown :: (KnownNat n, n = 255) = Proxy n - Proof (n = 255) (Proxy n) fromKnown n = Proof $ Tagged n Function to test: f2 :: (c ~ (n = 255)) = Proof c (Proxy n) - () f2 _ = () Example of use: main :: IO () main = do [arg] - getArgs let n = read arg :: Integer case someNatVal n of Nothing - error Input is not a natural number! Just sn - case fromSome sn of Just p - return $ f2 p _ - error Input if larger than 255 On 25 November 2014 at 10:51, Bas van Dijk v.dijk@gmail.com wrote: Hi, I have another type-level programming related question: {-# LANGUAGE GADTs #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE KindSignatures #-} import GHC.TypeLits Say I have a Proxy p of some type-level natural number: p :: forall (n :: Nat). Proxy n p = Proxy Imagine I get p from user input like this: main :: IO () main = do [arg] - getArgs let n = read arg :: Integer case someNatVal n of Nothing - error Input is not a natural number! Just (SomeNat (p :: Proxy n)) - ... I also have a function f which takes a proxy of a natural number but it has the additional constraint that the number should be lesser than or equal to 255: f :: forall (n :: Nat). (n = 255) = proxy n - () f _ = () How do I apply f to p? Obviously, applying it directly gives the type error: f p interactive:179:1: Couldn't match expected type ‘'True’ with actual type ‘n0
Re: Proving properties of type-level natural numbers obtained from user input
On 25 November 2014 at 19:34, Richard Eisenberg e...@cis.upenn.edu wrote: If I were you, I would just write `g` using unsafeCoerce in the right spot, instead of bothering with all the singletons, which would have to use unsafety anyway. Thanks, I hadn't considered this yet. Cheers, Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Proving properties of type-level natural numbers obtained from user input
Hi, I have another type-level programming related question: {-# LANGUAGE GADTs #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE KindSignatures #-} import GHC.TypeLits Say I have a Proxy p of some type-level natural number: p :: forall (n :: Nat). Proxy n p = Proxy Imagine I get p from user input like this: main :: IO () main = do [arg] - getArgs let n = read arg :: Integer case someNatVal n of Nothing - error Input is not a natural number! Just (SomeNat (p :: Proxy n)) - ... I also have a function f which takes a proxy of a natural number but it has the additional constraint that the number should be lesser than or equal to 255: f :: forall (n :: Nat). (n = 255) = proxy n - () f _ = () How do I apply f to p? Obviously, applying it directly gives the type error: f p interactive:179:1: Couldn't match expected type ‘'True’ with actual type ‘n0 =? 255’ The type variable ‘n0’ is ambiguous In the expression: f p In an equation for ‘it’: it = f p I imagine I somehow need to construct some Proof object using a function g like: g :: forall (n :: Nat). proxy n - Proof g _ = ... Where the Proof constructor encapsulates the (n = 255) constraint: data Proof where NoProof :: Proof Proof :: forall (n :: Nat). (n = 255) = Proxy n - Proof With g in hand I can construct c which patterns matches on g p and when there's a Proof the (n = 255) constraint will be in scope which allows applying f to p: c :: () c = case g p of NoProof - error Input is bigger than 255! Proof p - f p But how do I define g? Cheers, Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Caching intermediate powers in GHC.Float
Does the following make sense: https://ghc.haskell.org/trac/ghc/ticket/9120 Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
[Haskell] ZuriHac 2014 - Updates
Dear (potential) ZuriHac 2014 attendees, I would like to make a few announcements regarding ZuriHac 2014, a Haskell hackathon taking place in Zurich from Friday 6 June 2014 to Sunday 8 June 2014. Besides hacking on Haskell projects with core members of the community you will hear talks by Simon Marlow and Edward Kmett. Note that this event is open to any experience level, from beginners to gurus. In fact, one of the goals is to bring beginners in contact with experts so that the former can get a quick start in the Haskell community and the latter more help with their projects. For more information see: http://www.haskell.org/haskellwiki/ZuriHac2014 Registration I'm happy and sad to inform you that we've almost reached capacity for ZuriHac 2014. Happy because it looks like this might be the biggest Haskell Hackathon ever. Sad because I soon have to start adding new registrations to a waiting list. So if you want to join us, and haven't registered already, then please do so soon at: http://bit.ly/ZuriHac2014. Also if you've already registered but know you won't be able to make it, please cancel by emailing me to make room for others. T-Shirt --- Like last year, each attendee will get a free ZuriHac T-shirt. If you've already registered, please tell me which sizes and model you would like to have: Male: S, M, L, XL, XXL Female: S, M, L, XL, XXL Host Erudify, the company which is hosting ZuriHac, recently changed its name to Better. Do note that we haven't changed location. See our new website on why we have rebranded: http://better.com/en/rebranding Regards, The ZuriHac 2014 organizers ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] ANN: Simon Marlow Edward Kmett @ ZuriHac 2014
Dear Haskellers and ZuriHac 2014 attendees, On this lovely day (pun intended), I'm excited to announce that Simon Marlow and Edward Kmett will be giving talks at ZuriHac 2014. When: Friday 6 June 2014 - Sunday 8 June 2014 Where: Erudify offices, Zurich, Switzerland ZuriHac is an international Haskell hackathon: a grassroots, collaborative coding festival with a simple focus, to build and improve Haskell libraries, tools, and infrastructure. This is a great opportunity to meet your fellow Haskellers in real life, find new contributors for your project, improve existing libraries and tools, or even start new ones! 30 people already signed up for ZuriHac 2014 but there's still room for more. If you wish to attend, please register by filling in this form: http://bit.ly/ZuriHac2014 Full details can be found on the wiki page: http://www.haskell.org/haskellwiki/ZuriHac2014 We look forward to seeing you there! -- The organisers of ZuriHac 2014 ZuriHac 2014 is sponsored by Erudify Google ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell] ANN: ZuriHac 2014
Dear Haskellers, After a very successful ZuriHac 2013 we are delighted to announce ZuriHac 2014! When: Friday 6 June 2014 - Sunday 8 June 2014 Where: Erudify offices, Zurich, Switzerland ZuriHac is an international Haskell hackathon: a grassroots, collaborative coding festival with a simple focus, to build and improve Haskell libraries, tools, and infrastructure. This is a great opportunity to meet your fellow Haskellers in real life, find new contributors for your project, improve existing libraries and tools, or even start new ones! Registration If you wish to attend, please register by filling in this form: http://bit.ly/ZuriHac2014 Please note that we have a limited number of places -- first come, first served. Full details can be found on the wiki page: http://www.haskell.org/haskellwiki/ZuriHac2014 We look forward to seeing you there! -- The organisers of ZuriHac 2014 ZuriHac 2014 is sponsored by Erudify Google ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell-cafe] Proposal: new function for lifting
On 27 September 2013 21:51, Thiago Negri evoh...@gmail.com wrote: Stop lifting, start using shinny operators like this one: (^$) :: Monad m = m a - (a - b - c) - m b - m c (^$) = flip liftM2 Note that something like this is already provided by the InfixApplicative library: http://hackage.haskell.org/package/InfixApplicative ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] reifying typeclasses (resend)
You can indeed use GADTs to solve this: {-# LANGUAGE GADTs #-} data Universe a where UInt :: Int - Universe Int UChar :: Char - Universe Char class Universal a where universe :: a - Universe a instance Universal Int where universe = UInt instance Universal Char where universe = UChar argument :: (Universal a) = a - Int argument x = case universe x of UInt n - n UChar c - fromEnum c result :: (Universal a) = Int - a result val = x where x = case universe x of UInt _ - val UChar _ - toEnum val On 15 September 2013 09:38, Evan Laforge qdun...@gmail.com wrote: [ This is the second time I sent this, the first time it said it was awaiting moderation because I'm not subscribed to haskell-cafe, which is weird because I thought I was. Did a bunch of people get unsubscribed? ] I'm sure this is old-hat to typeclass wizards, but I've managed to get pretty far without understanding them too well, so here's a basic question. I haven't seen it phrased this way before though: I have a typeclass which is instantiated across a closed set of 3 types. It has an ad-hoc set of methods, and I'm not too happy with them because being a typeclass forces them to all be defined in one place, breaking modularity. A sum type, of course, wouldn't have that problem. But in other places I want the type-safety that separate types provide, and packing everything into a sum type would destroy that. So, expression problem-like, I guess. It seems to me like I should be able to replace a typeclass with arbitrary methods with just two, to reify the type and back. This seems to work when the typeclass dispatches on an argument, but not on a return value. E.g.: {-# LANGUAGE ScopedTypeVariables #-} class Taggable a where toTagged :: a - Tagged toTaggedType :: a - TaggedType fromTagged :: Tagged - Maybe a m_argument :: a - Int m_result :: Int - a data Tagged = TInt Int | TChar Char deriving (Show) data TaggedType = TypeInt | TypeChar deriving (Show) instance Taggable Int where toTagged = TInt toTaggedType _ = TypeInt fromTagged (TInt x) = Just x fromTagged _ = Nothing m_argument = id m_result = id instance Taggable Char where toTagged = TChar toTaggedType _ = TypeChar fromTagged (TChar x) = Just x fromTagged _ = Nothing m_argument = fromEnum m_result = toEnum argument :: (Taggable a) = a - Int argument a = case toTagged a of TInt x - x TChar c - fromEnum c result :: forall a. (Taggable a) = Int - a result val = case toTaggedType (undefined :: a) of TypeInt - val TypeChar - toEnum val Say m_argument and m_result are the ad-hoc methods I'd like to get out of the typeclass. I can do that well enough for 'argument', but 'result' runs into trouble. One is the ugly undefined trick with toTaggedType, but the bigger one is that ghc says 'Could not deduce (a ~ Int) from the context (Taggable a)'. I wasn't really expecting it to work, because it would entail a case with multiple types. As far as I know, the only way for that to happen is with GADTs. But I don't see how they could help me here. So, perhaps my intuition was wrong. toTagged and fromTagged methods give you the power to go between value and type level, but apparently that's not enough power to express what typeclasses give you. Also it seems like there's a fundamental difference between dispatching on argument vs dispatching on result. Is there a way to more formally understand the extents of what typeclasses provide, and what a toTagged fromTagged scheme gives me, so I can have a better intuition for how to go between value and type levels? Also, the toTaggedType thing is pretty ugly. Not just passing it undefined, but how it has to repeat the types. I don't really see a way to get around that though. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell] ANN: Google co-sponsoring ZuriHac 2013
Dear Haskellers, I would like to remind you that the Zurich FP Afternoon (with a keynote by Simon Marlow) is taking place next week (13:00, Thursday, 29 August) and is directly followed by the ZuriHac 2013 Haskell Hackathon [1]. There are still some places available at both events -- you're welcome to register at: http://bit.ly/ZuriHac2013Reg Google Switzerland will co-sponsor the FP Afternoon and ZuriHac 2013 together with ETH Zurich and Erudify. Their sponsorship means we can give each attendee a free t-shirt (picture on the wikipage [2]) and free food and drinks during the FP Afternoon. Google is also offering a quiz during the FP Afternoon with prizes including a Galaxy S4 mini. I hope to see you there! Bas [1] http://www.haskell.org/haskellwiki/ZuriHac2013 [2] http://www.haskell.org/haskellwiki/ZuriHac2013#News ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
[Haskell-cafe] ANN: Google co-sponsoring ZuriHac 2013
Dear Haskellers, I would like to remind you that the Zurich FP Afternoon (with a keynote by Simon Marlow) is taking place next week (13:00, Thursday, 29 August) and is directly followed by the ZuriHac 2013 Haskell Hackathon [1]. There are still some places available at both events -- you're welcome to register at: http://bit.ly/ZuriHac2013Reg Google Switzerland will co-sponsor the FP Afternoon and ZuriHac 2013 together with ETH Zurich and Erudify. Their sponsorship means we can give each attendee a free t-shirt (picture on the wikipage [2]) and free food and drinks during the FP Afternoon. Google is also offering a quiz during the FP Afternoon with prizes including a Galaxy S4 mini. I hope to see you there! Bas [1] http://www.haskell.org/haskellwiki/ZuriHac2013 [2] http://www.haskell.org/haskellwiki/ZuriHac2013#News ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Private classes
Hi Joachim, I used the following in the past: module M (PublicClass(..)) where class HiddenClass a class HiddenClass a = PublicClass a where ... instance HiddenClass SomeType instance PublicClass SomeType where ... Now users of M can't declare instances of PublicClass because they don't have its superclass HiddenClass in scope. Regards, Bas On Aug 17, 2013 8:10 PM, Joachim Breitner m...@joachim-breitner.de wrote: Hi, for some reason I was under the impression that if I don’t export the methods of a class, then no user of my module can create instances. But I was wrong and in fact they can; the methods will just all be bound to error Is there really no way to create a class so that no-one else can create any instances? Greetings, Joachim -- Joachim “nomeata” Breitner m...@joachim-breitner.de • http://www.joachim-breitner.de/ Jabber: nome...@joachim-breitner.de • GPG-Key: 0x4743206C Debian Developer: nome...@debian.org ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] Array, Vector, Bytestring
On 10 July 2013 08:57, Alfredo Di Napoli alfredo.dinap...@gmail.com wrote: To make the transition easier I have an experimental library which defines a ByteString as a type synonym of a Storable.Vector of Word8 and provides the same interface as the bytestring package: https://github.com/basvandijk/vector-bytestring That's interesting Bas. What bothers me about ByteStrings is that they need to be pinned inside the heap, preventing the GC from collecting them. Being pinned doesn't prevent an object from being garbage collected. It just means that the GC won't move the object around so that foreign code can reliably reference the object while the GC is running: http://ghc.haskell.org/trac/ghc/wiki/Commentary/Rts/Storage/GC/Pinned I assume that working with vector remove the problem, correct? There wasn't a problem in the first but note that a Storable Vector is implemented in the same way as a ByteString: a ForeignPtr and a length* I hope I have now improved your sleep quality ;-) Cheers, Bas * A ByteString also contains an offset but vector modifies the pointer in the ForeignPtr instead so we safe an Int there. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Examples of MVars usage
On 12 June 2013 21:29, Francisco M. Soares Nt. xfrancisco.soa...@gmail.com wrote: I am looking for packages on hackage which use MVars extensively. Those which create plenty of MVars Hi Francisco, Also take a look at Control.Concurrent.Chan in the base library: http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Concurrent-Chan.html A big Chan has a lot of MVars inside. Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] [Hackathon] ANN: ZuriHac 2013 FP Afternoon with keynote by Simon Marlow
On 10 June 2013 19:38, Roman Cheplyaka r...@ro-che.info wrote: Hi Bas, When: Thursday 30 August - Friday 1 September Where: Erudify offices, Zurich, Switzerland Is this a mistake? 30 August is Friday, 1 September is Sunday. Oops! You're right, that's embarrassing :-) Thanks, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Array, Vector, Bytestring
On 5 June 2013 11:50, Peter Simons sim...@cryp.to wrote: I meant to say that there is redundancy in *both*. The libraries mentioned in this thread re-implement the same type internally and expose APIs to the user that are largely identical. I agree. I hope that ByteStrings will be replaced by a Storable.Vector of Word8 at some point in the future. To make the transition easier I have an experimental library which defines a ByteString as a type synonym of a Storable.Vector of Word8 and provides the same interface as the bytestring package: https://github.com/basvandijk/vector-bytestring It includes a comprehensive benchmark suite which compares it to bytestring. IIRC some functions are way faster in vector than their bytestring equivalents and they have the potential to fuse. However some functions are still way slower so more work has to be done in vector to beat bytestring completely. Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: new bridge! (prelude-prime)
On 23 May 2013 11:26, Joachim Breitner m...@joachim-breitner.de wrote: So you can get what you want by not depending on base, but rather have prelude-prime re-export all modules from base plus its own Preldue. How would you re-export all base's modules from the prelude-prime package? I didn't know this was already possible. Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: new bridge! (prelude-prime)
On 23 May 2013 11:54, Joachim Breitner m...@joachim-breitner.de wrote: Hi, Am Donnerstag, den 23.05.2013, 11:52 +0200 schrieb Bas van Dijk: On 23 May 2013 11:26, Joachim Breitner m...@joachim-breitner.de wrote: So you can get what you want by not depending on base, but rather have prelude-prime re-export all modules from base plus its own Preldue. How would you re-export all base's modules from the prelude-prime package? I didn't know this was already possible. manually... you create a .hs file for every module in base, which imports the module in base (using a package-qualified import), gives it a qualified name and puts that name in the export list. I see. Thanks for the clarification. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell] ANN: strict-base-types-0.1
Good stuff Simon! It would be great if either strict-base-types, strict or a merger of the two will find its way into the Haskell Platform. Even better if it also merged with strict-concurrency and strict-io so that we have one go-to package for strict types and operations. Cheers, Bas On 8 May 2013 13:40, Simon Meier iridc...@gmail.com wrote: Dear fellow haskellers, the strict-base-types package makes it easy to get rid of the unnecessary laziness (and the resulting space leaks) in your applications; i.e., no more data AppState = AppState { _field :: !(Maybe T.Text) , ... } as the alternative import qualified Data.Maybe.Strict as S data AppState = AppState { _field :: !(S.Maybe T.Text) , ... } is now equally cheap. See http://hackage.haskell.org/package/strict-base-types-0.1 for a full explanation of the functionality provided by this package. happy hacking, Simon ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: [Haskell-cafe] Streaming bytes and performance
On 20 March 2013 11:41, Konstantin Litvinenko to.darkan...@gmail.com wrote: On 03/20/2013 11:17 AM, Branimir Maksimovic wrote: Are you sure? I use ghc 7.6.2 Huh, I use 7.4.2, and if 7.6.2 can handle this I will try to switch. Not sure how to do that on ubuntu 12.10... I always install ghcs under my home directory: wget http://www.haskell.org/ghc/dist/7.6.2/ghc-7.6.2-x86_64-unknown-linux.tar.bz2 tar -xf ghc-7.6.2-x86_64-unknown-linux.tar.bz2 cd ghc-7.6.2 configure --prefix=$HOME/ghcs/7.6.2 make install Then put $HOME/ghcs/7.6.2/bin in front of your $PATH. You could also use: hsenv --ghc=ghc-7.6.2-x86_64-unknown-linux.tar.bz2 for this: http://hackage.haskell.org/package/hsenv My colleague Jason just made a nice improvement: https://github.com/tmhedberg/hsenv/pull/22 which allows you to do: hsenv --ghc=7.6.2 which will automatically download the right ghc for your platform and install it in a new fresh environment isolated from the rest of your system. Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Optimizing performance problems with Aeson rendering large Text arrays
On Feb 1, 2013 1:15 PM, Oliver Charles ol...@ocharles.org.uk wrote: Urgh, the formatting got totally destroyed in sending, I think. If so, here's a paste of my email as I intended it to be sent: http://hpaste.org/81648 Sorry about that! - Ocharles ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe If I make a special case for text based UUIDs in aeson: data Value = ... | UUID Text | ... Data.Aeson.Encode.fromValue (UUID s) = singleton '' fromText s singleton '' Then encoding time improves by 20%. So a big part of the time is spent encoding the UUID strings. Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] aeson-0.6.1.0 deriveJSON error
On 26 January 2013 14:47, j...@stuttard.org wrote: ghc doesn't seem to be unifying deriveJSON (String-String) parameter with id :: a - a. It seems you're using aeson HEAD. Note that the deriveJSON from the released aeson-0.6.1.0 as the type: deriveJSON :: (String - String) - Name - Q [Dec] But in aeson-HEAD it has the following type: deriveJSON :: Options - Name - Q [Dec] Cheers, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] aeson-0.6.1.0 deriveJSON error
On 26 January 2013 15:20, Bas van Dijk v.dijk@gmail.com wrote: But in aeson-HEAD it has the following type: deriveJSON :: Options - Name - Q [Dec] Note that I'm currently working on extending the encoding Options record: * I added a constructorNameModifier :: String - String which is applied to constructor names and is handy for lower-casing them for example. * I extended the sumEncoding with a ObjectWithSingleField constructor which causes a constructor to be encoded to an object with a single field named after the constructor (modified by the constructorNameModifier) and the value will be the contents of the constructor. * I'm also modifying the GHC Generics code to take the encoding Options into account. This work is happening in my parameterize-generic-encoding-with-options branch: https://github.com/basvandijk/aeson/commits/parameterize-generic-encoding-with-options Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How can I avoid buffered reads?
On 9 December 2012 10:29, Leon Smith leon.p.sm...@gmail.com wrote: On Thu, Dec 6, 2012 at 5:23 PM, Brandon Allbery allber...@gmail.com wro\ Both should be cdevs, not files, so they do not go through the normal filesystem I/O pathway in the kernel and should support select()/poll(). (ls -l, the first character should be c instead of - indicating character-mode device nodes.) If ghc is not detecting that, then *that* is indeed an I/O manager issue. The issue here is that if you look at the source of fdReadBuf, you see that it's a plain system call without any reference to GHC's (relatively new) IO manager. What if you use threadWaitRead on the fd before you read from it? http://hackage.haskell.org/packages/archive/base/latest/doc/html/Control-Concurrent.html#v:threadWaitRead Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Portability of Safe Haskell packages
On 23 November 2012 15:47, Roman Cheplyaka r...@ro-che.info wrote: Should it be advised to surround safe annotations with CPP #ifs? Or does anyone see a better way out of this contradiction? I think that would be good advice. Note that even if you're only using GHC then you still want to use CPP in order to support older GHC versions which don't support Safe Haskell as in: http://hackage.haskell.org/packages/archive/usb/1.1.0.4/doc/html/src/System-USB-Internal.html Arguably, in that example it would be better to move the check for the availability of Safe Haskell to the cabal file which would define a CPP pragma SAFE_HASKELL which can be used in source files. Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] I killed performance of my code with Eval and Strategies
On Nov 14, 2012 10:44 PM, Janek S. fremenz...@poczta.onet.pl wrote: calculateSeq :: [Double] - [Double] calculateSeq [] = [] calculateSeq (x:xs) = (sin . sqrt $ x) : xs Do you really mean to calculate the 'sin . sqrt' of just the head of the list, or do you mean: calculateSeq = map (sin . sqrt) ? Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] mtl-2.1 severly broken, cabal needs blacklisting
On 13 November 2012 17:27, Andreas Abel andreas.a...@ifi.lmu.de wrote: This calls for a means of blacklisting broken or malicious packages. cabal update should also pull a blacklist of packages that will never be selected by cabal install (except maybe by explicit user safety overriding). Maybe we can use the existing preferred-versions file that cabal-install uses: http://hackage.haskell.org/packages/archive/preferred-versions Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Strange behavior with listArray
On 12 November 2012 14:52, Daniel Fischer daniel.is.fisc...@googlemail.com wrote: I see no loop in that, and ghci doesn't either: Oops you're right of course. Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Taking over ghc-core
Great! On 10 November 2012 16:17, Shachaf Ben-Kiki shac...@gmail.com wrote: With Don Stewart's blessing (https://twitter.com/donsbot/status/267060717843279872), I'll be taking over maintainership of ghc-core, which hasn't been updated since 2010. I'll release a version with support for GHC 7.6 later today. Shachaf ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Strange behavior with listArray
On 12 November 2012 04:50, Alex Stangl a...@stangl.us wrote: I'm stymied trying to figure out why the program below blows up with loop when I use f 0 If you replace the a!0 in f by its value 0, f is equivalent to: f k = if k 0 then f 0 else 0 : f 1 Do you see the loop now? Maybe you meant f to be: f k = if k 0 then f (a!k) else 0 : f 1 Regards, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Motion to unify all the string data types
On 10 November 2012 17:57, Johan Tibell johan.tib...@gmail.com wrote: It better communicates intent. A e.g. lazy byte string can be used for two separate things: * to model a stream of bytes, or * to avoid costs due to concatenating strings. By using a strict byte string you make it clear that you're not trying to do the former (at some potential cost due to the latter). When you want to do the former it should be clear to the consumer that he/she better consume the string in an incremental manner as to preserve laziness and avoid space leaks (by forcing the whole string). Good advice. And when you want to do the latter you should use a Builder[1] (or [2] if you're working with text). Bas [1] http://hackage.haskell.org/packages/archive/bytestring/0.10.2.0/doc/html/Data-ByteString-Builder.html [2] http://hackage.haskell.org/packages/archive/text/0.11.2.3/doc/html/Data-Text-Lazy-Builder.html ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell] ANNOUNCE: GHC version 7.6.1
On 6 September 2012 18:05, Ian Lynagh i...@well-typed.com wrote: The GHC Team is pleased to announce a new major release of GHC, 7.6.1. Great! * It is now possible to defer type errors until runtime using the -fdefer-type-errors flag. In section 7.13.1 it says: ...given the following code: x :: Int x = 0 y :: Char y = x z :: Int z = y evaluating x will result in a runtime type error. Shouldn't this be: evaluating z will result in a runtime type error. Cheers, Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell] ANNOUNCE: GHC version 7.6.1
On 6 September 2012 18:05, Ian Lynagh i...@well-typed.com wrote: The GHC Team is pleased to announce a new major release of GHC, 7.6.1. Great! * It is now possible to defer type errors until runtime using the -fdefer-type-errors flag. In section 7.13.1 it says: ...given the following code: x :: Int x = 0 y :: Char y = x z :: Int z = y evaluating x will result in a runtime type error. Shouldn't this be: evaluating z will result in a runtime type error. Cheers, Bas ___ Haskell mailing list Haskell@haskell.org http://www.haskell.org/mailman/listinfo/haskell
Re: New INLINE pragma syntax idea, and some questions
On 4 August 2012 15:53, Brandon Simmons brandon.m.simm...@gmail.com wrote: The only thing that bothers me about this foldl is the presence of z0 xs0, which I think are only there on the LHS to indicate to GHC where it should inline. Are these really needed? Since GHC only inlines functions which are fully applied (where according to [1] fully applied means applied to as many arguments as appear (syntactically) on the LHS of the function definition) I think it's more desirable to remove these arguments (or at least the xs0) since then the function is more likely to be inlined in cases such as: sum = foldl (+) 0 [1] http://www.haskell.org/ghc/docs/latest/html/users_guide/pragmas.html#inline-pragma ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Type error when deriving Generic for an associated data type
On 12 July 2012 12:33, Andres Löh and...@well-typed.com wrote: Your example compiles for me with HEAD (but fails with 7.4.1 and 7.4.2, yes). I've not tested if it also works. Great, I will wait for a new release then. Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Type error when deriving Generic for an associated data type
Hi, I'm hitting on an issue when deriving Generic for an associated data type: {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE DeriveGeneric #-} import GHC.Generics class Foo a where data T a :: * instance Foo Int where data T Int = Bla deriving Generic Couldn't match type `Rep (T Int)' with `M1 t0 t1 (M1 t2 t3 U1)' Expected type: Rep (T Int) x Actual type: M1 t0 t1 (M1 t2 t3 U1) x In the pattern: M1 (M1 U1) In an equation for `to': to (M1 (M1 U1)) = Bla In the instance declaration for `Generic (T Int)' The GHC trac seems to be down. Is this a known issue? Cheers, Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] lazy boxed array and builder?
On 12 July 2012 15:35, Yves Parès yves.pa...@gmail.com wrote: I remember this discussion, lazy vectors would also enable an implementation of bytestring and (maybe) text only with unboxed vectors, unifying it all: type ByteString = Vector Word8 Yes, I would like to add a lazy storable vector to vector-bytestring[1] to make the API 100% consistent with bytestring. Ideally we would have a type like: data Lazy vector a = Empty | Chuck {-# UNPACK #-} !(vector a) (Lazy vector a) Unfortunately GHC can't unpack polymorphic fields. The next best thing is to use a type family which for each type of vector would return its lazy version (where the vector is unpacked in the cons cell). Then we would need a class for common operations on those lazy vectors. Regards, Bas [1] http://hackage.haskell.org/package/vector-bytestring https://github.com/basvandijk/vector-bytestring ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Segmentation fault/access violation in generated code
On 23 June 2012 02:40, Ian Lynagh ig...@earth.li wrote: Hi Bas, On Sun, Jun 17, 2012 at 05:11:35PM +0200, Bas van Dijk wrote: module Main where import Foreign import qualified Foreign.Concurrent as FC import Control.Concurrent import Bindings.Libusb.InitializationDeinitialization main :: IO () main = do ctxPtr - alloca $ \ctxPtrPtr - do _ - c'libusb_init ctxPtrPtr peek ctxPtrPtr fp - newForeignPtr p'libusb_exit ctxPtr -- fp - FC.newForeignPtr ctxPtr $ c'libusb_exit ctxPtr threadDelay 300 print $ fp == fp What happens if you just call c'libusb_exit ctxPtr at the end, instead of using a finalizer? Then I don't get an error. So executing the following program with the argument fp gives an error (although this time I don't get an access violation but instead Windows pops up a dialog box indicating an error) and without an argument I get no error: {-# LANGUAGE ForeignFunctionInterface #-} module Main where import Foreign import Foreign.C.Types import Control.Concurrent import System.Environment main :: IO () main = do ctxPtr - alloca $ \ctxPtrPtr - do _ - c'libusb_init ctxPtrPtr peek ctxPtrPtr args - getArgs case args of [fp] - do fp - newForeignPtr p'libusb_exit ctxPtr threadDelay 100 print $ fp == fp _ - c'libusb_exit ctxPtr data C'libusb_context = C'libusb_context foreign import stdcall libusb_init c'libusb_init :: Ptr (Ptr C'libusb_context) - IO CInt foreign import stdcall libusb_exit p'libusb_exit :: FunPtr (Ptr C'libusb_context - IO ()) foreign import stdcall libusb_exit c'libusb_exit :: Ptr C'libusb_context - IO () Are you able to reproduce this with just a .c file that is compiled and linked with the program, rather than needing libusb? That would make it easier to reproduce, to understand, and to add a test. I'm not sure how to do this. I guess just copying the libusb .c and .h files to the same directory as the .hs file is not enough since libusb requires a configure phase. Regards, Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Segmentation fault/access violation in generated code
I just tried building the following program with the new GHC win64_alpha1 and apart from warnings from using the unsupported stdcall calling convention running the program doesn't give a segmentation fault as it does when building the program with GHC-7.4.2: {-# LANGUAGE ForeignFunctionInterface #-} module Main where import Foreign import Foreign.C.Types main :: IO () main = do ctxPtr - alloca $ \ctxPtrPtr - do _ - c'libusb_init ctxPtrPtr peek ctxPtrPtr fp - newForeignPtr p'libusb_exit ctxPtr threadDelay 100 print $ fp == fp data C'libusb_context = C'libusb_context foreign import stdcall libusb_init c'libusb_init :: Ptr (Ptr C'libusb_context) - IO CInt foreign import stdcall libusb_exit p'libusb_exit :: FunPtr (Ptr C'libusb_context - IO ()) Regards, Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Segmentation fault/access violation in generated code
Hello, I'm trying to solve #5254 (http://hackage.haskell.org/trac/ghc/ticket/5254). The issue can be isolated to the following short program which only uses bindings-libusb (http://hackage.haskell.org/packages/archive/bindings-libusb/1.4.4.1/doc/html/Bindings-Libusb-InitializationDeinitialization.html): -- module Main where import Foreign import qualified Foreign.Concurrent as FC import Control.Concurrent import Bindings.Libusb.InitializationDeinitialization main :: IO () main = do ctxPtr - alloca $ \ctxPtrPtr - do _ - c'libusb_init ctxPtrPtr peek ctxPtrPtr fp - newForeignPtr p'libusb_exit ctxPtr -- fp - FC.newForeignPtr ctxPtr $ c'libusb_exit ctxPtr threadDelay 300 print $ fp == fp -- When I run this program on Windows I get the following error after 3 seconds: example.exe True Segmentation fault/access violation in generated code The error disappears when I change the newForeignPtr line to the commented FC.newForeignPtr line. Any idea why this is happening? I don't know if it has anything to do with it but note that the libusb FFI functions are using the stdcall calling convention on Windows. I'm using GHC-7.4.2 but this error also occurs in previous versions. To reproduce this just download libusb (I recommend http://libusbx.org/) and when cabal installing bindings-libusb tell it the path to the include and library files, as in: cabal install bindings-libusb --extra-include-dirs=...\libusb\include\libusb-1.0 --extra-lib-dirs=...\libusb\MinGW32\dll and make sure the libusb-1.0.dll is in your working directory when running the example program. Regards, Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
[Haskell-cafe] Extending constraints
Hello, I have the following program: -- {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE ExistentialQuantification #-} {-# LANGUAGE ScopedTypeVariables #-} import Data.Proxy (Proxy) import Data.Typeable (Typeable, TypeRep, typeOf) data ProxyWrapper constraint = forall a. constraint a = ProxyWrapper (Proxy a) typeOfInnerProxy :: ProxyWrapper constraint - TypeRep typeOfInnerProxy (ProxyWrapper p) = typeOfArg p typeOfArg :: forall t a. Typeable a = t a - TypeRep typeOfArg _ = typeOf (undefined :: a) -- Type checking this gives the following expected type error: ProxyWrapper.hs:12:37: Could not deduce (Typeable a) arising from a use of `typeOfArg' from the context (constraint a) bound by a pattern with constructor ProxyWrapper :: forall (constraint :: * - Constraint) a. (constraint a) = Proxy a - ProxyWrapper constraint, in an equation for `typeOfInnerProxy' Is there a way to extend the 'constraint' with the 'Typeable' constraint in the type signature of 'typeOfInnerProxy'? Regards, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Extending constraints
On 5 June 2012 17:52, Andres Löh and...@well-typed.com wrote: Hi Bas. I haven't thought about this for long, but ... data ProxyWrapper constraint = forall a. constraint a = ProxyWrapper (Proxy a) I'm assuming adding Typable a in ProxyWrapper is not an option for you? No, I would rather keep that type as unconstrained as possible. So then what about: class (c1 a, c2 a) = Ext c1 c2 a instance (c1 a, c2 a) = Ext c1 c2 a typeOfInnerProxy :: ProxyWrapper (Ext Typeable constraint) - TypeRep typeOfInnerProxy (ProxyWrapper p) = typeOfArg p This will certainly require all sorts of undecidable instances :) But does it work for you? It works. Thanks a lot! Cheers, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Extending constraints
On 5 June 2012 17:57, Bas van Dijk v.dijk@gmail.com wrote: It works. It turns out it doesn't work exactly as I want. Say I have this ProxyWrapper of Nums: p :: ProxyWrapper Num p = ProxyWrapper (Proxy :: Proxy Int) then the following would give a type error: oops :: TypeRep oops = typeOfInnerProxy p Couldn't match expected type `Ext Typeable constraint0' with actual type `Num' Expected type: ProxyWrapper (Ext Typeable constraint0) Actual type: ProxyWrapper Num In the first argument of `typeOfInnerProxy', namely `p' In the expression: typeOfInnerProxy p Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Extending constraints
On 5 June 2012 18:46, Gábor Lehel illiss...@gmail.com wrote: I must be missing something, but this seems a bit useless to me. You have a phantom type parameter on Proxy, and then you're hiding it. So when you pattern match on ProxyWrapper you recover the fact that there was a type which satisfies the constraint, but you don't know what type it was, and neither do you know about any values which are of the type. What are you trying to do? I need a list of types that satisfy a certain constraint. I would like to have the static guarantee that types that don't satisfy the constraint can't be put in the list, as in: nums :: [ProxyWrapper Num] nums = [ ProxyWrapper (Proxy :: Proxy Int) , ProxyWrapper (Proxy :: Proxy Double) , ProxyWrapper (Proxy :: Proxy String) -- not allowed ] fracs :: [ProxyWrapper Fractional] fracs = [ ProxyWrapper (Proxy :: Proxy Double) , ProxyWrapper (Proxy :: Proxy Float) , ProxyWrapper (Proxy :: Proxy Int) -- not allowed ] That said, if you want to be able to recover a Typeable constraint, I don't see any way except for using 'ProxyWrapper (Ext Typeable constraint)' as Andres says or putting 'forall a. (constraint a, Typeable a)' in the definition of ProxyWrapper. Indeed, I'm now going for the latter option. Regards, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Weird behavior of the NonTermination exception
On 4 May 2012 14:12, Simon Marlow marlo...@gmail.com wrote: The forked thread is deadlocked, so the MVar is considered unreachable and the main thread is also unreachable. Hence both threads get sent the exception. The RTS does this analysis using the GC, tracing the reachable objects starting from the roots. It then send an exception to any threads which were not reachable, which in this case is both the main thread and the child, since neither is reachable. We (the user) knows that waking up the child thread will unblock the main thread, but the RTS doesn't know this, and it's not clear how it could find out easily (i.e. without multiple scans of the heap). Thanks Simon, I learned something new today. Cheers, Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Weird behavior of the NonTermination exception
Hello, Before I turn the following into a ticket I want to ask if I miss something obvious: When I run the following program: - import Prelude hiding (catch) import Control.Exception import Control.Concurrent main :: IO () main = do mv - newEmptyMVar _ - forkIO $ do catch action (\e - putStrLn $ I solved the Halting Problem: ++ show (e :: SomeException)) putStrLn putting MVar... putMVar mv () putStrLn putted MVar takeMVar mv action :: IO () action = let x = x in x - I get the output: $ ghc --make Loop.hs -o loop -O2 -fforce-recomp ./loop [1 of 1] Compiling Main ( Loop.hs, Loop.o ) Linking loop ... loop: thread blocked indefinitely in an MVar operation I solved the Halting Problem: loop putting MVar... putted MVar As can be seen, the putMVar is executed successfully. So why do I get the message: thread blocked indefinitely in an MVar operation? Note that if I change the action to a normal error the message disappears. I discovered this bug when hunting for another one. I have a Haskell web-server where one of the request handlers contained a loop. All exceptions thrown by handlers are caught and logged. When executing the looping handler I noticed ~0% CPU usage so I assumed that the handler wasn't actually looping because a NonTermination exception was thrown. However for some reason the NonTermination exception was not caught and logged. I haven't yet isolated this bug into a small test-case but when trying that I discovered the above. Regards, Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Weird behavior of the NonTermination exception
On 3 May 2012 17:31, Edward Z. Yang ezy...@mit.edu wrote: Excerpts from Bas van Dijk's message of Thu May 03 11:10:38 -0400 2012: As can be seen, the putMVar is executed successfully. So why do I get the message: thread blocked indefinitely in an MVar operation? GHC will send BlockedIndefinitelyOnMVar to all threads involved in the deadlock, so it's not unusual that this can interact with error handlers to cause the system to become undeadlocked. But why is the BlockedIndefinitelyOnMVar thrown in the first place? According to the its documentation and your very enlightening article it is thrown when: The thread is blocked on an MVar, but there are no other references to the MVar so it can't ever continue. The first condition holds for the main thread since it's executing takeMVar. But the second condition doesn't hold since the forked thread still has a reference to the MVar. I just tried delaying the thread before the putMVar: - main :: IO () main = do mv - newEmptyMVar _ - forkIO $ do catch action (\e - putStrLn $ I solved the Halting Problem: ++ show (e :: SomeException)) putStrLn Delaying for 2 seconds... threadDelay 200 putStrLn putting MVar... putMVar mv () putStrLn putted MVar takeMVar mv - Now I get the following output: loop: thread blocked indefinitely in an MVar operation I solved the Halting Problem: loop Delaying for 2 seconds... Now it seems the thread is killed while delaying. But why is it killed? It could be a BlockedIndefinitelyOnMVar that is thrown. However I get the same output when I catch and print all exceptions in the forked thread: main :: IO () main = do mv - newEmptyMVar _ - forkIO $ handle (\e - putStrLn $ Oh nooo: ++ show (e :: SomeException)) $ do catch action (\e - putStrLn $ I solved the Halting Problem: ++ show (e :: SomeException)) putStrLn Delaying for 2 seconds... threadDelay 200 putStrLn putting MVar... putMVar mv () putStrLn putted MVar takeMVar mv Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Weird behavior of the NonTermination exception
On 3 May 2012 18:14, Bas van Dijk v.dijk@gmail.com wrote: Now it seems the thread is killed while delaying. But why is it killed? Oh I realise the forked thread is killed because the main thread terminates because it received a BlockedIndefinitelyOnMVar exception and then all daemonic threads are killed. Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: default instance for IsString
On 23 April 2012 20:34, J. Garrett Morris jgmor...@cs.pdx.edu wrote: On Mon, Apr 23, 2012 at 9:58 AM, Yitzchak Gale g...@sefer.org wrote: In addition, OverloadedStrings is unsound. No. OverloadedStrings treats string literals as applications of fromString to character list constants. fromString can throw errors, just like fromInteger; this is no less sound than any Haskell function throwing an exception. But it would be safer if those errors were moved to compile time by treating overloaded literals as Template Haskell splices. As in: 1 would be translated to: $(fromIntegerLit 1) where: class FromIntegerLit a where fromIntegerLit :: Integer - Q (Exp a) (this assumes that Exp is parameterized by the type of the value it splices to which is currently not the case. However you can work around this by using a Proxy or Tagged value.) An instance for Integer is trivial: instance FromIntegerLit Integer where fromIntegerLit = litE . integerL The extra safety comes when giving an instance for natural numbers, for example: newtype Nat = Nat Integer instance FromIntegerLit Nat where fromIntegerLit n | n 0 = error Can't have negative Nats | otherwise = 'Nat `appE` fromIntegerLit n Note that the error will be thrown at compile time when the user has written a negative Nat literal. Regards, Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
[Haskell-cafe] Parameterize constraints of existentially quantified types
Hi, I just found out that with the new ConstraintKinds extension we can parameterize the constraint of an existentially quantified type: {-# LANGUAGE KindSignatures, ConstraintKinds, ExistentialQuantification #-} import GHC.Exts data Some (c :: * - Constraint) = forall a. c a = Some a This could be used to define SomeException for example: import Control.Exception (Exception) type SomeException = Some Exception Are there any other use cases? Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Arguments against an hypothetical Data.ByteString.Generic?
On 27 March 2012 11:00, Yves Parès yves.pa...@gmail.com wrote: Hello, As vector provides a class generalizing all flavours (Data.Vector.Generic.Vector), it occurs to me that the same could be done for ByteString. Then, packages based on it would have the choice between hardcoded and generic, they wouldn't have to duplicate a module to handle both strict and lazy versions, as (with the exception of functions for communication with C code) they already provide the same API. I would be willing to make it, it's a concern I've had in mind for a long time, but as I'm pretty sure the idea isn't new, I would very much like to know if and what arguments (related to performance maybe ? I don't know...) were raised against that. It's not entirely what you need but are you aware of my vector-bytestring library? http://hackage.haskell.org/package/vector-bytestring It doesn't (yet) abstract over strict and lazy ByteStrings. But that would be a nice addition! In an ideal world we would have a Lazy type family which for each type of vector would return its lazy version (where the vector is unpacked in the cons cell). Then we would need your generic API for working with both lazy and strict vectors. Regards, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Arguments against an hypothetical Data.ByteString.Generic?
On 27 March 2012 21:46, Yves Parès yves.pa...@gmail.com wrote: Yes, thank you to remind me of that, I remember now having seen the project. Strict ByteStrings being an alias to Vector Word8 is a good idea (are bytestrings are already implemented exactly like Data.Vector.Storable.Vector). But in that case we could use the API of vector for bytestrings (the bytestring API would be provided only for backwards compatibility, right?). Yes, I hope that one day the bytestring package and the ByteString type will be deprecated in favor of vector and Data.Vector.Storable.Vector Word8 respectively. vector-bytestring is indeed intended as a package which should make the transition easier. Does vector-bytestring plans to be the new implementation for bytestrings in the end or is it a side-package? I hope that once we get on par with bytestring's performance we can replace it (we're almost there!, Yell if you want to see some benchmark results). In an ideal world we would have a Lazy type family which for each type of vector would return its lazy version What about a type like: data Vector v a = Empty | Chuck {-# UNPACK #-} !(v a) (Vector v a) ?? If you build with -Wall you'll see the following unfortunate warning: Warning: Ignoring unusable UNPACK pragma on the first argument of `Chunk' Johan Tibell recently discussed some of his ideas on how to solve this: http://www.haskell.org/pipermail/glasgow-haskell-users/2012-March/022079.html But for now we need to make a specialized type for every different vector type and use an associated type family to abstract over these different types. Regards, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: generic-deepseq 1.0.0.0
On 23 February 2012 22:09, Maxime Henrion mhenr...@gmail.com wrote: On Sun, 2012-02-19 at 21:06 +0100, Bas van Dijk wrote: On 19 February 2012 18:11, Maxime Henrion mhenr...@gmail.com wrote: I'm guilty of not having preserved the rnf :: a - () function as the class function though, it's a wrapper around deepseq in my code. I just didn't see the point of having a class function with such a signature versus having a function just like seq :: a - b - b. In retrospect, that might have been a bad idea, and maybe I should switch to have an rnf :: a - () class function to make switching even easier? I'm not sure but maybe a method like rnf :: a - () is easier to optimize. Also in my experience (with generics support in aeson and cereal) it's a very good idea (performance-wise) to INLINE your methods like I did in my previous message. Of course the only way to know for sure is the create some (criterion) benchmarks. Well I wrote some dumb criterion benchmarks that run deepseq over increasingly bigger lists of numbers, and it appears that using rnf as the member function of the DeepSeq class indeed makes a _huge_ difference. Nice, that's what I expected. Have you checked if adding INLINE pragma's helps even more? (I guess not since it's already on par with manual written code, as you mentioned) BTW I would also recommend making a benchmark for a big sum type. Some nitpicking: * In the instance: instance GDeepSeq U1 where grnf _ = () I think it makes sense to pattern match on the U1 constructor, as in: grnf U1 = (). I haven't checked if that's necessary but my fear is that assuming: data Unit = Unit deriving Generic; instance DeepSeq Unit rnf (⊥ :: Unit) would equal: () while I would expect it to equal ⊥. * Why do you have the instance: instance GDeepSeq V1 where grnf _ = () The only way to construct values of a void type is using ⊥. And I would expect that rnf ⊥ = ⊥, not (). I think the best thing is to just remove the V1 instance. Cheers, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: generic-deepseq 1.0.0.0
On 19 February 2012 13:12, Maxime Henrion mhenr...@gmail.com wrote: Any suggestions are welcome. Nice work but it would be nice to have this functionality directly in the deepseq package as in: #ifdef GENERICS {-# LANGUAGE DefaultSignatures, TypeOperators, FlexibleContexts #-} #endif class NFData a where rnf :: a - () rnf a = a `seq` () #ifdef GENERICS default rnf :: (Generic a, GNFData (Rep a)) = a - () rnf = grnf . from class GNFData f where grnf :: f a - () instance GNFData U1 where grnf U1 = () {-# INLINE grnf #-} instance NFData a = GNFData (K1 i a) where grnf = rnf . unK1 {-# INLINE grnf #-} instance GNFData f = GNFData (M1 i c f) where grnf = grnf . unM1 {-# INLINE grnf #-} instance (GNFData f, GNFData g) = GNFData (f :+: g) where grnf (L1 x) = grnf x grnf (R1 x) = grnf x {-# INLINE grnf #-} instance (GNFData f, GNFData g) = GNFData (f :*: g) where grnf (x :*: y) = grnf x `seq` grnf y {-# INLINE grnf #-} #endif Unfortunately this is not possible since the two default implementations conflict. I see two solutions: 1) Change the DefaultSignatures extension to always give preference to the default signature. I think giving preference to the default signature makes sense since it's usually more specific (more constraint) and thus more correct than the default implementation. 2) Remove the default implementation of rnf. I understand the default implementation gives some convenience when writing instances for types that have an all strict representation, as in: instance NFData Int instance NFData Word instance NFData Integer ... However, I think having the default implementation can mask some bugs as in: data T = C Int; instance NFData T which will neither give a compile time error nor warning. I don't think it's that much more inconvenient to write: instance NFData Int where rnf = rnf' instance NFData Word where rnf = rnf' instance NFData Integer where rnf = rnf' ... where rnf' :: a - () rnf' a = a `seq` () So I would vote for option 2, removing the default rnf implementation. If I find some time I will turn this into an official proposal. Regards, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: generic-deepseq 1.0.0.0
On 19 February 2012 18:11, Maxime Henrion mhenr...@gmail.com wrote: If you're not dealing with an abstract datatype, you _shouldn't_ have an explicit instance, because it would be possible to write an incorrect one, while that is impossible if you just derive a generic implementation (as long as the generic code is correct, of course). I agree. I hadn't considered this advantage yet. I guess it's the same argument for why it's better to automatically derive Data and Typeable instances using the DeriveDataTypeable extension. So, knowing that it would necessarily be backwards incompatible (I wasn't intending to hack on GHC :-), and also that, in the end, this is not quite the same class as the NFData class from the deepseq package, I thought it made more sense to create another package that would be mostly compatible with deepseq, but with a different class name so as to force people to reevaluate the need for their instances if they have some. I'd be interested in knowing what you and others think about that. Maybe I'm being overly cautious? I do think it's better to integrate this into the deepseq package (and thus removing the default implementation of rnf). Otherwise we end up with two ways of evaluating values to normal form. I'm guilty of not having preserved the rnf :: a - () function as the class function though, it's a wrapper around deepseq in my code. I just didn't see the point of having a class function with such a signature versus having a function just like seq :: a - b - b. In retrospect, that might have been a bad idea, and maybe I should switch to have an rnf :: a - () class function to make switching even easier? I'm not sure but maybe a method like rnf :: a - () is easier to optimize. Also in my experience (with generics support in aeson and cereal) it's a very good idea (performance-wise) to INLINE your methods like I did in my previous message. Of course the only way to know for sure is the create some (criterion) benchmarks. One last issue: Say I have a type like: data T = C !Int Currently GHC Generics can't express the strictness annotation. This means that your deepseq will unnecessarily evaluate the Int (since it will always be evaluated already). It would be nice if the strictness information could be added to the K1 type. (José, would it be hard to add this to GHC.Generics?) Regards, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
GHCi-7.4.1: Importing a non existing module succeeds
Should I file a bug for this: GHCi 7.2.2: import I.Do.Not.Exist no location info: Could not find module `I.Do.Not.Exist' Use -v to see a list of the files searched for. GHCi 7.4.1: import I.Do.Not.Exist (and for the record: I.Do.Not.Exist does not exist) Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Error when deriving Typeable for associated type
Hello, Given the following program: --- {-# LANGUAGE DeriveDataTypeable, TypeFamilies #-} import Data.Typeable class C a where data T a :: * data MyType1 = MyType1 deriving Typeable data MyType2 = MyType2 deriving Typeable instance C MyType1 where data T MyType1 = A1 deriving (Typeable) instance C MyType2 where data T MyType2 = A2 deriving (Typeable) --- I get the following unexpected error: TF_Data.hs:12:34: Duplicate instance declarations: instance Typeable1 T -- Defined at TF_Data.hs:12:34 instance Typeable1 T -- Defined at TF_Data.hs:15:34 When looking at the output of -ddump-deriv I see that the following instance is generated: instance Typeable1 T where ... I would have expected that the following instances were generated instead: instance Typeable1 (T MyType1) where ... instance Typeable1 (T MyType2) where ... Is this a bug in GHC? Thanks, Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Error when building cabal package with template haskell configured for profiling
Hello, I would like to profile a cabal package that contains template haskell code. However I get the following error: $ cabal configure --ghc-options=-O2 -prof -auto-all -caf-all ... $ cabal build ... Dynamic linking required, but this is a non-standard build (eg. prof). You need to build the program twice: once the normal way, and then in the desired way using -osuf to set the object file suffix. What's the best way to solve this? Currently I do a cabal build -v and copy the ghc --make ... command line. Then I first build the program normally (without -prof) and then build it with -prof and -osuf p_o like the error messages suggests. This is annoying however. Is there a ticket for this bug? Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: Error when building cabal package with template haskell configured for profiling
On 27 January 2012 15:14, Felipe Almeida Lessa felipe.le...@gmail.com wrote: On Fri, Jan 27, 2012 at 12:06 PM, Bas van Dijk v.dijk@gmail.com wrote: $ cabal configure --ghc-options=-O2 -prof -auto-all -caf-all Why aren't you using the specific options for profiling? $ cabal configure --help | grep profiling -p --enable-library-profiling Enable Library profiling --disable-library-profiling Disable Library profiling --enable-executable-profiling Enable Executable profiling --disable-executable-profiling Disable Executable profiling This gives the following error: $ cabal configure --enable-executable-profiling ... $ cabal build ... cannot find normal object file `some_file.o' while linking an interpreted expression However when I apply the same trick as before, first building normally then building with profiling enabled, it works: $ cabal configure ... $ cabal build ... $ cabal configure --enable-executable-profiling ... $ cabal build ... success! Thanks for the hint! Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] Serializing UTCTimes
Thanks Ertugrul and Yitzchak. I failed to notice the Real and Fractional instances for DiffTime. Thanks very much for pointing me to it. I dropped the dependency on datetime and implemented your suggestions. Bas On 21 January 2012 22:29, Yitzchak Gale g...@sefer.org wrote: Bas van Dijk wrote: What's the recommended way for serializing (with the cereal package) an UTCTime? Serialize the Day part as an Integer using toModifiedJulianDay/ModifiedJulianDay, (Note that Day is not a constructor, it's just the name of the type.) Serialize the DiffTime as a Rational, as Ertugrul said. I'm now using the datetime package Why? It just obscures the time library. But I will have to look at the code of datetime to see if I'm not losing precision. You are losing precision. If you only care about time to the nearest second, you can truncate the Rational of the DiffTime (don't round, because this may be the last second of a day) and then use fromIntegral to deserialize. Regards, Yitz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Serializing UTCTimes
Hello, What's the recommended way for serializing (with the cereal package) an UTCTime? It's easy to give Serialize instances for UTCTime and Day: instance Serialize UTCTime where get = liftM2 UTCTime get get put (UTCTime day time) = put day put time instance Serialize Day where get = liftM Day get put = put . toModifiedJulianDay However I have no idea how to serialize the DiffTime stored in an UTCTime: instance Serialize DiffTime where get = ? put = ? Regards, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Serializing UTCTimes
On 20 January 2012 15:03, Bas van Dijk v.dijk@gmail.com wrote: What's the recommended way for serializing (with the cereal package) an UTCTime? I'm now using the datetime package so I can do: import Data.DateTime (fromSeconds, toSeconds) instance Serialize UTCTime where get = fromSeconds $ get put = put . toSeconds But I will have to look at the code of datetime to see if I'm not loosing precision. Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hackage trac broken
On 15 January 2012 12:01, Joachim Breitner nome...@debian.org wrote: Is this known and will it be fixed? It was shut down because of massive spamming: http://www.haskell.org/pipermail/cabal-devel/2012-January/008427.html I have no idea who's working on it and when it will be up again. Cheers, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: ConstraintKinds and default associated empty constraints
On 23 December 2011 17:44, Simon Peyton-Jones simo...@microsoft.com wrote: My attempt at forming a new understanding was driven by your example. class Functor f where type C f :: * - Constraint type C f = () sorry -- that was simply type incorrect. () does not have kind * - Constraint So am I correct that the `class Empty a; instance Empty a` trick is currently the only way to get default associated empty constraints? Will this change in GHC-7.4.1? (For example by having an overloaded `()`) The reason I ask is I would like to know if it's already feasible to start proposing adding these associated constraints to Functor, Applicative and Monad. Cheers, Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: ConstraintKinds and default associated empty constraints
That would be nice. It would also be nice to be able to use _ in type signatures as in: const :: a - _ - a const x _ = x During type checking each _ could be replaced by a new unique type variable. Visa versa should also be possible: during type inferencing each unique type variable could be replaced by a _. Bas On Jan 9, 2012 6:22 AM, wren ng thornton w...@freegeek.org wrote: On 1/8/12 8:32 AM, Bas van Dijk wrote: On 23 December 2011 17:44, Simon Peyton-Jonessimonpj@**microsoft.comsimo...@microsoft.com wrote: My attempt at forming a new understanding was driven by your example. class Functor f where type C f :: * - Constraint type C f = () sorry -- that was simply type incorrect. () does not have kind * - Constraint So am I correct that the `class Empty a; instance Empty a` trick is currently the only way to get default associated empty constraints? Couldn't the following work? class Functor f where type C f :: * - Constraint type C f _ = () It seems to me that adding const to the type level (either implicitly or explicitly) is cleaner and simpler than overloading () to be Constraint, *-Constraint, *-*-Constraint,... -- Live well, ~wren __**_ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.**org Glasgow-haskell-users@haskell.org http://www.haskell.org/**mailman/listinfo/glasgow-**haskell-usershttp://www.haskell.org/mailman/listinfo/glasgow-haskell-users ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] GHC 7.4: Expected behavior or bug?
On 27 December 2011 17:38, Michael Snoyman mich...@snoyman.com wrote: Thanks to Mark Wright for pointing this out[1]. We have the equivalent of the following code in persistent: {-# LANGUAGE MultiParamTypeClasses #-} data Key backend entity = Key class Monad (b m) = Foo b m where func :: b m (Key b m) This code works fine with GHC 7.0, but I get the following message from GHC 7.4: Expecting two more arguments to `b' In the type `b m (Key b m)' In the class declaration for `Foo' Is this expected behavior, or a bug? If the former, what would be a possible workaround? Thanks, Michael [1] https://github.com/yesodweb/persistent/issues/31 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe I fixed a similar breakage in the hmatrix library: https://github.com/AlbertoRuiz/hmatrix/commit/a4f38eb196209436f72b938f6355f6e28474bef3 I don't know if it's a bug in GHC, but the workaround is to add an explicit kind signature: {-# LANGUAGE KindSignatures, MultiParamTypeClasses #-} data Key (backend :: * - * - *) entity = Key class Monad (b m) = Foo b m where func :: b m (Key b m) Cheers, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC 7.4: Expected behavior or bug?
On 27 December 2011 17:47, Bas van Dijk v.dijk@gmail.com wrote: I fixed a similar breakage in the hmatrix library: https://github.com/AlbertoRuiz/hmatrix/commit/a4f38eb196209436f72b938f6355f6e28474bef3 GHC-7.4.1-rc1 also reported another type error in code that was accepted by GHC = 7.2.2. These were the type errors I got: [24 of 36] Compiling Numeric.LinearAlgebra.Algorithms ( lib/Numeric/LinearAlgebra/Algorithms.hs, dist/build/Numeric/LinearAlgebra/Algorithms.o ) lib/Numeric/LinearAlgebra/Algorithms.hs:576:23: No instance for (RealFrac (RealOf t0)) arising from a use of `floor' Possible fix: add an instance declaration for (RealFrac (RealOf t0)) In the expression: floor In the second argument of `($)', namely `floor $ logBase 2 $ pnorm Infinity m' In the expression: max 0 $ floor $ logBase 2 $ pnorm Infinity m lib/Numeric/LinearAlgebra/Algorithms.hs:576:31: No instance for (Floating (RealOf t0)) arising from a use of `logBase' Possible fix: add an instance declaration for (Floating (RealOf t0)) In the expression: logBase 2 In the second argument of `($)', namely `logBase 2 $ pnorm Infinity m' In the second argument of `($)', namely `floor $ logBase 2 $ pnorm Infinity m' lib/Numeric/LinearAlgebra/Algorithms.hs:576:39: No instance for (Num (RealOf t0)) arising from the literal `2' Possible fix: add an instance declaration for (Num (RealOf t0)) In the first argument of `logBase', namely `2' In the expression: logBase 2 In the second argument of `($)', namely `logBase 2 $ pnorm Infinity m' lib/Numeric/LinearAlgebra/Algorithms.hs:576:43: No instance for (Normed Matrix t0) arising from a use of `pnorm' Possible fix: add an instance declaration for (Normed Matrix t0) In the second argument of `($)', namely `pnorm Infinity m' In the second argument of `($)', namely `logBase 2 $ pnorm Infinity m' In the second argument of `($)', namely `floor $ logBase 2 $ pnorm Infinity m' lib/Numeric/LinearAlgebra/Algorithms.hs:593:19: No instance for (Container Vector t0) arising from a use of `add' Possible fix: add an instance declaration for (Container Vector t0) In the expression: add In an equation for `|+|': |+| = add In an equation for `expGolub': expGolub m = iterate msq f !! j where j = max 0 $ floor $ logBase 2 $ pnorm Infinity m a = m */ fromIntegral ((2 :: Int) ^ j) q = geps eps eye = ident (rows m) lib/Numeric/LinearAlgebra/Algorithms.hs:599:1: Couldn't match type `t0' with `t' because type variable `t' would escape its scope This (rigid, skolem) type variable is bound by the type signature for expm :: Field t = Matrix t - Matrix t The following variables have types that mention t0 expGolub :: Matrix t0 - Matrix t0 (bound at lib/Numeric/LinearAlgebra/Algorithms.hs:575:1) Note that RealOf is a type family: type family RealOf x type instance RealOf Double = Double type instance RealOf (Complex Double) = Double type instance RealOf Float = Float type instance RealOf (Complex Float) = Float Adding the following explicit type signature fixed it: expGolub :: ( Fractional t, Element t, Field t , Normed Matrix t , RealFrac (RealOf t) , Floating (RealOf t) ) = Matrix t - Matrix t I have no idea if this should be considered a bug. Regards, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell Platform and Windows - where's 2011.4?
On 27 December 2011 19:13, Steve Horne sh006d3...@blueyonder.co.uk wrote: On haskell.org, the 2011.4.0.0 version is shown as the current stable release - but the most recent download link is for the 2011.2.0.0 version. What download link are you referring to? I see that: http://hackage.haskell.org/platform/windows.html correctly points to the 2011.4.0.0 release. Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: ConstraintKinds and default associated empty constraints
On 22 December 2011 01:58, wagne...@seas.upenn.edu wrote: Quoting Bas van Dijk v.dijk@gmail.com: I'm playing a bit with the new ConstraintKinds feature in GHC 7.4.1-rc1. I'm trying to give the Functor class an associated constraint so that we can make Set an instance of Functor. The following code works but I wonder if the trick with: class Empty a; instance Empty a, is the recommended way to do this: Maybe something like this? class Functor f where type C f a :: Constraint type C f a = () instance Functor Set where type C Set a = Ord a ~d ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users Yes I already tried that, but the following gives a type error: instance Functor [] where fmap = map testList = fmap (+1) [1,2,3] Could not deduce (C [] b0) arising from a use of `fmap' In the expression: fmap (+ 1) [1, 2, 3] ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: ConstraintKinds and default associated empty constraints
On 22 December 2011 09:31, Simon Peyton-Jones simo...@microsoft.com wrote: What about class Functor f where type C f :: * - Constraint type C f = () After all, just as (Ord a, Show a) is a contraint, so is (). But there's a kind mis-match there. `C f` should have kind `* - Constraint` but () has kind *. Or do I have to enable some language extension to make this work? Thanks, Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: ANNOUNCE: GHC 7.4.1 Release Candidate 1
On 21 December 2011 19:29, Ian Lynagh ig...@earth.li wrote: * There is a new feature constraint kinds (-XConstraintKinds): http://www.haskell.org/ghc/dist/stable/docs/html/users_guide/constraint-kind.html I'm trying to run the ConstraintKinds example from the documentation: {-# LANGUAGE ConstraintKinds, TypeFamilies #-} type family Typ a b :: Constraint type instance Typ Int b = Show b type instance Typ Bool b = Num b But GHC complains: Not in scope: type constructor or class `Constraint' Do I have to import some GHC module for this? Cheers, Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: ANNOUNCE: GHC 7.4.1 Release Candidate 1
On 22 December 2011 00:10, José Pedro Magalhães j...@cs.uu.nl wrote: Hi Bas, On Wed, Dec 21, 2011 at 23:02, Bas van Dijk v.dijk@gmail.com wrote: On 21 December 2011 19:29, Ian Lynagh ig...@earth.li wrote: * There is a new feature constraint kinds (-XConstraintKinds): http://www.haskell.org/ghc/dist/stable/docs/html/users_guide/constraint-kind.html I'm trying to run the ConstraintKinds example from the documentation: {-# LANGUAGE ConstraintKinds, TypeFamilies #-} type family Typ a b :: Constraint type instance Typ Int b = Show b type instance Typ Bool b = Num b But GHC complains: Not in scope: type constructor or class `Constraint' Do I have to import some GHC module for this? Yes: GHC.Prim. (Which reminds me, Simon, we had agreed to re-export Constraint from GHC.Exts, but it wasn't clear to me how to do this, since Constraint is a kind, not a type, so it can't just go on the export list of the module...) Cheers, Pedro Cheers, Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users Thanks Pedro, that works. I already read through the docs of GHC.Prim but could not find it: http://www.haskell.org/ghc/dist/stable/docs/html/libraries/ghc-prim-0.2.0.0/GHC-Prim.html I guess haddock is not smart enough to understand kinds yet... ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
ConstraintKinds and default associated empty constraints
I'm playing a bit with the new ConstraintKinds feature in GHC 7.4.1-rc1. I'm trying to give the Functor class an associated constraint so that we can make Set an instance of Functor. The following code works but I wonder if the trick with: class Empty a; instance Empty a, is the recommended way to do this: {-# LANGUAGE ConstraintKinds, TypeFamilies, FlexibleInstances #-} import GHC.Prim (Constraint) import Prelude hiding (Functor, fmap) import Data.Set (Set) import qualified Data.Set as S (map, fromList) class Functor f where type C f :: * - Constraint type C f = Empty fmap :: (C f a, C f b) = (a - b) - f a - f b class Empty a; instance Empty a instance Functor Set where type C Set = Ord fmap = S.map instance Functor [] where fmap = map testList = fmap (+1) [1,2,3] testSet = fmap (+1) (S.fromList [1,2,3]) Cheers and thanks for a great new feature! Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] Alternative versus Monoid
On 16 December 2011 16:26, Yves Parès limestr...@gmail.com wrote: 1) What about the First type? Do we {-# DEPRECATE #-} it? Personnaly, I'm in favor of following the same logic than Int: Int itself is not a monoid. You have to be specific: it's either Sum or Mult. It should be the same for Maybe: we remove its instance of Monoid, and we only use First and Last. The reason you need to be specific with Int is that it's not clear which semantics (sum or product) you want. The semantics of Maybe are clear: it's failure-and-prioritized-choice. Changing the order of the arguments of mappend should be the job of Dual. If we really want to drop the Monoid instance for Maybe and keep First and Last and also want to be consistent we should also drop the Monoid instances of [a], a-b, Endo a and of all the tuples. And instead define Monoid instance for First [a], Last [a], First (a-b), Last (a-b), etc. I don't think this is what we want. Regards, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Interruptible threads with IO loops
On 21 December 2011 09:52, Fedor Gogolev k...@knsd.net wrote: I'm trying to get some threads that I can stop and get last values that was computed (and that values are IO values, in fact). I'm not sure it's what you need but you might want to look at: http://hackage.haskell.org/package/Workflow Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Adding state to a library
On 18 December 2011 22:26, Kevin Jardine kevinjard...@gmail.com wrote: I have a library of functions that all take a config parameter (and usually others) and return results in the IO monad. It is sometimes useful to drop the config parameter by using a state-like monad.. If you're not modifying the configuration, a reader monad transformer is probably enough: http://hackage.haskell.org/packages/archive/transformers/0.2.2.0/doc/html/Control-Monad-Trans-Reader.html#t:ReaderT You probably want to define your own monad transformer for your library: newtype MyMonad m a = M {unM :: ReaderT Config m a} deriving (Functor, Applicative, Monad, MonadTrans, MonadIO) getConfig :: MyMonad m Config getConfig = M ask I have found that I can wrap all my functions like so: withLibrary cfg f = f cfg This can now be defined as: withLibrary :: Config - MyMonad m a - m a withLibrary cfg m = runReaderT (unM m) cfg stateF a b c d = getConfig = \cfg - liftIO $ withLibrary cfg libraryF a b c d notice that I need stateF and libraryF lines, each with n parameters. Upgrading my library like this is rather tedious. I would prefer to just write something like stateF = upgrade libraryF but I can find no way to define the function upgrade in Haskell. This must be a fairly common problem. Is there a simple solution? What do you mean by upgrading? Cheers, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Alternative versus Monoid
On 16 December 2011 05:26, Brent Yorgey byor...@seas.upenn.edu wrote: I, for one, would be quite in favor of changing the current Monoid (Maybe a) instance to correspond to the failure-and-prioritized-choice semantics So lets do this. Some questions: 1) What about the First type? Do we {-# DEPRECATE #-} it? 2) What about the Last type? It could be deprecated in favor of Dual. 3) Do we need a new type (like the current Maybe) for lifting semigroups into a Monoid? IMHO we don't since the semigroup package does a better job with the Option type (like Brent mentioned). 4) How much code will break from this change? 5) Anyone up for proposing this to librar...@haskell.org? Regards, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Alternative versus Monoid
Attached is a git patch for base which makes the proposed changes. From 824bdca994b3fcceff21fcb68e1b18f1d4f03bd5 Mon Sep 17 00:00:00 2001 From: Bas van Dijk v.dijk@gmail.com Date: Fri, 16 Dec 2011 15:16:14 +0100 Subject: [PATCH] Give the Maybe Monoid the expected failure-and-prioritized-choice semantics instead of the lift-a-semigroup-to-a-monoid semantics. The old semantics didn't even achieve the latter since it required a Monoid instance on a, rather than a semigroup Also DEPRECATE First in favor of Maybe and Last in favor of Dual. --- Data/Monoid.hs | 46 -- 1 files changed, 20 insertions(+), 26 deletions(-) diff --git a/Data/Monoid.hs b/Data/Monoid.hs index 228e254..d1d9564 100644 --- a/Data/Monoid.hs +++ b/Data/Monoid.hs @@ -186,14 +186,14 @@ instance Num a = Monoid (Product a) where -- -- @ -- findLast :: Foldable t = (a - Bool) - t a - Maybe a --- findLast pred = getLast . foldMap (\x - if pred x ---then Last (Just x) ---else Last Nothing) +-- findLast pred = getDual . foldMap (\x - if pred x +--then Dual (Just x) +--else Dual Nothing) -- @ -- -- Much of Data.Map's interface can be implemented with -- Data.Map.alter. Some of the rest can be implemented with a new --- @alterA@ function and either 'First' or 'Last': +-- @alterA@ function and either 'Maybe' or 'Dual Maybe': -- -- alterA :: (Applicative f, Ord k) = --(Maybe a - f (Maybe a)) - k - Map k a - f (Map k a) @@ -204,28 +204,21 @@ instance Num a = Monoid (Product a) where -- insertLookupWithKey :: Ord k = (k - v - v - v) - k - v -- - Map k v - (Maybe v, Map k v) -- insertLookupWithKey combine key value = --- Arrow.first getFirst . alterA doChange key +-- alterA doChange key -- where --- doChange Nothing = (First Nothing, Just value) --- doChange (Just oldValue) = --- (First (Just oldValue), --- Just (combine key value oldValue)) +-- doChange m@Nothing = (m, Just value) +-- doChange m@(Just oldValue) = (m, Just (combine key value oldValue)) -- @ --- | Lift a semigroup into 'Maybe' forming a 'Monoid' according to --- http://en.wikipedia.org/wiki/Monoid: \Any semigroup @S@ may be --- turned into a monoid simply by adjoining an element @e@ not in @S@ --- and defining @e*e = e@ and @e*s = s = s*e@ for all @s ∈ S@.\ Since --- there is no \Semigroup\ typeclass providing just 'mappend', we --- use 'Monoid' instead. -instance Monoid a = Monoid (Maybe a) where +instance Monoid (Maybe a) where mempty = Nothing - Nothing `mappend` m = m - m `mappend` Nothing = m - Just m1 `mappend` Just m2 = Just (m1 `mappend` m2) - + Nothing `mappend` r = r + l `mappend` _ = l -- | Maybe monoid returning the leftmost non-Nothing value. +-- +-- /DEPRECATED in favor of 'Maybe'!/ +{-# DEPRECATED First Use Maybe instead #-} newtype First a = First { getFirst :: Maybe a } #ifndef __HADDOCK__ deriving (Eq, Ord, Read, Show) @@ -237,11 +230,13 @@ instance Show a = Show (First a) #endif instance Monoid (First a) where -mempty = First Nothing -r@(First (Just _)) `mappend` _ = r -First Nothing `mappend` r = r +mempty = First mempty +First l `mappend` First r = First (l `mappend` r) -- | Maybe monoid returning the rightmost non-Nothing value. +-- +-- /DEPRECATED in favor of 'Dual'!/ +{-# DEPRECATED Last Use Dual instead #-} newtype Last a = Last { getLast :: Maybe a } #ifndef __HADDOCK__ deriving (Eq, Ord, Read, Show) @@ -253,9 +248,8 @@ instance Show a = Show (Last a) #endif instance Monoid (Last a) where -mempty = Last Nothing -_ `mappend` r@(Last (Just _)) = r -r `mappend` Last Nothing = r +mempty = Last mempty +Last x `mappend` Last y = Last (y `mappend` x) {- { -- 1.7.5.4 ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] DB vs read/show for persisting large data
On 14 December 2011 15:22, Claude Heiland-Allen cla...@goto10.org wrote: I ran into this very nightmare in one project, and was recommend safecopy [0] by someone on the #haskell IRC channel. I've not (yet) used it but it looks very nice! [0] http://hackage.haskell.org/package/safecopy Or better yet, use acid-state which is build on top of safecopy: http://acid-state.seize.it/ Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell functions caller-callee details
On 9 December 2011 16:41, Shakthi Kannan shakthim...@gmail.com wrote: Given a Haskell package is there a way I can get each functions' caller-callee details? Are there any existing tools/libraries that can help me get this data from the source? Check out SourceGraph: http://hackage.haskell.org/package/SourceGraph ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
GHC HEAD build error
Hello, I'm trying to build GHC HEAD but get the following error: inplace/bin/ghc-stage1 -H64m -O0 -fasm -Iincludes -Irts -Irts/dist/build -DCOMPILING_RTS -package-name rts -dcmm-lint -i -irts -irts/dist/build -irts/dist/build/autogen -Irts/dist/build -Irts/dist/build/autogen-optc-O2 -c rts/HeapStackCheck.cmm -o rts/dist/build/HeapStackCheck.o rts/HeapStackCheck.cmm:159:305: parse error on input `(' The bug is in the GC_GENERIC macro on line 99: Capability_interrupt(MyCapability()) != 0 :: CInt However, I can't spot the problem. Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] ANNOUNCE: monad-control-0.3
On 6 December 2011 04:03, Joey Hess j...@kitenet.net wrote: I'm trying to convert from 0.2 to 0.3, but in way over my head. {-# LANGUAGE GeneralizedNewtypeDeriving #-} newtype Annex a = Annex { runAnnex :: StateT AnnexState IO a } deriving ( Monad, MonadIO, -- MonadControlIO MonadBaseControl IO ) You can use the following: {-# LANGUAGE GeneralizedNewtypeDeriving, TypeFamilies, MultiParamTypeClasses #-} import Control.Applicative import Control.Monad import Control.Monad.Base import Control.Monad.Trans.Class import Control.Monad.Trans.Control import Control.Monad.Trans.State import Control.Monad.IO.Class newtype Annex a = Annex { runAnnex :: StateT AnnexState IO a } deriving (Applicative, Functor, Monad, MonadIO) data AnnexState = AnnexState instance MonadBase IO Annex where liftBase = Annex . liftBase instance MonadBaseControl IO Annex where newtype StM Annex a = StAnnex (StM (StateT AnnexState IO) a) liftBaseWith f = Annex $ liftBaseWith $ \runInIO - f $ liftM StAnnex . runInIO . runAnnex When I have some time I will add some better documentation to monad-control. Cheers, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: monad-control-0.3
On 6 December 2011 09:12, Bas van Dijk v.dijk@gmail.com wrote: instance MonadBaseControl IO Annex where newtype StM Annex a = StAnnex (StM (StateT AnnexState IO) a) liftBaseWith f = Annex $ liftBaseWith $ \runInIO - f $ liftM StAnnex . runInIO . runAnnex Oops forgot the restoreM method: restoreM = Annex . restoreM . unStAnnex unStAnnex (StAnnex st) = st ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: monad-control-0.3
On 6 December 2011 05:06, Michael Snoyman mich...@snoyman.com wrote: Maybe this will help[1]. It's using RWST instead of StateT, but it's the same idea. [1] https://github.com/yesodweb/yesod/commit/7619e4e9dd88c152d1e00b6fea073c3d52dc797f#L0R105 Hi Michael, Note that you can just reuse the MonadTransControl instance of the RWST transformer: instance MonadTransControl (GGWidget master) where newtype StT (GGWidget master) a = StWidget {unStWidget :: StT (GWInner master) a} liftWith f = GWidget $ liftWith $ \run - f $ liftM StWidget . run . unGWidget restoreT = GWidget . restoreT . liftM unStWidget Cheers, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: monad-control-0.3
On 6 December 2011 12:59, Michael Snoyman mich...@snoyman.com wrote: On Tue, Dec 6, 2011 at 11:49 AM, Bas van Dijk v.dijk@gmail.com wrote: On 6 December 2011 05:06, Michael Snoyman mich...@snoyman.com wrote: Maybe this will help[1]. It's using RWST instead of StateT, but it's the same idea. [1] https://github.com/yesodweb/yesod/commit/7619e4e9dd88c152d1e00b6fea073c3d52dc797f#L0R105 Hi Michael, Note that you can just reuse the MonadTransControl instance of the RWST transformer: instance MonadTransControl (GGWidget master) where newtype StT (GGWidget master) a = StWidget {unStWidget :: StT (GWInner master) a} liftWith f = GWidget $ liftWith $ \run - f $ liftM StWidget . run . unGWidget restoreT = GWidget . restoreT . liftM unStWidget Cheers, Bas Thanks Bas, I was just in the process of converting Widget from being a RWS to a Writer, and your code made it much simpler :). Michael Do you think it's useful to have the following two utility functions for defining a MonadTransControl instance for your own monad transformer provided that your transformers is defined in terms of another transformer: defaultLiftWith ∷ (Monad m, MonadTransControl tInner) ⇒ (tInner m α → t m α) -- ^ Constructor → (∀ β n. t n β → tInner n β) -- ^ Deconstructor → (∀ β. StT tInner β → StT t β) -- ^ State constructor → ((Run t → m α) → t m α) defaultLiftWith con deCon st = \f → con $ liftWith $ \run → f $ liftM st ∘ run ∘ deCon defaultRestoreT ∷ (Monad m, MonadTransControl tInner) ⇒ (tInner m α → t m α) -- ^ Constructor → (StT t α → StT tInner α) -- ^ State deconstructor → (m (StT t α) → t m α) defaultRestoreT con unSt = con ∘ restoreT ∘ liftM unSt For example in your case you would use these as follows: instance MonadTransControl (GGWidget master) where newtype StT (GGWidget master) a = StWidget {unStWidget :: StT (GWInner master) a} liftWith = defaultLiftWith GWidget unGWidget StWidget restoreT = defaultRestoreT GWidget unStWidget Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: monad-control-0.3
On 3 December 2011 10:18, Herbert Valerio Riedel h...@gnu.org wrote: btw, how did you manage to get measurements from 2 different versions of the same library (monad-control 0.3 and 0.2.0.3) into a single report? By renaming the old package to monad-control2 and using the PackageImports extension. I do wonder why it's not possible to use two different versions of the same package at the same time. Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: monad-control-0.3
On 3 December 2011 00:45, Bas van Dijk v.dijk@gmail.com wrote: Note that Peter Simons just discovered that these packages don't build with GHC-7.0.4 (https://github.com/basvandijk/monad-control/issues/3). I just committed some fixes which enable them to be build on GHC = 6.12.3. Hopefully I can release these fixes this weekend. I just released the fixes: http://hackage.haskell.org/package/monad-control-0.3.0.1 http://hackage.haskell.org/package/lifted-base-0.1.0.1 Cheers, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Weird interaction between literate haskell, ghci and OverloadedStrings
On 3 December 2011 11:19, Erik de Castro Lopo mle...@mega-nerd.com wrote: Joachim Breitner wrote: it does not seem to be related to literate haskell, if I copy the code from your file into a .hs without the , ghci still does not activate the OverloadedStrings extension when loading the file. I hadn't noticed that. I’d consider this a bug until the developers explain why this should or cannot be different, and suggest you file it as such. I agree. I've lodged a bug report here: http://hackage.haskell.org/trac/ghc/ticket/5673 I think it's very dangerous if language extensions leak from modules by default. For example if someone creates a library and needs to use some unsafe language extensions like: {-# LANGUAGE UndecidableInstances, OverlappingInstances, IncoherentInstances #-} module SomeLib where ... You surely don't want to silently enable these in some unsuspecting client: module MyFirstHaskellModule where import SomeLib ... I can imagine having a pragma for explicitly exporting language extensions: {-# EXPORT_LANGUAGE OverloadedStrings #-} Cheers, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANNOUNCE: monad-control-0.3
Hello, I just released monad-control-0.3. The package for lifting control operations (like catch, bracket, mask, alloca, timeout, forkIO, modifyMVar, etc.) through monad transformers: http://hackage.haskell.org/package/monad-control-0.3 It has a new and improved API which is: * easier to understand by explicitly representing the monadic state using type families. * 60 times faster than the previous release! * more general because control operations can now, not only be lifted from IO, but from any base monad (ST, STM, etc.) I also released a new package: lifted-base: http://hackage.haskell.org/package/lifted-base-0.1 It provides lifted versions of functions from the base library. Currently it exports the following modules: * Control.Exception.Lifted * Control.Concurrent.Lifted * Control.Concurrent.MVar.Lifted * System.Timeout.Lifted These are just modules which people have needed in the past. If you need a lifted version of some function, just ask me to add it or send me a patch. Note that Peter Simons just discovered that these packages don't build with GHC-7.0.4 (https://github.com/basvandijk/monad-control/issues/3). I just committed some fixes which enable them to be build on GHC = 6.12.3. Hopefully I can release these fixes this weekend. Regards, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: monad-control-0.3
On 3 December 2011 00:45, Bas van Dijk v.dijk@gmail.com wrote: * 60 times faster than the previous release! Here are some benchmark results that compare the original monad-peel, the previous monad-control-0.2.0.3 and the new monad-control-0.3: http://basvandijk.github.com/monad-control.html Note that the benchmarks use Bryan O'Sullivan's excellent new criterion-0.6 package. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Why no multiple default method implementations?
On 24 November 2011 16:46, José Pedro Magalhães j...@cs.uu.nl wrote: Hi Bas, On Thu, Nov 24, 2011 at 09:23, Bas van Dijk v.dijk@gmail.com wrote: Hello, Now that we have DefaultSignatures, why is it not allowed to have multiple default method implementations, as in: {-# LANGUAGE DefaultSignatures #-} class Foo a where foo :: a foo = error foo default foo :: Num a = a foo = 1 GHC complains: Conflicting definitions for `foo' The following use of multiple default signatures also gives the same error: class Foo a where foo :: a default foo :: Fractional a = a foo = 0.5 default foo :: Num a = a foo = 1 Couldn't GHC always pick the most specific default method, just as it does with instances when OverlappingInstances is enabled? As far as I understand, GHC never looks at the context to decide which instance is applicable: http://www.haskell.org/ghc/docs/7.2.1/html/users_guide/type-class-extensions.html#instance-overlap Your instances above are duplicates. Right. The reason I asked is that I'm adding default generic implementations for the 'arbitrary' and 'shrink' methods of the Arbitrary type class of QuickCheck: class Arbitrary a where arbitrary :: Gen a shrink :: a - [a] shrink _ = [] default arbitrary :: (Generic a, GArbitrary (Rep a)) = Gen a arbitrary = fmap to gArbitrary default shrink :: (Generic a, GArbitrary (Rep a)) = a - [a] shrink = map to . gShrink . from However the normal default implementation of 'shrink' conflicts with the generic default implementation. So I had to remove it and manually add it to each of the instances that previously implicitly used the default implementation. This is not a big deal though. Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
Re: [Haskell-cafe] Documenting strictness properties for Data.Map.Strict
On 18 November 2011 06:44, Johan Tibell johan.tib...@gmail.com wrote: Here are some examples: insertWith (+) k undefined m == undefined delete undefined m == undefined map (\ v - undefined) == undefined mapKeys (\ k - undefined) == undefined Any ideas for further improvements? I would use '_|_' instead of 'undefined'. Then again, this does require the reader to know what '_|_' means. But note we already use this symbol in the base library. Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A Mascot
On 16 November 2011 05:18, John Meacham j...@repetae.net wrote: Not nearly enough attention is paid to the other striking feature, the laziness. The 'bottom' symbol _|_ should feature prominently. The two most defining features of haskell are that it is purely functional and _|_ inhabits every type. The combination of which is very powerful. Is ⊥ the right symbol to express the non-strict evaluation of the language? Is it true that non-strict evaluation requires that ⊥ inhabits every type? In other words: why can't there exist a non-strict total language (probably having some form of coinductive types)? Cheers, Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] A Mascot
On 16 November 2011 11:05, MigMit miguelim...@yandex.ru wrote: Maybe it's just me, but I've thought that being non-strict just means that it's possible for a function to produce some value even if it's argument doesn't; in other words, that it's possible to have f (_|_) ≠ (_|_). If there was no such thing as (_|_), what would non-strictness mean? Thanks, non-strictness is indeed defined using ⊥ like you mentioned. I think I was confusing non-strict evaluation with coinduction. They have the same advantages but the latter is less powerful but safer than the former. Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] deepseq-1.2.0.1 missing Data.Map instance
On 15 November 2011 23:50, Daniel Fischer daniel.is.fisc...@googlemail.com wrote: The change is already in the latest released deepseq version, but will only be in the containers version to be released with ghc-7.4. The change is already in the released containers-0.4.2.0. So the only thing Henry needs to do is install that version and rebuild his libraries against that version. Bas ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Monad-control rant
Hi Mikhail, your type class: class MonadAbort e μ ⇒ MonadRecover e μ | μ → e where recover ∷ μ α → (e → μ α) → μ α looks a lot like the MonadCatchIO type class from MonadCatchIO-transformers: class MonadIO m = MonadCatchIO m where catch :: E.Exception e = m a - (e - m a) - m a I haven't looked at your code in detail but are you sure your continuation based AIO monad doesn't suffer from the same unexpected behavior as the ContT monad transformer with regard to catching and handling exceptions? The API docs of MonadCatchIO-transformers explain the bug in detail: http://hackage.haskell.org/packages/archive/MonadCatchIO-transformers/0.2.2.3/doc/html/Control-Monad-CatchIO.html Regards, Bas On 12 November 2011 13:55, Mikhail Vorozhtsov mikhail.vorozht...@gmail.com wrote: On 11/12/2011 07:34 AM, Bas van Dijk wrote: Are you going to release a new version of monad-control right away Not just yet. I've split `monad-control` into two packages: * `monad-control`: just exports `Control.Monad.Trans.Control`. This part is finished. * `lifted-base`: wraps all modules of the `base` package which export `IO` computations and provides lifted version instead. For example we have `Control.Exception.Lifted`, `Control.Concurrent.Lifted`, etc. As you can imagine the latter is a lot of boring work. Fortunately it's easy to do so will probably not take a lot of time. BTW if by any chance you want to help out, that will be much appreciated! The repos can be found [here](https://github.com/basvandijk/lifted-base) Maybe I should elaborate on why I stopped using monad-control and rolled out my own version of lifted Control.Exception in monad-abort-fd package. I'm CC-ing the Cafe just in case someone else might be interested in the matter of IO lifting. Imagine we have a monad for multiprogramming with shared state: -- ContT with a little twist. Both the constructor and runAIO -- are NOT exported. newtype AIO s α = AIO { runAIO ∷ ∀ β . (α → IO (Trace s β)) → IO (Trace s β) } runAIOs ∷ MonadBase IO μ ⇒ s -- The initial state → [AIO s α] -- The batch of programs to run. -- If one program exits normally (without using -- aioExit) or throws an exception, the whole batch -- is terminated. → μ (s, Maybe (Attempt α)) -- The final state and the result. -- Nothing means deadlock or that -- all the programs exited with -- aioExit. runAIOs = liftBase $ mask_ $ ... bloody evaluation ... data Trace s α where -- Finish the program (without finishing the batch). TraceExit ∷ Trace s α -- Lift a pure value. TraceDone ∷ α → Trace s α -- A primitive to execute and the continuation. TraceCont ∷ Prim s α → (α → IO (Trace s β)) → Trace s β -- Primitive operations data Prim s α where -- State retrieval/modification PrimGet ∷ Prim s s PrimSet ∷ s → Prim s () -- Scheduling point. The program is suspended until -- the specified event occurs. PrimEv ∷ Event e ⇒ e → Prim s (EventResult e) -- Scheduling point. The program is suspended until the state -- satisfies the predicate. PrimCond ∷ (s → Bool) → Prim s () -- Run computation guarded with finalizer. PrimFin ∷ IO (Trace s α) → (Maybe α → AIO s β) → Prim s (α, β) -- Run computation guarded with exception handler. PrimHand ∷ IO (Trace s α) → (SomeException → AIO s α) → Prim s α aioExit ∷ AIO s α aioExit = AIO $ const $ return TraceExit aioAfter ∷ (s → Bool) → AIO s () aioAfter cond = AIO $ return . TraceCont (PrimCond cond) aioAwait ∷ Event e ⇒ e → AIO s (EventResult e) aioAwait e = AIO $ return . TraceCont (PrimEv e) runAIOs slices the programs at scheduling points and enqueues the individual pieces for execution, taking care of saving/restoring the context (finalizers and exception handlers). The Functor/Applicative/Monad/MonadBase/etc instances are pretty trivial: instance Functor (AIO s) where fmap f (AIO g) = AIO $ \c → g (c . f) instance Applicative (AIO s) where pure a = AIO ($ a) (*) = ap instance Monad (AIO s) where return = pure AIO g = f = AIO $ \c → g (\a → runAIO (f a) c) instance MonadBase IO (AIO s) where liftBase io = AIO (io =) instance MonadState s (AIO s) where get = AIO $ return . TraceCont PrimGet put s = AIO $ return . TraceCont (PrimSet s) instance MonadAbort SomeException (AIO s) where abort = liftBase . throwIO trace ∷ AIO s α → IO (Trace s α) trace (AIO g) = g (return . TraceDone) instance MonadRecover SomeException (AIO s) where recover m h = AIO $ return . TraceCont (PrimHand (trace m) h) instance MonadFinally (AIO s) where finally' m f = AIO $ return . TraceCont (PrimFin (trace m) f) -- finally m = fmap fst . finally' m . const -- No async exceptions in AIO instance MonadMask () (AIO s) where getMaskingState = return () setMaskingState
Re: ANNOUNCE: GHC version 7.2.2
On 11 November 2011 22:03, Ian Lynagh ig...@earth.li wrote: The GHC Team is pleased to announce a new bugfix release of GHC, 7.2.2. Yay! These GHC releases always feel like little presents... I noticed the links to modules in base in the latest docs point to the previous base library causing 404 errors: http://www.haskell.org/ghc/docs/latest/html/libraries/index.html Cheers, Bas ___ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users