Re: [Haskell-cafe] UTF-8 in Haskell.

2010-12-23 Thread Maciej Piechotka
On Thu, 2010-12-23 at 14:15 +0800, Magicloud Magiclouds wrote: On Thu, Dec 23, 2010 at 2:01 PM, Mark Lentczner ma...@glyphic.com wrote: On Dec 22, 2010, at 9:29 PM, Magicloud Magiclouds wrote: Thus under all situation (ascii, UTF-8, or even UTF-32), my program always send 4 bytes through

[Haskell-cafe] New simplified primes; no VIP necessary.

2010-12-23 Thread Will Ness
Hi, For those who remember the discussion about this about a year ago, it turns out there was a simpler version after all lurking somewhere in there (or is it _out_?). I've just posted it to the haskellwiki's Prime Numbers page: primes = 2: primes' where primes' = 3: 5: [7,9..]

Re: [Haskell-cafe] Functor = Applicative = Monad

2010-12-23 Thread Simon Marlow
On 22/12/10 19:17, John Smith wrote: On 22/12/2010 19:03, Simon Marlow wrote: On 14/12/2010 08:35, Isaac Dupree wrote: On 12/14/10 03:13, John Smith wrote: I would like to formally propose that Monad become a subclass of Applicative, with a call for consensus by 1 February. The change is

[Haskell-cafe] Yet Another Haskell Tutorial missing (maybe lost on server move?)

2010-12-23 Thread Henning Thielemann
The page http://www.haskell.org/haskellwiki/Yet_Another_Haskell_Tutorial says that there is a darcs repository at http://darcs.haskell.org/yaht/ but it is not. Also in the canonical replacement location http://code.haskell.org/yaht/ I cannot find it. The Wikiboook

Re: [Haskell-cafe] UTF-8 in Haskell.

2010-12-23 Thread Max Bolingbroke
On 23 December 2010 05:29, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote:  If so, OK, then I think I could make a packInt which turns an Int into 4 Word8 first. Thus under all situation (ascii, UTF-8, or even UTF-32), my program always send 4 bytes through the network. Is that OK?

[Haskell-cafe] non_lazy_ptr ld error?

2010-12-23 Thread Evan Laforge
Lately I've been seeing this error occasionally when recompiling: Undefined symbols: _UiziTrackC_d26DB, referenced from: _UiziTrackC_d26DB$non_lazy_ptr in TrackC.o ld: symbol(s) not found If I delete the .o file for the mentioned module and recompile, it links fine. This makes me think

Re: [Haskell-cafe] parsec2 vs. parsec3... again

2010-12-23 Thread Felipe Almeida Lessa
On Thu, Dec 23, 2010 at 1:01 AM, Evan Laforge qdun...@gmail.com wrote: So, my current options are either figure out some way to speed up parsec3+Text, revert to parsec2+String and give up, or try an entirely different parsing library.  I've heard attoparsec is fast but I'd have to switch to

Re: [Haskell-cafe] Proof in Haskell

2010-12-23 Thread Sjoerd Visscher
On Dec 21, 2010, at 6:57 PM, austin seipp wrote: https://gist.github.com/750279 I took Austins code and modified it to run on a Tree GADT which is parameterized by its shape: https://gist.github.com/752982 Would this count as a function mirror with proof that mirror (mirror x) == x? --

[Haskell-cafe] Help!! Cannot get RandT and liftIO to work together...

2010-12-23 Thread JP Moresmau
Hello all, sorry I must have taken my stupid pills this morning, I cannot get the following code to compile, what am I missing? data MyState=MyState Integer newState:: (RandomGen g) = RandT g IO MyState newState = do time-liftIO getCPUTime rand-getRandomR (1,6) return $

Re: [Haskell-cafe] Functor = Applicative = Monad

2010-12-23 Thread mokus
On 22/12/2010 19:03, Simon Marlow wrote: On 14/12/2010 08:35, Isaac Dupree wrote: On 12/14/10 03:13, John Smith wrote: I would like to formally propose that Monad become a subclass of Applicative, with a call for consensus by 1 February. The change is described on the wiki at

Re: [Haskell-cafe] Help!! Cannot get RandT and liftIO to work together...

2010-12-23 Thread Daniel Fischer
On Thursday 23 December 2010 15:52:40, JP Moresmau wrote: Hello all, sorry I must have taken my stupid pills this morning, I cannot get the following code to compile, what am I missing? Works here. Which versions of the packages and GHC are you using?

Re: [Haskell-cafe] Help!! Cannot get RandT and liftIO to work together...

2010-12-23 Thread Daniel Fischer
On Thursday 23 December 2010 15:52:40, JP Moresmau wrote: what am I missing? Maybe I just spotted it: But the MonadRandom docs say: Instances: MonadIOhttp://hackage.haskell.org/packages/archive/transformers/0.2.2.0/doc/html/Control- Monad-IO-Class.html#t:MonadIO m links to the

Re: [Haskell-cafe] Help!! Cannot get RandT and liftIO to work together...

2010-12-23 Thread JP Moresmau
GHC 6.12.1, base 4.2.0.0, MonadRandom-0.1.6, transformers-0..2.2.0, on Windows.Could it be that my system is not picking up the MonadIO I think it does? JP On Thu, Dec 23, 2010 at 4:13 PM, Daniel Fischer daniel.is.fisc...@googlemail.com wrote: On Thursday 23 December 2010 15:52:40, JP

Re: [Haskell-cafe] Help!! Cannot get RandT and liftIO to work together...

2010-12-23 Thread Daniel Fischer
On Thursday 23 December 2010 16:21:05, JP Moresmau wrote: GHC 6.12.1, base 4.2.0.0, MonadRandom-0.1.6, transformers-0..2.2.0, on Windows. Could it be that my system is not picking up the MonadIO I think it does? Probably. With 6.12.1, you'll probably have an mtl-1.* installed, so the

Re: [Haskell-cafe] Help!! Cannot get RandT and liftIO to work together...

2010-12-23 Thread JP Moresmau
Thanks a million, it worked! Following all the dependencies sometimes is a bit of a headache. But in a sense, I'm happy to see I had understood how to use the monad transformer correctly, it wasn't me being (too) stupid. Thanks again! JP On Thu, Dec 23, 2010 at 4:32 PM, Daniel Fischer

Re: [Haskell-cafe] Proof in Haskell

2010-12-23 Thread Daniel Peebles
I think it's pretty legit. You aren't actually making a claim about the values in the tree but I think parametricity handles that for you, especially since you have existential types for the payload at every tree level (so you can't go shuffling those around). The only thing missing (and that you

Re: [Haskell-cafe] parsec2 vs. parsec3... again

2010-12-23 Thread Johan Tibell
On Thu, Dec 23, 2010 at 3:03 PM, Felipe Almeida Lessa felipe.le...@gmail.com wrote: Michael Snoyman wants attoparsec-text as well [1]. [1] http://docs.yesodweb.com/blog/wishlist/ It's on my Christmas wishlist too. Johan ___ Haskell-Cafe mailing

Re: [Haskell-cafe] parsec2 vs. parsec3... again

2010-12-23 Thread Michael Snoyman
On Thu, Dec 23, 2010 at 6:21 PM, Johan Tibell johan.tib...@gmail.com wrote: On Thu, Dec 23, 2010 at 3:03 PM, Felipe Almeida Lessa felipe.le...@gmail.com wrote: Michael Snoyman wants attoparsec-text as well [1]. [1] http://docs.yesodweb.com/blog/wishlist/ It's on my Christmas wishlist too.

Re: [Haskell-cafe] Why is Haskell flagging this?

2010-12-23 Thread Ryan Ingram
Haha, not exactly. You can replace sj - get let (a, sk) = runState something sj put sk with a - something Also, you don't need do notation for single statements; do return x is just return x On Wed, Dec 22, 2010 at 7:21 PM, michael rice nowg...@yahoo.com wrote: Thanks for the tip, Ozgur.

[Haskell-cafe] List of numbers to list of ranges

2010-12-23 Thread C K Kashyap
Hi all, Here's my attempt to convert a list of integers to a list of range tuples - Given [1,2,3,6,8,9,10], I need [(1,3),(6,6),8,10)] My attempt using foldl yields me the output in reverse. I can ofcourse reverse the result, but what would be a better way? f xs = foldl ff [] xs where

Re: [Haskell-cafe] Proof in Haskell

2010-12-23 Thread Ryan Ingram
On Thu, Dec 23, 2010 at 8:19 AM, Daniel Peebles pumpkin...@gmail.com wrote: Simulating bottoms wouldn't be too hard, but I don't think the statement is even true in the presence of bottoms, is it? Isn't it? data Tree a = Tip | Node (Tree a) a (Tree a) mirror :: Tree a - Tree a mirror Tip =

Re: [Haskell-cafe] Proof in Haskell

2010-12-23 Thread Ryan Ingram
On Tue, Dec 21, 2010 at 9:57 AM, austin seipp a...@hacks.yi.org wrote: For amusement, I went ahead and actually implemented 'Mirror' as a type family, and used a little bit of hackery thanks to GHC to prove that indeed, 'mirror x (mirror x) = x' since with a type family we can express 'mirror'

Re: [Haskell-cafe] List of numbers to list of ranges

2010-12-23 Thread Daniel Fischer
On Thursday 23 December 2010 18:27:43, C K Kashyap wrote: Hi all, Here's my attempt to convert a list of integers to a list of range tuples - Given [1,2,3,6,8,9,10], I need [(1,3),(6,6),8,10)] My attempt using foldl yields me the output in reverse. I can ofcourse reverse the result, but

Re: [Haskell-cafe] Proof in Haskell

2010-12-23 Thread Daniel Peebles
Fair enough :) that'll teach me to hypothesize something without thinking about it! I guess I could amend my coinductive proof: http://hpaste.org/paste/42516/mirrormirror_with_bottom#p42517 does that cover bottom-ness adequately? I can't say I've thought through it terribly carefully. On Thu,

Re: [Haskell-cafe] List of numbers to list of ranges

2010-12-23 Thread Henning Thielemann
On Thu, 23 Dec 2010, C K Kashyap wrote: Here's my attempt to convert a list of integers to a list of range tuples - Given [1,2,3,6,8,9,10], I need [(1,3),(6,6),8,10)] That's an interesting problem! My first attempt: List.unfoldr (\xs - case xs of [] - Nothing; y:ys - case span (uncurry

Re: [Haskell-cafe] List of numbers to list of ranges

2010-12-23 Thread Henning Thielemann
On Thu, 23 Dec 2010, Daniel Fischer wrote: On Thursday 23 December 2010 18:27:43, C K Kashyap wrote: Hi all, Here's my attempt to convert a list of integers to a list of range tuples - Given [1,2,3,6,8,9,10], I need [(1,3),(6,6),8,10)] My attempt using foldl yields me the output in

Re: [Haskell-cafe] List of numbers to list of ranges

2010-12-23 Thread Daniel Fischer
On Thursday 23 December 2010 18:27:43, C K Kashyap wrote: Hi all, Here's my attempt to convert a list of integers to a list of range tuples - Given [1,2,3,6,8,9,10], I need [(1,3),(6,6),8,10)] My attempt using foldl yields me the output in reverse. I can ofcourse reverse the result, but

Re: [Haskell-cafe] Proof in Haskell

2010-12-23 Thread Dan Doel
On Thursday 23 December 2010 12:52:07 pm Daniel Peebles wrote: Fair enough :) that'll teach me to hypothesize something without thinking about it! I guess I could amend my coinductive proof: http://hpaste.org/paste/42516/mirrormirror_with_bottom#p42517 does that cover bottom-ness

Re: [Haskell-cafe] List of numbers to list of ranges

2010-12-23 Thread Ross Paterson
On Thu, Dec 23, 2010 at 10:57:43PM +0530, C K Kashyap wrote: Here's my attempt to convert a list of integers to a list of range tuples - Given [1,2,3,6,8,9,10], I need [(1,3),(6,6),8,10)] import Data.Function import Data.List ranges ns = [(head gp, last gp) | gp - map

Re: [Haskell-cafe] List of numbers to list of ranges

2010-12-23 Thread Stephen Tetley
I'd go with direct recursion for this one - the pattern of consumption and production that generates the answer doesn't seem to neatly match any of the standard recursion combinators (map, unfold, fold, mapAccum, ...) nor exotic ones (skipping streams c.f. the Stream fusion paper, apomorphisms,

Re: [Haskell-cafe] Infinite lists in real world programs

2010-12-23 Thread Patai Gergely
fromList :: [a] - SignalGen (Signal a) fromList xs = stateful xs tail = memo . fmap head 1) It does what I want, but is it the good way to do it? Yes, I'd do it the same way, assuming that the input is always an infinite list (so this version should probably be called unsafeFromList...).

[Haskell-cafe] (Co/Contra)Functor and Comonad

2010-12-23 Thread Mario Blažević
Why are Cofunctor and Comonad classes not a part of the base library? I recently defined a data type (Control.Cofunctor.Ticker in monad-coroutine on Hackage) that happens to be a co-functor, or contra-functor if you prefer. In other words, it can implement the following function: cofmap ::

Re: [Haskell-cafe] List of numbers to list of ranges

2010-12-23 Thread Stephen Tetley
On 23 December 2010 21:12, Stephen Tetley stephen.tet...@gmail.com wrote: I'd go with direct recursion for this one - the pattern of consumption and production that generates the answer doesn't seem to neatly match any of the standard recursion combinators (map, unfold, fold, mapAccum, ...)

Re: [Haskell-cafe] List of numbers to list of ranges

2010-12-23 Thread Henning Thielemann
On Thu, 23 Dec 2010, Stephen Tetley wrote: On 23 December 2010 21:12, Stephen Tetley stephen.tet...@gmail.com wrote: I'd go with direct recursion for this one - the pattern of consumption and production that generates the answer doesn't seem to neatly match any of the standard recursion

Re: [Haskell-cafe] List of numbers to list of ranges

2010-12-23 Thread Stephen Tetley
On 23 December 2010 22:01, Henning Thielemann lemm...@henning-thielemann.de wrote: This could be seen as type Step st a = (Maybe a, st). I have thought about mapping from [Int] to [Maybe (Int, Int)] by mapAccumL, then compressing the result with catMaybes. However we need to append a final

Re: [Haskell-cafe] (Co/Contra)Functor and Comonad

2010-12-23 Thread Stephen Tetley
On 23 December 2010 21:43, Mario Blažević mblaze...@stilo.com wrote: Why are Cofunctor and Comonad classes not a part of the base library? [SNIP] Later on I found that this question has been raised before by Conal Elliott, nearly four years ago.

Re: [Haskell-cafe] Infinite lists in real world programs

2010-12-23 Thread Yves Parès
Thanks for your answers. In fact I tried to use Simple with a clock signal and it's painful to pass it wherever you need it. Param is much more practical. I like Elerea, I tried Reactive and Yampa, and I found them (especially Yampa) heavy and not very practical. The fact that Elerea is

[Haskell-cafe] The Bay Area Haskell Hackathon is coming up: Feb 11-13, 2011

2010-12-23 Thread Bryan O'Sullivan
Mark Lentczner and I are organizing, and it will be held at Hacker Dojo in Mountain Viewhttp://maps.google.com/maps/place?cid=2122486601784397611q=hacker+dojogl=us . If you plan to attend, please fill in our sign-up

Re: [Haskell-cafe] List of numbers to list of ranges

2010-12-23 Thread Johannes Waldmann
This one looks somewhat symmetrical: f xs = let xys = filter ( \ (x,y) - y - x 1 ) $ zip xs ( tail xs ) in zip ( [ head xs ] ++ map snd xys ) ( map fst xys ++ [ last xs ] ) ___ Haskell-Cafe mailing list

Re: [Haskell-cafe] List of numbers to list of ranges

2010-12-23 Thread Martin Erwig
All the previous solutions seem to assume that the list of numbers is already sorted. In cases where this assumption cannot be made, an alternative solution is to simply insert the numbers into a diet. eecs.oregonstate.edu/~erwig/papers/abstracts.html#JFP98

Re: [Haskell-cafe] (Co/Contra)Functor and Comonad

2010-12-23 Thread Mario Blažević
On Thu, Dec 23, 2010 at 5:25 PM, Stephen Tetley stephen.tet...@gmail.comwrote: On 23 December 2010 21:43, Mario Blažević mblaze...@stilo.com wrote: Why are Cofunctor and Comonad classes not a part of the base library? [SNIP] Later on I found that this question has been raised before by

[Haskell-cafe] ANN: xmobar 0.12 released

2010-12-23 Thread Jose A. Ortega Ruiz
I'm happy to announce a new relase of xmobar, the text-based monitor bar. You can read everything about xmobar and this release at our new web address (http://projects.haskell.org/xmobar/), or see below for a summary of what's new (cf. http://projects.haskell.org/xmobar/releases.html). ##

Re: [Haskell-cafe] (Co/Contra)Functor and Comonad

2010-12-23 Thread Daniel Peebles
For me, mostly naming. Cofunctor isn't the right name for it, and comap, while short, feels wrong. Contrafunctor feels better but is also cumbersome. No problems with Comonad, though. On Thu, Dec 23, 2010 at 9:16 PM, Mario Blažević mblaze...@stilo.com wrote: On Thu, Dec 23, 2010 at 5:25 PM,

Re: [Haskell-cafe] (Co/Contra)Functor and Comonad

2010-12-23 Thread C. McCann
On Thu, Dec 23, 2010 at 5:25 PM, Stephen Tetley stephen.tet...@gmail.com wrote: On 23 December 2010 21:43, Mario Blažević mblaze...@stilo.com wrote: Why are Cofunctor and Comonad classes not a part of the base library? [SNIP] Later on I found that this question has been raised before by Conal

Re: [Haskell-cafe] (Co/Contra)Functor and Comonad

2010-12-23 Thread Tony Morris
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 ...regardless of the utility of a contravariant functor type-class, I strongly advocate for calling it Contrafunctor and not Cofunctor. I have seen numerous examples of confusion over this, particularly in other languages. On 24/12/10 12:16, Mario

Re: [Haskell-cafe] (Co/Contra)Functor and Comonad

2010-12-23 Thread Mario Blažević
On Thu, Dec 23, 2010 at 11:25 PM, Tony Morris tonymor...@gmail.com wrote: -BEGIN PGP SIGNED MESSAGE- Hash: SHA1 ...regardless of the utility of a contravariant functor type-class, I strongly advocate for calling it Contrafunctor and not Cofunctor. I have seen numerous examples of

Re: [Haskell-cafe] (Co/Contra)Functor and Comonad

2010-12-23 Thread Isaac Dupree
On 12/23/10 16:43, Mario Blažević wrote: Cofunctor and Comonad IMHO, as you say, there is only one design of cofunctor. class Cofunctor cf where cofmap :: (a - b) - cf b - cf a The only question is capitalization and spelling.* Since there are multiple designs of Comonad floating around,

Re: [Haskell-cafe] (Co/Contra)Functor and Comonad

2010-12-23 Thread C. McCann
On Thu, Dec 23, 2010 at 11:46 PM, Mario Blažević mblaze...@stilo.com wrote: I don't personally care what's it called, as long as it's available. Can anybody point to an authoritative source for the terminology, though? Wikipedia claims that cofunctor is a contravariant functor. Does nLab

Re: [Haskell-cafe] ANNOUNCE: storable-endian

2010-12-23 Thread Eugene Kirpichov
...I mean, storable-endian 0.2.1 actually - 0.2.0 had a stupid bug. 2010/12/24 Eugene Kirpichov ekirpic...@gmail.com: Hello Hennig, Thanks for the suggestions! I've released storable-endian 0.2.0, which does not use TH and bases on your suggestion (though it has a bit of boilerplate because

Re: [Haskell-cafe] ANNOUNCE: storable-endian

2010-12-23 Thread Eugene Kirpichov
Hello Hennig, Thanks for the suggestions! I've released storable-endian 0.2.0, which does not use TH and bases on your suggestion (though it has a bit of boilerplate because of abandoning TH, but I don't think that's critical). Here's the new source: