Re: [Haskell-cafe] iPhone/Android and Haskell [Was: Embedded funcional programming?]
Our best bet is to compile to ARM native code and then use the NDK to talk to the Java APIs. Cheers. ~Liam ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re[2]: [Haskell-cafe] GHC, odd concurrency space leak
Hello Bertram, Sunday, April 18, 2010, 3:36:31 AM, you wrote: This expands as always a = a always a = a a always a = a a a always a ... where each application is represented by a newly allocated object (or several, I have not looked at it in detail) on the heap. why you think so? i always thought that in ghc just sequentially executes statements, the RealWorld magic exists only at compile-time -- Best regards, Bulatmailto:bulat.zigans...@gmail.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Functional Dependencies conflicts
There must be some kind of a private joke I don't get... BTW, all you've said is pretty scaring... It's strange I can't declare a generic instance for Binary types... I thought I was trying to do something quite common in Haskell. Apparently I'm still a young padawan with many things to learn. Anyway, it's not the first time I get worked up with multi-param typeclasses and functionnal dependencies 2010/4/18 Ivan Lazar Miljenovic ivan.miljeno...@gmail.com Daniel Fischer daniel.is.fisc...@web.de writes: Wow. Makes me wonder what quicksilver says about IncoherentInstances. Not quicksilver, but according to lambdabot: ivanm @quote incoherent lambdabot sproingie says: * enables IncoherentInstances and ends up with Sarah Palin in his living room -- 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] GHC, odd concurrency space leak
Bulat Ziganshin wrote: This expands as always a = a always a = a a always a = a a a always a ... where each application is represented by a newly allocated object (or several, I have not looked at it in detail) on the heap. why you think so? At the time I wrote this, because it explains the space leak and because the space leak disappears if I address this precise issue. But I've since verified the theory by inspecting Core and Cmm code. i always thought that in ghc just sequentially executes statements, the RealWorld magic exists only at compile-time Yes, that's what happens once () gets actually executed in IO. But this fact and the RealWorld token have nothing to do with the whole issue, which is about accumulating a chain of IO actions that have not yet been executed. I'll continue to write a b, which in IO, modulo newtypes, stands for \(s :: RealWorld#) - case a s of (s', _) - b s' The fact that the state token disappears at runtime does not change that this is a closure, represented by a (function) heap node. So we have some IO action let x = always a Now we run x, but also hold onto the corresponding thunk to reuse it later, say let x = always a in x x In order to execute that, x is forced, and evaluated to let x = let x' = always a in a x' in x x or, equivalently, let x' = always a x = a x' in x x Then the first step of the IO action is performed, resulting in let x' = always a x = a x' in x' x And now the same reduction happens again for x', let x2 = always a x' = a x2 x = a x' in x2 x and then again for x2, let x3 = always a x2 = a x3 x' = a x2 x = a x' in x2 x and so on, ad infinitum. This leaks memory because x, x', x2 etc. can't be garbage collected - there's still a reference to x. Note that this also explains why the space leak disappears if we remove the 'forever' in the spawner thread in the original example. This would not happen if the 'always a' was reused, i.e. if the code tied a knot as let act = a act in act does, but as you can see in the Core (and even Cmm if you look closely enough) that does not happen in those cases where the code leaks memory. HTH, Bertram ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Embedded funcional programming?
Hello, I'm new to this, so the only problems I see are finding a compiler that targets the platform (ARM7, for instance, or others) and uploading the compiled firmware to the device. I used Hume [1] to program Mindstorms NXT robots (ARM7) as well as Tmote Sky sensors (MSP430). In both cases I ported the HAM virtual machine and interpreted bytecode. In the case of NXT I used the hardware layer of leJOS [2], simply ripping out the JVM and replacing it with HAM. As for the Tmote Sky, the VM sat on top of Contiki [3], so it was possible to send HAM bytecode over the air, and the sensor would intercept it, stop the currently running program and execute the new one. Hume can also be compiled directly to C, and I got it to run on a home-brew LPC2106 based embedded platform (also with an ARM7 core) we use in education. The main problem was the size of the generated code. See [4] for details. My overall impression is that Hume could be a very nice language to program embedded systems with, given proper tool support (for starters, it's really crying for a visual editor) and a high-quality compiler. Gergely [1] http://www-fp.cs.st-andrews.ac.uk/hume/index.shtml [2] http://lejos.sourceforge.net/ [3] http://www.sics.se/contiki/ [4] http://www-fp.cs.st-andrews.ac.uk/hume/papers/pg_thesis/ -- http://www.fastmail.fm - Email service worth paying for. Try it for free ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] GHC Api typechecking
Hi, I checked out how Hint is doing it, but unfortunately they're calling a function in the GHC api's interactive part to typecheck a single statement, much like :t in ghci, So I can't use it to typecheck whole modules. I've tried working around not being able to construct a TargetId but ran into another wall. I can't find anyway to do dependency analysis on the in-memory target, so the dependency graph would be empty which is ofcourse a big problem. Does anyone know if Leksah uses the GHC api for typechecking? And if it only gives type errors after you save a file? The code I've been trying is typeCheckStringOnly :: String - IO (ApiResults Bool) typeCheckStringOnly contents = handleSourceError processErrors $ runGhc (Just libdir) $ do buffer - liftIO $ stringToStringBuffer contents clock - liftIO getClockTime dflags - getSessionDynFlags setSessionDynFlags dflags let srcLoc = mkSrcLoc (mkFastString internal:string) 1 1 dynFlag = defaultDynFlags state= mkPState buffer srcLoc dynFlag parsed = unP Parser.parseModule state pkgId= stringToPackageId internal name = mkModuleName Unknown mod' = mkModule pkgId name location = ModLocation Nothing summary = ModSummary mod' HsSrcFile location clock Nothing [] [] dynFlag Nothing (\a-setSession $ a { hsc_mod_graph = [summary] }) = getSession case parsed of PFailed _ _- return $ ApiOk False POk newstate mdata - do let module' = ParsedModule summary mdata check - typecheckModule module' return $ ApiOk True this fails with a ghc panic : panic! (the 'impossible' happened) (GHC version 6.12.1 for i386-unknown-mingw32): no package state yet: call GHC.setSessionDynFlags Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug :( Cheers, Phyx -Original Message- From: Gwern Branwen [mailto:gwe...@gmail.com] Sent: Saturday, April 17, 2010 20:59 To: Phyx Subject: Re: [Haskell-cafe] GHC Api typechecking On Sat, Apr 17, 2010 at 1:49 PM, Phyx loneti...@gmail.com wrote: Hi all, I was wondering if someone knows how to do the following: I’m looking to typecheck a string using the GHC Api, where I run into problems is that I need to construct a Target, but the TargetId only seem to reference physical files. Ofcourse I can write the string to a file and typecheck that file, but I would like to do it all in memory and avoid IO if possible. Does anyone know if this is possible? For the record I’m trying to create the target as follows createTarget :: String - IO Target createTarget content = do clock - getClockTime buffer - stringToStringBuffer content return $ Target { targetId = TargetModule (mkModuleName string:internal) ß problem , targetAllowObjCode = True , targetContents = Just (buffer,clock) } typeCheckStringOnly :: String - IO (ApiResults Bool) typeCheckStringOnly contents = handleSourceError processErrors $ runGhc (Just libdir) $ do dflags - getSessionDynFlags setSessionDynFlags dflags target - liftIO $ createTarget contents addTarget target load LoadAllTargets let modName = mkModuleName string:internal ß problem again, don’t know how to create the dependency graph then. graph - depanal [modName] True (\a-setSession $ a { hsc_mod_graph = graph }) = getSession value - fmap typecheckedSource (typeCheck modName) return $ ApiOk True Cheers, Phyx Have you looked at how the Hint package does things? -- gwern ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Embedded funcional programming?
I'm new to this, so the only problems I see are finding a compiler that targets the platform (ARM7, for instance, or others) and uploading the compiled firmware to the device. You might find that the extra RAM requirements for a non-C language becomes a problem - especially when it manifestly translates to extra euros/dollars on the BOM costs (aka bill-of-materials). About 15 years ago, I wrote my PhD Thesis on the topic of Functional Programming and Embedded Systems. ftp://ftp.cs.york.ac.uk/pub/malcolm/thesis.html Back then, I was using the Gofer interpreter (a forerunner of Hugs), compiling Haskell to bytecode, and targetted at the M68000. Bytecode is one important way to reduce the RAM requirements. An interpreter can also be quite parsimonious with heap allocation - as I recall, I extended the embedded board from 256kb of RAM to 768kb (yes, note kilobytes, not Mb) in anticipation of heap pressure, but in the end came nowhere near needing all of that. Regards, Malcolm ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Confusions about the Haskell Platform (for Mac)
On Sun, Apr 18, 2010 at 01:46, Don Stewart wrote: leather: 2. What is the difference between Haskell and the Haskell Platform? I see one or the other in various places. To get from www.haskell.org to downloading the Mac software, I go through Download Haskell, Get the Haskell Platform Mac, and Download Haskell for Mac OS X (intel). Well, for one, we have characterized the difference between GHC and the Haskell Platform as: GHC is to the HP as Linux Kernel is to Linux Now, Haskell for newcomers might mean toolchain on my machine -- which is the Haskell Platform. Or it might mean the language. We try to ensure advertising for the HP makes it simple: Download Haskell, but documentation pages carefully describe the fact that the HP is a development environment for the Haskell language. It just occurred to me to check what Sun/Oracle does for Java. I guess what is on haskell.org is no worse than what is on http://java.com/en/download/ . But perhaps answering such questions as What is Haskell? or Why download the Haskell Platform? as well as a short blurb about the use of the terms Haskell and Haskell Platform would help. Personally, I prefer to separate the name of the language from the name of the development tools, because I think that causes unnecessary confusion. End-users do not need to care about Haskell, unlike Java since they need the JRE, so potential developers and students are the audience. This group needs the Haskell Platform for developing with Haskell, and having the tools referred to as Haskell Platform is clear enough (imho) without having to call the tools Haskell. In the end, whatever the choice, the language on haskell.org should probably be somewhat more consistent. Sean ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Confusions about the Haskell Platform (for Mac)
Sean Leather leat...@cs.uu.nl writes: Personally, I prefer to separate the name of the language from the name of the development tools, because I think that causes unnecessary confusion. End-users do not need to care about Haskell, unlike Java since they need the JRE, so potential developers and students are the audience. This group needs the Haskell Platform for developing with Haskell, and having the tools referred to as Haskell Platform is clear enough (imho) without having to call the tools Haskell. I think the partial confusion here is that most newer languages have the same name as their defacto implementation (Python [though the implementation is technically CPython], Perl, Ruby, etc.). Whilst Haskell has other implementations apart from GHC, none of the others are as featureful, etc. So pretty much if you want Haskell, then you want GHC. -- 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] Functional Dependencies conflicts
On Apr 18, 2010, at 11:01 AM, Limestraël wrote: It's strange I can't declare a generic instance for Binary types... I thought I was trying to do something quite common in Haskell. A common workaround is to define a newtype like this newtype GenericBinary a = GB { fromGB :: a } and an instance like this instance Binary a = Binarizable (GenericBinary a) a where toBinary = fromGB which only needs FlexibleInstances enabled. You can then 'tag' Binary types for which you want to use the generic default instance above with the GB newtype constructor. Whether this is less of a pain than implementing a Binarizable instance for each Binary type is a different question.. Sebastian -- Underestimating the novelty of the future is a time-honored tradition. (D.G.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Functional Dependencies conflicts
On Sun, Apr 18, 2010 at 5:01 AM, Limestraël limestr...@gmail.com wrote: There must be some kind of a private joke I don't get... BTW, all you've said is pretty scaring... And somewhat exaggerated, of course. Reasonable uses exist for all three extensions, but they're firmly in the category of avoid unless you know what you're doing. Well, at least two of them are, I'm not sure when IncoherentInstances is a good idea (if ever). It's worth experimenting with them in some toy code for a while before trying to use them for real. In any case, if you do use those extensions, they can usually be isolated to some extent. A library can use them internally without requiring client code to enable them, and in an application use can be restricted to just a few modules, enabling the extensions on a per-module basis. My rule of thumb is the sausage principle--outside code should be able to act as if GHC somewhere picked up a more expressive means of specifying instance heads and/or a smarter termination checker and carry on blissfully ignorant of by what providence the instances were obtained. That is, if one eats sausage, it is best to not dwell on how it is made, so to speak. It's strange I can't declare a generic instance for Binary types... I thought I was trying to do something quite common in Haskell. Apparently I'm still a young padawan with many things to learn. Anyway, it's not the first time I get worked up with multi-param typeclasses and functionnal dependencies What you're trying to do is perfectly reasonable, unfortunately it doesn't mesh well with how type classes/instances work. A lot of the reason why the distressing extensions under discussion exist at all is working around those limitations. Type families are a start on cleaning up one aspect of the type class system--namely, the awkwardness of functional dependencies. Unfortunately, type families don't really help on the how to write generic but not completely general instances right now, and in fact are incompatible with overlapping instances, making some things impossible! I think there have been some discussions of proposals toward fixing this as well, but I'm not sure what the status of those are. - C. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] help with Haskell programming
Hello I am kinda newbie in Haskell you can help help me with some programming I am trying to make function like for example func :: (a - Bool) - (a - Bool) this function make calculation and return bool . I want to be able to make bool True when It is False and False when it is True while returning the a. Thank you -- Mujtaba Ali Alboori ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] help with Haskell programming
I'm not certain exactly what you mean, but I *think* you mean: func :: (a - Bool) - (a - Bool) func = (not .) Bob On 18 Apr 2010, at 16:35, Mujtaba Boori wrote: Hello I am kinda newbie in Haskell you can help help me with some programming I am trying to make function like for example func :: (a - Bool) - (a - Bool) this function make calculation and return bool . I want to be able to make bool True when It is False and False when it is True while returning the a. Thank you -- Mujtaba Ali Alboori ___ 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] help with Haskell programming
Hello Mujtaba, I wonder is this homework? If that's the case there is nothing wrong with asking homework related questions but they should probably be marked as such. I think the most straight forward solution will use function composition (.) and the (not) function -keith On Sun, Apr 18, 2010 at 11:35 AM, Mujtaba Boori mujtaba.bo...@gmail.com wrote: Hello I am kinda newbie in Haskell you can help help me with some programming I am trying to make function like for example func :: (a - Bool) - (a - Bool) this function make calculation and return bool . I want to be able to make bool True when It is False and False when it is True while returning the a. Thank you -- Mujtaba Ali Alboori ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- keithsheppard.name ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: US Patent for the idea ...
On Sat, 17 Apr 2010 23:33:48 +0100, you wrote: I think in all fairness to examiners that in a way they have an impossible job due to the fact that what is a clever idea to one programmer will be a trivial idea to another: the field is so huge and people have such different experiences. In US patent law, algorithms themselves were deemed unpatentable quite some time ago (I believe that European patent law is more liberal in that regard, but I don't know all of the details). So a lot of the discussion concerning software patents in this country has been on whether or not software can be considered to be an invention separate from the underlying algorithms used in its construction. Since those of us who work with software realize that software is often little more than a restatement of an algorithm in a way that is suitable for a computing device to understand, it's very difficult to draw a clear line between the two. People do occasionally come up with truly novel ideas about how to perform some software task, but it seems to me that unless the novelty involves some aspect that can be separated from the algorithmic approach used, it shouldn't be patentable. For example, quicksort, though certainly novel, is purely an algorithm, so it shouldn't be patentable--it is completely independent of any tangible implementation. But a sorting technique that is optimized for large datasets that can't be held entirely in volatile memory, and explicitly takes advantage of known characteristics of disk latency, etc., could very well be patentable. -Steve Schafer ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] GHC Api typechecking
Looking at the code for GHC, it turns out that your use case is not supported. It is not allowed to have in-memory-only files. If you specify a buffer it will still try to find the module file on the disk, but it will (or at least should) use the contents from the specified string buffer. I've been thinking about changing the Finder (the part that maps module names to source files and .hi files) to use a notion of a virtual file. This way, the API client could define how and where data is stored. On 18 April 2010 11:01, Phyx loneti...@gmail.com wrote: Hi, I checked out how Hint is doing it, but unfortunately they're calling a function in the GHC api's interactive part to typecheck a single statement, much like :t in ghci, So I can't use it to typecheck whole modules. I've tried working around not being able to construct a TargetId but ran into another wall. I can't find anyway to do dependency analysis on the in-memory target, so the dependency graph would be empty which is ofcourse a big problem. Does anyone know if Leksah uses the GHC api for typechecking? And if it only gives type errors after you save a file? The code I've been trying is typeCheckStringOnly :: String - IO (ApiResults Bool) typeCheckStringOnly contents = handleSourceError processErrors $ runGhc (Just libdir) $ do buffer - liftIO $ stringToStringBuffer contents clock - liftIO getClockTime dflags - getSessionDynFlags setSessionDynFlags dflags let srcLoc = mkSrcLoc (mkFastString internal:string) 1 1 dynFlag = defaultDynFlags state = mkPState buffer srcLoc dynFlag parsed = unP Parser.parseModule state pkgId = stringToPackageId internal name = mkModuleName Unknown mod' = mkModule pkgId name location = ModLocation Nothing summary = ModSummary mod' HsSrcFile location clock Nothing [] [] dynFlag Nothing (\a-setSession $ a { hsc_mod_graph = [summary] }) = getSession case parsed of PFailed _ _ - return $ ApiOk False POk newstate mdata - do let module' = ParsedModule summary mdata check - typecheckModule module' return $ ApiOk True this fails with a ghc panic : panic! (the 'impossible' happened) (GHC version 6.12.1 for i386-unknown-mingw32): no package state yet: call GHC.setSessionDynFlags Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug :( Cheers, Phyx -Original Message- From: Gwern Branwen [mailto:gwe...@gmail.com] Sent: Saturday, April 17, 2010 20:59 To: Phyx Subject: Re: [Haskell-cafe] GHC Api typechecking On Sat, Apr 17, 2010 at 1:49 PM, Phyx loneti...@gmail.com wrote: Hi all, I was wondering if someone knows how to do the following: I’m looking to typecheck a string using the GHC Api, where I run into problems is that I need to construct a Target, but the TargetId only seem to reference physical files. Ofcourse I can write the string to a file and typecheck that file, but I would like to do it all in memory and avoid IO if possible. Does anyone know if this is possible? For the record I’m trying to create the target as follows createTarget :: String - IO Target createTarget content = do clock - getClockTime buffer - stringToStringBuffer content return $ Target { targetId = TargetModule (mkModuleName string:internal) ß problem , targetAllowObjCode = True , targetContents = Just (buffer,clock) } typeCheckStringOnly :: String - IO (ApiResults Bool) typeCheckStringOnly contents = handleSourceError processErrors $ runGhc (Just libdir) $ do dflags - getSessionDynFlags setSessionDynFlags dflags target - liftIO $ createTarget contents addTarget target load LoadAllTargets let modName = mkModuleName string:internal ß problem again, don’t know how to create the dependency graph then. graph - depanal [modName] True (\a-setSession $ a { hsc_mod_graph = graph }) = getSession value - fmap typecheckedSource (typeCheck modName) return $ ApiOk True Cheers, Phyx Have you looked at how the Hint package does things? -- gwern ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Push the envelope. Watch it bend. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] problem with cabal on snow leopard
that is good to know! thanks -carter On Sun, Apr 18, 2010 at 1:09 AM, Ivan Lazar Miljenovic ivan.miljeno...@gmail.com wrote: Carter Schonwald carter.schonw...@gmail.com writes: the deleting .ghc/ solves that problem, but another problem i've had is that when trying to build gtk2hs, I'm unable to find the package.conf file that apparently needs to be modfied, and only a package.conf.d folder are these somehow the same thing or where is it hidden/what am i overlooking? There is as yet no release of gtk2hs that works with GHC 6.12.1. -- 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] Re: help with Haskell programming
Thanks for helping me but I have another problem (sorry for asking) . I tried to figure it out . how about if I want to compare two kind with () (||) for func :: (a - Bool) - (a - Bool) - (a - Bool) I tried some thing like func = ((||) .) This is the annoying part about Haskell . I can not understand composition . On Sun, Apr 18, 2010 at 4:35 PM, Mujtaba Boori mujtaba.bo...@gmail.comwrote: Hello I am kinda newbie in Haskell you can help help me with some programming I am trying to make function like for example func :: (a - Bool) - (a - Bool) this function make calculation and return bool . I want to be able to make bool True when It is False and False when it is True while returning the a. Thank you -- Mujtaba Ali Alboori -- Mujtaba Ali Alboori ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: help with Haskell programming
Using composition can be tricky with more than one arg. I just want to be sure you're not really looking for something like: func :: (a - Bool) - (b - Bool) - (a - b - Bool) keeping with your given type I think you're looking for something like: func f1 f2 x = (f1 x) || (f2 x) I'm sure there is a nice way to do this with function composition but I still find composition less intuitive than explicit args in cases like this. On Sun, Apr 18, 2010 at 1:00 PM, Mujtaba Boori mujtaba.bo...@gmail.com wrote: Thanks for helping me but I have another problem (sorry for asking) . I tried to figure it out . how about if I want to compare two kind with () (||) for func :: (a - Bool) - (a - Bool) - (a - Bool) I tried some thing like func = ((||) .) This is the annoying part about Haskell . I can not understand composition . On Sun, Apr 18, 2010 at 4:35 PM, Mujtaba Boori mujtaba.bo...@gmail.com wrote: Hello I am kinda newbie in Haskell you can help help me with some programming I am trying to make function like for example func :: (a - Bool) - (a - Bool) this function make calculation and return bool . I want to be able to make bool True when It is False and False when it is True while returning the a. Thank you -- Mujtaba Ali Alboori -- Mujtaba Ali Alboori ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- keithsheppard.name ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: help with Haskell programming
This is the annoying part about Haskell . I can not understand composition . One of the ways of understanding composition (and many other functions in Haskell) is by trying to understand its type. Here it is shown by looking at the type in the interpreter GHCi. *Main :t (.) (.) :: (b - c) - (a - b) - a - c It's a function that takes three arguments, the first two of which are functions, and the third is something else. Since (.) is a polymorphic function, we can tell everything about it (if we ignore certain other features of Haskell which are not immediately relevant). To give names to things, let's say composition is declared as follows: (.) f g x = ... We know that the type of x must be the same as the type of the argument to the function f. The result type of f is the same and the input type of g. The result type of g is the result type of (.). From these observations, we know that (.) applies g to x and f to the result of that. We can even write that definition down. (.) f g x = f (g x) But, in the case of (.), we don't need to look at the definition to understand how it works. We can get all the information from the type. The next step in understanding (.) is seeing how it's used. If you want to compose two functions, you can use their types to figure out what the result is. You mentioned (.) (||), so let's look at that first. Then, we can use GHCi to verify our understanding. The type of (||) is Bool - Bool - Bool or, equivalently, Bool - (Bool - Bool) (since - is right associative). If we apply (.) to (||), then we can substitute parts of the type of (||) into the type of (.) to figure out the type of (.) (||) (which is equivalent to ((||) .). First, note the types of the two components: (.) :: (b - c) - (a - b) - a - c (||) :: Bool - (Bool - Bool) Then, since (||) is plugged into the first argument of (.), we bind the right-hand sides below (from the type of (||)) to the left-hand sides (from (.)): b = Bool c = Bool - Bool The resulting type is: (.) (||) :: (a - Bool) - a - Bool - Bool and GHCi agrees. If you are looking for something of this type, then you've found it. Otherwise, you need to rethink your definition. Regards, Sean ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: help with Haskell programming
To do this, you need not just fmap (composition), but also ap, or the combined form, liftA2: func = liftA2 (||) Bob On 18 Apr 2010, at 18:21, Keith Sheppard wrote: Using composition can be tricky with more than one arg. I just want to be sure you're not really looking for something like: func :: (a - Bool) - (b - Bool) - (a - b - Bool) keeping with your given type I think you're looking for something like: func f1 f2 x = (f1 x) || (f2 x) I'm sure there is a nice way to do this with function composition but I still find composition less intuitive than explicit args in cases like this. On Sun, Apr 18, 2010 at 1:00 PM, Mujtaba Boori mujtaba.bo...@gmail.com wrote: Thanks for helping me but I have another problem (sorry for asking) . I tried to figure it out . how about if I want to compare two kind with () (||) for func :: (a - Bool) - (a - Bool) - (a - Bool) I tried some thing like func = ((||) .) This is the annoying part about Haskell . I can not understand composition . On Sun, Apr 18, 2010 at 4:35 PM, Mujtaba Boori mujtaba.bo...@gmail.com wrote: Hello I am kinda newbie in Haskell you can help help me with some programming I am trying to make function like for example func :: (a - Bool) - (a - Bool) this function make calculation and return bool . I want to be able to make bool True when It is False and False when it is True while returning the a. Thank you -- Mujtaba Ali Alboori -- Mujtaba Ali Alboori ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- keithsheppard.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
Re: [Haskell-cafe] Re: help with Haskell programming
Thanks a lot guys you were really helpful func f1 f2 x = (f1 x) || (f2 x) is working for me On Sun, Apr 18, 2010 at 6:27 PM, Thomas Davie tom.da...@gmail.com wrote: To do this, you need not just fmap (composition), but also ap, or the combined form, liftA2: func = liftA2 (||) Bob On 18 Apr 2010, at 18:21, Keith Sheppard wrote: Using composition can be tricky with more than one arg. I just want to be sure you're not really looking for something like: func :: (a - Bool) - (b - Bool) - (a - b - Bool) keeping with your given type I think you're looking for something like: func f1 f2 x = (f1 x) || (f2 x) I'm sure there is a nice way to do this with function composition but I still find composition less intuitive than explicit args in cases like this. On Sun, Apr 18, 2010 at 1:00 PM, Mujtaba Boori mujtaba.bo...@gmail.com wrote: Thanks for helping me but I have another problem (sorry for asking) . I tried to figure it out . how about if I want to compare two kind with () (||) for func :: (a - Bool) - (a - Bool) - (a - Bool) I tried some thing like func = ((||) .) This is the annoying part about Haskell . I can not understand composition . On Sun, Apr 18, 2010 at 4:35 PM, Mujtaba Boori mujtaba.bo...@gmail.com wrote: Hello I am kinda newbie in Haskell you can help help me with some programming I am trying to make function like for example func :: (a - Bool) - (a - Bool) this function make calculation and return bool . I want to be able to make bool True when It is False and False when it is True while returning the a. Thank you -- Mujtaba Ali Alboori -- Mujtaba Ali Alboori ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- keithsheppard.name ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Mujtaba Ali Alboori ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] GHC Api typechecking
Ah, That's a shame :( I guess for now I'll just write the buffer out to disc first and switch it later on if the feature gets added. Thanks, Phyx -Original Message- From: Thomas Schilling [mailto:nomin...@googlemail.com] Sent: Sunday, April 18, 2010 18:21 To: Phyx Cc: Gwern Branwen; haskell-cafe@haskell.org Subject: Re: [Haskell-cafe] GHC Api typechecking Looking at the code for GHC, it turns out that your use case is not supported. It is not allowed to have in-memory-only files. If you specify a buffer it will still try to find the module file on the disk, but it will (or at least should) use the contents from the specified string buffer. I've been thinking about changing the Finder (the part that maps module names to source files and .hi files) to use a notion of a virtual file. This way, the API client could define how and where data is stored. On 18 April 2010 11:01, Phyx loneti...@gmail.com wrote: Hi, I checked out how Hint is doing it, but unfortunately they're calling a function in the GHC api's interactive part to typecheck a single statement, much like :t in ghci, So I can't use it to typecheck whole modules. I've tried working around not being able to construct a TargetId but ran into another wall. I can't find anyway to do dependency analysis on the in-memory target, so the dependency graph would be empty which is ofcourse a big problem. Does anyone know if Leksah uses the GHC api for typechecking? And if it only gives type errors after you save a file? The code I've been trying is typeCheckStringOnly :: String - IO (ApiResults Bool) typeCheckStringOnly contents = handleSourceError processErrors $ runGhc (Just libdir) $ do buffer - liftIO $ stringToStringBuffer contents clock - liftIO getClockTime dflags - getSessionDynFlags setSessionDynFlags dflags let srcLoc = mkSrcLoc (mkFastString internal:string) 1 1 dynFlag = defaultDynFlags state = mkPState buffer srcLoc dynFlag parsed = unP Parser.parseModule state pkgId = stringToPackageId internal name = mkModuleName Unknown mod' = mkModule pkgId name location = ModLocation Nothing summary = ModSummary mod' HsSrcFile location clock Nothing [] [] dynFlag Nothing (\a-setSession $ a { hsc_mod_graph = [summary] }) = getSession case parsed of PFailed _ _ - return $ ApiOk False POk newstate mdata - do let module' = ParsedModule summary mdata check - typecheckModule module' return $ ApiOk True this fails with a ghc panic : panic! (the 'impossible' happened) (GHC version 6.12.1 for i386-unknown-mingw32): no package state yet: call GHC.setSessionDynFlags Please report this as a GHC bug: http://www.haskell.org/ghc/reportabug :( Cheers, Phyx -Original Message- From: Gwern Branwen [mailto:gwe...@gmail.com] Sent: Saturday, April 17, 2010 20:59 To: Phyx Subject: Re: [Haskell-cafe] GHC Api typechecking On Sat, Apr 17, 2010 at 1:49 PM, Phyx loneti...@gmail.com wrote: Hi all, I was wondering if someone knows how to do the following: Im looking to typecheck a string using the GHC Api, where I run into problems is that I need to construct a Target, but the TargetId only seem to reference physical files. Ofcourse I can write the string to a file and typecheck that file, but I would like to do it all in memory and avoid IO if possible. Does anyone know if this is possible? For the record Im trying to create the target as follows createTarget :: String - IO Target createTarget content = do clock - getClockTime buffer - stringToStringBuffer content return $ Target { targetId = TargetModule (mkModuleName string:internal) ß problem , targetAllowObjCode = True , targetContents = Just (buffer,clock) } typeCheckStringOnly :: String - IO (ApiResults Bool) typeCheckStringOnly contents = handleSourceError processErrors $ runGhc (Just libdir) $ do dflags - getSessionDynFlags setSessionDynFlags dflags target - liftIO $ createTarget contents addTarget target load LoadAllTargets let modName = mkModuleName string:internal ß problem again, dont know how to create the dependency graph then. graph - depanal [modName] True (\a-setSession $ a { hsc_mod_graph = graph }) = getSession value - fmap typecheckedSource (typeCheck modName) return $ ApiOk True Cheers, Phyx Have you looked at how the Hint package does things? -- gwern ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Push the envelope. Watch it bend. ___ Haskell-Cafe mailing list
Re: [Haskell-cafe] ANNOUNCE: Agata-0.2.0
If this is to be used with QuickCheck maybe it should be named that way. eg quickcheck-agatath ? This way its found faster. Marc Weber ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: Agata-0.2.0
Wow, very cool! Thank you :) This is so helpful I'm surprised it isn't part of QuickCheck. Why isn't it? Maybe it will be eventually. It would introduce some package dependencies though, and as the version number hints it's not exactly mature code. 2010/4/18 Duane Johnson duane.john...@gmail.com: Wow, very cool! This is so helpful I'm surprised it isn't part of QuickCheck. Why isn't it? Regards, Duane Johnson On Apr 17, 2010, at 6:43 PM, Jonas Almström Duregård wrote: {-#LANGUAGE TemplateHaskell #-} import Test.QuickCheck import Test.AgataTH data X a b = X [Either a b] deriving Show data Y = Y deriving Show data Z = Z deriving Show $(agatath $ deriveall [''X,''Y,''Z]) main = sample (arbitrary :: Gen (X Y Z)) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] iPhone/Android and Haskell [Was: Embedded funcional programming?]
liamoc: Our best bet is to compile to ARM native code and then use the NDK to talk to the Java APIs. Cheers. ~Liam That's great info -- we do have an unregisterised ARM port of GHC in Debian, iirc. (And the LLVM backend can generate ARM code too) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: GUI (was: Re: [Haskell-cafe] DLL on Windows)
Am Sonntag 18 April 2010 20:59:25 schrieb Neil Mitchell: Hi, I thought this thread suggested that a cabal install wx would now work? It does, as far as I can tell. I just tried it and got: ... generated 2439 constant definitions ok. setup.exe: wx-config: does not exist That's not our fault, I think :) You need wxWidgets-2.8.*. wx-config should have been installed as part of the wxWidgets package. Is that not included in the windows-installer of wxWidgets? $ which wx-config /usr/bin/wx-config $ wx-config --help wx-config [--prefix[=DIR]] [--exec-prefix[=DIR]] [--release] [--version- full] [--list] [--selected-config] [--host=HOST] [--toolkit=TOOLKIT] [--universal[=yes|no]] [--unicode[=yes|no]] [--debug[=yes|no]] [--static[=yes|no]] [--version[=VERSION]] [--basename] [--cc] [--cppflags] [--cflags] [--cxxflags] [--rescomp] [--libs] [-- cxx] [--ld] [--linkdeps] [--utility=UTIL] [LIB ...] wx-config returns information about the wxWidgets libraries available on your system. It may be used to retrieve the information required to build applications using these libraries using --cppflags, --cflags, -- cxxflags and --libs options. snip cabal: Error: some packages failed to install: wx-0.12.1.4 depends on wxcore-0.12.1.4 which failed to install. wxcore-0.12.1.4 failed during the configure step. The exception was: ExitFailure 1 If wxHaskell could be installed with one cabal command that would be incredibly cool :-) Thanks, Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: GUI (was: Re: [Haskell-cafe] DLL on Windows)
Am Sonntag 18 April 2010 21:41:06 schrieb Daniel Fischer: wx-config should have been installed as part of the wxWidgets package. Is that not included in the windows-installer of wxWidgets? Seems it's not so. http://www.haskell.org/haskellwiki/WxHaskell/Building says Windows users should also get the Windows port of wx-config. ( http://sites.google.com/site/wxconfig/ ) Furthermore, http://www.haskell.org/haskellwiki/WxHaskell/Building#On_Windows says you can't use just any old compiler to build wxWidgets on windows, but have to use the MinGW compiler. If wxHaskell could be installed with one cabal command that would be incredibly cool :-) Well, it's just one cabal command if you have all non-Haskell requirements installed as needed. Thanks, Neil ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Move MonadIO to base
This bounced because I have different emails registered for cafe@ and libraries@, so forwarding it along to the cafe. wren ng thornton wrote: wren ng thornton wrote: Heinrich Apfelmus wrote: Anders Kaseorg wrote: This concept can also be generalized to monad transformers: class MonadTrans t = MonadTransMorph t where morph :: Monad m = (forall b. (t m a - m b) - m b) - t m a [...] However, not all control operators can be lifted this way. Essentially, while you may downgrade an arbitrary selection of t m a values you may only promote one m a in return and all have to share the same return type a . In particular, it's not possible to implement lift :: (Monad m, MonadTrans t) = m a - t m a Why not? * morph says m(t m a) is a subset of (t m a) * Monad m says we can fmap :: (a-b) - (m a-m b) * Monad (t m) says we can return :: a - t m a lift ma = morph (\k - k (fmap return ma)) Or rather, lift ma = morph (\k - join (fmap (k . return) ma)) That's what I get for typing without checking. The type of morph requires us to Church-encode things needlessly; what we mean to say is: morph (fmap return ma). Again, having m(t m a)-(t m a) is strictly more expressive than only having (m a)-(t m a) because the former may avail itself of operations/operators of t. -- Live well, ~wren ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: cabal: other-modules
Ivan Lazar Miljenovic wrote: Why are people suddenly using the term morally when they mean why doesn't this do what I think it should? None of its definitions seem to match what you mean: The usage on this thread seems a bit nonstandard, but I'm assuming it's based off the more general idiom of things being morally equivalent--- that is, things which *should* be equal because we mean for them to be (regardless of what a particular model (e.g., a programming language) says). In other words, with the right set of beliefs (i.e., moral beliefs, or the right religion) they are indeed equal, but the world is violating those beliefs somehow. The implication being that the world (model, PL,...) should be changed, rather than the beliefs. -- Live well, ~wren ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] hamming distance allocation
Hello all: I want to generate some hamming distance statistics about a set of strings. As explained in another e-mail in this list, I used the following code to call the functions: (exampl holds the list of strings of size w) filter (\x - x /= 0) $ map (uncurry hammingX) [(xs, ys) | xs - exampl, ys - exampl] I have two hamming functions: -- hamming distance for variable length strings hamming :: String - String - Int hamming x y = hamming' x y 0 where hamming' [] _ !c = c hamming' _ [] !c = c hamming' (x:xs) (y:ys) !c | x == y = hamming' xs ys c | otherwise = hamming' xs ys (c + 1) -- function posted in this mailing list hamming2 :: String - String - Int hamming2 xs ys = length (filter not (zipWith (==) xs ys)) I am executing these functions millions of times and the bottleneck of my program is in them as explained by running in profiling mode with +RTS -K400M -p -RTS The costlier function is the hamming distance COST CENTREMODULE %time %alloc hammingDistances 66.6 41.9 It says that it is performing 41% of the allocations. In the case of hamming2 the allocations go as far as 52%. I could understand that there are allocations in hamming2 because we are creating pairs, but in the case of hamming there should be no allocation. How can I execute my hamming functions without allocating memory? Best regards, Arnoldo Muller ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] iPhone/Android and Haskell [Was: Embedded funcional programming?]
On 18/04/2010, at 1:39 PM, Darrin Chandler wrote: I recently purchased an Android phone and spent a little time looking around to see if Haskellers were doing anything there, but no luck so far. Has anyone here done anything with Android? Not Haskell, but FP on Android: http://www.kablambda.org/blog/2009/07/27/functional-programming-on-android/ I don't have an Android, so all I did was a 'hello world' to see if it could be done. Tom___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: GUI (was: Re: [Haskell-cafe] DLL on Windows)
On 19 April 2010 06:06, Daniel Fischer daniel.is.fisc...@web.de wrote: If wxHaskell could be installed with one cabal command that would be incredibly cool :-) Well, it's just one cabal command if you have all non-Haskell requirements installed as needed. Exactly; it's unreasonable to suggest/assume that cabal-install can deal with non-Haskell dependencies and toolchains for you. -- 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] ANN: vcd-0.1.0
The release adds a simple VCD parser (via Parsec) and minor changes to the VCD generation API. http://hackage.haskell.org/package/vcd ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] hamming distance allocation
Am Montag 19 April 2010 01:03:14 schrieb Arnoldo Muller: Hello all: I want to generate some hamming distance statistics about a set of strings. As explained in another e-mail in this list, I used the following code to call the functions: (exampl holds the list of strings of size w) filter (\x - x /= 0) $ map (uncurry hammingX) [(xs, ys) | xs - exampl, ys - exampl] I have two hamming functions: -- hamming distance for variable length strings hamming :: String - String - Int hamming x y = hamming' x y 0 where hamming' [] _ !c = c hamming' _ [] !c = c hamming' (x:xs) (y:ys) !c | x == y = hamming' xs ys c | otherwise = hamming' xs ys (c + 1) -- function posted in this mailing list hamming2 :: String - String - Int hamming2 xs ys = length (filter not (zipWith (==) xs ys)) I am executing these functions millions of times and the bottleneck of my program is in them as explained by running in profiling mode with +RTS -K400M -p -RTS The costlier function is the hamming distance COST CENTREMODULE %time %alloc hammingDistances 66.6 41.9 It says that it is performing 41% of the allocations. In the case of hamming2 the allocations go as far as 52%. Allocations are cheap, so that's not necessarily a problem. More important is, what's the maximum residency and how much is copied during GC? Are you compiling with -O2 ? I could understand that there are allocations in hamming2 because we are creating pairs, but in the case of hamming there should be no allocation. Why not? I don't know how GHC counts allocations, but everytime you go from (x:xs) to xs, you need a new pointer to the tail. If that counts as allocation, hamming must allocate a lot, too. How can I execute my hamming functions without allocating memory? Best regards, Arnoldo Muller ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] vector recycling
On 18/04/2010, at 08:07, Ben wrote: On Fri, Apr 16, 2010 at 11:19 PM, Roman Leshchinskiy r...@cse.unsw.edu.au wrote: That said, it would be quite possible to provide something like the following: fold_inplace :: Vector v a = (v a - b - v a) - v a - [b] - v a as far as i understand there would be two ways of writing such a function : 1) to use mutable vectors monadically underneath and hide them inside some kind of unsafeX, or 2) to give a specialized fold with sufficient hints to the compiler to use the rewriting framework. Right, I meant 2. I'm not saying it's necessarily a good idea, just that it would be possible. This could use the recycling framework to safely do as much in-place as possible while still preserving a purely functional interface. I have to think about it. Really, this looks like just a poor man's substitute for linear types. although i am supposed to know something about category theory, since my training is in math, i don't know about girard's later work. is there a short precis you can give (or a pointer?) This is a nice introduction: http://homepages.inf.ed.ac.uk/wadler/papers/linear/linear.ps Also, Clean's uniqueness types are quite similar. Roman ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: GUI (was: Re: [Haskell-cafe] DLL on Windows)
On 18/04/2010, Daniel Fischer daniel.is.fisc...@web.de wrote: Am Sonntag 18 April 2010 21:41:06 schrieb Daniel Fischer: wx-config should have been installed as part of the wxWidgets package. Is that not included in the windows-installer of wxWidgets? Seems it's not so. http://www.haskell.org/haskellwiki/WxHaskell/Building says Windows users should also get the Windows port of wx-config. ( http://sites.google.com/site/wxconfig/ Sadly, the Windows port of wxWidgets doesn't contain wx-config (all of the Unix variants have it - it's a shell script), which is a major problem as this by far the simplest way for the build system to work out the options used to build wxWidgets. The Windows port of wx-config is an attempt to fix this problem, but only currently supports gcc, hence the restriction to using MinGW (although I guess Cygwin would probably work). If wxHaskell could be installed with one cabal command that would be incredibly cool :-) Well, it's just one cabal command if you have all non-Haskell requirements installed as needed. An option I am looking at is creating a basic Windows installer for wxHaskell which would contain a compiled copy of wxWidgets and a copy of wx-config, and which would run cabal install wxWidgets out of the box. (basic here means you probably don't get to choose anything at all - not even where the wxWidgets libraries get installed) Provided that I don't need to maintain a source distribution, this might be a good way forward for some Windows users. The installer would be updated for 'significant' wxWidgets updates (you would be able to 'cabal install wx' at any time wxHaskell is updated once you have all of the libraries) Any interest - please let me know. Regards Jeremy ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Move MonadIO to base
On Sun, Apr 18, 2010 at 5:02 PM, wren ng thornton w...@community.haskell.org wrote: Heinrich Apfelmus wrote: Anders Kaseorg wrote: This concept can also be generalized to monad transformers: class MonadTrans t = MonadTransMorph t where morph :: Monad m = (forall b. (t m a - m b) - m b) - t m a [...] However, not all control operators can be lifted this way. Essentially, while you may downgrade an arbitrary selection of t m a values you may only promote one m a in return and all have to share the same return type a . In particular, it's not possible to implement lift :: (Monad m, MonadTrans t) = m a - t m a Why not? * morph says m(t m a) is a subset of (t m a) * Monad m says we can fmap :: (a-b) - (m a-m b) * Monad (t m) says we can return :: a - t m a lift ma = morph (\k - k (fmap return ma)) Maybe something like this? lift m = morph (\k - m = k . return) -- n.b., return and = are from different monads Again, having m(t m a)-(t m a) is strictly more expressive than only having (m a)-(t m a) because the former may avail itself of operations/operators of t. join . lift :: m (t m a) - t m a morph is more powerful than lift, but it isn't because of the type. -- Dave Menendez d...@zednenem.com http://www.eyrie.org/~zednenem/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Ocaml for Haskellers tutorial
There are some really impressive applications done with Ocaml, some of which I have wanted to try out. I have never had any difficulty installing the core Ocaml system, but have never yet succeeded in getting the additional libraries put together. (Home-brew package systems are not _always_ a good idea.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Ocaml for Haskellers tutorial
Then maybe you should try godi. It is the camlist's cabal, but while the authors of cabal have really done a good job, godi is still quite poorly written, and has not gained wide acceptance in the community. And, yes, there are cool applications written in ocaml. People claim that the best application ever written in ocaml is unison, but also since it is the only language french engineers learn at school, there are a lot of private applications such as the controller for line 14 of the parisian metro (the automatic line in Paris), or maybe things at airbus. And of course, coq is also written in ocaml. And, if the organization that developed caml (inria) had not stopped financing it, there would be a concurrent GC (in fact the algorithm exists, but has never been implemented), the FFI would probably be as nice as haskell's, and more than one person in the world would understand the code of ocamlc, Also, maybe there would be a norm for ocaml, and microsoft wouldn't have dumped the language as f#. Conclusion : if you want to be a researcher, come to France, it is pretty cool here... El 18/04/2010, a las 22:37, Richard O'Keefe escribió: There are some really impressive applications done with Ocaml, some of which I have wanted to try out. I have never had any difficulty installing the core Ocaml system, but have never yet succeeded in getting the additional libraries put together. (Home-brew package systems are not _always_ a good idea.) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: US Patent for the idea ...
When it comes to patents, there is less than meets the eye. A review of Intellectual Property in New Zealand a few years ago found that the NZ Intellectual Property Office quite deliberately do not review patent applications for originality. An IP law expert I spoke to about this felt that there was no problem, because patents that failed the originality criterion would fail in court. It didn't seem to bother him that defending yourself costs money. He was also untroubled that computer science professionals find most software patents incomprehensible; again, such patents fail a basic requirement so it should all be cleared up in court (and of course we can all afford that). The Australians recently conducted an experiment asking volunteers to check for prior art. The patent application I commented on claimed the invention of doing whole number arithmetic in a computer using big digits to base (10**max) where (10**max) just fits into a computer word. This of course goes back to _at least_ the 1960s. The people who claimed this particular patent may well have perfectly innocent intentions: they may not be trying to block anyone else doing obvious things, they may be trying to protect themselves against being blocked. The only way to tell, really, is to find out what they want for a licence to use their invention. The current review of New Zealand IP protection may well scrap software patents entirely, in part on the grounds that we cannot afford to do a proper job of scrutiny. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Re: Ocaml for Haskellers tutorial
On Apr 19, 2010, at 2:56 PM, Pierre-Etienne Meunier wrote: Then maybe you should try godi. It is the camlist's cabal, but while the authors of cabal have really done a good job, godi is still quite poorly written, and has not gained wide acceptance in the community. No, it is precisely godi that gives me endless grief, and has done so consistently for years. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: US Patent for the idea of using Haskell to implement UAX #9
revealed a link to a US Patent (7120900) for the idea of implementing the Unicode Bidirectional Algorithm (UAX #9 http://www.unicode.org/reports/tr9) in Haskell, making use, as far as I can tell, of nothing more than the normal approach any functional programmer would use, namely separation of concerns etc. In which case the patent should be null and void since obvious ideas aren't patentable, AFAIK. Doesn't matter: you'd need to pay lawyers to defend yourself to convince a court that it is null and void. So even if you may end up winning in the end (which is far from obvious), you'll have wasted a lot of time, effort, and money. Stefan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: Embedded funcional programming?
As a side comment, I haven't noticed any reaction in the Haskell/iPhone community about Apple's recent policy change. The stricter they make it, the better, since it hopefully gets us closer to the point where people will see that they should stay the heel away from any such handcuffs, Stefan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Strange error with type classes + associated types
Conal, Thanks for looking into this! Making (:-*) into a proper type seems promising. I did try wrapping (:-*) in a newtype but that didn't help (although I didn't expect it to). I see you just uploaded a new version of vector-space; what's new in 0.6.2? -Brent On Sat, Apr 17, 2010 at 10:28:45AM -0700, Conal Elliott wrote: Oh! I'd completely forgotten about this idea. Looking at Data.LinearMap in vector-space, I see a comment about exactly this ambiguity, as well as the start of a new module that wraps a data type around the linear map representation. I don't recall whether I got stuck or just distracted. On Sat, Apr 17, 2010 at 3:46 AM, Roman Leshchinskiy r...@cse.unsw.edu.auwrote: On 17/04/2010, at 11:00, Conal Elliott wrote: I'm unsure now, but I think I tried making Basis a data type (not syn) and ran into the problem I mentioned above. The Basis *synonyms* also have HasTrie instances, which is crucially important. If we switch to (injective) data types, then we lose the HasTrie instances. I'd be okay with defining HasTrie instances (preferably via deriving) for the associated Basis data types, but I couldn't figure out how to. Maybe it's not possible currently, or maybe I just didn't know how. Could you perhaps make (:-*) a proper type rather than a synonym? That would help with the ambiguity. Roman ___ 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] iPhone/Android and Haskell [Was: Embedded funcional programming?]
On 19 April 2010 05:29, Don Stewart d...@galois.com wrote: That's great info -- we do have an unregisterised ARM port of GHC in Debian, iirc. (And the LLVM backend can generate ARM code too) Sounds good. With regards to LLVM, what dependencies does LLVM ARM code have? Android has gnu libraries not llvm, i don't know if that is okay. A superior approach would be to compile haskell to Java or Dalvik bytecode (or even JVM bytecode if it doesn't use any JIT features; then we can compile that to dalvik bytecode), but this is obviously more work if we already have an ARM port. Here's the docs about the ABI we need to conform to in order to use the NDK. -- snip -- This is the name of an ABI for ARM-based CPUs that support *at* *least* the ARMv5TE instruction set. Please refer to following documentation for more details: - ARM Architecture Reference manual(a.k.a ARMARM) - Procedure Call Standard for the ARM Architecture (a.k.a. AAPCS) - ELF for the ARM Architecture (a.k.a. ARMELF) - ABI for the ARM Architecture (a.k.a. BSABI) - Base Platform ABI for the ARM Architecture (a.k.a. BPABI) - C Library ABI for the ARM Architecture (a.k.a. CLIABI) - C++ ABI for the ARM Architecture (a.k.a. CPPABI) - Runtime ABI for the ARM Architecture (a.k.a. RTABI) - ELF System V Application Binary Interface (DRAFT - 24 April 2001) - Generic C++ ABI (http://www.codesourcery.com/public/cxx-abi/abi.html) Note that the AAPCS standard defines 'EABI' as a moniker used to specify a _family_ of similar but distinct ABIs. Android follows the little-endian ARM GNU/Linux ABI as documented in the following document: http://www.codesourcery.com/gnu_toolchains/arm/arm_gnu_linux_abi.pdf With the exception that wchar_t is only one byte. This should not matter in practice since wchar_t is simply *not* really supported by the Android platform anyway. This ABI does *not* support hardware-assisted floating point computations. Instead, all FP operations are performed through software helper functions that come from the compiler's libgcc.a static library. Thumb (a.k.a. Thumb-1) instructions are supported. Note that the NDK will generate thumb code by default, unless you define LOCAL_ARM_MODE in your Android.mk (see docs/ANDROID-MK.TXT for all details). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] iPhone/Android and Haskell [Was: Embedded funcional programming?]
Also worth mentioning that the Android docs explicitly warn against allocating frequently suggesting reuse of objects is by far more preferable than regularly allocating stuff. If we go the Dalvik/Java route, then we'll have alot of work to do to make the GC work for us nicely, whereas compiling to native code gives us full control. The problem (and why I believe compiling to Java would be better) is that it is quite tedious and difficult to interact with Java APIs using native code. You write a shell of your application in java and put calls in to native code everywhere. It ruins alot of the glamor of Haskelling for android. That said, if we can somehow expose some Java functions to haskell (rather than the other way around) then we could eventually write an android API library for native haskell, giving us both the performance benefits and the android api. Cheers. ~Liam On 19 April 2010 14:25, Liam O'Connor lia...@cse.unsw.edu.au wrote: On 19 April 2010 05:29, Don Stewart d...@galois.com wrote: That's great info -- we do have an unregisterised ARM port of GHC in Debian, iirc. (And the LLVM backend can generate ARM code too) Sounds good. With regards to LLVM, what dependencies does LLVM ARM code have? Android has gnu libraries not llvm, i don't know if that is okay. A superior approach would be to compile haskell to Java or Dalvik bytecode (or even JVM bytecode if it doesn't use any JIT features; then we can compile that to dalvik bytecode), but this is obviously more work if we already have an ARM port. Here's the docs about the ABI we need to conform to in order to use the NDK. -- snip -- This is the name of an ABI for ARM-based CPUs that support *at* *least* the ARMv5TE instruction set. Please refer to following documentation for more details: - ARM Architecture Reference manual (a.k.a ARMARM) - Procedure Call Standard for the ARM Architecture (a.k.a. AAPCS) - ELF for the ARM Architecture (a.k.a. ARMELF) - ABI for the ARM Architecture (a.k.a. BSABI) - Base Platform ABI for the ARM Architecture (a.k.a. BPABI) - C Library ABI for the ARM Architecture (a.k.a. CLIABI) - C++ ABI for the ARM Architecture (a.k.a. CPPABI) - Runtime ABI for the ARM Architecture (a.k.a. RTABI) - ELF System V Application Binary Interface (DRAFT - 24 April 2001) - Generic C++ ABI (http://www.codesourcery.com/public/cxx-abi/abi.html) Note that the AAPCS standard defines 'EABI' as a moniker used to specify a _family_ of similar but distinct ABIs. Android follows the little-endian ARM GNU/Linux ABI as documented in the following document: http://www.codesourcery.com/gnu_toolchains/arm/arm_gnu_linux_abi.pdf With the exception that wchar_t is only one byte. This should not matter in practice since wchar_t is simply *not* really supported by the Android platform anyway. This ABI does *not* support hardware-assisted floating point computations. Instead, all FP operations are performed through software helper functions that come from the compiler's libgcc.a static library. Thumb (a.k.a. Thumb-1) instructions are supported. Note that the NDK will generate thumb code by default, unless you define LOCAL_ARM_MODE in your Android.mk (see docs/ANDROID-MK.TXT for all details). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] ANNOUNCE: Agata-0.2.0
If this is to be used with QuickCheck maybe it should be named that way. Certainly worth considering. There seems to be no convenient way of renaming packages on Hackage though, is there? I suppose it would be wrong/impossible to create an alias package (quickcheck-agata) with no modules, just a dependency on the primary package (Agata)? /Jonas 2010/4/18 Marc Weber marco-owe...@gmx.de: If this is to be used with QuickCheck maybe it should be named that way. eg quickcheck-agatath ? This way its found faster. Marc Weber ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] iPhone/Android and Haskell [Was: Embedded funcional programming?]
Ah, looks as though we'll have to write a C layer between Java and Haskell.. doing all of this in the FFI seems like hard: http://www.koushikdutta.com/2009/01/jni-in-android-and-foreword-of-why-jni.html Cheers. ~Liam On 19 April 2010 14:33, Liam O'Connor lia...@cse.unsw.edu.au wrote: Also worth mentioning that the Android docs explicitly warn against allocating frequently suggesting reuse of objects is by far more preferable than regularly allocating stuff. If we go the Dalvik/Java route, then we'll have alot of work to do to make the GC work for us nicely, whereas compiling to native code gives us full control. The problem (and why I believe compiling to Java would be better) is that it is quite tedious and difficult to interact with Java APIs using native code. You write a shell of your application in java and put calls in to native code everywhere. It ruins alot of the glamor of Haskelling for android. That said, if we can somehow expose some Java functions to haskell (rather than the other way around) then we could eventually write an android API library for native haskell, giving us both the performance benefits and the android api. Cheers. ~Liam On 19 April 2010 14:25, Liam O'Connor lia...@cse.unsw.edu.au wrote: On 19 April 2010 05:29, Don Stewart d...@galois.com wrote: That's great info -- we do have an unregisterised ARM port of GHC in Debian, iirc. (And the LLVM backend can generate ARM code too) Sounds good. With regards to LLVM, what dependencies does LLVM ARM code have? Android has gnu libraries not llvm, i don't know if that is okay. A superior approach would be to compile haskell to Java or Dalvik bytecode (or even JVM bytecode if it doesn't use any JIT features; then we can compile that to dalvik bytecode), but this is obviously more work if we already have an ARM port. Here's the docs about the ABI we need to conform to in order to use the NDK. -- snip -- This is the name of an ABI for ARM-based CPUs that support *at* *least* the ARMv5TE instruction set. Please refer to following documentation for more details: - ARM Architecture Reference manual (a.k.a ARMARM) - Procedure Call Standard for the ARM Architecture (a.k.a. AAPCS) - ELF for the ARM Architecture (a.k.a. ARMELF) - ABI for the ARM Architecture (a.k.a. BSABI) - Base Platform ABI for the ARM Architecture (a.k.a. BPABI) - C Library ABI for the ARM Architecture (a.k.a. CLIABI) - C++ ABI for the ARM Architecture (a.k.a. CPPABI) - Runtime ABI for the ARM Architecture (a.k.a. RTABI) - ELF System V Application Binary Interface (DRAFT - 24 April 2001) - Generic C++ ABI (http://www.codesourcery.com/public/cxx-abi/abi.html) Note that the AAPCS standard defines 'EABI' as a moniker used to specify a _family_ of similar but distinct ABIs. Android follows the little-endian ARM GNU/Linux ABI as documented in the following document: http://www.codesourcery.com/gnu_toolchains/arm/arm_gnu_linux_abi.pdf With the exception that wchar_t is only one byte. This should not matter in practice since wchar_t is simply *not* really supported by the Android platform anyway. This ABI does *not* support hardware-assisted floating point computations. Instead, all FP operations are performed through software helper functions that come from the compiler's libgcc.a static library. Thumb (a.k.a. Thumb-1) instructions are supported. Note that the NDK will generate thumb code by default, unless you define LOCAL_ARM_MODE in your Android.mk (see docs/ANDROID-MK.TXT for all details). ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe