Re: [q-lang-users] Speeding up Q
Brought to you by:
agraef
From: Brian B. <bri...@co...> - 2008-04-03 01:21:02
|
Oh, I think I see even more clearly, now. The data constructors "Just" and "Nothing" are not quite ordinary functions ... they're a special kind of function that is permitted -- by special rules -- to participate in pattern matching. But in TRs, any function is permitted in the pattern position because there's just one kind of function. Right? It always seems right to me to reduce the number of special cases. -----Original Message----- From: q-l...@li... [mailto:q-l...@li...] On Behalf Of Brian Beckman Sent: Wednesday, April 02, 2008 5:45 PM To: 'Discuss the Q language.' Subject: Re: [q-lang-users] Speeding up Q I think I see :) At the risk of being tiresome, I think you're saying that in something like this in Haskell data Maybe a = Nothing | Just a we get a type constructor "Maybe" and a type variable "a" on the left-hand side, and a pair of data constructors, which are just ordinary functions (?!) -- on the right-hand side, and "a" gets punned from a type variable on LHS into an ordinary data-variable of type a on the RHS. At least, that's how I understand it (perhaps very poorly :) The TYPE constructor, "Maybe," is NOT available for Haskell's pattern matching, but the data constructors are, by design f :: Num a => Maybe a -> a f (Just x) = x f Nothing = 0 In Q, this distinction doesn't even arise, correct? And if not, is the reason that data constructors like "Maybe" don't exist? And, if so, isn't the reason simply that a "kinded" type system can't exist in Q or other TRS, and that type-checking must always be dynamic because and there's only one KIND of thing (a function) and patterns are perforce just over functions? Or am I way off? Apologies for being so far off the deep end :) -----Original Message----- From: q-l...@li... [mailto:q-l...@li...] On Behalf Of Albert Graef Sent: Wednesday, April 02, 2008 11:13 AM To: Discuss the Q language. Subject: Re: [q-lang-users] Speeding up Q Brian Beckman wrote: > Would you be so kind as to give a tiny example of a 'constructor' versus a > 'defined function' to clarify how they're different in the lambda calculus > but not so in TR? My memory of lambda is that it's just the following I should have worded that more carefully. Of course, pure lambda calculus doesn't have constructor symbols (they're emulated using lambdas), but Haskell, ML et al have them. I was actually talking about the constructor discipline in pattern-matching definitions in Haskell et al. In a sense these are just rewriting rules, but there are two different classes of symbols, the defined functions which occur as head symbols in the definitions, and the constructor symbols which occur in the argument patterns. Consequently, in Haskell, ML etc. there's just no way you can write a rule like foo (foo x) = x; expressing the idempotence of a "function" foo, or Bar (Bar x y) z = Bar x (Bar y z); for making a binary "constructor" Bar right-associative. But in TR, these kinds of rules are just normal business. In a sense, these are all just conveniences. After all, lambda calculus is as universal as term rewriting and they can easily emulate each other. But rewriting rules are just *so* much more convenient, otherwise why would there be pattern-matching in virtually every modern FPL (and there's even a Lisp dialect which has them)? TR languages go all they way there, by just abolishing the artificial segregation between functions and constructors. Albert -- Dr. Albert Gr"af Dept. of Music-Informatics, University of Mainz, Germany Email: Dr....@t-..., ag...@mu... WWW: http://www.musikinformatik.uni-mainz.de/ag ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace _______________________________________________ q-lang-users mailing list q-l...@li... https://lists.sourceforge.net/lists/listinfo/q-lang-users ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace _______________________________________________ q-lang-users mailing list q-l...@li... https://lists.sourceforge.net/lists/listinfo/q-lang-users |