[Haskell-cafe] RFCQ: The Classy Prelude: a more fully polymophic, drop-in alternative prelude http://www.yesodweb.com/blog/2012/07/classy-prelude
I'd like to share Michael Snoyman's Classy Prelude: http://www.yesodweb.com/blog/2012/07/classy-prelude . The basic gist of the work is that many of the standard prelude functions are made for concrete types such as [a], [(a,b)], and [Char] but can be much more polymorphic. While this complicates error messages and makes learning Haskell more difficult, we believe experienced Haskellers will benefit from the added polymorphism. Note that we aren't saying that the standard Prelude should be replaced, rather we are offering this as a drop-in alternative. Note that it reexports most of the standard Prelude types so it should be very low impact to switch over. We love to hear your comments. Note however, that this is a RFCQ with the 'C' standing for constructive.. Thanks, Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANN: unordered-containers - a new, faster hashing-based containers library
If you want to use the library and need a short term fix, just write a small wrapper type/module newtype SizedMap = SizedMap (Int, HashMap) and track the size yourself. only complication is that on inserts and deletes you'll need to check if the key existed. other than that, it shouldn't be too difficult. This way, the library stays super optimized but, if you need, you can track the size. As Johan said, it would slow down insert and delete a bit. shouldn't affect lookup though.. max On Feb 20, 2011, at 11:40 AM, Louis Wasserman wrote: > I'd like to complain about that, too ;) > > Louis Wasserman > wasserman.lo...@gmail.com > http://profiles.google.com/wasserman.louis > > > On Sat, Feb 19, 2011 at 9:02 PM, Edward Kmett wrote: > On Sat, Feb 19, 2011 at 7:27 PM, Sterling Clover wrote: > On Sat, Feb 19, 2011 at 3:04 PM, Johan Tibell wrote: > > On Sat, Feb 19, 2011 at 11:58 AM, Louis Wasserman > > wrote: > >> A couple thoughts: > >> size takes O(n). That's just depressing. Really. > > > > This applies to all the container types. We could support O(1) size at > > the cost of slowing down e.g lookup, insert, and delete a little bit. > > I haven't measure how much yet. Would it be worth it? > > Getting a bit picky, but for the record, Data.Map and Data.Sequence > provide O(1) size, and Data.HashTable I believe stores the information > but doesn't expose it from its tiny API. That's not an argument either > way for what a HashMap should do, however :-) > > NB: Data.IntMap, which Data.HashMap is based on, actually only provides O(n) > size. > > -Edward > > ___ > 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] OSX i386/x86 and x86_64 - time to switch supported platforms?
Doesn't 10.5.x have the ability to generate and run 64-bit binaries? mc On Feb 4, 2011, at 10:19 AM, wren ng thornton wrote: > Max Cantor wrote: >> someone? wrote: >>> I think the original poster is saying that the targeted architecture for OS >>> X support >>> should be the architecture that OS X assumes by default, and these days >>> that's x86_64. > > That sounds reasonable to me. The big caveat is that OSX >= 10.5.8 && < 10.6 > should still be targeted as well. While non-x86_64 Macs are quite old, OSX > 10.6 is still pretty new and so there are a lot of people still using 10.5 > (and our department still has a couple boxes running 10.4). > > So even though 10.5.8 defaults to 32-bit, it should still be actively > supported (as an x86_64 architecture). Just pass the necessary flags to gcc :) > > >>> It would be really nice for x86 mode to be well supported for a while >>> longer. > > Yes, it'd be really nice to support 32-bit mode for a while yet, even if it > isn't actively being targeted for improvements. > > -- > Live well, > ~wren > > ___ > 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] OSX i386/x86 and x86_64 - time to switch supported platforms?
>> I'm not sure I can make sense of what you mean here. Given the preamble, I'd >> guess you're asking whether we should make x86_64 the targeted architecture >> for OSX support, and reclassify 32-bit OSX to unsupported or "hopefully it >> still works" status. (But in that case, it's the 32-bit which would be >> "relegated" to unsupported status while x86_64 is "considered a supported >> platform"...) Yes. I'm saying that I believe that OSX x86_64 should be the officially supported platform instead of 32-bit x86 with all the associated guarantees and assurances. I wanted to see how people felt about that. mc >> >> Can you clarify the question? > > Here's something that happened to me: GHC was installed on this machine and > worked fine, > but when the operating system was upgraded to Mac OS X 10.6.something, GHC > broke, with > messages along the lines of "you can't use 32-bit absolute addresses in > 64-bit code". > The operating system is perfectly happy running both 32-bit and 64-code code > and all > the tool chain is happy working with either, but the *default* changed from > "say nothing > get 32-bit" to "say nothing get 64-bit". I'm guessing that GHC gives the > compiler some > C code and some (32-bit) object files or libraries. > > So now I have *different* GHC setups on the 10.6.5 desktop machine and the > 10.5.8 laptop... Since both machines have only 4GB of physical memory, > 32-bit would be > fine, except for all those lovely extra registers in x86_64 mode. > > I think the original poster is saying that the targeted architecture for OS X > support > should be the architecture that OS X assumes by default, and these days > that's x86_64. > > It would be really nice for x86 mode to be well supported for a while longer. > > > ___ > 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-cafe] hsmagick on OSX 10.6
Just out of curiosity, has anyone gotten this to work? I'm getting bus errors whenever I call readImage. If anyone out there has gotten it working and would tell me which versions they're using of the relevant bits, that would be very much appreciated. Also, I'll post all my debug info if there's someone who's gotten this to work. thanks, mc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] OSX i386/x86 and x86_64 - time to switch supported platforms?
I originally posted this on haskell-GHC-users, but was curious how the wider community felt. The last 32-bit, Intel Mac was the Mac Mini, discontinued in August 2007. The bulk of them were discontinued in 2006, along with PowerPC Macs. Does it make sense to relegate OSX x86_64 to community status while the 32-bit version is considered a supported platform? Given that I'm far from experienced enough to be able to contribute meaningfully to GHC, I'm not complaining about anyone's efforts, just that those efforts might be a bit misallocated. I'd venture a guess that far more people are interested in running 64-bit GHC on OSX than in running GHC on what is now fairly antiquated hardware. mc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell Platform 2011.x - planned release date?
January has come and gone and HP 2011 has not come with it. Is there an updated timetable for the next version of the HP? I'm not complaining or upset or whining, just trying to plan. Great work so far, looking forward to HP 2011! mc ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Where are all the Taiwanese Haskellers?
Did you check haskellers.com? If you come down south there's a decent group here in Singapore. Max On Dec 1, 2010, at 4:58 AM, Pasqualino Titto Assini wrote: > Hello, > > I am going to Taiwan with my family for about five weeks (I am > Italian, my wife is Taiwanese and we have two kids) and I wondered if > there was any Taiwanese Haskeller that would be interested in meeting > for a chat about Haskell, Life and Everything else, maybe in front of > a nice cup of 高山茶. > > We arrive in Taiwan on the 4th of December, spend a few days nearby > Taipei and then down to Pu-Li and Kaoshong, where we will spend about > 4 weeks and then probably back to Taipei for a few more days around > the 10 of January. > > I am afraid that my Chinese is almost non-existent (yes I know, that's > so stupid of me) so the conversation will have to be in English > (Italian or French would be fine as well :-)). > > All the very best, > > titto > > > -- > Dr. Pasqualino "Titto" Assini > http://quid2.org/ > > ___ > 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] Mysterious fact
FYI, I implemented an error monad using this church-encoded either instead of the conventional either. my thought was that since you skip the conditional at each bind call you'd get better performance. I was quite mistaken. Max On Nov 2, 2010, at 6:40 AM, Jeremy Shaw wrote: > Looks a lot like Church encoding to me: > > http://en.wikipedia.org/wiki/Church_encoding > > It was first discovered by the guy who invented lambda calculus :p > > - jeremy > > On Nov 1, 2010, at 5:28 PM, Andrew Coppin wrote: > >> The other day, I accidentally came up with this: >> >> {-# LANGUAGE RankNTypes #-} >> >> >> >> type Either x y = forall r. >> (x -> r) -> (y -> r) -> r >> >> left :: x -> >> Either >> x y >> left x f g >> = >> f x >> >> right :: y -> >> Either >> x y >> right y f g >> = >> g y >> >> >> This is one example; it seems that just about any algebraic type can be >> encoded this way. I presume that somebody else has thought of this before. >> Does it have a name? >> >> ___ >> 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-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Haskell in Industry
Remember that Banks/Financial Firms/Investment Banks were among the first big uses of punch card readers, mainframes, cobol, C, C++ (and OOP), VBA, Java.. I'm not saying if I like any of those languages (my presence on this list should give a clue how I feel) but investment banks picking up FP and Haskell bodes quite well for Haskell in the future. Max On Aug 10, 2010, at 12:59 AM, Tom Hawkins wrote: >> Good, we need more functional programmers actually solving real >> problems. But please put your skills to work in an industry other >> than investment banking. > > I've received a lot mail on this comment; mostly positive. Here's one > from someone who wishes to remain anonymous: > >> First of all I would like to say that I like your work regarding e.g. >> Atom. Second, I would like to know what exactly is bad about a Haskell >> job in investment banking as a lot of good programmers work in this >> industry. > > It's disproportionate. 95% of the job offerings in functional > programming are with investment firms. I believe investment banking > is important, but does it really need to dominate a large percentage > of the world's top tier programmers? Is computing the risk of > derivative contracts more important than pursuing sustainable energy, > new drug discovery, improving crop yields, etc. Some will argue > investment banking enables all of these things -- and I'm sure many > people in the industry go to work everyday feeling proud of their > contributions. But I just think most of this talent is going in to > improve the bottom line and little else. > > (Yes, I realize that's were the money is, and that's who's hiring. > Actually I'm very glad. Investment banking is the first industry to > adopt functional programming on a large scale. And others will > follow.) > > -Tom > ___ > 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] data.binary get reading beyond end of input bytestring?
I have a similar issue, I think. The problem with attoparsec is it only covers the unmarshalling side, writing data to disk still requires manually marshalling values into ByteStrings. Data.Binary with Data.Derive provide a clean, proven (encode . decode == id) way of doing this. If there's a way to accomplish this with attoparsec, I'd love to know. Max On Jul 28, 2010, at 10:32 PM, Gregory Collins wrote: > Conrad Parker writes: > >> Hi, >> >> I am reading data from a file as strict bytestrings and processing >> them in an iteratee. As the parsing code uses Data.Binary, the >> strict bytestrings are then converted to lazy bytestrings (using >> fromWrap which Gregory Collins posted here in January: >> >> -- | wrapped bytestring -> lazy bytestring >> fromWrap :: I.WrappedByteString Word8 -> L.ByteString >> fromWrap = L.fromChunks . (:[]) . I.unWrap > > This just makes a 1-chunk lazy bytestring: > >(L.fromChunks . (:[])) :: S.ByteString -> L.ByteString > > >> ). The parsing is then done with the library function >> Data.Binary.Get.runGetState: >> >> -- | Run the Get monad applies a 'get'-based parser on the input >> -- ByteString. Additional to the result of get it returns the number of >> -- consumed bytes and the rest of the input. >> runGetState :: Get a -> L.ByteString -> Int64 -> (a, L.ByteString, Int64) >> >> The issue I am seeing is that runGetState consumes more bytes than the >> length of the input bytestring, while reporting an >> apparently successful get (ie. it does not call error/fail). I was >> able to work around this by checking if the bytes consumed > input >> length, and if so to ignore the result of get and simply prepend the >> input bytestring to the next chunk in the continuation. > > Something smells fishy here. I have a hard time believing that binary is > reading more input than is available? Could you post more code please? > > >> However I am curious as to why this apparent lack of bounds checking >> happens. My guess is that Get does not check the length of the input >> bytestring, perhaps to avoid forcing lazy bytestring inputs; does that >> make sense? >> >> Would a better long-term solution be to use a strict-bytestring binary >> parser (like cereal)? So far I've avoided that as there is >> not yet a corresponding ieee754 parser. > > If you're using iteratees you could try attoparsec + attoparsec-iteratee > which would be a more natural way to bolt parsers together. The > attoparsec-iteratee package exports: > >parserToIteratee :: (Monad m) => >Parser a > -> IterateeG WrappedByteString Word8 m a > > Attoparsec is an incremental parser so this technique allows you to > parse a stream in constant space (i.e. without necessarily having to > retain all of the input). It also hides the details of the annoying > buffering/bytestring twiddling you would be forced to do otherwise. > > Cheers, > G > -- > Gregory Collins > ___ > 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-cafe] Iteratee package: combining enumerators
I have a series of files with binary encoded data in them, and want to create an enumerator iterates on the first element at the front of all the files. Something like the pseudocode: return . minimum =<< mapM (fmap (heads . lines) readFile) listOfFileNames I can use convStream to create an enumerator which runs iteratees on each tuple in a single file: (convStream decodeStrings) :: Monad m => IterateeG [] String m a -> IterateeG WrappedByteString Word8 m (IterateeG [] MyDataType m a) or, with the EnumerateeGMM tysyn: (convStream decodeStrings) :: Monad m => EnumerateeGMM WrappedByteString Word8 [] String m a My question is if there is a simple way to combine the Enumeratees to enumerate on a set of files or if I have to write an enumerator from scratch. Thank you in advance, Max P.S. John, apologies for the duped email, sent from the wrong address by mistake.___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Talking to Java from Haskell?
I use Apache Thrift, as someone else mentioned for IPC with some java code that connects to a third party data vendor. As of version 0.2, there are some bugs that you need to be aware of. However, and possibly more of interest to you, I have already written a FIX implementation in pure haskell. Its not exactly shippable code but it works fine for me. Its not as full featured as quick fix but its fine for single orders. Since you seem to be in a similar line of work to me (using haskell for finance/trading) perhaps we shoudl have a chat. Get me on gtalk at this address. Max On Jul 9, 2010, at 8:11 PM, Daniel Cook wrote: >> A simpler solution might be Facebook's thrift [1] > > This is a very interesting solution. I'll investigate Thrift further, > but it may wind up being what I do. Does anyone know how solid this > code is in Haskell? > >> the Java binary directly from Haskell using System.Process and friends, and >> rather than communicating over ports, communicate over pipes. > > Cool!This is probably a second step, though - first get the code > working, then worry about > making it all fast. > > > On Fri, Jul 9, 2010 at 5:11 AM, sterl wrote: >> Daniel Cook wrote: >>> >>> b) Wrap the Java library with some code to use a lightweight message >>> queue (zeromq) to send messages to my Haskell program? (This would >>> require essentially re-implementing an abstracted subset of the the >>> protocol into 0MQ messages) >> >> A simpler solution might be Facebook's thrift [1] (now an Apache project). >> You write a simple file in a C-inspired IDL which gives typedefs and RPC >> signatures, and not only do you get the data structures and serialization >> functions in a number of target languages including Haskell and Java, but >> you get lightweight, relatively robust, server and client implementations. >> The implementations of the Java functions can then be written in Scala or >> Clojure, so you avoid having to leave fp-land entirely. One could even run >> the Java binary directly from Haskell using System.Process and friends, and >> rather than communicating over ports, communicate over pipes. In any case, >> I've had good luck with this approach. >> >> Cheers, >> Sterl. >> >> [1] http://incubator.apache.org/thrift/ >> > ___ > 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] EnumMap 0.0.2 and Containers-0.3
Wasn't implying that they should. My bad for not checking the relative release dates, but, even had I checked, its still reasonable to ask if there are known issues, isn't it? Max On Jul 12, 2010, at 11:06 AM, Ivan Miljenovic wrote: > On 12 July 2010 13:04, Max Cantor wrote: >> Is there a reason that EnumMap specifically requires containers < 0.3 or >> just a matter of not having been tested? It seems to compile just fine (but >> with one warning for a deprecated call). > > Because it hasn't been updated since containers-0.3 came out, and most > programmers don't have crystal balls to be able to see in the future > and see if their code will work with future versions of their > dependencies. > > > -- > Ivan Lazar Miljenovic > ivan.miljeno...@gmail.com > IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] EnumMap 0.0.2 and Containers-0.3
Is there a reason that EnumMap specifically requires containers < 0.3 or just a matter of not having been tested? It seems to compile just fine (but with one warning for a deprecated call). Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell Indonesia
selamat datang! On Jun 18, 2010, at 9:27 PM, Jean-Denis Koeck wrote: > Hi! I'm of Indonesian descent (by my mother) and I'll be there this summer. > Nice to meet you! > > Jean-Denis > > 2010/6/15 vipex.id > Hi, I'm new in Haskell & wondering is there Indonesian people using Haskell > here. > > Nice meet* you all :) > > Regards, > vipex > > ___ > 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-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell Indonesia
Given that I can see Indonesia (pulau batam) from my bedroom window, I'm going to say that I didn't cross any lines.. On Jun 16, 2010, at 6:17 AM, Ivan Lazar Miljenovic wrote: > Max Cantor writes: > >> Its not indonesia, but the Singapore FP Users is pretty close by. >> [snip] > > Fine, if we're going to start promoting non-Indonesian Haskell > groups/events, I give you AusHack: > http://www.haskell.org/haskellwiki/AusHac2010 > > (It was about time for more promotion for this; it's starting in a > months time!!!) > > -- > Ivan Lazar Miljenovic > ivan.miljeno...@gmail.com > IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: [Haskell-beginners] Accounting Engine in Haskell
I think Haskell would be an excellent choice. Several reasons come to mind: Given the arbitrary complexity of such projects, an EDSL describing book entries etc would be a very good fit for the project. As people have said once or twice, Haskell is a great fit for EDSLs If you want to get ambitious and scale this up to a multithreaded, multiuser environment, STM would be a very good concurrency model. This pretty much just leaves Haskell or Clojure. Finally, the type system of haskell is hugely useful to this project. Jane Street Capital (ocaml users and damned good at it) has a programming motto: make illegal transactions unrepresentative. The type systems of Haskell and OCaml let you structure this kind of project in a way to catch most of your bugs at compile time. So, I think Haskell is the perfect intersection of EDSL support, Concurrency, and powerful, static typing for the project. Good luck, keep us informed of your progress. Max On Jun 15, 2010, at 5:34 PM, Yitzchak Gale wrote: > Hi Amir, > > Amiruddin Nagri wrote: >> My current project is about making an accounting engine... > > Take a look at the related but different project "hledger". > > http://hackage.haskell.org/package/hledger > http://hackage.haskell.org/package/hledger-lib > >> consistency, handling large data(performance) and >> availability... >> I am interested in knowing if Haskell will be the right fit >> for my project. > > These things can certainly be achieved, and Haskell is > a great platform for it. Reliability and assurance of correctness > are very important for financial systems, and Haskell is > especially good at providing them together with good > performance. > > However, keep in mind that you are undertaking a very > ambitious project. There are a lot of little design decisions > to be made along the way which, if made without a lot of > previous experience in whatever language you are using, > could lead to serious problems later on in a large system > like this. > > I recommend: > > o Start with a less ambitious version of the project - > a simpler prototype with less requirements, or components > that can be developed as a stand-alone and later integrated > into your larger system. > > o Work closely with the community, on the #haskell > IRC channel and the Haskell Cafe mailing list, to get > guidance from experienced Haskellers. Share and discuss > your code as you go along. > > (Or, if you select a different language that you are not > very experienced in for developing large high-assurance > commercial systems, do the same with that language's > community.) > >> Also there has been some concerns because of lazy evaluation >> in Haskell and memory leaks associated with it. > > The possibility for memory and performance leaks in large > systems written in Haskell is no more or less than in any > other mature programming language. As in any language, > it takes experience and care to avoid them as your application > scales up. > > Good luck, > Yitz > ___ > 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] Haskell Indonesia
Its not indonesia, but the Singapore FP Users is pretty close by. We aren't limited to just Haskell but there are several haskellers in the group. If you'd like to join us, drop an email to: singapore-functional-programm...@googlegroups.com Max On Jun 15, 2010, at 7:11 PM, leledumbo wrote: > > I'm one of them :) > Nice to meet you... > > > vipex.id wrote: >> >> Hi, I'm new in Haskell & wondering is there Indonesian people using >> Haskell >> here. >> >> Nice meet* you all :) >> >> Regards, >> vipex >> >> ___ >> Haskell-Cafe mailing list >> Haskell-Cafe@haskell.org >> http://www.haskell.org/mailman/listinfo/haskell-cafe >> >> > > -- > View this message in context: > http://old.nabble.com/Haskell-Indonesia-tp2215p28889986.html > Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. > > ___ > 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-cafe] GeneralizedNewtypeDeriving and TypeFamilies
So I understand from http://hackage.haskell.org/trac/ghc/ticket/4083 that GeneralizedNewtypeDeriving doesn't play well with TypeFamilies. But, if a typeclass is only using type synonyms, is there any reason why newtype deriving would not work? For a toy example: class Cls a where type MyType a foo :: MyType a -> in this case, if you have something like: instance Cls () where type MyType () = () foo = id would: newtype Bar = Bar () deriving (Cls) be well defined? Thanks, Max___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Speed of Error handling with Continuations vs. Eithers
Where is my bind statement doing a case analysis? Isn't it just propagating, in a sense, the case analysis that came from values coming into the monad via return or via throwError? Also, why wouldn't callCC work here? I'm not that familiar with the ContT monad so any more details would be very much appreciated. Max On May 15, 2010, at 6:40 AM, Derek Elkins wrote: > On Fri, May 14, 2010 at 4:53 PM, Antoine Latter wrote: >> On Fri, May 14, 2010 at 4:25 PM, Derek Elkins >> wrote: >>> You did it wrong. All you did was Church encode the Either type. >>> Your bind is still doing a case-analysis. All you have to do is use >>> ContT r (Either e). The bind implementation for ContT is completely >>> independent of the underlying monad. It doesn't even require the m in >>> ContT r m to be a functor, let alone a monad. Therefore the ContT >>> bind doesn't do any case-analysis because it doesn't know anything >>> about the underlying monad. One way to look at what is happening is >>> to compare it to Andrzej Filiniski's work in "Representing Monads" and >>> "Representing Layered Monads". >>> >> >> Would you then use callCC to get the required short-circuit-on-error >> behavior? >> >> A church encoding of Either coded as a monad transformer still >> wouldn't hit the inner monad on bind, even if it is weaving the left >> and right continuations together. > > callCC wouldn't work well here. What would work better is another > control operator commonly called 'control' which does not resume if > the passed in continuation isn't invoked. However, it's usually even > clearer (or at least more concise) in these situations to work with > the continuation passing style directly. > > -- fail directly using CPS > fail :: String -> ContT r (Either String) a > fail s = ContT $ \k -> Left s ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Speed of Error handling with Continuations vs. Eithers
Makes sense. From what you wrote, it seems like this might be a dead-end and can't really be optimized away. Do you agree? Max On May 10, 2010, at 8:38 PM, Jan-Willem Maessen wrote: > > > On Mon, May 10, 2010 at 5:38 AM, Max Cantor wrote: > Based on some discussions in #haskell, it seemed to be a consensus that using > a modified continuation monad for Error handling instead of Eithers would be > a significant optimization since it would eliminate a lot of conditional > branching (everytime >>= is called in the Either monad, there is a > conditional. > > My suspicion, based on using a similar monad to implement IO in Eager > Haskell, is that you're creating a lot of closures. This is rather more > expensive in general than the extra control flow required to inspect the > Eithers. > > In more detail: CPS works well if the compiler can inline most of the > continuation passing and turn your code back into direct style, at least > along the "no failures" path. In this case you can avoid creating closures > except at what would have been actual function call points in your original > code, and at catch points for the error continuation. However, I expect that > you're probably calling functions that are polymorphic in Monad (stuff like > mapM etc.) that is not being inlined or specialized. These end up building a > continuation rather naively on the heap. You're essentially moving the call > stack to the heap, and the compiler can't assist you in moving it back again; > hence, slow code. > > To make matters worse, you get a lot more branch prediction leverage with > pointer-tagged Either than you possibly could with a closure invocation on a > modern architecture. But I suspect that's rather unimportant compared to > allocation time / memory footprint issues here. > > -Jan-Willem Maessen > > > I implemented a ErrCPS monad which does exactly that, but the speed has been > disappointing. It runs almost exactly 3x slower than a drop in replacement > using the MonadError instance of Either from mtl. > > mkEMA and midError are basically toy functions but I dont know why Either is > so much faster. I've experimented with putting some seq's in the bindErrCPS > and even {-# INLINE (>>=) #-} in the Monad instance, but to no avail. > > I've copy/pasted the code below, any suggestions on optimization, or if this > is simply a bad idea would be much appreciated. Strangely, compiling with > -O2 seems to have no effect on the speed: > > > -Max > [... code snipped] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Speed of Error handling with Continuations vs. Eithers
Based on some discussions in #haskell, it seemed to be a consensus that using a modified continuation monad for Error handling instead of Eithers would be a significant optimization since it would eliminate a lot of conditional branching (everytime >>= is called in the Either monad, there is a conditional. I implemented a ErrCPS monad which does exactly that, but the speed has been disappointing. It runs almost exactly 3x slower than a drop in replacement using the MonadError instance of Either from mtl. mkEMA and midError are basically toy functions but I dont know why Either is so much faster. I've experimented with putting some seq's in the bindErrCPS and even {-# INLINE (>>=) #-} in the Monad instance, but to no avail. I've copy/pasted the code below, any suggestions on optimization, or if this is simply a bad idea would be much appreciated. Strangely, compiling with -O2 seems to have no effect on the speed: -Max > {-# LANGUAGE MultiParamTypeClasses #-} > {-# LANGUAGE FlexibleInstances #-} > {-# LANGUAGE FlexibleContexts #-} > {-# LANGUAGE Rank2Types #-} > module Main where > > import Control.Applicative > import Control.Monad.Error -- hiding (foldM) > import Control.Monad.Trans > import Control.Monad hiding (foldM) > import System.Random > import Control.Monad.Identity (runIdentity, Identity) > import Control.Monad.Reader.Class > import Data.Time.LocalTime as Time -- for benchmarking > import Data.Time.Calendar (Day) > import Data.Time.LocalTime (getZonedTime) > midError :: MonadError String m => Double -> Double -> m Double > midError a b = if (b < 1) then throwError "check val" > else let r = (a + b) / 2 in r `seq` (return r) > mkEMA l = foldM midError 1 l > newtype ErrCPS e m a = ErrCPS { runErrCPS :: forall r . (e -> m r) -- error > handler > -> (a -> m r) -- success handler > -> m r } > > {-# INLINE retErrCPS #-} > retErrCPS :: a -> ErrCPS e m a > retErrCPS x = ErrCPS $ \_ good -> good x > > {-# INLINE bindErrCPS #-} > bindErrCPS :: ErrCPS e m b -> (b -> ErrCPS e m a) -> ErrCPS e m a > bindErrCPS m f = ErrCPS $ \err good -> runErrCPS m err $ \x -> runErrCPS (f > x) err good > > instance Monad m => Monad (ErrCPS e m) where > return = retErrCPS > (>>=) = bindErrCPS > main :: IO () > main = do > let n = 50 > runEither e b g = either b g e > runTest f s = do > sg <- newStdGen > let l = take n $ randomRs (2, 5) sg > mapM_ (\e -> e `seq` return ()) l > stopwatch $ f (mkEMA l) > (putStr . show) > (putStr . (s ++) . show) > > forever $ do runTest runEither "either: " >runTest runErrCPS "errCPS: " ErrCPS based code seems to run almost exactly 3x slower than the Either based code: errCPS: 37453.226 Action ran in: 30 msec either: 26803.055 Action ran in: 11 msec errCPS: 15840.626 Action ran in: 34 msec either: 32556.881 Action ran in: 10 msec errCPS: 38933.121 Action ran in: 30 msec either: 35370.820 Action ran in: 11 msec ... > > instance (Error e, Monad m) => MonadError e (ErrCPS e m) where > throwError = errCPS > catchError m f = ErrCPS $ \err good -> runErrCPS m (\e -> runErrCPS (f e) > err good) good > > > -- * MTL stuff > instance MonadTrans (ErrCPS e ) where lift m = ErrCPS $ \_ good -> m >>= good > instance (MonadIO m) => MonadIO (ErrCPS e m ) where liftIO = lift . liftIO > Random utility stuff > stopwatch :: IO () -> IO () > stopwatch act = do > t1 <- getFastTimeOfDay > act > t2 <- getFastTimeOfDay > putStrLn $ " Action ran in: " ++ show (t2 - t1) ++ " msec" > type FastTimeOfDay = Int > > -- | Return the current trading day. This should respect the > -- fact that the Trading Day ranges from > -- SingTime 6am (UTC -02:00) to SST 5:59 am (UTC -1:59). > getTradingDay :: IO Day > getTradingDay = error "getTradingDay undefined" > > getFastTimeOfDay :: IO FastTimeOfDay > getFastTimeOfDay = getZonedTime >>= >(return . fastFromTimeOfDay . Time.localTimeOfDay . > Time.zonedTimeToLocalTime) > > timeOfDayFromFast :: FastTimeOfDay -> Time.TimeOfDay > timeOfDayFromFast fast = Time.TimeOfDay > { Time.todHour = fromIntegral (fast `div` (3600 * 1000)) > , Time.todMin = fromIntegral (fast `div` (60 * 1000)) `mod` 60 > , Time.todSec = fromRational $ (fromIntegral fast) / 1000 > } > > fastFromTimeOfDay :: Time.TimeOfDay -> FastTimeOfDay > fastFromTimeOfDay t = fromIntegral $ > ((Time.todHour t) * 360) + > ((Time.todMin t) * 6) + > (round $ 1000 * Time.todSec t) > > instance (Monad m) => Functor (ErrCPS e m) where > fmap f m = ErrCPS $ \err good -> runErrCPS m err (good . f) > > instance (Monad m) => Applicative (ErrCPS e m) where > pure = return > f <*> a = do f' <- f >a' <- a >
Re: [Haskell-cafe] What is the consensus about -fwarn-unused-do-bind ?
I'm in the camp of adding -fno-warn-unused-do-bind to my cabal files. I hate sacrificing the purity of -Wall but I have so many forkIOs in my code that I think it was the best option. Max On Apr 10, 2010, at 3:08 PM, Ivan Miljenovic wrote: > On 10 April 2010 02:07, Bryan O'Sullivan wrote: >> Personally, I find it to be tremendously noisy and unhelpful, and I always >> edit my .cabal files to turn it off. I think of it as a usability >> regression. > > Yeah, I'm very tempted to do this as well. This warning might make > sense for IO, but I think it's of less use for other monads. > > -- > Ivan Lazar Miljenovic > ivan.miljeno...@gmail.com > IvanMiljenovic.wordpress.com > ___ > 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] generalized newtype deriving allows the definition of otherwise undefinable functions
Isn't this just an extension of the notion that multi-parameter typeclasses without functional dependencies or type families are dangerous and allow for type-naughtiness? On Mar 9, 2010, at 5:45 AM, Wolfgang Jeltsch wrote: > Hello, > > some time ago, it was pointed out that generalized newtype deriving could be > used to circumvent module borders. Now, I found out that generalized newtype > deriving can even be used to define functions that would be impossible to > define > otherwise. To me, this is surprising since I thought that generalized newtype > deriving was only intended to save the programmer from writing boilerplate > code, not to extend expressiveness. > > Have a look at the following code: > >> {-# LANGUAGE >>GeneralizedNewtypeDeriving, >>MultiParamTypeClasses, >>FlexibleInstances >> #-} >> >> class Iso a b where >> >>conv :: item a -> item b >> >> instance Iso a a where >> >>conv = id >> >> newtype Wrapped a = Wrap a deriving (Iso a, Show) > > Now any value whose type contains some type t can be converted into a value > of > the type that you get if you replace t by Wrap t. Here is some code to > demonstrate this for binary operations: > >> newtype BinOp a = BinOp (a -> a -> a) >> >> convBinOp :: (a -> a -> a) -> (Wrapped a -> Wrapped a -> Wrapped a) >> convBinOp op = let BinOp op' = conv (BinOp op) in op' > > Now, you can enter > >convBinOp (*) (Wrap 5) (Wrap 3) > > into GHCi, and you will get > >Wrap 15 > > as the result. > > The point is, of course, that such conversions are not only possible for > binary operations but for arbitrary values and that these conversions are > done > by a single generic function conv. I don’t think it would be possible to > implement conv without generalized newtype deriving. > > Any thoughts? > > Best wishes, > Wolfgang > ___ > 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] Children elements with HXT
That stuffed me up for a bit. I wrote some ugly template haskell a while back to automatically generate XmlPickler instances. can send to you if you want On Dec 23, 2009, at 7:55 AM, Tony Morris wrote: > Adding (a_remove_whitespace,v_1) as a parser option when running solves > it. Silly me. > > > Tony Morris wrote: >> I am trying to parse XML using HXT following >> http://www.haskell.org/haskellwiki/HXT/Conversion_of_Haskell_data_from/to_XML >> >> Here is my XML file (way.xml): >> >> > version="3" changeset="1368552" user="Matt" uid="70"> >> >> >> >> >> The problem is when parsing, by reading the entries into the >> list held by the Way data structure, I cannot get anything but an >> empty list. >> >> Here is my parsing code: >> >> import Text.XML.HXT.Arrow >> >> newtype Way = Way { >> tags :: [Tag] >> } deriving (Eq, Show) >> >> xpWay :: PU Way >> xpWay = xpElem "way" (xpWrap (Way, tags) (xpList xpTag)) >> >> data Tag = Tag { >> k :: String, >> v :: String >> } deriving (Eq, Show) >> >> xpTag :: PU Tag >> xpTag = xpElem "tag" (xpWrap (uncurry Tag, k &&& v) (xpPair (xpAttr >> "k" xpText) (xpAttr "v" xpText))) >> >> When I run, I get the following result: >> >> Main> run = runX (xunpickleDocument xpWay [] "way.xml") >> [Way {tags = []}] >> >> Why is the tags list empty instead of holding two entries? >> >> >> > > -- > Tony Morris > http://tmorris.net/ > > > ___ > 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] Problem with cabal install zlib
I actually ran into this problem last night. Here's my workaround (note that it involves downgrading to zlib-0.5.0.0 1) unregister the zlib-0.5.2.0 package (prompt> ghc-pkg unregister zlib-0.5.2.0) 2) rebuild and install cabal-install: prompt> tar -zxvf ~/.cabal/packages/hackage.haskell.org/cabal-install/0.6.4/cabal-install-0.6.4.tar.gz prompt> cd cabal-install-0.6.4 prompt> runghc Setup.hs configure --user && runghc Setup.hs build && runghc Setup.hs install Note that this requires that you still have zlib-0.5.0.0 installed. Also your paths and options for configuring may vary. But, this worked for me. Max On Dec 19, 2009, at 5:39 PM, Ozgur Akgun wrote: > Thanks for the feedback. > > I guess the following part is the problematic part: (But I've no idea how to > resolve it) > > Creating dist/build (and its parents) > Creating dist/build/autogen (and its parents) > Preprocessing library zlib-0.5.2.0... > Creating dist/build/Codec/Compression/Zlib (and its parents) > /usr/bin/hsc2hs --cc=/usr/bin/gcc --ld=/usr/bin/gcc > --cflag=-D__GLASGOW_HASKELL__=610 --lflag=-lz > --cflag=-I/Users/ozgurakgun/.cabal/lib/bytestring-0.9.1.5/ghc-6.10.4/include > --cflag=-I/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/base-4.1.0.0/include > > --cflag=-I/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/include > --lflag=-L/Users/ozgurakgun/.cabal/lib/bytestring-0.9.1.5/ghc-6.10.4 > --lflag=-L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/base-3.0.3.1 > > --lflag=-L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/syb-0.1.0.1 > > --lflag=-L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/base-4.1.0.0 > > --lflag=-L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/integer-0.1.0.1 > > --lflag=-L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4/ghc-prim-0.1.0.0 > --lflag=-L/Library/Frameworks/GHC.framework/Versions/610/usr/lib/ghc-6.10.4 > --lflag=-lm --lflag=-lffi --lflag=-lgmp --lflag=-ldl -o > dist/build/Codec/Compression/Zlib/Stream.hs Codec/Compression/Zlib/Stream.hsc > Only one output file may be specified > cabal: Error: some packages failed to install: > zlib-0.5.2.0 failed during the building phase. The exception was: > exit: ExitFailure 1 > > > 2009/12/19 Duncan Coutts > On Fri, 2009-12-18 at 23:01 +, Ozgur Akgun wrote: > > Hi, > > > > When I run cabal install zlib or cabal upgrade zlib I get the > > following error: > > > > Resolving dependencies... > > Configuring zlib-0.5.2.0... > > Preprocessing library zlib-0.5.2.0... > > Only one output file may be specified > > We'll need more details here. Try running with -v2 or -v3. It should say > what command it's running. > > Duncan > > > > > -- > Ozgur Akgun > ___ > 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-cafe] ATTN: Singapore based Haskellers - Singapore FP Users Group First Meeting
We are organizing a Functional Programming Users Group in Singapore and our first meeting is Monday, November 2nd at 6 pm. We will meet initially in the Lobby of 8 Shenton Way. Map: http://bit.ly/1PzqlB -or- http://maps.google.com/maps?f=q&source=s_q&hl=en&geocode=&q=8+Shenton+Way,+Singapore+068811&sll=37.0625,-95.677068&sspn=37.325633,79.101563&ie=UTF8&hq=&hnear=8+Shenton+Way,+Singapore+068811&ll=1.276047,103.847408&spn=0.01152,0.019312&z=16&iwloc=A If you have any trouble, please feel free to call me at +65-9329-6139 Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC devs
It is pretty amazing what such a small coterie of devs has accomplished in GHC. Compare this to the thousands that work on GCC/ javac/csc and vis studio etc. So, once again, kudos. max On Oct 16, 2009, at 2:30 AM, Andrew Coppin wrote: Daniel Peebles wrote: Well-Typed is in the UK too :) Really? Cool! I wonder where... Oh, Oxford. So also not far from me. However, given that I can't even construct a simple sentence correctly... On Thu, Oct 15, 2009 at 1:52 PM, Andrew Coppin wrote: Sometimes I have these delusions that I should go ever there and see if they'll hire me... ...I think we can safely conclude that nobody is going to be interested in hiring me. :-/ ___ 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-cafe] FP Market Place (was Market Place for Haskell development teams?)
Haskell, and FP languages more broadly, are finding a pretty solid niche in small scale, but technically demanding and lucrative projects. Financial modeling and analytics are the first thing that comes to mind. The work of Galois, Atom, etc also sort of fit this mold. While the people on this list are clearly leaning towards Haskell, this is a niche that Haskell shares with OCaml, Erlang, and even Scala and Clojure. Perhaps, combining efforts with those communities (call it lambdajobs or something) would help get closer to a critical mass and aid cross-pollination between communities. Considering the salaries and value-add with skilled FP programmers, and the difficulty in finding them, this could even be a profitable venture in the long run if employers are charged for successful placements or for ads once we get going. Just my 2¢ Max On Oct 1, 2009, at 11:56 AM, Curt Sampson wrote: On 2009-09-29 13:18 +0200 (Tue), Alberto G. Corona wrote: What is the vehicle that haskell can use to enter the mainstream?. Actually, I have one more thought on that: wait. I'd had the impression that Haskell was becoming fairly well known (if not yet heavily used, in comparison to languages like Java), but I just ran across some hard evidence for this. In the 32 languages ranked on http://www.langpop.com/ , Haskell consistently comes down near the bottom in the various rankings of use. (But hey, we're not so weird we're not in there!) But if you look down near the bottom, at the chart labeled "Normalized Discussion Site Results," you'll notice that Haskell comes out sixth. Even trying to be more fair to the mainstream, and changing the weighting to drop Lambda the Ultimate completely (after all, they're just a bunch of academic wankers, right?) and bring IRC down to a contribution of 0.5 instead of 1 (apparently those academic wankers have lots of time to chat online), Haskell still comes out tenth, with a score over a third that of the leader, Java, and close to half that of PHP and C (2nd and 3rd place, respectively). We've also got at least one undeniably good, production-quality compiler (which is more than PHP or Ruby can say), and have sold many tens of thousands, perhaps even hundreds of thousands, of books. At this point, I don't think many people (John A. De Goes excepted) are looking at people writing major applications in Haskell as if they're aliens living on another planet. Haskell is in the mainstream already as far as being taken seriously; most of the complaints I'm seeing seem to be grasping at the same kinds of straws that the anti-Java guys were back in the late '90s. ("It's hopeless if it uses garbage collection.") We've even got our own over-hyped, under-utilized supposed benefit ("it's good for multicore"). The main whinging seems to be about libraries, of which we have "only" 1585 on hackage. Compare with RubyForge, which has 2059 projects in "beta" or better status, or 2961 if we include "alpha" as well. The Ruby Application Archive has 1768 projects; I have no idea how much overlap there is, or how many of these are real. I think we just need to sit tight for a couple of years. cjs -- Curt Sampson +81 90 7737 2974 Functional programming in all senses of the word: http://www.starling-software.com ___ 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] Request for Comments - hscurrency 0.0.1
@Jason I'm not sure what you mean about exposing the type information. Unless you mean that each currency would be a separate type somehow. While this is a similar problem to the dimensional issue, the problem is that the FX rates are changing all the time. While the conversion between a meter and a foot is always constant, with FX rates thats not the case. So 2ft + 3m is always a well defined value but something like USD 1 + JPY 1 gives a function of the USDJPY exchange rate, not a constant value. @ Antoine I'll add some comments. you're right that doubles are not typically used nor would they be in a finished product. for the time being, however, I dont know if its better to use Ratio's, Fixed's or what, so just settled on the most straightforward for now. On Aug 16, 2009, at 1:26 AM, Jason Dagit wrote: On Sat, Aug 15, 2009 at 5:15 AM, Max Cantor wrote: Hi all, I'm putting together some simple tools to do safe calculations on different currencies. For instance, making sure that you dont add something like 5 USD + 10 JPY without doing a proper conversion. I've put up some code on google code which probably explains what I'm trying to do more succinctly than this email. I'm curious what poeple think about the library, its the first haskell code I've written for the purpose of sharing and I intend to add it to hackage once I finalize the interface a bit more. The code is at: http://bit.ly/1Cjjlj I'm very open to suggestions on improving the interface. RIght now its very simple and straightforward but potentially limited. Right now it looks like you have taken the approach of embedded domain specific language. You have not exposed the currency units to the type system. Therefore you rely on the rules of your embedded language to do proper conversions. Have you considered exposing the type information to the type checker? A similar question came up recently on a Portland functional programming mailing list and my reply can be found here: http://groups.google.com/group/pdxfunc/tree/browse_frm/month/2009-08/5c565768ecf30c57?rnum=1&_done=%2Fgroup%2Fpdxfunc%2Fbrowse_frm%2Fmonth%2F2009-08%3F#doc_5c565768ecf30c57 The experimental code which resulted is here: http://gist.github.com/165691 You may also want to look at the dimensional package: http://code.google.com/p/dimensional/ Jason ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Request for Comments - hscurrency 0.0.1
Hi all, I'm putting together some simple tools to do safe calculations on different currencies. For instance, making sure that you dont add something like 5 USD + 10 JPY without doing a proper conversion. I've put up some code on google code which probably explains what I'm trying to do more succinctly than this email. I'm curious what poeple think about the library, its the first haskell code I've written for the purpose of sharing and I intend to add it to hackage once I finalize the interface a bit more. The code is at: http://bit.ly/1Cjjlj I'm very open to suggestions on improving the interface. RIght now its very simple and straightforward but potentially limited. I originally wrote it so that the Prc type would be an instance of several numerical classes but eventually stripped that out as it required returning undefined in several cases (such as calling toIntegral on a Prc which was a composite of several currencies). I felt it was better to avoid having partial functions.. Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Haskell2Xml - Suggest looking at HXT
Hi Dmitry, I've been using HXT and its XmlPickler class for encoding and decoding between XML <-> Haskell types. It takes a while to wrap your brain around the arrows based API for HXT (something I'm still working on) but it seems to be quite powerful and well maintained. Also, I've written some Template Haskell code to derive instances for the XmlPickler class (so that types can automatically be encoded and decoded as XML. Its not pretty, has bugs, and is far from perfect but I can send that to you if you'd like a way to get stared. Max On Aug 7, 2009, at 7:04 PM, Dmitry Olshansky wrote: Well, great thanks for interesting links. But definitely at first I need a time to try to understand what Generic Haskell and EMGM are. Does it stronger than Template Haskell? Could it be explained briefly and simplistic for first impression? Could it be compared with SYB or TH? Would it be applied to realisation of translation or to target Haskell code? Regards, Dmitry 2009/8/7 Sean Leather On Fri, Aug 7, 2009 at 12:05, John Lask wrote: the paper: Scripting XML with Generic Haskell Frank Atanassow, Dave Clarke and Johan Jeuring October 14, 2003 describes a translation from XML Schema to Haskell data types (like dtd2haskell) in generic haskell, I believe that the code for the tool described may also be available, how hard it would be to migrate over to vanilla haskell+generics is another question It looks like this almost might work in EMGM. They use a Label in addition to all the other representation structure elements. EMGM doesn't have a Label, but it might be useful to add it... With any needed changes such as the Label done, migrating this Generic Haskell code to EMGM would not be difficult. Sean ___ 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: Re[2]: [Haskell-cafe] What to say about Haskell?
Any chance of renaming it to "Advocacy"? On Jul 14, 2009, at 11:42 PM, Cristiano Paris wrote: On Tue, Jul 14, 2009 at 5:12 PM, Cristiano Paris wrote: ... Why don't we create a specific Wiki page about "Haskell advocation", http://haskell.org/haskellwiki/Advocation Cristiano ___ 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-cafe] Goldman Sachs - your home for OCaml and Erlang?
I know that this is a bit off topic, but thought it would interest several readers. Apparently, GS, which. AFAIK, doesn't make a lot of noise in the FP space compared to some other banks, does use some FP: http://www.zerohedge.com/article/aleynikov-code-dump-uncovered ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Text.JSON, Speed and Bytestrings
Hi Cafe, I am using the Text.JSON library to [un]marshall messages passed over the network and was wondering if the speed would be significantly improved by either changing the code or adding a module to implement the same functionality using Bytestrings instead of classical strings? If the consensus is that it would be worth it, I'll look into adding that code.. Thanks, Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Leksah works!
I emphatically second this.. (except for using vim instead of emacs) -Max On Jul 1, 2009, at 12:03 AM, David Leimbach wrote: I would love to have a standalone Mac OS X compatible build to try. As it stands, I have not been successful getting a Cocoa/Carbon GTK running on Leopard, and can't afford the time to fight with making it work. I too typically use Emacs, but also like to use Yi once in a while as well. Dave On Tue, Jun 30, 2009 at 7:28 AM, jutaro wrote: As Leksah developer I approve your comment. Even better we will soon have a new release that integrates GHCi and a !visual debugger! plus other useful features like much enhanced text search with regex and grep and enhanced GUI framework with a tentative support for multiple screens. So stay tuned and we appreciate help of any kind. Jürgen jkff wrote: > > Hi. > Quite a while ago I launched Leksah and couldn't get anything done at > all; so I thought it is probably never be completed and abandoned > attempts to find an IDE for Haskell. > > However, 3 days ago I launched the new version and it works fantastic! > It has an IntelliSense popup with type annotations, a module browser, > build-on-the-fly and other things, even though I used it only for 15 > minutes (then the ICFP contest began, where I wrote in Python and > Java). > > Main point: It seems a vastly more convenient IDE for Haskell than vim > (don't know about emacs-mode). > > So, I'd like to encourage haskellers to install it and give it a try :) > > -- > Eugene Kirpichov > Web IR developer, market.yandex.ru > ___ > Haskell-Cafe mailing list > Haskell-Cafe@haskell.org > http://www.haskell.org/mailman/listinfo/haskell-cafe > > -- View this message in context: http://www.nabble.com/Leksah-works%21-tp24266240p24272909.html Sent from the Haskell - Haskell-Cafe mailing list archive at Nabble.com. ___ 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-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Generic polyvariadic printf in Haskell98
To be fair, isn't the printf typing in ocaml a massively ugly hack to the type system? Isn't there an example in the template haskell tutorial that gives a typesafe, clean generic printf function? Max On Jun 5, 2009, at 4:29 PM, Erik de Castro Lopo wrote: o...@okmij.org wrote: Still, the code is a bit unsatisfactory because of the appearances of "error" in pr_aux functions. The errors like passing too many or too few arguments to printf (as demanded by the format specification) are caught only at run-time. We can certainly do better. I'd love to see it. Coming from Ocaml one of the things I miss is compile time checking of printf arguments. Erik -- -- Erik de Castro Lopo http://www.mega-nerd.com/ ___ 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-cafe] HXT XmlPicklers - TH Derivation
Hi, I have developed some simple TH code to automatically derive XmlPickler instances for my types and if there is interest, I will clean it up and submit a patch. Its not complete, but is a start. Any interest? Max ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Pattern match question in HAXML code
Going through the instances for HTypeable (http://www.haskell.org/HaXml/HaXml/src/Text/XML/HaXml/TypeMapping.html#toHType ) I saw the following instance for Either a b. My question is, why doesn't the pattern match in the where clause always fail? If (Left x) = m does not fail, doesn't that imply that m is a Left x and therefore the (Right y) = m should fail? thanks, max instance (HTypeable a, HTypeable b) => HTypeable (Either a b) where toHType m = Defined "Either" [hx, hy] [ Constr "Left" [hx] [hx] {-Nothing-} , Constr "Right" [hy] [hy] {-Nothing-}] where (Left x) = m (Right y) = m hx = toHType x hy = toHType y ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe