Re: [Haskell-cafe] Parsec monad transformer with IO?

2010-03-18 Thread Luke Palmer
On Thu, Mar 18, 2010 at 10:37 AM, Stefan Klinger wrote: > Hello! > > Nice, Parsec 3 comes with a monad transformer [1]. So I thought I could > use IO as inner monad, and perform IO operations during parsing. > > But I failed. Monad transformers still bend my mind. My problem: I > don't see a funct

Re: [Haskell-cafe] How to put data from a string to a tuple

2010-03-05 Thread Luke Palmer
Consider taking this to the haskell-beginners list. On Fri, Mar 5, 2010 at 4:32 AM, Pradeep Wickramanayake wrote: > Hi, > > Im self learner in Haskell. And im stuck in a  small place which I tried > searching in google but couldn't find > Proper answer > > I have some values in a string, Im remov

Re: [Haskell-cafe] GPL answers from the SFLC (WAS: Re: ANN: hakyll-0.1)

2010-03-05 Thread Luke Palmer
On Fri, Mar 5, 2010 at 12:53 AM, Kevin Jardine wrote: > I'm a Haskell newbie but long time open source developer and I've been > following this thread with some interest. > > The GPL is not just a license - it is a form of social engineering and social > contract. The idea if I use the GPL is th

Re: [Haskell-cafe] Monad laws

2010-03-02 Thread Luke Palmer
On Tue, Mar 2, 2010 at 4:37 PM, Yitzchak Gale wrote: > For this reason, I consider it a bug in GHC that return :: IO a > is lazy. Wait a minute... return undefined >>= const (return 42) = const (return 42) undefined = return 42 But if return undefined = undefined, then that equals; undefi

Re: [Haskell-cafe] Monad laws

2010-03-02 Thread Luke Palmer
On Tue, Mar 2, 2010 at 1:17 PM, David Sabel wrote: > Hi, > when checking the first monad law (left unit) for the IO-monad (and also for > the ST monad): > > return a >>= f ≡ f a > > I figured out that there is the "distinguishing" context (seq [] True) which > falsifies the law > for a and f defin

[Haskell-cafe] Re: Real-time garbage collection for Haskell

2010-03-02 Thread Luke Palmer
On Tue, Mar 2, 2010 at 7:17 AM, Simon Marlow wrote: >> For games, >> though, we have a very good point that occurs regularly where we know >> that all/most short-lived objects will no longer be referenced - at the >> start of a fresh frame. > > System.Mem.performGC is your friend, but if you're un

Re: [Haskell-cafe] Real-time garbage collection for Haskell

2010-02-28 Thread Luke Palmer
On Sun, Feb 28, 2010 at 2:06 AM, Pavel Perikov wrote: > Did you really seen 100ms pauses?! I never did extensive research on this but > my numbers are rather in microseconds range (below 1ms). What causes such a > long garbage collection? Lots of allocated and long-living objects? This is all h

[Haskell-cafe] Real-time garbage collection for Haskell

2010-02-27 Thread Luke Palmer
I have seen some proposals around here for SoC projects and other things to try to improve the latency of GHC's garbage collector. I'm currently developing a game in Haskell, and even 100ms pauses are unacceptable for a real-time game. I'm calling out to people who have seen or made such proposal

Re: [Haskell-cafe] Computing sums

2010-02-20 Thread Luke Palmer
On Sat, Feb 20, 2010 at 3:30 AM, Andrew Coppin wrote: > Have I just invented arrows? No... you have a data type which is *an* Arrow (probably/almost). The pure implementation bugs me because of its use of undefined. Might still be okay though. I would be more comfortable if it could not output

Re: [Haskell-cafe] Type arithmetic with ATs/TFs

2010-02-12 Thread Luke Palmer
On Fri, Feb 12, 2010 at 2:10 PM, Edward Kmett wrote: > On Fri, Feb 12, 2010 at 2:11 PM, Andrew Coppin > wrote: >> >> OK, well in that case, I'm utterly puzzled as to why both forms exist in >> the first place. If TFs don't allow you to do anything that can't be done >> with ATs, why have them? >>

Re: [Haskell-cafe] a beginner question: decorate-op-undecorate

2010-02-05 Thread Luke Palmer
On Fri, Feb 5, 2010 at 10:34 AM, Aran Donohue wrote: > What would be an idiomatic Haskell way to accomplish this? Currently I've > got "liftedPartitionEithers :: [a] -> (a -> Either b c) -> ([a], [a])" which > is my own version of partitionEithers that calls a selector first. Since you are not us

Re: [Haskell-cafe] Hierachical abstraction

2010-01-29 Thread Luke Palmer
On Fri, Jan 29, 2010 at 11:45 AM, Andrew Coppin wrote: > But now suppose that I want not just circles, but *anything* that can > possibly be reduced to line segments. If all you know about it is that it can be reduced to line segments, there is no loss of generality in representing that simply as

Re: [Haskell-cafe] Hierachical abstraction

2010-01-28 Thread Luke Palmer
On Thu, Jan 28, 2010 at 12:42 PM, Andrew Coppin wrote: > I wonder if you can make a parser combinator library which is *not* monadic? > And, if you could, in what way would that limit the kinds of things you can > parse? Absolutely! I believe both Applicatives and Arrows were originally invented

Re: [Haskell-cafe] Linguistic hair-splitting

2010-01-27 Thread Luke Palmer
On Wed, Jan 27, 2010 at 11:39 AM, Jochem Berndsen wrote: >> Now, here's the question: Is is correct to say that [3, 5, 8] is a >> monad? > > In what sense would this be a monad? I don't quite get your question. I think the question is this: if m is a monad, then what do you call a thing of type

Re: [Haskell-cafe] foldl in terms of foldr

2010-01-26 Thread Luke Palmer
On Tue, Jan 26, 2010 at 1:56 PM, Ryan Ingram wrote: > On Tue, Jan 26, 2010 at 5:04 AM, Xingzhi Pan > wrote: >> myFoldl :: (a -> b -> a) -> a -> [b] -> a >> myFoldl f z xs = foldr step id xs z >>    where step x g a = g (f a x) >> >> Btw, is there a way I can observe the type signature of 'step'

[Haskell-cafe] Codensity improvement of free monads

2010-01-25 Thread Luke Palmer
Hello haskell-cafe, I have just read "Asymptotic Improvement of Computations over Free Monads" by Janis Voigtlander, since I have been working with free monads a lot recently and don't want to get hit by their quadratic performance when I start to care about that. But after reading the paper, I s

Re: [Haskell-cafe] Parsers for Text Adventures

2010-01-17 Thread Luke Palmer
On Sun, Jan 17, 2010 at 7:02 AM, Stephen Tetley wrote: > I wouldn't use read instead something either a simple function: > > > verb :: String -> Maybe Verb > > verb "Go" = Just Go > > verb "Get" = Just Get > > verb _ = Nothing > > Or possible a Map: > > > verb2 :: String -> Maybe Verb > > v

Re: [Haskell-cafe] Parsers for Text Adventures

2010-01-17 Thread Luke Palmer
On Sun, Jan 17, 2010 at 6:30 AM, Mark Spezzano wrote: > I've written a Parser called keyword > > keyword :: Parser Verb > keyword = do x <- many1 letter >return (read x) > > (read this as > "take-at-least-one-alphabetic-letter-and-convert-to-a-Verb-type") > > which DOES wo

Re: [Haskell-cafe] Re: lawless instances of Functor

2010-01-05 Thread Luke Palmer
On Mon, Jan 4, 2010 at 7:25 PM, Maciej Piechotka wrote: > On Tue, 2010-01-05 at 08:01 +0900, Derek Elkins wrote: >> If h . p = q . g then fmap h . fmap p = fmap q . fmap g >> Setting p = id gives >> h . id = h = q . g && fmap h . fmap id = fmap q . fmap g >> Using fmap id = id and h = q . g we get

Re: [Haskell-cafe] Why doesn't laziness save the day here?

2010-01-05 Thread Luke Palmer
On Mon, Jan 4, 2010 at 6:31 PM, Dale Jordan wrote: > Can anyone explain why this is looping or point out a better way to > generate an arbitrary-length random list while still being able to > reuse the generator?  (I'd rather not use split since this generator > doesn't support it and its of dubio

Re: [Haskell-cafe] Re: Re: Data.Ring -- Pre-announce

2010-01-04 Thread Luke Palmer
On Mon, Jan 4, 2010 at 1:13 PM, Maciej Piechotka wrote: > However then we lost the monoid (ok. I haven't send patch but please > accept[1]) along with alternative/monad plus - which is much more > popular, standard and useful then Copointed/Comonad. This point is a self-fulfilling prophecy. We d

Re: [Haskell-cafe] A question on DSL's

2010-01-04 Thread Luke Palmer
On Mon, Jan 4, 2010 at 12:16 PM, Tom Hawkins wrote: > One argument for option 2 is to carry forward datatypes to the target > language.  For example, if you want to describe a state machine with > the state as a type: What do you mean "carry forward". Can you elaborate on your simple example? W

Re: [Haskell-cafe] Re: Data.Ring -- Pre-announce

2010-01-04 Thread Luke Palmer
On Mon, Jan 4, 2010 at 6:51 AM, Maciej Piechotka wrote: > About comonad - not exactly as every comonad is copointed and the only > possible way is extract Empty = _|_ I think this module could be cleaned up by disallowing empty lists. You have this nice semantic property that "every clist has a f

Re: [Haskell-cafe] lazily-loaded structures

2010-01-01 Thread Luke Palmer
On Fri, Jan 1, 2010 at 6:24 PM, Jeff Davis wrote: > I wonder if it might be useful to approach it like a virtual memory > system. Searching for a value that hasn't been loaded into the structure > would raise an exception, which would then be caught, handled by using > normal (safe) IO, and then t

Re: [Haskell-cafe] Data.Ring -- Pre-announce

2009-12-31 Thread Luke Palmer
On Thu, Dec 31, 2009 at 2:59 AM, John Van Enk wrote: > Hi List, > > I recently needed a ring structure (circular list with bi-directional > access) and didn't see anything obvious on Hackage. I threw something > together fairly quickly and would like some feedback before tossing it on > Hackage. >

Re: [Haskell-cafe] Space Efficiency When Sorting a List of Many Lists

2009-12-31 Thread Luke Palmer
On Wed, Dec 30, 2009 at 9:39 PM, Peter Green wrote: > I can guess that there might be be less laziness and more instantiation when >  sorting is introduced, Yes, by a lot. Sorting requires keeping the entire list in memory. And Haskell lists, unfortunately, are not that cheap in terms of space u

Re: [Haskell-cafe] Value classes

2009-12-30 Thread Luke Palmer
On Wed, Dec 30, 2009 at 1:12 PM, Mads Lindstrøm wrote: > This idea, of value classes, do not feel all that novel. Somebody has > properly thought about it before, but gave it a different name. If > anybody has links to some papers it would be much appreciated. If > anybody has some thoughts of the

[Haskell-cafe] Preconditions as Typeclasses (Was: Re: Mysterious factorial)

2009-12-30 Thread Luke Palmer
On Wed, Dec 30, 2009 at 11:15 AM, Ralf Hinze wrote: >> I would use: >> >> foldm :: Monoid m => [m] -> m >> >> Which is just a better implementation of mconcat / fold.  The reason I >> prefer this interface is that foldm has a precondition in order to >> have a simple semantics: the operator you're

Re: [Haskell-cafe] Mysterious factorial

2009-12-30 Thread Luke Palmer
On Wed, Dec 30, 2009 at 10:35 AM, Ralf Hinze wrote: > As an aside, in one of my libraries I have a combinator > for folding a list in a binary-subdivision scheme. > >> foldm                         :: (a -> a -> a) -> a -> [a] -> a I would use: foldm :: Monoid m => [m] -> m Which is just a bett

Re: [Haskell-cafe] Alternatives to type classes.

2009-12-29 Thread Luke Palmer
On Tue, Dec 29, 2009 at 6:22 PM, Jason Dusek wrote: >  Consider the real numbers. They "are" a group. We have an >  identity element `0', inverses and closure under the associative >  operation `+'. > >    Group+ = (+, 0, -1 * _) > >  They are another group, too -- the group with `*': > >    Group

Re: [Haskell-cafe] Finally tagless and abstract relational Algebra

2009-12-29 Thread Luke Palmer
On Tue, Dec 29, 2009 at 6:36 AM, Kim-Ee Yeoh wrote: > Conal gives a lot of useful advice on DSL design. > One way to start is to articulate existing pain. Where and why is SQL > painful? > Another trick is to work backwards: What kind of code do you really want to > write? A bit of unsolicited op

Re: [Haskell-cafe] Mixing internal functions and datatypes with externally available ones

2009-12-27 Thread Luke Palmer
On Sun, Dec 27, 2009 at 5:51 AM, DPX-Infinity wrote: > Hello. > I'm writing a library - some kind a wrapper around SDL library, an engine. > For example, I have a module Graphics.UI.SDL.XEngine.State and > functions modifyState and setColor in it. These functions are using > "global" variable of t

Re: [Haskell-cafe] getPtrSize works, but is annoying

2009-12-18 Thread Luke Palmer
On Fri, Dec 18, 2009 at 12:20 PM, Gregory Crosswhite wrote: > Ugh, I figured out how to write code to do what I wanted, but it seems like > an ugly solution: > >        getPtrSize :: Ptr a -> Int >        getPtrSize = getFrom dummy >          where >                getFrom :: a -> Ptr a -> Int >

Re: [Haskell-cafe] Re: Allowing hyphens in identifiers

2009-12-17 Thread Luke Palmer
On Thu, Dec 17, 2009 at 10:39 PM, Richard O'Keefe wrote: > > On Dec 18, 2009, at 5:00 PM, Luke Palmer wrote: >>  My preferred way to increase the readability of code is to >> keep names short and *limited in scope*. > > That's good.  Haskell code is chock full of

Re: [Haskell-cafe] Re: Allowing hyphens in identifiers

2009-12-17 Thread Luke Palmer
On Thu, Dec 17, 2009 at 8:39 PM, Richard O'Keefe wrote: > > On Dec 17, 2009, at 4:45 AM, Ben Millwood wrote: >> >> By the way, I like camelCase because I think that in most cases you >> *don't* want to break identifiers up into their component words > > My experience has been that in order to make

Re: [Haskell-cafe] Design question

2009-12-16 Thread Luke Palmer
On Wed, Dec 16, 2009 at 9:40 AM, hask...@kudling.de wrote: > Hi, > > i am not quite sure how to do this in the most elegant way: > > I have some data structures: > > data A = A Double > data B = B Double > data C = C Double > ... > > and i want to allow only a subset in another data structure, so

[Haskell-cafe] Pure extremism (was: Re: Why?)

2009-12-12 Thread Luke Palmer
On Fri, Dec 11, 2009 at 7:07 PM, Jason Dusek wrote: > 2009/12/11 Luke Palmer : >> The idea being that any code that is pure could be evaluated >> anywhere with a very simple interpreter. If you have pure >> code, you can trace it back and evaluate it in a sandbox where

Re: [Haskell-cafe] Why?

2009-12-11 Thread Luke Palmer
On Fri, Dec 11, 2009 at 4:55 PM, Jason Dusek wrote: > 2009/12/10 Luke Palmer : >> I always meet with armies of resistance when I say this... > >  The troops arrive. > >> ...but unsafePerformIO should die a horrible, unforgiven >> death. "Well what if

Re: [Haskell-cafe] Re: Why?

2009-12-11 Thread Luke Palmer
On Fri, Dec 11, 2009 at 10:04 AM, pbrowne wrote: > Two questions > 1) Is this correspondence between operational and logical semantics a > desirable property of *purity* in the Haskell world? > > 2) What, if anything, prevents the execution of a Haskell term from > being a proof in equational logi

Re: [Haskell-cafe] Why?

2009-12-10 Thread Luke Palmer
On Thu, Dec 10, 2009 at 6:34 PM, David Leimbach wrote: >> >> >> 2b. You can define brand new flow control constructs *inside* the >> >> language >> >> itself. (E.g., in Java, a "for" loop is a built-in language construct. >> >> In >> >> Haskell, "for" is a function in Control.Monad. Just a plain o

Re: [Haskell-cafe] Why?

2009-12-10 Thread Luke Palmer
On Thu, Dec 10, 2009 at 2:42 PM, Stephen Tetley wrote: > C'mon Andrew - how about some facts, references? Filling in :-) > 2009/12/10 Andrew Coppin : > > >> 1. Code optimisation becomes radically easier. The compiler can make very >> drastic alterations to your program, and not chance its meanin

Re: [Haskell-cafe] Re: Type system speculation

2009-12-10 Thread Luke Palmer
On Thu, Dec 10, 2009 at 1:46 PM, Andrew Coppin wrote: > o...@okmij.org wrote: >> >> Andrew Coppin wrote: >> >>> >>> What we're really trying to do here is attach additional information to a >>> value - information which exists only in the type checker's head, but has >>> no >>> effect on runtime b

Re: [Haskell-cafe] Lisp like symbols in haskell

2009-12-08 Thread Luke Palmer
On Tue, Dec 8, 2009 at 1:48 AM, Michael Vanier wrote: > Do you mean symbols as in "interned strings with an O(1) string comparison > method"?  I would love to have those, but I don't see an easy way to get it > without being in the IO or ST monad. data Sym = Sym String Hash fromString :: String

Re: [Haskell-cafe] When are undecidables ok?

2009-12-05 Thread Luke Palmer
On Sat, Dec 5, 2009 at 10:04 PM, Michael Snoyman wrote: > I know this is basically a rewording of a previous e-mail, but I realized > this is the question I *really* wanted to ask. > > We have this language extension UndecidableInstances (not to mention > OverlappingInstances), which seem to divid

Re: [Haskell-cafe] From function over expression (+, *) derive function over expression (+)

2009-12-04 Thread Luke Palmer
On Fri, Dec 4, 2009 at 10:26 AM, Radek Micek wrote: > Hello. > > I have two types for expression: > > data Expr = Add Expr Expr | Mul Expr Expr | Const Int > > data AExpr = AAdd AExpr AExpr | AConst Int > > The first one supports addition and multiplication and the second > only addition. > > I ca

Re: [Haskell-cafe] Is Haskell a Fanatic?

2009-12-04 Thread Luke Palmer
On Fri, Dec 4, 2009 at 9:34 AM, Keith Sheppard wrote: > There is nothing wrong with constructive criticism and debate. We > should welcome it and I think that the initial response did. But the > OP's follow up of: > > "It will be better for all of you to figure it out for yourselves and > gain mor

Re: [Haskell-cafe] GHC magic optimization ?

2009-12-04 Thread Luke Palmer
On Fri, Dec 4, 2009 at 9:44 AM, Mark Lentczner wrote: > > On Dec 4, 2009, at 2:43 AM, Luke Palmer wrote: > >> So GHC leaves it to the user to specify sharing.  If you want an >> expression shared, let bind it and reuse. > > Does GHC treat where and let the same in t

Re: [Haskell-cafe] Re: computing lists of pairs

2009-12-04 Thread Luke Palmer
On Fri, Dec 4, 2009 at 6:42 AM, Christian Maeder wrote: > Daniel Fischer schrieb: >> Am Mittwoch 02 Dezember 2009 18:54:51 schrieb Christian Maeder: >>> Daniel Fischer schrieb: However, according to a couple of tests, the "funkyName" version is somewhat faster and allocates less. >>> My

Re: [Haskell-cafe] GHC magic optimization ?

2009-12-04 Thread Luke Palmer
On Fri, Dec 4, 2009 at 3:36 AM, Neil Brown wrote: > But let's say you have: > > g x y = f x y * f x y > > Now the compiler (i.e. at compile-time) can do some magic.  It can spot the > common expression and know the result of f x y must be the same both times, > so it can convert to: > > g x y = le

Re: [Haskell-cafe] Greetings! 2D Graphics?

2009-12-04 Thread Luke Palmer
On Fri, Dec 4, 2009 at 12:13 AM, M Xyz wrote: > Greetings, my name is M. This is my first time posting to a mailing list so > forgive me if I've done something wrong. I just finished "Real World > Haskell" and am currently working through "School of Expression". I am new > to Haskell but I already

Re: [Haskell-cafe] Optimization with Strings ?

2009-12-03 Thread Luke Palmer
On Thu, Dec 3, 2009 at 12:21 PM, Alberto G. Corona wrote: > " In fact, the correct answer is that pEqualsP should produce an error and > qEqualsQ should never terminate" > > ¿¿??? > should? or you want to say "actually do that so the optimization does is not > done"? > The correct amswer is not th

Re: [Haskell-cafe] I miss OO

2009-12-03 Thread Luke Palmer
On Thu, Dec 3, 2009 at 4:09 AM, Peter Verswyvelen wrote: > Also Luke Palmer talked a couple of times about "co-algebraic" > approaches, but not being a computer scientist, I never really > understood what that meant ("just reverse all the arrows"?) Disclaimer: I a

Re: [Haskell-cafe] Implicit newtype unwrapping

2009-12-02 Thread Luke Palmer
On Wed, Dec 2, 2009 at 6:08 PM, Greg Fitzgerald wrote: > Gregory Crosswhite wrote: >> Out of curiosity, why would one want a "newtype" that were unwrapped >> implicitly, rather than just using "type"? > > One reason might be because you only switched from 'type' to 'newtype' > so that you could

Re: [Haskell-cafe] Existencial Types

2009-12-01 Thread Luke Palmer
On Tue, Dec 1, 2009 at 4:21 PM, rodrigo.bonifacio wrote: > Thanks Luke. > > In fact I, will have different implementations of the Transformation type. > Something like: > > data SelectScenarios = SelectScenarios { > > scIds :: [Id] > > } What is this different type buying you? You can never "dow

Re: [Haskell-cafe] module export question

2009-12-01 Thread Luke Palmer
On Tue, Dec 1, 2009 at 3:11 PM, Sean McLaughlin wrote: > Say I have the following module: > > > module A >  ( T(T) >  , t >  , val >  ) > where > > data T = T { t :: Int } > > val :: T > val = T 7 > > > > When I use

Re: [Haskell-cafe] Existencial Types

2009-12-01 Thread Luke Palmer
On Tue, Dec 1, 2009 at 11:21 AM, David Menendez wrote: > On Tue, Dec 1, 2009 at 1:00 PM, rodrigo.bonifacio > wrote: >> Dear all, I wrote the following  types: >> >>> class Transformation t where >>>  (<+>) :: t -> SPLModel  -> InstanceModel -> InstanceModel >> >>> data Configuration = forall t .

Re: [Haskell-cafe] Help mixing pure and IO code

2009-11-30 Thread Luke Palmer
On Mon, Nov 30, 2009 at 8:36 PM, Hector Guilarte wrote: > One time I needed to do use a random number in some places of a completly > pure program so I made a infinite list of random numbers and passed it > around all the time in the functions as they where called, using the head of > the list I p

Re: [Haskell-cafe] Great Programs to Read?

2009-11-30 Thread Luke Palmer
On Mon, Nov 30, 2009 at 5:22 AM, Michael Lesniak wrote: > Hello, > > In terms of > >  "to become a great programmer, you need to read great programs"[1] > > what are "great" programs written in Haskell (for your personal > definition of great), which source code is freely available on hackage > or

Re: [Haskell-cafe] Are there standard idioms for lazy, pure error handling?

2009-11-29 Thread Luke Palmer
On Sun, Nov 29, 2009 at 11:08 PM, Malcolm Wallace wrote: > Are you sure that there can be no error recovery, to continue with events > after a mal-formed event has been discarded?  In many cases, it is possible. >  However, if you really want to terminate the stream at the first error, and > to re

Re: Re[2]: [Haskell-cafe] haskell in online contests

2009-11-27 Thread Luke Palmer
On Fri, Nov 27, 2009 at 9:18 PM, vishnu wrote: > Hi Bulat >    hmm ok I understand the issue of compiler maturity. But I thought > lazyness was meant to be a bonus? Or is it that if you really try to squeeze > performance it becomes more of a hindrance? One of my favorite quotes by Heinrich Apfel

Re: [Haskell-cafe] I miss OO

2009-11-25 Thread Luke Palmer
On Thu, Nov 26, 2009 at 12:03 AM, Eugene Kirpichov wrote: > Hi, > > Are you sure you need to store the time *inside* your "objects" > instead of using, say, pairs "(Time, YourObject)" (and lists of them > instead of lists of your objects)? > It would seem strange to me that a note HAS-A time even

Re: [Haskell-cafe] I miss OO

2009-11-25 Thread Luke Palmer
On Wed, Nov 25, 2009 at 2:08 PM, Erik de Castro Lopo wrote: > Michael Mossey wrote: > >> I'm fairly new to Haskell, and starting to write some big projects. >> Previously I used OO exclusively, mostly Python. I really miss the >> "namespace" capabilities... a class can have a lot of generic method

Re: [Haskell-cafe] Idea for a very simple GUI llibrary

2009-11-22 Thread Luke Palmer
Nice idea. I will try it if you write runGUI :-) This is an imperative style library. For more Haskellian GUI library ideas, see Fruit (http://www.haskell.org/fruit/) and TVs (http://www.haskell.org/haskellwiki/TV). They may not pass the "builds" constraint :-P Luke 2009/11/22 Maurí­cio CA :

Re: [Haskell-cafe] Status of TypeDirectedNameResolution proposal?

2009-11-18 Thread Luke Palmer
You know, another solution to the records problem, which is not quite as convenient but much simpler (and has other applications) is to allow local modules. module Foo where module Bar where data Bar = Bar { x :: Int, y :: Int } module Baz where data Baz = Baz { x :: Int, y :: Int }

Re: [Haskell-cafe] Re: ANNOUNCE: deepseq-1.0.0.0

2009-11-17 Thread Luke Palmer
On Tue, Nov 17, 2009 at 8:48 PM, Dean Herington wrote: > The documentation claim that "The default implementation of 'deepseq' is > simply 'seq'" is not exactly right, as `deepseq` and `seq` have different > signatures.  Which raises the more interesting question: Why did you choose > a different

Re: Re[Haskell-cafe] cursive to foldr

2009-11-17 Thread Luke Palmer
On Tue, Nov 17, 2009 at 7:39 PM, David Menendez wrote: > On Tue, Nov 17, 2009 at 6:31 PM, Ezra Lalonde wrote: >> >> Using the same basic structure you did, and foldr, I think below is the >> simplest method: >> >> >> import Data.Maybe >> >> searchList :: (a -> Bool) -> [a] ->

Re: [Haskell-cafe] GHCi's :t misbehaving

2009-11-17 Thread Luke Palmer
It's very hard to tell what is going on without more details. If you *at least* give the ghci session, and possibly the whole code (while it might be too much to read, it is not to much to load and try ourselves). This looks like a monomorphism restriction, which shouldn't happen when you are usi

Re: [Haskell-cafe] Status of TypeDirectedNameResolution proposal?

2009-11-17 Thread Luke Palmer
On Tue, Nov 17, 2009 at 5:18 AM, Simon Peyton-Jones wrote: > | What's the status of the TDNR proposal [1]? Personally I think it is a > | very good idea and I'd like to see it in Haskell'/GHC rather sooner > | than later. Working around the limitations of the current record > | system is one of my

Re: [Haskell-cafe] Howto start a bigger project

2009-11-16 Thread Luke Palmer
Ummm. what is it? 2009/11/16 Günther Schmidt : > Hi all, > > I'm stuck with a problem where I need serious help from other haskellers, in > particular those that participate here on this list. It's a rather big > project and I will need to set it up in an organized way, something with a > blog

Re: [Haskell-cafe] bit of help with n-ary please...

2009-11-08 Thread Luke Palmer
On Mon, Nov 9, 2009 at 12:31 AM, Stefan Holdermans wrote: >> Answers to spec. > > > You didn't answered the "homework" question: > >>> I don't know if this is homework. > > I'm a bit suspicious: > http://www.dcs.shef.ac.uk/intranet/teaching/modules/level2/com2010.html  . > > See http://www.haskell

Re: [Haskell-cafe] Memoizing in parallel

2009-11-08 Thread Luke Palmer
On Sun, Nov 8, 2009 at 2:51 AM, Pierre-Etienne Meunier wrote: > Hi, > > I'm designing an algorithm that uses dynamic programming. I've written it > with an array, and it works, but it is still very slow and needs way too > much memory. > > Then I realized that the array was very sparse (at most a

Re: [Haskell-cafe] Fair diagonals

2009-11-06 Thread Luke Palmer
On Fri, Nov 6, 2009 at 3:06 AM, Martijn van Steenbergen wrote: > "(...) Likewise, a breadth-first search of a data structure can fall short > if it has an infinitely branching node. Omega addresses this problem by > using a "diagonal" traversal that gracefully dissolves such data." > > However, I

Re: [Haskell-cafe] Code generated by pointfree does not compile

2009-11-05 Thread Luke Palmer
On Thu, Nov 5, 2009 at 4:46 AM, Boris Lykah wrote: > > Hi all! > > I was playing with pointfree tool from hackage and found that it produces > wrong code for some functions which use list comprehension. > > Here are several examples: > > :main f x = concat [x:f x| x<-[0..x-1]] > f = fix ((join .)

Re: [Haskell-cafe] Fair diagonals

2009-11-03 Thread Luke Palmer
On Tue, Nov 3, 2009 at 1:42 PM, Martijn van Steenbergen wrote: > Dear café, > > I am looking for a function that does an N-dimensional diagonal traversal. I > want the traversal to be fair: the sum of the indices of the produced > combinations should be non-decreasing. Let me illustrate with an ex

Re: [Haskell-cafe] ANN: mecha-0.0.1

2009-10-31 Thread Luke Palmer
Neat! What a cool idea. On Sat, Oct 31, 2009 at 5:27 PM, Tom Hawkins wrote: > Mecha is a little solid modeling language intended for machine design. >  Mecha has two layers: a pure functional layer for defining solids > (aka. parts), and a monadic layer for arranging parts into assemblies. >  So

Re: [Haskell-cafe] Applicative but not Monad

2009-10-30 Thread Luke Palmer
On Fri, Oct 30, 2009 at 10:39 AM, Tom Davie wrote: > Of note, there is a sensible monad instance for zip lists which I *think* > agrees with the Applicative one, I don't know why they're not monads: > instance Monad (ZipList a) where >   return = Ziplist . return >   join (ZipList []) = ZipList []

Re: [Haskell-cafe] Real World Haskell Chapter 19 and GHC 6.10

2009-10-21 Thread Luke Palmer
On Wed, Oct 21, 2009 at 3:29 AM, Michael Mossey wrote: > The examples in the "error handling" chapter (19) of RWH don't run under GHC > 6.10. > > For instance, an example might be > > main = handle (\_ -> putStrLn "error") (print $ 5 `div` 0) > > Trying to load this results in "amigous type variab

Re: [Haskell-cafe] Re: list -> sublists

2009-10-20 Thread Luke Palmer
On Tue, Oct 20, 2009 at 9:27 AM, satorisanitarium wrote: > >> Now back to your original problem. Can you write a function g such that >> g [1,2,3,2,4,1,6,3,6,2,3,5,2,5,2,1,6,4] >> returns >> ([1,2,3],[2,4,1,6,3,6,2,3,5,2,5,2,1,6,4]) >> > I know the diference between x and [x], my problem lies in g

Re: [Haskell-cafe] Re: [Haskell-beginners] map question

2009-10-19 Thread Luke Palmer
On Sun, Oct 18, 2009 at 5:31 PM, Will Ness wrote: > Luke Palmer gmail.com> writes: > >> >> Or you could use the "subtract" function. >> >>   >>> map (subtract 2) [3,4,5] >>   [1,2,3] > > I don't want to. I think at about this

Re: [Haskell-cafe] How to use "bracket" properly ?

2009-10-19 Thread Luke Palmer
On Mon, Oct 19, 2009 at 6:10 AM, Roel van Dijk wrote: > On Mon, Oct 19, 2009 at 1:44 PM, zaxis wrote: >> oh! thanks!  But why ? > > A let can introduce multiple declarations. > > So this > > foo = do >  let x = 3 >  let y = 4 >  return $ x+ y > > can also be written like > > foo = do >  let x = 3

Re: [Haskell-cafe] Re: [Haskell-beginners] map question

2009-10-18 Thread Luke Palmer
On Sun, Oct 18, 2009 at 4:47 PM, Will Ness wrote: > Gregory Propf yahoo.com> writes: > >> >> >> I actually meant it as sort of a joke but maybe it's not after all. > > Seriously though, using anything non-ASCII in source code is a bad idea, > because there are lots of fonts and editors in the wor

Re: [Haskell-cafe] Very evil

2009-10-15 Thread Luke Palmer
Maybe you would like the hetero-map package. Its purpose is to do precisely what you are doing, but in a typesafe way. On Thu, Oct 15, 2009 at 3:10 PM, Andrew Coppin wrote: > {-# LANGUAGE EmptyDataDecls #-} > > module Main (main) where > > import Unsafe.Coerce > > data Anything > > newtype Key x

Re: [Haskell-cafe] How do I get this done in constant mem?

2009-10-09 Thread Luke Palmer
On Fri, Oct 9, 2009 at 2:05 PM, wrote: > Hi all, > > I think there is something about my use of the IO monad that bites me, > but I am bored of staring at the code, so here you g.  The code goes > through a list of records and collects the maximum in each record > position. > > > -- test.hs > imp

Re: [Haskell-cafe] Re: Generalizing IO

2009-10-08 Thread Luke Palmer
On Thu, Oct 8, 2009 at 1:42 PM, Andrew Coppin wrote: > Heinrich Apfelmus wrote: >> >> Alternatively, you can use algebraic data types instead of type classes >> to generalize one program to different implementations. For monads, this >> can be achieved with >> >>     http://hackage.haskell.org/pac

Re: [Haskell-cafe] random question

2009-10-07 Thread Luke Palmer
On Wed, Oct 7, 2009 at 2:59 PM, Michael Mossey wrote: > My thread about randomness got hijacked so I need to restate my remaining > question here. Is it acceptable to write pure routines that use but do not > return generators, and then call several of them from an IO monad with a > generator obta

Re: Re[2]: [Haskell-cafe] Creating an alias for a function

2009-10-07 Thread Luke Palmer
On Wed, Oct 7, 2009 at 1:26 AM, Bulat Ziganshin wrote: > Hello Ross, > > Wednesday, October 7, 2009, 6:02:28 AM, you wrote: > >> car = head > > unfortunately it doesn't work without -fno-monomorphism-restriction It should be fine without the monomorphism restriction. Said restriction only applie

Re: [Haskell-cafe] Splitting data and function declarations over multiple files

2009-09-30 Thread Luke Palmer
On Wed, Sep 30, 2009 at 9:54 AM, Peter Verswyvelen wrote: > I guess this is related to the expression problem. > Suppose I have a datatype > data Actor = Ball ... | Paddle ... | Wall ... > and a function > move (Ball ...) = > move (Paddle ...) = > move (Wall ...) = > in Haskell one must put Actor

Re: [Haskell-cafe] Type synonyms vs standard types

2009-09-29 Thread Luke Palmer
On Tue, Sep 29, 2009 at 2:21 PM, Olex P wrote: > This idea with new level of abstraction is good but in some cases it can > make things overcomplicated / less efficient. Does that mean "leave simple > built-in types as is"? > But probably that's all is the matter of habit and style. Well as far a

Re: [Haskell-cafe] Type synonyms vs standard types

2009-09-29 Thread Luke Palmer
On Tue, Sep 29, 2009 at 11:40 AM, Olex P wrote: > Hi everyone, > > Dumb question about declaring a function and type synonyms. > There are to different declarations of the same function: > > attrNames :: String -> AttrDict -> [String] > > attrNames :: AttrClass -> AttrDict -> AttrNames > > First g

Re: [Haskell-cafe] How to decide if a number is an integer?

2009-09-29 Thread Luke Palmer
On Tue, Sep 29, 2009 at 2:30 AM, Magicloud Magiclouds wrote: > Resolved. As Thomas said, mixing up sure is a bad thing. But then I > have to name so many meanless (at least I think) computing process That is the primary challenge of writing readable code: identifying the meaningful parts. Yo

Re: [Haskell-cafe] Re: QuickCheck Questions

2009-09-28 Thread Luke Palmer
On Mon, Sep 28, 2009 at 3:28 PM, Andrew Coppin wrote: > Ben Franksen wrote: >> >> If it turns out that a >> precise spec is unwieldy (too complex) then this is a hint that maybe it >> is >> not a good abstraction. > > Or your specification language is insufficient to describe it... > > (I don't kn

Re: [Haskell-cafe] An issue with EDSLs in the ``finally tagless'' tradition

2009-09-23 Thread Luke Palmer
On Wed, Sep 23, 2009 at 10:24 PM, Brad Larsen wrote: > On Wed, Sep 23, 2009 at 11:12 PM, Luke Palmer wrote: >> I would like to see an example of this unmodularity, making use of the >> polymorphism, so I can understand what you're asking better. >> >> Luke

Re: [Haskell-cafe] An issue with EDSLs in the ``finally tagless'' tradition

2009-09-23 Thread Luke Palmer
On Wed, Sep 23, 2009 at 7:59 PM, Brad Larsen wrote: > The trouble comes in when defining a more general arithmetic > expression type class.  Suppose we want polymorphic arithmetic > expressions: > >> class PolyArithExpr exp where >>   constant :: a     -> exp a >>   addP     :: exp a -> exp a -> e

Re: [Haskell-cafe] flexible contexts problem

2009-09-12 Thread Luke Palmer
2009/9/12 Sean McLaughlin : > I'm having trouble understanding the following behavior.  The following > program compiles: > {-# OPTIONS_GHC -XMultiParamTypeClasses -XFlexibleContexts  #-} > import Control.Monad.State > class Has α s where >   has :: s -> (α, s) > project :: (MonadState s m, Has α s

Re: Re[2]: [Haskell-cafe] memoization

2009-09-10 Thread Luke Palmer
On Thu, Sep 10, 2009 at 6:34 AM, Peter Verswyvelen wrote: > You might want to watch out for multithreading issues, although in > this case, I don't think it will cause sever problems, besides a > couple of redundant cache updates. > > > On Thu, Sep 10, 2009 at 2:07 PM, Bulat Ziganshin > wrote: >>

Re: [Haskell-cafe] How to Create Data Type of memory

2009-09-06 Thread Luke Palmer
On Sun, Sep 6, 2009 at 11:45 PM, Akshay Dave wrote: > Hi, >    Thanks for your prompt reply. Actually I am trying to convert the > following transitive semantics to Haskell: > > (Memory maps I to Z) > lookup m i =   ( meaning lookup for I in memory m) > > evB b m = true/(while b do c od;m) -> (c; w

Re: [Haskell-cafe] How to Create Data Type of memory

2009-09-06 Thread Luke Palmer
On Sun, Sep 6, 2009 at 11:22 PM, Akshay Dave wrote: > Hi All, >    I am stuck in converting the transition semantics in Haskell. Please let > me know how to define memory data types in Haskell( like we define pointer > in C). Prompt help would be greatly appreciated. I'm sorry, but I can't underst

Re: [Haskell-cafe] Trying to reduce memory costs of String duplicates

2009-09-05 Thread Luke Palmer
2009/9/5 Günther Schmidt : > Hi all, > > I'm reading in a data of 216k records into a map of Key, Values Pairs, the > values being strings. > > As it happens out of 216k String values there really are only about 6.6k > distinct string values, so I could save a lot of RAM if I was able to > "insert"

Re: [Haskell-cafe] Cleaning up stable names?

2009-09-01 Thread Luke Palmer
Have you considered computing a hash of the scene graph description (compositionally)? This gives you all the same advantages, including re-using shared subparts of the graph (which would be unlikely to stay around for very long as stable names). Luke On Tue, Sep 1, 2009 at 11:02 AM, Peter Versw

Re: [Haskell-cafe] Question about Lazy.IO

2009-09-01 Thread Luke Palmer
On Tue, Sep 1, 2009 at 3:05 AM, staafmeister wrote: > Hi, > > I've been wondering about Lazy IO for a while. Suppose we have a program > like > > main = interact (unlines . somefunction . lines) > > then somefunction is a pure function. With the semantic interpretation of: > given a input list > re

<    1   2   3   4   5   6   7   >