Re: [Haskell-cafe] Vanishing polymorphism
To cut a long story short, could someone explain why: :t negate negate :: forall a. (Num a) = a - a :t let f (fn :: forall a . Num a = a - a) r s = (fn r, fn s) in f negate let f (fn :: forall a . Num a = a - a) r s = (fn r, fn s) in f negate :: forall r s. (Num r, Num s) = r - s - (r, s) but :t let f r s = (return negate) = (\fn - return (fn r, fn s)) in f let f r s = (return negate) = (\fn - return (fn r, fn s)) in f :: forall a (m :: * - *). (Num a, Monad m) = a - a - m (a, a) and :t let f r s = (return negate) = (\(fn::forall n . (Num n) = n - n) - return (fn r, fn s)) in f interactive:1:35: Couldn't match expected type `a - a' against inferred type `forall n. (Num n) = n - n' In the pattern: fn :: forall n. (Num n) = n - n In a lambda abstraction: \ (fn :: forall n. (Num n) = n - n) - return (fn r, fn s) In the second argument of `(=)', namely `(\ (fn :: forall n. (Num n) = n - n) - return (fn r, fn s))' I.e. why does the polymorphism get destroyed? Unless annotated otherwise, functions destroy the polymorphism of their arguments. In your first example f's argument is annotated to be polymorphic, hence you can call it with two different types. In your second example, the lambda abstraction does not declare it expects a polymorphic argument. So you get a monomorhpic one. Neither does return or =. So that all works fine. In your third example, return destroys the polymorphism of negate. becomes monomorphic for some a, the a - a without forall. = is happy with the monomorphism. Then it is received by the lambda abstraction that expects a polymorphic type and causes the error. You can read more about this in the paper: Practical type inference for arbitrary-rank types Simon Peyton Jones, Dimitrios Vytiniotis, Stephanie Weirich, and Mark Shields http://research.microsoft.com/~simonpj/papers/higher-rank/index.htm Basically, it comes down to the fact that preserving polymorphism is too hard for type inference, unless you the prorgrammer provide sufficient declarations for it. Cheers, Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Vanishing polymorphism
On Tue, 8 May 2007, David House wrote: On 08/05/07, Matthew Sackman [EMAIL PROTECTED] wrote: :t let f r s = (return negate) = (\(fn::forall n . (Num n) = n - n) - return (fn r, fn s)) in f interactive:1:35: Couldn't match expected type `a - a' against inferred type `forall n. (Num n) = n - n' In the pattern: fn :: forall n. (Num n) = n - n In a lambda abstraction: \ (fn :: forall n. (Num n) = n - n) - return (fn r, fn s) In the second argument of `(=)', namely `(\ (fn :: forall n. (Num n) = n - n) - return (fn r, fn s))' I.e. why does the polymorphism get destroyed? Here fn is bound by a lambda abstraction, and is therefore monomorphic. I can't find anything in the Report about that, This won't be in the Haskell 98 report. I have to enable -fglasgow-exts in GHCi to get this even parsed. Tom -- Tom Schrijvers Department of Computer Science K.U. Leuven Celestijnenlaan 200A B-3001 Heverlee Belgium tel: +32 16 327544 e-mail: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Roles == type classes ???
The way roles/traits are described in [1] (and the pages it links to) make me think of Haskell type classes. Am I completely off in doing that? /M [1]: http://griddlenoise.blogspot.com/2007/05/traits-roles-as-alternative-to-abstract.html -- Magnus Therning (OpenPGP: 0xAB4DFBA4) [EMAIL PROTECTED] Jabber: [EMAIL PROTECTED] http://therning.org/magnus Software is not manufactured, it is something you write and publish. Keep Europe free from software patents, we do not want censorship by patent law on written works. Those who would give up Essential Liberty to purchase a little Temporary Safety, deserve neither Liberty nor Safety -- Benjamin Franklin, Historical Review of Pennsylvania, 1759 pgpAAfGwnpdna.pgp Description: PGP signature ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Roles == type classes ???
On Wed, 2007-05-09 at 10:41 +0100, Magnus Therning wrote: The way roles/traits are described in [1] (and the pages it links to) make me think of Haskell type classes. Am I completely off in doing that? At http://mail.python.org/pipermail/python-3000/2007-April/007026.html we find this passage, which sounds faintly familiar: | Now, how do roles/traits differ from interfaces? The primary | distinction is that interfaces only define behavior¹, whereas roles can | provide a dummy implementation. Dude, where's my language? -k ¹ For some value of 'behavior', apparently. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: How to decrease ghc link time
Georg Sauthoff wrote: well, I work with a Haskell project which I regulary compile with ghc. I am a bit unhappy with the link time of the project (i.e. the time ghc needs to link everyting). The project consinst of ~60 Haskell and ~25 foreign files. Some parts of the project are organized like a 'cluster', i.e. the foreign part has only one function, which is used from Haskell-Code. What could I do to improve the link time? Make sure everything being linked is on the local file system (or use remote filesystems that can be cached locally). GHC itself links in 2-3 seconds here on an x86_64/Linux machine, which I think is pretty reasonable. Windows is much slower though. Cheers, Simon ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Re: How to decrease ghc link time
Simon Marlow [EMAIL PROTECTED] wrote: Hi, Georg Sauthoff wrote: I am a bit unhappy with the link time of the project (i.e. the time ghc needs to link everyting). The project consinst of ~60 Haskell and ~25 foreign files. [..] Make sure everything being linked is on the local file system (or use remote filesystems that can be cached locally). thanks for the advice! Currently I am using NFS ... GHC itself links in 2-3 seconds here on an x86_64/Linux machine, which I think is pretty reasonable. Windows is much slower though. Yes, that sounds ok, currently the project needs 6-7 seconds over NFS (under Solaris) ... Best regards Georg Sauthoff ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] built-in lists vs inductively defined list
On Wed, May 09, 2007 at 02:45:34PM +0100, Jos? Miguel Vila?a wrote: Can someone tell me if would be any difference (beside syntax) between the built-in Haskell list with [] and : and lists given by a inductive datatype definition like data List a = Nil | Cons a (List a) This is, is any of the compilers doing some special optimizations for the built-in lists? To the best of my knowledge, there are no optimizations specific to [] in the compiler proper. However, the standard library has a *lot* of speed hacks you will need to duplicate! Stefan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] built-in lists vs inductively defined list
On Wed, 09 May 2007, Stefan O'Rear [EMAIL PROTECTED] wrote: To the best of my knowledge, there are no optimizations specific to [] in the compiler proper. However, the standard library has a *lot* of speed hacks you will need to duplicate! Some of which are not expressible in ordinary Haskell (rewrite rules used for short-cut deforestation). -- /NAD ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Safe forward-mode AD in Haskell?
d :: Num a = (forall b. (Num b) = (a - b) - b - b) - a - a d f x = let (Bundle y y') = f lift (Bundle x 1) in y' The key change is in the type of d, which now accepts a polymorphic function on numbers, but passes in a lift function, which allows us to pass in higher-level variables. In one sense this function is ugly. In another sense, it's prettier, as you can now hide *all* of the Bundle data in a differentiation module. To summarize: In my original version it is necessary to export 'd' and 'lift', which both expose 'Bundle' through their type signatures (and 'lift' even returns a 'Bundle', though how one could (ab)use it outside the intended context of a 'd' escapes me). In constrast, with your variation only 'd' need be exported and everything else in the module (including 'Bundle) is completely hidden. The cost is that functions must be conditioned before they can be differentiated. Thanks for your input! -Bjorn ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] built-in lists vs inductively defined list
On Wed, May 09, 2007 at 04:11:40PM +0200, Nils Anders Danielsson wrote: On Wed, 09 May 2007, Stefan O'Rear [EMAIL PROTECTED] wrote: To the best of my knowledge, there are no optimizations specific to [] in the compiler proper. However, the standard library has a *lot* of speed hacks you will need to duplicate! Some of which are not expressible in ordinary Haskell (rewrite rules used for short-cut deforestation). I just want to note that no particular compiler was named so far in this thread and this is a very compiler specific area. To OP: are you asking about the language or some particular implementation? Best regards Tomasz ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Picking an architecture for a Haskell web app
Folks, I have finished an alpha version of my EasyLanguage [1] to C# compiler and need to deploy it on Amazon EC2/S3. The compiler web interface is very simple: paste EL code, get back C# code or the same EL code with the error highlighted. I view the site as more than just a compiler, though, and want a blog, forums, etc. Last but not least, I want to be able to update portions of the site without shutting it down. My choice seems to boil down to HAppS [2], HOPE [3], or a combination of Ruby/Rails with Lambdabot. At first glance, HAppS lacks publishing (my ultimate need) but promises an interface to S3 sometime in the future. My understanding is that it's ready but is not being released. HAppS is heavy on features that I may not make use of. I had a hard time understanding the HPaste [4] code written using HAppS and I don't fancy using XSLT as my HTML template language. HOPE has a publishing framework (blog, RSS, comments). I could write the forums or just use Google Groups. I like the module system and the FCGI interface should let me couple HOPE with Lighty [5]. The HOPE code base looks clean and simple and I'm guessing that adding Lambdabot-style dynamic loading of modules would be straightforward. Overall, HOPE has everything that I need, without unnecessary extras. It does not have an interface to Amazon S3, though, and I would need that to rewrite the storage bits to use S3 instead of a regular database. Lambdabot by itself doesn't offer much apart from robust dynamic loading of Haskell code. Its features have been heavily tested, though, which gives me a warm feeling. I'm thinking that the same hot- loading technology that Lambdabot uses could be coupled with either HAppS or HOPE. Lambdabot has a FCGI which should make mixing it with HOPE particularly easy. Going with Ruby and Rails I will have everything I need and more. The compiler could run in a separate server (think Lambdabot) but I would need to manage two different platforms. Is my assessment correct? Did I miss anything? What approach do you favor? Thanks, Joel P.S. I have the same compiler written in OCaml which is what I started with. Developing it has been a relative breeze but deploying on the web was a tale of frustration. I gave up and finished the Haskell version. [1] http://lambda-the-ultimate.org/node/2201 [2] http://happs.org/HAppS/README.html [3] http://hope.bringert.net/about [4] http://hpaste.org [5] http://www.lighttpd.net/ -- http://wagerlabs.com/ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: Re [Haskell-cafe] Vanishing polymorphism
On 08/05/07, Matthew Sackman [EMAIL PROTECTED] wrote: :t let f r s = let g (fn::forall n . (Num n) = n - n) = return (fn r, fn s) in (return negate) = g in f Ah, I may have been off the mark earlier. I think the problem is due to the fact that you can't pass higher-order polymorphic functions around. I.e., the following is a classic example of something people expect to work, but doesn't: runST $ ... runST is a rank-2 polymorphic function, and you're attempting to pass it as a parameter to the ($) function, which doesn't work. I think your problem is similar. Here's the module I used to investigate goings on: {-# OPTIONS_GHC -fglasgow-exts #-} import Data.Complex g :: (Num a, Num b, Monad m) = a - b - (forall n. Num n = n - n) - m (a, b) g r s fn = return (fn r, fn s) f :: Maybe (Int, Complex Float) f = return negate = g (4 :: Int) (1 :+ 2) You're attempting to pass the rank-2 polymorphic function g (4 :: Int) (1 :+ 2) as a parameter to (=), which doesn't work. General point: couldn't GHC's error reporting be improved at times like these? -- -David House, [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] generate Haskell code from model
I have done some experiments relating to our discussion. The approach to generate Haskell code from UML class diagrams is not very promising. However one may define a visual notation of Haskell (this is no new idea of course), provide better tool support (in particular editor+code generator) and pull the Haskellers away from vim, emacs or even from the Visual Studio Plugin Visual Haskell, that is more a Haskell IDE Integration than a visual programming environment (great work either way!). I have described a possible toolchain towards a real Visual Haskell at my blog: http://www.steffen-mazanek.de/blog/2007/05/visual-language-howto.html Best regards, Steffen 2007/4/14, Brian Smith [EMAIL PROTECTED]: On 4/14/07, Steffen Mazanek [EMAIL PROTECTED] wrote: Brian, but don't you think that you have to write a lot of boilerplate code in Haskell? I have never felt I was writing a lot of boilerplate. There are a lot of abstraction mechanisms in Haskell to avoid boilerplate. Second, if Haskell should be more successful in the real world there has to be a way of demonstrating basic ideas of a big program to customers. How would you do this? Everybody knows UML class diagrams, for example. In contrast, nobody knows about termgraphs or lambda *g*. I've never had to show a UML or ER diagram to any business people--usually they want a slideshow that is far simpler and a little prettier. The fact that nobody knows about termgraphs or lambda in your group means that you probably shouldn't be considering Haskell (for the same reason my bosses always asked me to document everything--in case you get hit by a bus). Thank you very much for contributing to the discussion. Please assume, that you have to generate the code from a model. Further assume, that you have no choice and are not allowed to discuss the sense of this approach :-) How should the code look like? I am not sure if you are trying to solve a real problem or not. If you are solving a real problem, where you already happen to have an EMF model which you are required to generate code from, then I recommend to just do everything in Java using the existing tools built for EMF. If you decide to still keep working in Haskell, and it works out well, please share your solution because I think many people here will be very interested. wxHaskell, OOHaskell, and O'Haskell are all starting points for this type of project. - Brian -- Dipl.-Inform. Steffen Mazanek Institut für Softwaretechnologie Fakultät Informatik Universität der Bundeswehr München 85577 Neubiberg Tel: +49 (0)89 6004-2505 Fax: +49 (0)89 6004-4447 E-Mail: [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
RE: [Haskell-cafe] built-in lists vs inductively defined list
Hi again, IMHO for what concerns to the language they only differ in syntax. They are equal up to constructor names. What could be the case is that some compiler could do some optimizations that end up with better performance in time and space when using lists. But for what people gently ask me, the optimizations are in the functions over list and not in the data structure itself. Do you know something about an implementation that does something about the data structure itself? Best Miguel Vilaça -Mensagem original- De: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Em nome de Tomasz Zielonka Enviada: quarta-feira, 9 de Maio de 2007 16:13 Para: Haskell Cafe Assunto: Re: [Haskell-cafe] built-in lists vs inductively defined list On Wed, May 09, 2007 at 04:11:40PM +0200, Nils Anders Danielsson wrote: On Wed, 09 May 2007, Stefan O'Rear [EMAIL PROTECTED] wrote: To the best of my knowledge, there are no optimizations specific to [] in the compiler proper. However, the standard library has a *lot* of speed hacks you will need to duplicate! Some of which are not expressible in ordinary Haskell (rewrite rules used for short-cut deforestation). I just want to note that no particular compiler was named so far in this thread and this is a very compiler specific area. To OP: are you asking about the language or some particular implementation? Best regards Tomasz ___ 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] generate Haskell code from model
Hi Steffen, It sounds a lot to me like: * Create a visual meta-language * Program with diagrams * Translate to Haskell If thats the case, how is Translate to Haskell different from Translate to C++? It only makes a difference if you go in and edit the result, but then you've lost your model? The other thing is that defining a domain specific language is well understood in Haskell, and generally looks quite nice. The advantage is that it can integrate with the rest of Haskell easily - if you take away the Haskell and move into the realm of models I don't see how you can keep this selling point. (Personal note: I detest modelling languages with a passion, and I love Haskell with a passion - I'm curious whether I love or hate the combination) Thanks Neil On 5/9/07, Steffen Mazanek [EMAIL PROTECTED] wrote: I have done some experiments relating to our discussion. The approach to generate Haskell code from UML class diagrams is not very promising. However one may define a visual notation of Haskell (this is no new idea of course), provide better tool support (in particular editor+code generator) and pull the Haskellers away from vim, emacs or even from the Visual Studio Plugin Visual Haskell, that is more a Haskell IDE Integration than a visual programming environment (great work either way!). I have described a possible toolchain towards a real Visual Haskell at my blog: http://www.steffen-mazanek.de/blog/2007/05/visual-language-howto.html Best regards, Steffen 2007/4/14, Brian Smith [EMAIL PROTECTED]: On 4/14/07, Steffen Mazanek [EMAIL PROTECTED] wrote: Brian, but don't you think that you have to write a lot of boilerplate code in Haskell? I have never felt I was writing a lot of boilerplate. There are a lot of abstraction mechanisms in Haskell to avoid boilerplate. Second, if Haskell should be more successful in the real world there has to be a way of demonstrating basic ideas of a big program to customers. How would you do this? Everybody knows UML class diagrams, for example. In contrast, nobody knows about termgraphs or lambda *g*. I've never had to show a UML or ER diagram to any business people--usually they want a slideshow that is far simpler and a little prettier. The fact that nobody knows about termgraphs or lambda in your group means that you probably shouldn't be considering Haskell (for the same reason my bosses always asked me to document everything--in case you get hit by a bus). Thank you very much for contributing to the discussion. Please assume, that you have to generate the code from a model. Further assume, that you have no choice and are not allowed to discuss the sense of this approach :-) How should the code look like? I am not sure if you are trying to solve a real problem or not. If you are solving a real problem, where you already happen to have an EMF model which you are required to generate code from, then I recommend to just do everything in Java using the existing tools built for EMF. If you decide to still keep working in Haskell, and it works out well, please share your solution because I think many people here will be very interested. wxHaskell, OOHaskell, and O'Haskell are all starting points for this type of project. - Brian -- Dipl.-Inform. Steffen Mazanek Institut für Softwaretechnologie Fakultät Informatik Universität der Bundeswehr München 85577 Neubiberg Tel: +49 (0)89 6004-2505 Fax: +49 (0)89 6004-4447 E-Mail: [EMAIL PROTECTED] ___ 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] built-in lists vs inductively defined list
On Wed, 2007-05-09 at 09:08 -0700, Jason Morton wrote: I'd love to understand these rewrite-rules a little better; could anyone point me to where (if?) they are documented? Here's a list of papers on fusion and deforestation: http://haskell.org/haskellwiki/Research_papers/Compilation#Fusion_and_deforestation Specifically you want to read about short-cut fusion and rules. I'd recommend: A short cut to deforestation Shortcut fusion for accumulating parameters and zip-like functions Playing by the rules: rewriting as a practical optimisation technique in GHC Duncan ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Object Files Become Downloader.Obfuskated
I discovered a curious thing after a compiling a medium sized Haskell project using the 64 bit linux Haskell GHC 6.6.1 compiler. Several of the generated object files (.o) show up as containing the virus Downloader.Obfuskated by my AVG anti-virus program when viewing the files from windows xp 64. Since the files were generated by GHC on linux I find it hard to believe that they actually contain this virus. A google search reveals one other mention of something like this happening with no further explanation. The virus detection appears no where else except in object files generated by the ghc linux compiles. -- View this message in context: http://www.nabble.com/Object-Files-Become-Downloader.Obfuskated-tf3718136.html#a10402103 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