Re: [Haskell-cafe] Fwd: Re: Period of a sequence

2011-06-27 Thread Luke Palmer
On Mon, Jun 27, 2011 at 4:25 PM, Twan van Laarhoven wrote: > On 2011-06-27 13:51, Steffen Schuldenzucker wrote: > >> Could you specify what exactly the function is supposed to do? I am >> pretty sure that a function like >> >> seqPeriod :: (Eq a) => [a] -> Maybe Integer -- Nothing iff non-periodic

Re: [Haskell-cafe] ANNOUNCE: doctest-0.3.0

2011-06-16 Thread Luke Palmer
On Thu, Jun 16, 2011 at 12:22 PM, Simon Hengel wrote: > I just uploaded a new version of doctest[1] to Hackage. > Sweet! > I think using all lower-case package names is a good thing. I'm just curious -- why? Luke ___ Haskell-Cafe mailing list Haske

Re: [Haskell-cafe] Exception for NaN

2011-05-13 Thread Luke Palmer
On Thu, May 12, 2011 at 5:50 PM, Daniel Fischer < daniel.is.fisc...@googlemail.com> wrote: > Prelude Data.List> maximum [0,-1,0/0,-5,-6,-3,0/0,-2] > 0.0 > Prelude Data.List> minimum [0,-1,0/0,-5,-6,-3,0/0,-2] > -2.0 > Prelude Data.List> sort [0,-1,0/0,-5,-6,-3,0/0,-2] > [-6.0,-5.0,-2.0,NaN,-3.0,Na

Re: [Haskell-cafe] How often is the planet updated?

2011-04-28 Thread Luke Palmer
On Thu, Apr 28, 2011 at 4:26 AM, Magnus Therning wrote: > I see that Planet Haskell hasn't been updated since April 26. Is > something wrong with it, or does it really not update more often than > that? > In the past it has reliably updated within an hour of my publishing a new post. Luke _

Re: [Haskell-cafe] Haskell from SML - referrential Transparency?!

2011-04-19 Thread Luke Palmer
On Tue, Apr 19, 2011 at 1:41 PM, Gregory Guthrie wrote: > Perhaps the description was unclear; > >F1;f1 gives result r1;r2 (not the same) >F1;f2gives r1;r2 >F2,f1gives r1;r2 > No, you were clear, and Felipe's answer still makes sense. Since f1 and f2 have the sam

Re: [Haskell-cafe] "import" functionality in DSLs

2011-04-16 Thread Luke Palmer
You can get away with this using {-# LANGUAGE RecordWildCards #-}, if you put your prelude into a record. Here's a test I did to make sure the technique worked: {-# LANGUAGE RecordWildCards #-} import Prelude hiding ((+)) data Foo = Foo { (+) :: Int -> Int -> Int, n0 :: Int } prelude

Re: [Haskell-cafe] Programming Chalenges: The 3n+1 problem

2011-04-14 Thread Luke Palmer
On Thu, Apr 14, 2011 at 4:29 AM, Dmitri O.Kondratiev wrote: > 3n+1 is the first, "warm-up" problem at Programming Chalenges site: > > http://www.programming-challenges.com/pg.php?page=downloadproblem&probid=110101&format=html > > (This problem illustrates Collatz conjecture: > > http://en.wikipedi

Re: [Haskell-cafe] Deciding equality of functions.

2011-04-09 Thread Luke Palmer
On Sat, Apr 9, 2011 at 11:26 AM, Grigory Sarnitskiy wrote: > I guess that deciding whether two functions are equal in most cases is > algorithmically impossible. However maybe there exists quite a large domain > of decidable cases? If so, how can I employ that in Haskell? > > It is a common situat

Re: [Haskell-cafe] Asynchronous Arrows need Type Specialization - Help!

2011-04-02 Thread Luke Palmer
On Sat, Apr 2, 2011 at 10:09 AM, Paul L wrote: > Sorry, forgot to CC the list. I wonder why Gmail doesn't default to > reply-all. > If you have keyboard shortcuts on, reply to messages with the "a" key instead of the "r" key. I hardly ever use "r". Luke > On Fri, Apr 1, 2011 at 9:48 PM, David

Re: [Haskell-cafe] working off a Yesod example file, need help lifting values from one monad into another. (and probably other things too).

2011-03-28 Thread Luke Palmer
On Mon, Mar 28, 2011 at 6:28 PM, Michael Litchard wrote: > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > 10 > 11 > 12 > 13 > 14 > 15 > 16 > 17 > 18 > 19 > 20 > 21 > 22 > 23 > 24 > 25 > 26 > 27 > 28 > 29 > 30 > 31 > 32 > 33 > 34 > 35 > 36 > 37 > 38 > 39 > 40 > 41 > 42 > 43 > 44 > 45 > 46 > 47 > 48 > 49 > 50

Re: [Haskell-cafe] Tying the recursive knot

2011-03-24 Thread Luke Palmer
On Thu, Mar 24, 2011 at 4:02 PM, Joshua Ball wrote: > Never mind. I figured it out on my own. Here's my solution for > posterity. There's probably a "fix" hiding in there somewhere - notice > the new type of reduce. Yep, there is: > force :: M.Map Key Chain -> M.Map Key [Int] > force mp = ret wh

Re: [Haskell-cafe] a finite free category

2011-03-23 Thread Luke Palmer
On Wed, Mar 23, 2011 at 3:58 PM, Vasili I. Galchin wrote: > Hello, > >     Does there exist Haskell to generate a finite free category from a > finite multipath graph with loops? AKA the transitive closure of a graph? Luke ___ Haskell-Cafe mailing lis

Re: [Haskell-cafe] [Agda] Defining subtraction for naturals

2011-03-17 Thread Luke Palmer
If you are implementing lazy naturals, I wonder if defining 0 - 1 to be infinity makes mathematical sense. It's like arithmetic mod infinity Luke On Thu, Mar 17, 2011 at 12:35 PM, wren ng thornton wrote: > Another question on particulars. When dealing with natural numbers, we run > into the

Re: [Haskell-cafe] Type trickery

2011-03-16 Thread Luke Palmer
On Wed, Mar 16, 2011 at 7:52 AM, Andrew Coppin wrote: >>> Hmm, yes. That will work, but I wonder if there's some way of doing this >>> that doesn't limit the scope of the container to one single span of >>> code... >> >> You can write helper functions which take containers as argument by >> parame

Re: [Haskell-cafe] Reference monad

2011-03-11 Thread Luke Palmer
On Fri, Mar 11, 2011 at 8:18 PM, Joshua Ball wrote: > Suppose I want the following functions: > > newRef :: a -> RefMonad (Ref a) > readRef :: Ref a -> RefMonad a > writeRef :: Ref a -> a -> RefMonad () Assuming this is a pure interface, you need one more thing: runRefMonad :: RefMonad a -> a T

Re: [Haskell-cafe] ANN: theoremquest-0.0.0

2011-02-28 Thread Luke Palmer
On Mon, Feb 28, 2011 at 7:59 AM, Tom Hawkins wrote: > I have been wanting to gain a better understanding of interactive > theorem proving for some time.  And I've often wondered: Can theorem > proving be made into a user-friendly game that could attract mass > appeal? And if so, could a population

Re: [Haskell-cafe] Fun with the ST monad

2011-02-25 Thread Luke Palmer
Lazy ST is capable of returning values lazily. Not naively -- eg. if you are writing elements to an STRef and then returning the contents of the STRef at the end, then of course it will not return gradually (who's to say that the last thing you do before you return isn't to write [] to the STRef?)

Re: [Haskell-cafe] linear logic

2011-02-22 Thread Luke Palmer
On Tue, Feb 22, 2011 at 4:23 PM, Nick Rudnick wrote: > Hi Vasili, > > not understanding clearly «in a categorical logic sense» -- but I can be > sure you already checked out coherent spaces, which might be regarded as > underlying Girard's original works in this sense?? I have a faint idea about >

Re: [Haskell-cafe] monadic plumbing

2011-02-22 Thread Luke Palmer
On Tue, Feb 22, 2011 at 2:03 PM, Alberto G. Corona wrote: > Recently I had to navigatate trough data structures chained with mutable > referenes in th STM monad. The problem is that their values are enveloped in >  Either or Maybe results. > functional compositions in the Either of Maybe , or list

Re: [Haskell-cafe] Can i split a String by its element ?

2011-02-21 Thread Luke Palmer
See the http://hackage.haskell.org/package/split package. You should be able to do this by splitting the string on comma, and then splitting the result on 0, plus some plumbing. Luke On Mon, Feb 21, 2011 at 11:46 PM, z_axis wrote: > > I want to split "2,15,33,0,8,1,16,18" to ([2,15,33],[8,1,16,

Re: [Haskell-cafe] Infinite types should be optionally allowed

2011-02-21 Thread Luke Palmer
e > My test code is on github here: https://github.com/jvranish/InfiniteTypes > Also, is there a book you'd recommend that would explain this in further > detail? > Thanks, > - Job > > On Mon, Feb 16, 2009 at 5:16 PM, Luke Palmer wrote: >> >> On Sat, Feb 14, 2009 at 2:

Re: [Haskell-cafe] ANN: vector-buffer package 0.1

2011-02-14 Thread Luke Palmer
This interface is an outlaw. main = do buf <- newBuffer 10 :: IO (Buffer Int) pushNextElement buf 1 let v1 = V.toList (toVector buf) v2 = V.toList (toVector buf) print v1 pushNextElement buf 2 print v2 Despite v1 and v2 being defined to equal the exact same thing,

Re: [Haskell-cafe] Proving correctness

2011-02-11 Thread Luke Palmer
On Fri, Feb 11, 2011 at 4:06 AM, C K Kashyap wrote: > Hi Folks, > I've come across this a few times - "In Haskell, once can prove the > correctness of the code" - Is this true? You can prove the correctness of code for any language that has precise semantics. Which is basically none of them (I b

Re: [Haskell-cafe] community server & hasktags learned recursing into directories

2011-02-04 Thread Luke Palmer
On Fri, Feb 4, 2011 at 3:35 PM, Marc Weber wrote: > hasktags learned about how to recurse into subdirectories itself. > > This is especially useful for windows because writing scripts can be > done but is less well known > (http://stackoverflow.com/questions/4865391/answer/submit) > > Now I'd lik

Re: [Haskell-cafe] ($) not as transparent as it seems

2011-02-03 Thread Luke Palmer
This is probably a result of strictness analysis. error is technically strict, so it is reasonable to optimize to: let e = error "foo" in e `seq` error e On Thu, Feb 3, 2011 at 1:44 PM, Steffen Schuldenzucker wrote: > > Dear cafe, > > does anyone have an explanation for this?: > error

Re: [Haskell-cafe] Haskell for children? Any experience?

2011-01-28 Thread Luke Palmer
On Fri, Jan 28, 2011 at 10:47 AM, Chris Smith wrote: > Jason, thanks for the comments.  Unfortunately, I probably won't do blogs > about it.  Hate to say it, but anyone who has read much outside of > /r/haskell will surely agree it's irresponsible to write about children on > Reddit.  And things I

Re: [Haskell-cafe] Browser Game Engine

2011-01-17 Thread Luke Palmer
On Sun, Jan 16, 2011 at 8:26 PM, Tom Hawkins wrote: > I want to create a simple browser game using Haskell.  It would be > nothing complicated: basic 2D graphics, limited sound, and minimal > network traffic. > > What is the recommended medium?  Flash or JavaScript+SVG? Unity3D is scriptable with

Re: [Haskell-cafe] H98, OOHaskell - getting started with objects in Haskell

2011-01-17 Thread Luke Palmer
On Mon, Jan 17, 2011 at 1:44 AM, Wolfgang Jeltsch wrote: > Am Sonntag, den 16.01.2011, 14:48 -0800 schrieb gutti: >> Looking at life u probably could save time, if u only would evaluate >> code on cells, where the neighbors have changed status. So rather than >> triggering them all centrally and e

Re: [Haskell-cafe] Is this the "right" way to do polymorphism?

2011-01-07 Thread Luke Palmer
If you always expect to be passing c as a parameter and never returned, it is probably better off as a data type. Eg. HTTPClient might look like a traditional OO class: class HTTPClient c where foo :: c -> stuff bar :: c -> stuff I've found that it is easier to work with if y

Re: [Haskell-cafe] Problem on overlapping instances

2011-01-05 Thread Luke Palmer
You can't. If you have special semantics for [String], then it is not really a [String], it is something else. So let the type system know that: newtype SomethingElse = SomethingElse [String] instance Binary SomethingElse where ... On Wed, Jan 5, 2011 at 1:24 AM, Magicloud Magiclouds wrot

Re: [Haskell-cafe] How about Haskell Golf just like vimgolf.com

2011-01-03 Thread Luke Palmer
On Mon, Jan 3, 2011 at 5:47 PM, Alex Kropivny wrote: > Could a subreddit of some kind be used for this, or is a new site necessary? Or maybe a stackexchange. While they are publicly going for big "official branding" sites, I get the impression that they would be open to a little thing like this.

Re: [Haskell-cafe] A good video on monad

2011-01-03 Thread Luke Palmer
On Sun, Jan 2, 2011 at 11:48 PM, C K Kashyap wrote: > Hi, > I found this nice video on monads (although for clojure). > > http://www.youtube.com/watch?v=ObR3qi4Guys > > Question - in the video, if I understood right, the guy implements > "return" as a function that takes a value and returns a func

Re: [Haskell-cafe] getting last char of String

2010-12-31 Thread Luke Palmer
http://haskell.org/hoogle/?hoogle=[Char]+-%3E+Char "last" looks conspicuous :-) On Fri, Dec 31, 2010 at 1:39 PM, Aaron Gray wrote: > Is there an easy Haskell function that gets the last Char of a [Char] or > String ? > Many thanks in advance, > Aaron > > _

Re: [Haskell-cafe] What's the motivation for η rul es?

2010-12-28 Thread Luke Palmer
Eta conversion corresponds to extensionality; i.e. there is nothing more to a function than what it does to its argument. Suppose f x = g x for all x. Then using eta conversion: f = (\x. f x) = (\x. g x) = g Without eta this is not possible to prove. It would be possible for two functions to b

Re: [Haskell-cafe] IO, sequence, lazyness, takeWhile

2010-12-13 Thread Luke Palmer
On Mon, Dec 13, 2010 at 7:15 AM, Jacek Generowicz wrote: > -- Is it possible to rewrite code written in this style > > untilQuit = do >  text <- getLine >  report text >  if text == "quit" >     then return () >     else untilQuit > > -- in a style using higher order functions for abstract iterati

Re: [Haskell-cafe] Offer to mirror Hackage

2010-12-08 Thread Luke Palmer
On Wed, Dec 8, 2010 at 8:29 AM, C. McCann wrote: > On Wed, Dec 8, 2010 at 5:41 AM, Ketil Malde wrote: >> I'm a bit surprised to find that there seems to be a lot of opposition >> to this view, but perhaps the existing structure is more secure than I >> thought? > > The difference is in the abilit

Re: [Haskell-cafe] Help defining a Typeable polymorphic-state monad transformer

2010-12-06 Thread Luke Palmer
This has nothing to do with a monad. This is just about data. You want a type that can contain any Typeable type, and a safe way to cast out of that type into the type that came in. Such a thing exists, it's called Data.Dynamic. Then your monad is just StateT Dynamic, where your magical maybeif

Re: [Haskell-cafe] Interactive OpenGL-based graphics and ghci?

2010-11-20 Thread Luke Palmer
On Sat, Nov 20, 2010 at 4:46 PM, Conal Elliott wrote: > I'm trying to find some way to do interactive, OpenGL-based graphics in > Haskell on Mac OS X. > Does anyone here use GLUT or SDL on Mac OS X with ghci, or maybe an > alternative library? I was reading the GHC 7 release notes and saw this:

Re: [Haskell-cafe] Ralf Laemmel's riddle on surviving without the monad transformation library

2010-11-15 Thread Luke Palmer
I haven't watched the lecture. But what does he mean "survive"? Does it mean to do anything that you can do with mtl? On Mon, Nov 15, 2010 at 12:53 AM, C K Kashyap wrote: > Hi, > > Can someone provide me the solution to the following riddle that Ralf > asked in his lecture at > http://channel9.

Re: [Haskell-cafe] Re: ANNOUNCE zeno 0.1.0

2010-11-15 Thread Luke Palmer
Is the source code public, so I can run it on my own machine? Luke >> Hi all, >> >> My masters project Zeno was recently mentioned on this mailing list so >> I thought I'd announce that I've just finished a major update to it, >> bringing it slightly closer to being something useful. Zeno is a fu

Re: [Haskell-cafe] Re: ANNOUNCE zeno 0.1.0

2010-11-15 Thread Luke Palmer
Oops. It's right there on the site. My eyes skipped over it for some reason. On Sat, Nov 13, 2010 at 2:11 PM, Luke Palmer wrote: > Is the source code public, so I can run it on my own machine? > > Luke > >>> Hi all, >>> >>> My masters project Zeno wa

Re: [Haskell-cafe] Re: ANNOUNCE zeno 0.1.0

2010-11-13 Thread Luke Palmer
I guess I'm not on the list that received the original announce. But I have to say, I played with the demo ( http://www.doc.ic.ac.uk/~ws506/tryzeno/ ). Wow! I am delighted and impressed, and I think this is a huge step forward. Great work! Luke On Sat, Nov 13, 2010 at 1:31 AM, Petr Pudlak wr

Re: [Haskell-cafe] Splittable random numbers

2010-11-12 Thread Luke Palmer
On Fri, Nov 12, 2010 at 3:33 AM, Richard Senington wrote: > In short, I am worried by the properties of this random number generator. I > propose improving the testing system, and then posting both the test suite > and this random generator to > Hackage, unless you really want it up now in a very

Re: [Haskell-cafe] Serialization of (a -> b) and IO a

2010-11-11 Thread Luke Palmer
On Thu, Nov 11, 2010 at 6:16 PM, Dan Doel wrote: > serialize is not at all the same in this regard. There is no class of > functions that is immune to its inspection powers, presumably, because that's > its whole point. But that also means that there is no class of functions for > which we are jus

Re: [Haskell-cafe] Splittable random numbers

2010-11-11 Thread Luke Palmer
On Thu, Nov 11, 2010 at 3:13 AM, Richard Senington wrote: > I got hold of, and looked through the paper suggested in the root of this > thread “Pseudo random trees in Monte-Carlo", and based upon this > I have thrown together a version of the binary tree based random number > generator suggested.

Re: [Haskell-cafe] Type Directed Name Resolution

2010-11-11 Thread Luke Palmer
On Thu, Nov 11, 2010 at 1:41 AM, Luke Palmer wrote: > On Thu, Nov 11, 2010 at 1:34 AM, John Lask wrote: >> On 11/11/2010 5:21 PM, Ketil Malde wrote: >>> >>> "Richard O'Keefe"  writes: >>> >>>>> it is often desirable to h

Re: [Haskell-cafe] Type Directed Name Resolution

2010-11-11 Thread Luke Palmer
On Thu, Nov 11, 2010 at 1:34 AM, John Lask wrote: > On 11/11/2010 5:21 PM, Ketil Malde wrote: >> >> "Richard O'Keefe"  writes: >> it is often desirable to have the same field names for many records in the same module. >> > > very much so, this is currently possible, with the restriction

Re: [Haskell-cafe] Serialization of (a -> b) and IO a

2010-11-11 Thread Luke Palmer
On Thu, Nov 11, 2010 at 12:53 AM, Jesse Schalken wrote: > I have had a look at hs-plugins, but it is unclear how to derive a simple > pair of functions `(a -> b) -> ByteString` and `ByteString -> Either > ParseError (a -> b)`, for example, from the functionality it provides, if it > is possible at

Re: [Haskell-cafe] Re: "Haskell is a scripting language inspiredby Python."

2010-11-04 Thread Luke Palmer
On Thu, Nov 4, 2010 at 6:00 PM, Donn Cave wrote: > I don't care about whether Python had any influence, but I'd sure > like to stamp out the "scripting language" rumor. You all are talking about calling Haskell a scripting language like it's a bad thing. Coming from a Perl background, I learned

Re: [Haskell-cafe] What is simplest extension language to implement?

2010-11-04 Thread Luke Palmer
On Thu, Nov 4, 2010 at 5:30 AM, Malcolm Wallace wrote: >> ehm. I missed something and ghc api is well documented and stable ? > > There are other ways of adding Haskell as a scripting language - bundling > ghc is not necessary. Do tell. >> It is inacceptable for scripting language, faced to no-p

Re: [Haskell-cafe] Re: Text: find

2010-10-17 Thread Luke Palmer
On Sun, Oct 17, 2010 at 4:05 PM, Bryan O'Sullivan wrote: > On Sun, Oct 17, 2010 at 1:51 PM, Antoine Latter wrote: >> >> What would the definition of a function of the form: >> >> > find :: (Text -> Bool) -> Text -> Maybe Text >> >> look like? > > Can you be more specific? I assume you mean that t

Re: [Haskell-cafe] Compiling a DSL on the shoulders of GHC

2010-10-17 Thread Luke Palmer
On Sun, Oct 17, 2010 at 12:12 PM, Patai Gergely wrote: >> And it is not enough to provide just a driver function, that is called in >> 'main', say >>    run :: IOArrow a b -> a -> IO b >> ? > No, because I need to compile the stream processing program itself by a > different tool. Not sure how th

Re: [Haskell-cafe] Strict Core?

2010-10-15 Thread Luke Palmer
On Fri, Oct 15, 2010 at 4:21 PM, Andrew Coppin wrote: >  On 15/10/2010 11:10 PM, Gregory Crosswhite wrote: >> >>  Yes, I had seen this paper before and wondered the same thing at the >> time, but it was only just now when you brought the paper up that I realized >> I could ask people about it here

Re: [Haskell-cafe] Re: Re-order type (flip map)

2010-10-10 Thread Luke Palmer
On Sun, Oct 10, 2010 at 4:47 PM, Ozgur Akgun wrote: > > On 10 October 2010 22:32, Johannes Waldmann > wrote: >> >> Oh, and while we're at it - are there standard notations >> for "forward" function composition and application? >> >> I mean instead of      h . g . f $ x >> I'd sometimes prefer   x

Re: [Haskell-cafe] Eta-expansion destroys memoization?

2010-10-07 Thread Luke Palmer
On Thu, Oct 7, 2010 at 6:17 AM, Brent Yorgey wrote: > The source code seems to be easy to read, but I don't think I understand > that. For me I think if I change the first line from > fib = ((map fib' [0 ..]) !!) > to > fib x = ((map fib' [0 ..]) !!) x > It should do the same thing since I think

Re: [Haskell-cafe] Pronouncing "Curry" and "currying"

2010-10-06 Thread Luke Palmer
Here's how I say it (literally): http://hubrisarts.com/curry.wav On Wed, Oct 6, 2010 at 1:21 PM, Petr Pudlak wrote: > Hi all, > > I have a question for native English speakers: What is the correct > pronunciation of the name "Curry" (in "Haskell Curry") and the derived verb > "currying"? I found

Re: Re[2]: [Haskell-cafe] Lambda-case / lambda-if

2010-10-05 Thread Luke Palmer
On Mon, Oct 4, 2010 at 9:04 PM, Dean Herington wrote: > With respect to "datatype destructing" functions, the Prelude has: > > maybe :: b -> (a -> b) -> Maybe a -> b > either :: (a -> c) -> (b -> c) -> Either a b -> c > > which suggests the following signatures for the analogues for Bool and list

Re: [Haskell-cafe] Polyvariadic functions operating with a monoid

2010-10-03 Thread Luke Palmer
On Sun, Oct 3, 2010 at 1:26 PM, Luke Palmer wrote: > On Sun, Oct 3, 2010 at 1:24 AM, Kevin Jardine wrote: >> I had a situation where I had some related types that all had toString >> functions. >> >> Of course in Haskell, lists all have to be composed of values of &

Re: [Haskell-cafe] Polyvariadic functions operating with a monoid

2010-10-03 Thread Luke Palmer
On Sun, Oct 3, 2010 at 1:24 AM, Kevin Jardine wrote: > I had a situation where I had some related types that all had toString > functions. > > Of course in Haskell, lists all have to be composed of values of > exactly the same type, so instead of passing around lists of values > with these related

Re: [Haskell-cafe] Re: I still cannot seem to get a GUI working under Windows.

2010-10-02 Thread Luke Palmer
On Sat, Oct 2, 2010 at 4:32 AM, Bulat Ziganshin wrote: > Hello Heinrich, > > Saturday, October 2, 2010, 1:36:48 PM, you wrote: > >> Would you put a flattr button [1] on the wxHaskell page? This way, >> people like me would be able to show their appreciation by donating a > > this page doesn't desc

Re: [Haskell-cafe] Re: Ultra-newbie Question

2010-09-20 Thread Luke Palmer
On Mon, Sep 20, 2010 at 5:11 PM, Luke Palmer wrote: > On Sun, Sep 19, 2010 at 5:01 PM, Henrique Becker > wrote: >> Why not? >> >> import Data.Number.Nat as N >> >> lastN :: Integral b => b -> [a] -> [a] >> lastN n xs = N.drop (N.length xs - n&#x

Re: [Haskell-cafe] Re: Ultra-newbie Question

2010-09-20 Thread Luke Palmer
On Sun, Sep 19, 2010 at 5:01 PM, Henrique Becker wrote: > Why not? > > import Data.Number.Nat as N > > lastN :: Integral b => b -> [a] -> [a] > lastN n xs = N.drop (N.length xs - n') xs >        where n' = N.toNat n Wow. That is gorgeous! I think it's basically the same idea as my "zipWith" imp

Re: [Haskell-cafe] Ultra-newbie Question

2010-09-18 Thread Luke Palmer
I think this is O(n) time, O(1) space (!). lastk :: Int -> [a] -> [a] lastk k xs = last $ zipWith const (properTails xs) (drop k xs) where properTails = tail . tails Luke On Sat, Sep 18, 2010 at 1:51 PM, Daniel Fischer wrote: > On Saturday 18 September 2010 19:44:38, Jake McArthur wrote: >>

Re: [Haskell-cafe] Reachable variables exercise

2010-09-16 Thread Luke Palmer
I am not totally sure if I understand your proposal correctly, but if I do, then it has a flaw. Consider: class Boolable a where boolify :: a -> Bool class O a where o :: a main = print $ boolify o It seems like under your proposal this should not be a type error. B

Re: [Haskell-cafe] record update

2010-09-14 Thread Luke Palmer
On Tue, Sep 14, 2010 at 1:31 PM, Jonathan Geddes wrote: > With these extensions, couldn't I write the following? >>someUpdate :: MyRecord -> MyRecord >>someUpdate myRecord@(MyRecord{..}) = let >>     { field1 = f field1 >>     , field2 = g field2 >>     , field3 = h filed3 >>     } in myRecord{..}

Re: [Haskell-cafe] Statically tracking "validity" - suggestions?

2010-08-31 Thread Luke Palmer
I have a description of the design pattern you need, appropriately named: http://lukepalmer.wordpress.com/2009/03/24/certificate-design-pattern/ On Tue, Aug 31, 2010 at 12:24 AM, strejon wrote: > > Hello. I'm using Haskell to write a specification for some software. The > software uses certificat

Re: [Haskell-cafe] Re: Fwd: Semantics of iteratees, enumerators, enumeratees?

2010-08-23 Thread Luke Palmer
On Mon, Aug 23, 2010 at 1:06 AM, Heinrich Apfelmus wrote: > Conal Elliott wrote: >> >> For anyone interested in iteratees (etc) and not yet on the iteratees >> mailing list. >> >> I'm asking about what iteratees *mean* (denote), independent of the >> various >> implementations.  My original note (

Re: [Haskell-cafe] Simple Sudoku solver using Control.Monad.Logic

2010-08-22 Thread Luke Palmer
On Sun, Aug 22, 2010 at 1:18 PM, Daniel Fischer wrote: > On Sunday 22 August 2010 20:12:16, Vladimir Matveev wrote: >> I think the problem is with terribly inefficient data representation. > > Worse, it's a terribly inefficient algorithm. > The constraints are applied too late, so a huge number of

Re: [Haskell-cafe] lazy skip list?

2010-08-19 Thread Luke Palmer
On Thu, Aug 19, 2010 at 9:57 PM, Felipe Lessa wrote: > However, I haven't thought about how operations such as 'cons' and > 'tail' would be implemented =).  OP just asked about indexing ;-). Well if all you need is indexing, then an integer trie does it, right? http://hackage.haskell.org/package

Re: [Haskell-cafe] Can we come out of a monad?

2010-08-09 Thread Luke Palmer
On Mon, Aug 9, 2010 at 1:19 PM, John Lato wrote: > I don't find purify2 particularly helpful because I almost never want > to break out of any arbitrary monad; I want to be able to break out of > a specific monad without knowing which monad it is, that is: > > purify3 :: Monad m => m a -> a > puri

Re: [Haskell-cafe] Laziness question

2010-08-01 Thread Luke Palmer
On Sun, Aug 1, 2010 at 2:53 AM, Stefan Holdermans wrote: > Nicolas, > >> I would deeply in favor of renaming seq to unsafeSeq, and introduce a >> type class to reintroduce seq in a disciplined way. > > There is a well-documented [1] trade-off here:  Often, calls to seq are > introduced late in a

Re: [Haskell-cafe] OpenGL Speed!

2010-07-29 Thread Luke Palmer
Yep, no surprise there. I would suggest using bitmap[1] to construct your bitmap, and bitmap-opengl to put it into an OpenGL texture and draw it on a textured quad. I think OpenGL is actually an OK choice for this application, because it is the most portable graphics method we have available. If

Re: [Haskell-cafe] Memoization in Haskell?

2010-07-08 Thread Luke Palmer
On Thu, Jul 8, 2010 at 4:23 PM, Daniel Fischer wrote: > On Friday 09 July 2010 00:10:24, Daniel Fischer wrote: >> You can also use a library (e.g. >> http://hackage.haskell.org/package/data- memocombinators) to do the >> memoisation for you. > > Well, actualy, I think http://hackage.haskell.org/pa

Re: [Haskell-cafe] Finding zipper for custom tree

2010-07-01 Thread Luke Palmer
On Thu, Jul 1, 2010 at 1:54 PM, Sergey Mironov wrote: > Hello list! > I am trying to understand zipper concept using papers like [1] and [2]. > Though main idea looks clear, I still have a problem in applying it for > custom data types. > > Please help me with deriving Zipper-type from > >> data D

Re: [Haskell-cafe] whine and solution about programmers not respecting documentations

2010-06-28 Thread Luke Palmer
On Mon, Jun 28, 2010 at 1:44 PM, Albert Y.C.Lai wrote: > Why should anyone expect > >  deleteBy (>=) 5 [0..10] > > to accomplish anything meaningful, if he/she respects the written docs? I proposed the following solution: http://lukepalmer.wordpress.com/2009/07/01/on-the-by-functions/ > > Tod

Re: [Haskell-cafe] The Arrow class (was: Vague: Assembly line process)

2010-06-19 Thread Luke Palmer
On Fri, Jun 18, 2010 at 5:57 PM, Ryan Ingram wrote: > Related to this, I really would like to be able to use arrow notation > without "arr"; I was looking into writing a "circuit optimizer" that > modified my arrow-like circuit structure, but since it's impossible to > "look inside" arr, I ran int

Re: [Haskell-cafe] Vague: Assembly line process

2010-06-14 Thread Luke Palmer
So hang on, what is the problem? You have described something like a vague model, but what information are you trying to get? Say, perhaps, a set of possible output lists from a given input list? Luke On Mon, Jun 14, 2010 at 11:16 AM, Martin Drautzburg wrote: > Hello all, > > this is a problem

Re: [Haskell-cafe] How to browse code written by others

2010-06-14 Thread Luke Palmer
On Mon, Jun 14, 2010 at 2:02 AM, Jean-Marie Gaillourdet wrote: > Hello, > > On 13.06.2010, at 22:32, Martin Drautzburg wrote: > >> I need your advice about how to browse code which was written by someone else >> (Paul Hudak's Euterpea, to be precise, apx. 1 LOC). I had set some hopes >> on lek

Re: [Haskell-cafe] Re: How to "Show" an Operation?

2010-06-11 Thread Luke Palmer
On Thu, Jun 10, 2010 at 2:10 PM, Maciej Piechotka wrote: > data Named a = Named String a > > instance Functor Named where >    f `fmap` (Named s v) = Named s (f v) > > instance Applicative Named where >    pure x = Named "" x >    (Named s f) <*> (Named t v) = Named (s ++ "(" ++ t ++ ")") (f v) T

Re: [Haskell-cafe] Re: How to "Show" an Operation?

2010-06-10 Thread Luke Palmer
On Thu, Jun 10, 2010 at 10:43 PM, Brandon S. Allbery KF8NH wrote: > On Jun 10, 2010, at 17:38 , Martin Drautzburg wrote: >>> >>> instance Applicative Named where >>>   pure x = Named "" x >>>   (Named s f) <*> (Named t v) = Named (s ++ "(" ++ t ++ ")") (f v) >> >> Applicative. Need to study that >

Re: [Haskell-cafe] Thread scheduling

2010-06-10 Thread Luke Palmer
Say, using System.Time.getClockTime. Luke On Thu, Jun 10, 2010 at 11:31 PM, Luke Palmer wrote: > On Thu, Jun 10, 2010 at 11:50 AM, Andrew Coppin > wrote: >> Control.Concurrent provides the threadDelay function, which allows you to >> make the current thread sleep until T

Re: [Haskell-cafe] Thread scheduling

2010-06-10 Thread Luke Palmer
On Thu, Jun 10, 2010 at 11:50 AM, Andrew Coppin wrote: > Control.Concurrent provides the threadDelay function, which allows you to > make the current thread sleep until T=now+X. However, I can't find any way > of making the current thread sleep until T=X. In other words, I want to > specify an abs

Re: [Haskell-cafe] How to "Show" an Operation?

2010-06-09 Thread Luke Palmer
On Wed, Jun 9, 2010 at 12:33 PM, Martin Drautzburg wrote: > So far so good. However my "Named" things are all functions and I don't see I > ever want to map over any of them. But what I'd like to do is use them like > ordinary functions as in: > > f::Named (Int->Int) > f x > > Is there a way to do

Re: [Haskell-cafe] Proof question -- (==) over Bool

2010-05-21 Thread Luke Palmer
2010/5/21 R J : > I'm trying to prove that (==) is reflexive, symmetric, and transitive over > the Bools, given this definition: > (==)                       :: Bool -> Bool -> Bool > x == y                     =  (x && y) || (not x && not y) > My question is:  are the proofs below for reflexivity

Re: [Haskell-cafe] ANN: has-0.4 Entity based records

2010-05-04 Thread Luke Palmer
On Tue, May 4, 2010 at 10:18 AM, HASHIMOTO, Yusaku wrote: > Hello, > > I'm pleased to announce the release of my new library, named "has", > written to aim to ease pain at inconvinience of Haskell's build-in > records. Hmm, nice work, looks interesting. > With the has, You can reuse accessors ov

Re: [Haskell-cafe] Strict type system allows for a maximum number of programming errors to be caught at compile time.

2010-05-03 Thread Luke Palmer
On Mon, May 3, 2010 at 10:13 PM, Ivan Miljenovic wrote: > On 4 May 2010 13:30, Luke Palmer wrote: >> Here is a contrived example of what I am referring to: >> >> prefac f 0 = 1 >> prefac f n = n * f (n-1) >> >> fac = (\x -> x x) (\x -> prefac (x x)) &

Re: [Haskell-cafe] Strict type system allows for a maximum number of programming errors to be caught at compile time.

2010-05-03 Thread Luke Palmer
On Mon, May 3, 2010 at 11:07 AM, Kyle Murphy wrote: > The problem with dynamic typing is that it has a much higher chance of > having a subtle error creep into your code that can go undetected for a long > period of time. A strong type system forces the code to fail early where > it's easier to tr

Re: [Haskell-cafe] Strict type system allows for a maximum number of programming errors to be caught at compile time.

2010-05-03 Thread Luke Palmer
On Mon, May 3, 2010 at 9:34 AM, Casey Hawthorne wrote: >>Strict type system allows for a maximum number of programming errors to be >>caught at compile time. > > I keep hearing this statement but others would argue that programming > errors caught at compile time only form a minor subset of all e

Re: [Haskell-cafe] Re: Learning about Programming Languages (specifically Haskell)

2010-05-03 Thread Luke Palmer
On Mon, May 3, 2010 at 9:17 AM, Kyle Murphy wrote: > Reasons to learn Haskell include: > Lazy evaluation can make some kinds of algorithms possible to implement that > aren't possible to implement in other languages (without modification to the > algorithm). One could say the reverse as well. I

Re: [Haskell-cafe] singleton types

2010-04-25 Thread Luke Palmer
2010/4/25 Günther Schmidt : > Hello, > > HaskellDB makes extensive use of Singleton Types, both in its original > version and the more recent one where it's using HList instead of the legacy > implementation. > > I wonder if it is possible, not considering feasibility for the moment, to > implement

Re: [Haskell-cafe] I need help getting started

2010-04-24 Thread Luke Palmer
On Sat, Apr 24, 2010 at 10:34 PM, wrote: > Hi, > > > > I’m just starting to learn, or trying to learn Haskell.  I want to write a > function to tell me if a number’s prime.  This is what I’ve got: > > > > f x n y = if n>=y > >   then True > >   else > >   if gcd x n == 1 >

Re: [Haskell-cafe] FRP for game programming / artifical life simulation

2010-04-21 Thread Luke Palmer
On Wed, Apr 21, 2010 at 4:47 PM, Ben Christy wrote: > I have an interest in both game programming and artificial life. I have > recently stumbled on Haskell and would like to take a stab at programming a > simple game using FRP such as YAMPA or Reactive but I am stuck. I am not > certain which one

Re: [Haskell-cafe] Re: instance Eq (a -> b)

2010-04-14 Thread Luke Palmer
On Wed, Apr 14, 2010 at 5:13 AM, Luke Palmer wrote: > On Wed, Apr 14, 2010 at 4:41 AM,   wrote: >> As ski noted on #haskell we probably want to extend this to work on Compact >> types and not just Finite types >> >> instance (Compact a, Eq b) => Eq (a -> b)

Re: [Haskell-cafe] Re: instance Eq (a -> b)

2010-04-14 Thread Luke Palmer
On Wed, Apr 14, 2010 at 4:41 AM, wrote: > As ski noted on #haskell we probably want to extend this to work on Compact > types and not just Finite types > > instance (Compact a, Eq b) => Eq (a -> b) where ... > > For example (Int -> Bool) is a perfectly fine Compact set that isn't finite > and (In

Re: [Haskell-cafe] Announce: hothasktags

2010-04-07 Thread Luke Palmer
On Wed, Apr 7, 2010 at 1:23 AM, Evan Laforge wrote: > On Thu, Apr 1, 2010 at 1:46 PM, Luke Palmer wrote: >> Hi, >> >> I'd like to draw attention to a little script I wrote.  I tend to use >> qualified imports and short names like "new" and "filte

Re: [Haskell-cafe] Re: Hackage accounts and real names

2010-04-05 Thread Luke Palmer
On Mon, Apr 5, 2010 at 9:18 PM, Ertugrul Soeylemez wrote: > David House wrote: > >> * "Reputation. Using a RealName is the most credible way to build a >> combined online and RealLife identity." (Some people don't want this, >> for whatever reasons.) > > I agree that the restriction should be lif

[Haskell-cafe] Announce: hothasktags

2010-04-01 Thread Luke Palmer
Hi, I'd like to draw attention to a little script I wrote. I tend to use qualified imports and short names like "new" and "filter". This makes hasktags pretty much useless, since it basically just guesses which one to go to. hothasktags is a reimplementation of hasktags that uses haskell-src-ex

Re: [Haskell-cafe] Re: Are there any female Haskellers?

2010-03-28 Thread Luke Palmer
2010/3/28 Pekka Enberg : > 2010/3/28 Günther Schmidt : >> This is definately a point where we will continue to disagree. I found >> myself assuming that there are no female haskellers and wanted to verify it >> by asking for data. > > So what exactly is off-topic for this list?  Is unsubscribing fr

Re: [Haskell-cafe] Are there any female Haskellers?

2010-03-27 Thread Luke Palmer
On Sat, Mar 27, 2010 at 2:22 PM, Peter Verswyvelen wrote: > So the first computer nerd was a women??!!! ;-) ;-) ;-) Yeah, and she was so attractive that the entire male gender spent the next 50 years trying to impress her. Luke > On Sat, Mar 27, 2010 at 9:06 PM, John Van Enk wrote: >> http

Re: [Haskell-cafe] Abstraction in data types

2010-03-18 Thread Luke Palmer
On Thu, Mar 18, 2010 at 12:17 PM, John Meacham wrote: > On Wed, Mar 17, 2010 at 09:20:49PM -0700, Darrin Chandler wrote: >> data Point    = Cartesian (Cartesian_coord, Cartesian_coord) >>               | Spherical (Latitude, Longitude) > > Just a quick unrelated note, though you are probably aware

  1   2   3   4   5   6   7   >