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
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
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
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
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 +
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
--
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
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
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'
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)
, {
] ++
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
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 ++
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) =
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
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
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
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
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
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.
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
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
37 matches
Mail list logo