Re: [Haskell-cafe] How to present the commonness of some objects?

2009-07-03 Thread Luke Palmer
On Thu, Jul 2, 2009 at 8:32 PM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Wow, this complex Thank you. I will try that. No, don't! There is an easier way. Don't use a class, just use a record. I would translate your class as: data Widget = Widget { widgetRun :: IO

Re: [Haskell-cafe] How to present the commonness of some objects?

2009-07-03 Thread Bulat Ziganshin
Hello Magicloud, I thought class was for this purpose. But it turns out not. http://haskell.org/haskellwiki/OOP_vs_type_classes -- Best regards, Bulatmailto:bulat.zigans...@gmail.com ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] How to declare a Typeless Function

2009-07-03 Thread Magnus Therning
On Fri, Jul 3, 2009 at 4:43 AM, Alexander Dunlapalexander.dun...@gmail.com wrote: swap :: Array (Int, Int) a - [Int] - Array (Int, Int) a The lowercase a means that that type variable is polymorphic, i.e. it can be any type. Another option would be to simply not put in type of 'swap', load it

[Haskell-cafe] hiding instance definitions in imported modules or redefining them, can it be done?

2009-07-03 Thread John Lask
Is there a way to hide instance definitions when importing a module for instance I want to import Data.Monoid but wish to redefine the instance of Monoid for ( a-b) I don't suppose this is possible? Specifically, I wish to define a specialised instance of Monoid for String-Int, but it

[Haskell-cafe] Re: A Strict GCL Interpreter in Haskell

2009-07-03 Thread Heinrich Apfelmus
Tillmann Rendel wrote: Now we can write our interpreter: eval :: Expression - Result eval (Literal n) = Number n eval (Add a b) = case eval a of Number result_of_a - case b of Number result_of_b - Number (result_of_a +

Re: [Haskell-cafe] How to present the commonness of some objects?

2009-07-03 Thread Stuart Cook
2009/7/3 Luke Palmer lrpal...@gmail.com: Keep in mind that with this solution *and* with the ExistentialQuantification solution, there is no possibility of downcasting.  I.e. if you were planning on making a GraphicalWidget subclass, and them somewhere seeing if a a Widget is actually a

Re: [Haskell-cafe] ORM for haskell?

2009-07-03 Thread Jochem Berndsen
Chris Eidhof wrote: I've something working that sort of does this. You define your model in the following way: data User = User {name :: String, password :: String, age :: Int, post :: BelongsTo Post} data Post = Post {title :: String, body :: String} Then there's some boilerplate code

[Haskell-cafe] Re: Monad Input/Output and Monad Transformers

2009-07-03 Thread John Lato
From: Maciej Piechotka uzytkown...@gmail.com 1. Learning haskell I discovered that I/O should be avoided nearly 'at all costs'. The problem is that the IO monad is the only one which have more interactive work flow. There is Reader/Writer monad but in fact AFAIU first one is about the

Re: [Haskell-cafe] ORM for haskell?

2009-07-03 Thread Chris Eidhof
On 3 jul 2009, at 11:28, Jochem Berndsen wrote: Chris Eidhof wrote: I've something working that sort of does this. You define your model in the following way: data User = User {name :: String, password :: String, age :: Int, post :: BelongsTo Post} data Post = Post {title :: String, body

Re: [Haskell-cafe] How to declare a Typeless Function

2009-07-03 Thread Joe Fredette
It's important to note that such a function is not Typeless but rather Polymorphic -- that is, it is a type which can be satisfied for many values of it's type variables. For instance, the function `(+) :: Num a = a - a - a` is polymorphic, since it's one type variable can be satisfied by any

[Haskell-cafe] On the parallel between java annotations and monads

2009-07-03 Thread Rafael Almeida
Hello, After an extensive search (5 minutes googling) I could not find any comparison between Java annotations (or Python annotations for that matter) and Monads. I think they are similar in various aspects and I want to discuss them here. I'm sure several of you have experience with Java

Re: [Haskell-cafe] On the parallel between java annotations and monads

2009-07-03 Thread Eugene Kirpichov
Could you clarify on what is the precise relationship between the annotations and monads? Or at least an example, like, The @Foo annotation corresponds to the Cont monad in the following way:... I personally don't see any connection at all, although I'm rather familiar with both. 2009/7/3

[Haskell-cafe] Re: How to present the commonness of some objects?

2009-07-03 Thread Maurí­cio
Wow, this complex Thank you. I will try that. No, don't! There is an easier way. (...) This is the point at which you are forced to move away from OO thinking. This seems to be worth clearing a little bit. I usually read people saying that this kind of misundestanding is a confusion

Re: [Haskell-cafe] Monad Input/Output and Monad Transformers

2009-07-03 Thread Richard Kelsall
Gwern Branwen wrote: ... Ultimately, the problem with Haskell and ML for our purposes is that the brightest and most aggressive programmers in those languages, using the most aggressive optimization techniques known to the research community, remain unable to write systems codes that compete

[Haskell-cafe] Re: hiding instance definitions in imported modules or redefining them, can it be done?

2009-07-03 Thread Maurí­cio
Is there a way to hide instance definitions when importing a module for instance No, there isn't. See item 5.4: http://haskell.org/onlinereport/modules.html Best, Maurício ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] How to present the commonness of some objects?

2009-07-03 Thread Ross Mellgren
Wordy (and yet technically accurate) names aside, isn't this basically the same thing, except that you must pass the dictionary around by hand? What is the advantage of doing the dictionary passing manually, other than being able to avoid the scoping issue (that requires case) and the

Re: [Haskell-cafe] Flipping *-*-* kinds, or monadic finally-tagless madness

2009-07-03 Thread Kim-Ee Yeoh
Hi Edward, Your runPretty version fits the bill nicely, thank you. I might still retain the state monad version because it allows generalizations beyond pretty-printing. As for fixing the original bug, I've found that the real magic lies in the incantation (Y . unY) inserted at the appropriate

[Haskell-cafe] Help needed to pick a better name then hack

2009-07-03 Thread Jinjing Wang
Hack is such an inconvenient name for a package, may I get some inspiration from renaming it? Also, is there an idiom to use when upgrading package name on hackage? Best, -- jinjing ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] On the parallel between java annotations and monads

2009-07-03 Thread Keith Sheppard
I see some parallels between Inversion of Control/Dependency Injection frameworks and monads. I would say annotations are tools that are sometimes used for those frameworks, but they are also used for other unrelated things (warning suppression, overriding functions ...) so it may be more clear to

[Haskell-cafe] Re: Help needed to pick a better name then hack

2009-07-03 Thread Simon Michael
We've had the Common Gateway Interface.. and the Web Server Gateway Interface.. now I think it's high time for the Haskell And General Gateway Interface for Servers. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] How to present the commonness of some objects?

2009-07-03 Thread Luke Palmer
2009/7/3 Ross Mellgren rmm-hask...@z.odi.ac Wordy (and yet technically accurate) names aside, isn't this basically the same thing, except that you must pass the dictionary around by hand? A SomeWidget is defined as any object which has a Widget dictionary. It's still an object; the link from

[Haskell-cafe] ANN: bloxorz clone

2009-07-03 Thread Patai Gergely
Hello all, This post is not about my own creation, it's just a little fun program written by a student of mine. You can install the bloxorz package to try it out, and read more about its background on my blog: http://just-bottom.blogspot.com/2009/07/playing-and-learning.html Gergely --

[Haskell-cafe] Cont, ContT and IO()

2009-07-03 Thread Günther Schmidt
Hi, I've got an IO action, some file system IO, traversing one level only and iterating over files found. I wish to build in an early exit, ie. if an IO action in the loop encounters a particular value I want it to abort the loop. Now so far, pls don't shoot, I have done this by

Re: [Haskell-cafe] Cont, ContT and IO()

2009-07-03 Thread Tim Wawrzynczak
Well, continuations come from Scheme, and by and large, they are usually used in languages like Scheme (i.e. PLT web server), or Smalltalk (Seaside web server), but they can be very useful in e.g. cases like yours for making a convenient way to make a local exit. I did this in one toy game

Re: [Haskell-cafe] Cont, ContT and IO()

2009-07-03 Thread Thomas Schilling
Here's some code I wrote the other day: hasCycle :: (Applicative m, MonadIO m) = Node - m Bool hasCycle n0 = runContT (*callCC* go) return where go *abort* = do visit [] IM.empty n0 return False where visit preds h n = do nid - nodeId n h' - foldM (\h'

[Haskell-cafe] How to pretty print code efficiently

2009-07-03 Thread John Ky
Hi, Currently I'm pretty printing code by building arrays of strings and calling indent. For example: instance JavaPrintableNamed AST.EnumeratedType where javaLinesNamed parentName (AST.EnumeratedType memberDefinitions) = [ public enum ++ asJavaId(parentName) , { ] ++

Re: [Haskell-cafe] Cont, ContT and IO()

2009-07-03 Thread jeff p
Couldn't resist taking the bait... Well, continuations come from Scheme, and by and large, they are usually used in languages like Scheme (i.e. PLT web server), or Smalltalk (Seaside web server), For a fuller history of continuatios, please see The Discoveries of Continuations by John

[Haskell-cafe] Re: How to pretty print code efficiently

2009-07-03 Thread Achim Schneider
John Ky newho...@gmail.com wrote: Hi, Currently I'm pretty printing code by building arrays of strings and calling indent. For example: instance JavaPrintableNamed AST.EnumeratedType where javaLinesNamed parentName (AST.EnumeratedType memberDefinitions) = [ public enum ++

Re: [Haskell-cafe] How to pretty print code efficiently

2009-07-03 Thread Alexander Dunlap
On Fri, Jul 3, 2009 at 6:45 PM, John Kynewho...@gmail.com wrote: Hi, Currently I'm pretty printing code by building arrays of strings and calling indent.  For example: instance JavaPrintableNamed AST.EnumeratedType where    javaLinesNamed parentName (AST.EnumeratedType memberDefinitions) =

[Haskell-cafe] Re: How to pretty print code efficiently

2009-07-03 Thread Achim Schneider
Achim Schneider bars...@web.de wrote: As for how to express it in code: I'd recommend a combination of a State monad to track the indentation, and the underused[1] Applicative interpretation of lists to concatenate stuff. = would function as concatenation of lines, getting the state, while

Re: [Haskell-cafe] Flipping *-*-* kinds, or monadic finally-tagless madness

2009-07-03 Thread wren ng thornton
Kim-Ee Yeoh wrote: type VarCount = int newtype Y b a = Y {unY :: VarCount - (b, VarCount)} Hi Edward, Your runPretty version fits the bill nicely, thank you. I might still retain the state monad version because it allows generalizations beyond pretty-printing. As for fixing the original

Re: [Haskell-cafe] Monoid wants a (++) equivalent

2009-07-03 Thread George Pollard
This discussion points to a wider issue: at some stage we should look at pulling all the nice new stuff into Haskell prelude. I'm looking at you, Data.Foldable,Traversable. Also, throw out `map`. ;) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Cont, ContT and IO()

2009-07-03 Thread wren ng thornton
Günther Schmidt wrote: Hi, I've got an IO action, some file system IO, traversing one level only and iterating over files found. I wish to build in an early exit, ie. if an IO action in the loop encounters a particular value I want it to abort the loop. Now so far, pls don't shoot, I have

Re: [Haskell-cafe] Monoid wants a (++) equivalent

2009-07-03 Thread Jason Dusek
2009/07/03 George Pollard por...@porg.es: This discussion points to a wider issue: at some stage we should look at pulling all the nice new stuff into Haskell prelude. I'm looking at you, Data.Foldable,Traversable. Also, throw out `map`. ;) What is the proper name for the operation on

Re: [Haskell-cafe] Monoid wants a (++) equivalent

2009-07-03 Thread Alexander Dunlap
On Fri, Jul 3, 2009 at 10:17 PM, Jason Dusekjason.du...@gmail.com wrote: 2009/07/03 George Pollard por...@porg.es: This discussion points to a wider issue: at some stage we should look at pulling all the nice new stuff into Haskell prelude. I'm looking at you, Data.Foldable,Traversable.

Re: [Haskell-cafe] Monoid wants a (++) equivalent

2009-07-03 Thread George Pollard
2009/7/4 Jason Dusek jason.du...@gmail.com: 2009/07/03 George Pollard por...@porg.es: Also, throw out `map`. ;)  What is the proper name for the operation on functions of a  functor, anyway? The name `fmap` seems to driven by an analogy  with `map`. This is getting a little off topic, but I

[Haskell-cafe] space leak hints?

2009-07-03 Thread Uwe Hollerbach
Good evening, all, I wonder if I could tap your collective wisdom regarding space leaks? I've been messing about with haskeem, my little scheme interpreter, and I decided to see if I could make it run reasonably space-efficiently. So far... no. Here's what I tried: I wrote a tiny scheme program