Re: [Haskell-cafe] Trouble installing FileManipCompat

2011-04-28 Thread Thomas Hartman
I uploaded a new version of FileManipCompat which is mtl-2 compatible. 2011/1/5 Daniel Fischer daniel.is.fisc...@googlemail.com: On Wednesday 05 January 2011 19:43:53, Tony Miller wrote: Thanks that works, but I have packages that rely on mtl=2.0, so its not the best solution. Perhaps the

Re: [Haskell-cafe] Haskell Web Framework Happstack 6 Released

2011-02-17 Thread Thomas Hartman
I don't know who said it first, but I'm repeating it. 2011 is going to be the tipping point year for haskell web frameworks. Thanks Jeremy! 2011/2/17 Jeremy Shaw jer...@n-heptane.com: Hello, I am pleased to announce the release of Happstack 6. We fully recommend that all Happstack users

[Haskell-cafe] What is the point of many and some functions in Control.Applicative (for Alternative?)

2010-07-03 Thread Thomas Hartman
When I load up Control.Applicative in ghci and try, eg many [1,2] or many (Just 1) or some [1,2] or some (Just 1) this never returns. What are the practical uses of these combinators, or for using the Alternative class in general? ___ Haskell-Cafe

Re: [Haskell-cafe] Function to find a substring

2010-06-07 Thread Thomas Hartman
If you want to use libs to make your life easier, maybe something along these lines? Prelude Data.List.Split Safe fmap length . headMay . split (onSublist asdf) $ blee blah asdf bloo Just 10 If they are big strings, it's probably faster to use bytestrings, or arrays of some kinds, rather than

Re: [Haskell-cafe] Removing alternate items from a list

2010-06-07 Thread Thomas Hartman
maybe this? map snd . filter (odd . fst) . zip [1,2..] $ [1,2,3,4,5] 2010/6/6 R J rj248...@hotmail.com: What's the cleanest definition for a function f :: [a] - [a] that takes a list and returns the same list, with alternate items removed?  e.g., f [0, 1, 2, 3, 4, 5] = [1,3,5]?

[Haskell-cafe] is there a way to prove the equivalence of these two implementations of (Prelude) break function?

2010-06-07 Thread Thomas Hartman
Here's two implementations of break, a snappy one from the prelude, and a slow stupid stateful one. They are quickchecked to be identical. Is there a way to prove they are identical mathematically? What are the techniques involved? Or to transform one to the other? import Control.Monad.State

Re: [Haskell-cafe] yet another functional reactive programming tutorial :)

2010-06-01 Thread Thomas Hartman
cabal installable would be nice. for that matter, throw it on hackage! 2010/5/26 Jinjing Wang nfjinj...@gmail.com: Dear list, As I'm learning frp and reading the wonderful tutorial at http://www.formicite.com/dopage.php?frp/frp.html , I'm putting up some more basic cheatsheet style

Re: [Haskell-cafe] Re: [web-devel] Google Summer of Code: BlazeHTML RFC

2010-05-30 Thread Thomas Hartman
I'm a heavy hsp user. Could hsp benefit from this project by using blaze as a back end instead of whatever it's using now? IIUC, Hsp uses hsx (via the preprocessor program trhsx) to convert xml-containing hybrid hsp/xml/html files into compilable haskell. I expected hsx uses XHTML (which iiuc is

[Haskell-cafe] why does Data.Text.Lazy.IO.readFile return the internal type Data.Text.Lazy.Internal.Text, when Data.Text.IO.readFile returns plain IO Data.Text.Text?

2010-04-30 Thread Thomas Hartman
*Main :t Data.Text.IO.readFile Data.Text.IO.readFile :: FilePath - IO T.Text but *Main :t Data.Text.Lazy.IO.readFile Data.Text.Lazy.IO.readFile :: FilePath - IO text-0.7.1.0:Data.Text.Lazy.Internal.Text why does the lazy version use the internal type, whereas the strict version of Text IO

Re: [Haskell-cafe] The instability of Haskell libraries

2010-04-23 Thread Thomas Hartman
1) Folks, what exactly is the situation with buildbots? 2) Easily available images for installing virtualized environments could also ameliorate the pain, no? wrt 1) It seems to me that in an ideal world you could have a candidate for uploading to hackage, but before uploading you could push a

Re: [Haskell-cafe] Build problems (hsp, trhsx, ultimately Happstack)

2010-04-23 Thread Thomas Hartman
I've had this problem too. I believe trhsx is installed by http://hackage.haskell.org/package/hsx So, you might need to -- upgrade hsx -- make sure that the upgraded trhsx executable is the one being executed by cabal install hsx (maybe deleting/temporarily moving other trhsx exes) thomas.

Re: [Haskell-cafe] The instability of Haskell libraries

2010-04-23 Thread Thomas Hartman
, 2 seems like a hard problem to solve. But 1) could be solved by having a candidate snapshot hackage that can be cloned at will, and buildbotted against, no? 2010/4/23 Erik de Castro Lopo mle...@mega-nerd.com: Thomas Hartman wrote: 1) Folks, what exactly is the situation with buildbots? If I'm

Re: [Haskell-cafe] Upgrading to Haskell Platform

2010-03-12 Thread Thomas Hartman
It should not be necessary to uninstall ghc, as hask plat and ghc are orthogonal by design. r Unless there is some gotcha I am unaware of, not being a mac user. You are aware that hask plat is beta though, right? You might be better served simply upgrading your cabal, and waiting for the

Re: [Haskell-cafe] Upgrading to Haskell Platform

2010-03-12 Thread Thomas Hartman
grab cabal here I mean: http://hackage.haskell.org/trac/hackage/wiki/CabalInstall 2010/3/12 Thomas Hartman tphya...@gmail.com: It should not be necessary to uninstall ghc, as hask plat and ghc are orthogonal by design. r Unless there is some gotcha I am unaware of, not being a mac user

Re: [Haskell-cafe] How to do the permutation and combination thing?

2010-03-12 Thread Thomas Hartman
There is also polyomino.f2s: http://www.polyomino.f2s.com/david/haskell/combinatorics.html Iirc correctly there is some stuff here that is not on hackage but probably could/should be. 2010/3/12 Victor Mateus Oliveira rhapso...@gmail.com: Hi, Give a try to this library:

[Haskell-cafe] mirroring patch tag

2010-03-12 Thread Thomas Hartman
http://blog.patch-tag.com/2010/03/13/mirroring-patch-tag/ cheers, thomas. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] sendfile leaking descriptors on Linux?

2010-02-28 Thread Thomas Hartman
As far as I can tell, stepcut was probably correct in his diagnosis before. I was getting two processes started because of a stray cron job. 2010/2/26 Thomas Hartman tphya...@gmail.com: Indeed, the error occurs when two processes are running at the same time. One process isn't serving anything

Re: [Haskell-cafe] sendfile leaking descriptors on Linux?

2010-02-26 Thread Thomas Hartman
I believe this might be causing problems for me with patch-tag. me: Like mightybyte, I run my app in a shell loop that will just restart it after a crash. But every once in a while it won't restart because of the busy socket and I need to do a manual restart, killing multiple processes (usually

Re: [Haskell-cafe] sendfile leaking descriptors on Linux?

2010-02-26 Thread Thomas Hartman
KF8NH allb...@ece.cmu.edu: On Feb 26, 2010, at 04:28 , Thomas Hartman wrote: me: Like mightybyte, I run my app in a shell loop that will just restart it after a crash. But every once in a while it won't restart because of the busy socket and I need to do a manual restart, killing multiple

Re: [Haskell-cafe] sendfile leaking descriptors on Linux?

2010-02-26 Thread Thomas Hartman
is it that your loop starts a second server when the first one has not finished? - jeremy On Fri, Feb 26, 2010 at 1:43 PM, Thomas Hartman tphya...@gmail.com wrote: Thanks, I altered my top level request handler as follows mysmartserver conf h stateProxy = do      socket - bindPort conf       I

Re: [Haskell-cafe] ANN: Dungeons of Wor - a largish FRP example and a fun game, all in one!

2010-02-11 Thread Thomas Hartman
1) This is missing the obligatory youtube video. 2) AWESOME! :) thomas. 2010/2/11 Patai Gergely patai_gerg...@fastmail.fm: Hello all, I just uploaded the first public version of Dungeons of Wor [1], a homage to the renowned three-decade-old arcade game, Wizard of Wor. While it makes a fine

Re: [Haskell-cafe] How many Haskell Engineer I/II/IIIs are there?

2010-02-11 Thread Thomas Hartman
Hear hear. But a few successful happstack private sector startups could change that... 2010/2/10 Jason Dusek jason.du...@gmail.com: 2010/02/10 Roderick Ford develo...@live.com: A U.S. president would probably subsidize such a job-creating endeavor too!  The US government generally subsidizes

Re: [Haskell-cafe] Re: sendfile leaking descriptors on Linux?

2010-02-09 Thread Thomas Hartman
Matt, have you seen this thread? Jeremy, are you saying this a bug in the sendfile library on hackage, or something underlying? thomas. 2010/2/9 Jeremy Shaw jer...@n-heptane.com: On Sun, Feb 7, 2010 at 9:22 AM, Bardur Arantsson s...@scientician.net wrote: True, it is perhaps technically not

Re: [Haskell-cafe] Re: sendfile leaking descriptors on Linux?

2010-02-06 Thread Thomas Hartman
me too. 2010/2/5 MightyByte mightyb...@gmail.com: I've been seeing a steady stream of similar resource vanished messages for as long as I've been running my happstack app.  This message I get is this: socket: 58: hClose: resource vanished (Broken pipe) I run my app from a shell script

Re: [Haskell-cafe] sendfile leaking descriptors on Linux?

2010-02-04 Thread Thomas Hartman
Do you have a test script to reproduce the behavior? I am interested in this patch-tag uses sendfile (via happstack) to serve static data, and I'd like to know if I'm affected by this. 2010/2/4 Bardur Arantsson s...@scientician.net: Hi all, I've been using the sendfile package off Hackage,

[Haskell-cafe] where is the eros distribution

2010-01-23 Thread Thomas Hartman
I was inspired by the google tech talk and would like to install and play with eros, but the http://darcs.haskell.org/packages/Eros/dist/ address pointed to at http://www.haskell.org/haskellwiki/Eros appears to be obsolete. ___ Haskell-Cafe mailing

[Haskell-cafe] unexpected behavior from filterM doesFileExist = getDirectoryContents

2010-01-09 Thread Thomas Hartman
Can somebody explain this? getDirectoryContents inD [..,#sanity.txt#,.,sanity.txt,etc.txt,patchTagDir.txt,jail.txt,notjail.txt,alldata.txt,allobjs.txt,namesNSizes.txt] filterM doesFileExist = getDirectoryContents inD [sanity.txt] ___ Haskell-Cafe

Re: [Haskell-cafe] unexpected behavior from filterM doesFileExist = getDirectoryContents

2010-01-09 Thread Thomas Hartman
Thanks, that was it. Dud question. 2010/1/9 Brandon S. Allbery KF8NH allb...@ece.cmu.edu: On Jan 10, 2010, at 00:24 , Thomas Hartman wrote: Can somebody explain this? getDirectoryContents inD [..,#sanity .txt #,.,sanity .txt ,etc .txt ,patchTagDir .txt ,jail .txt,notjail.txt

[Haskell-cafe] unexpected behavior / bug in try . System.FilePath.Find.findWithHandler

2010-01-05 Thread Thomas Hartman
say you want to execute a find function, but abort the computation if it hits any snags, such as an unreadable directory (eg chmod -R a-r dir). Currently try . System.FilePath.Find.findWithHandler will return an exception wrapped in Right, which seems Wrong. For sure it will just get ignored if

Re: [Haskell-cafe] What about adding a wiki for each haskell project?

2009-12-12 Thread Thomas Hartman
patch-tag.com has wikis now. They are some buggy behaviors I still need to address so I haven't blogged or otherwise drawn attention to it (arrrg) but my hope is that, quite soon, this will be quite slick and quite useful. 2009/12/11 Marc Weber marco-owe...@gmx.de hackage is success because:

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

2009-11-16 Thread Thomas Hartman
How about patch-tag? It's built with haskell (happstack), and one of its founding goals is to promote the use of haskell in real world so you're sure to be surrounded by like minded people. And wikis are about to go live so you could help beta test that feature too :) thomas. Am 16. November

Re: [Haskell-cafe] Re: [Haskell] ANNOUNCE: control-monad-exception 0.5 with monadic call traces

2009-11-03 Thread Thomas Hartman
When using happstack, I find it really annoying to get a Prelude.head: null list error (or similar) in my web browser window because somewhere, some library used something unsafe -- and of course, since this is haskell, no stack trace. if c-m-e can offer benefits around this, I would be very

[Haskell-cafe] hackage is down.

2009-11-01 Thread Thomas Hartman
http://hackage.haskell.org ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

[Haskell-cafe] creating documentation links failed with cabal install --haddock-options=--hyperlink-source. is this a bug?

2009-10-31 Thread Thomas Hartman
cabal haddock -–hyperlink-source installs documentation with links to source code, which also be on by defualt. cabal install –haddock-options=–hyperlink source does not install hyperlinked source. cabal install –haddock-options=-–hyperlink sourceblehblehbleh doesn’t throw an error, which

[Haskell-cafe] Upgrading an app from happstack 0.1 to happstack 0.3

2009-10-30 Thread Thomas Hartman
Upgrading an app from happstack 0.1 to happstack 0.3? Save yourself a few minutes and read this first. http://blog.patch-tag.com/2009/10/30/migrating-from-happstack-0-1-to-happstack-0-3/ -- Need somewhere to put your code? http://patch-tag.com Want to build a webapp? http://happstack.com

[Haskell-cafe] any haskellers in chicago? Impromptu lakeview meetup tomorrow (tuesday) evening.

2009-10-26 Thread Thomas Hartman
I'm visiting chicago, and found one other haskeller interested in a haskell meetup tomorrow 7:30 pm lakeview cafe intelligentsia. email thomashartman1 at gmail if you'd like to hook up! this is a relaxed occasion with no fixed agenda other than birds of a feather flocking home. thomas.

[Haskell-cafe] Re: systemtimmetypeable: Workaround for lack of deriveable data instance in either System.Time or Data.Time.

2009-10-21 Thread Thomas Hartman
this was for data-izing data.time or system.time or both. Given all this I won't be uploading anything to hackage, and hopefully the base libs + time will be data friendly soon enough. thomas. 2009/10/19 Thomas Hartman tphya...@gmail.com: At http://osdir.com/ml/haskell-cafe@haskell.org/2009-10/msg00197

[Haskell-cafe] Re: ghci can't find Paths_ module created by cabal

2009-10-21 Thread Thomas Hartman
from my bash hints file: thart...@ubuntu:~/haskellInstalls/gititthartman_ghci_with_data_files Loading a package with data files in ghci See http://neilmitchell.blogspot.com/2008/02/adding-data-files-using-cabal.html Snip: The above method works well after a program has been

[Haskell-cafe] debugtracehelpers Re: traceM and traceShowM

2009-10-19 Thread Thomas Hartman
I have this and a couple other handy functions in DebugTraceHelpers: http://patch-tag.com/r/tphyahoo/DebugTraceHelpers/snapshot/current/content/pretty hackage: http://hackage.haskell.org/packages/archive/DebugTraceHelpers/0.12/doc/html/Debug-Trace-Helpers.html 2009/10/16 Martijn van

[Haskell-cafe] systemtimmetypeable: Workaround for lack of deriveable data instance in either System.Time or Data.Time.

2009-10-19 Thread Thomas Hartman
At http://osdir.com/ml/haskell-cafe@haskell.org/2009-10/msg00197.html I griped that the lack of Data-Derivable time values was causing me headache in happstack. In the proposed cabal package

[Haskell-cafe] Why does replicateM (10^6) $ return 0 produce output in the IO monad, but overflow the maybe monad?

2009-10-14 Thread Thomas Hartman
-- Why does replicateM (10^6) $ return 0 produce output in the IO monad, but overflow the maybe monad? iterateNTimes i f x = foldr (.) id (replicate i f) $ x tntIO :: IO Int -- same as replicateM (10^6) $ return 0, same as sequence . replicate (10^6) $ return 0 tntIO = return . head =

[Haskell-cafe] why does iterateNTimes (10^6) (ap . liftM (:) . return $ 0) (return []) produce output in the IO monad, but stack overflow in the maybe monad?

2009-10-13 Thread Thomas Hartman
Can someone explain why the one stack overflows and the other one doesn't? iterateNTimes i f x = foldr (.) id (replicate i f) $ x tntIO :: IO Int -- same as replicateM (10^6) $ return 0 , and same as sequence . replicate (10^6) $ return 0 tntIO = iterateNTimes (10^6) (ap . liftM (:) . return $ )

[Haskell-cafe] Re: why does iterateNTimes (10^6) (ap . liftM (:) . return $ 0) (return []) produce output in the IO monad, but stack overflow in the maybe monad?

2009-10-13 Thread Thomas Hartman
= (iterateNTimes (10^6) (ap . liftM (:) . return $ 0) (return [])) -- stack overflow which now compiles. 2009/10/13 Thomas Hartman tphya...@gmail.com: Can someone explain why the one stack overflows and the other one doesn't? iterateNTimes i f x = foldr (.) id (replicate i f) $ x tntIO :: IO

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

2009-10-10 Thread Thomas Hartman
I don't know if this counts but how about import Control.Applicative import Control.Monad import Random import Data.List main'' i j = replicateM j $ maximum' $ (replicateM i . randomRIO $ (0,10^9)) maximum' = foldl1' max t = main'' (10^4) 5 2009/10/9 mf-hcafe-15c311...@etc-network.de: Hi

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

2009-10-10 Thread Thomas Hartman
Yes, you should not do this in IO. That requires the entire computation to finish before the result can be used. Not really the entire computation though... whnf, no? main = do let thunks :: IO [Int] thunks = (sequence . replicate (10^6) $ (randomRIO (0,10^9))) putStrLn . show . head =

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

2009-10-10 Thread Thomas Hartman
,undefined] t5IO = t5 t5Maybe = t5 t6IO = t6 t6Maybe = t6 *Main t5IO *** Exception: Prelude.undefined *Main t5Maybe *** Exception: Prelude.undefined *Main t6IO 1 *Main t6Maybe Just 1 2009/10/10 Thomas Hartman tphya...@gmail.com: Yes, you should not do this in IO.  That requires the entire

[Haskell-cafe] suggestions for doing date/time values with Data.Generics ?

2009-10-05 Thread Thomas Hartman
I want to patch the time package, which I darcs got head on. Goal is to be able to do newtype deriving for UTCTime which I reckon is the base time value, for use in happstack applications state. basically, need instances for UTCTime, for Data and Typeable. ** on #haskell: patch-tag I

[Haskell-cafe] Re: suggestions for doing date/time values with Data.Generics ?

2009-10-05 Thread Thomas Hartman
fwiw, this s what I'm doing till I figure out a better way: import System.Time data MyTime = MyTime Integer Integer deriving (Typeable,Data) myTimeToClockTime (MyTime a b) = TOD a b myTimeFromClockTime (TOD a b) = MyTime a b and use MyTime in the happstack state. 2009/10/5 Thomas Hartman

Re: [Haskell-cafe] Market Place for Haskell development teams?

2009-10-02 Thread Thomas Hartman
Hey, first of all, in terms of a platform for promoting haskell commercially, happstutorial.com actually implements a job board. Yeah, it's primitive and not feature complete, but on hackage, open source, and ready for anyone who would like to work on it. (Currently maintained by creighton hogg.)

Re: [Haskell-cafe] Market Place for Haskell development teams?

2009-10-02 Thread Thomas Hartman
correction, happstutorial is now tutorial.happstack.com. 2009/10/2 Thomas Hartman tphya...@gmail.com: Hey, first of all, in terms of a platform for promoting haskell commercially, happstutorial.com actually implements a job board. Yeah, it's primitive and not feature complete, but on hackage

Re: [Haskell-cafe] Re: cabal: : openFile: does not exist (No such file or directory)

2009-07-28 Thread Thomas Hartman
(No such file or directory) Anybody figured it out? - Job Vranish On Fri, Jul 17, 2009 at 11:17 AM, Thomas Hartman tphya...@gmail.com wrote: cabal -v3 update will give you a more verbose version of what is going wrong. cabal --help regrettably, cabal --help doesn't tell you

Re: [Haskell-cafe] Generalizing takeWhile

2009-07-22 Thread Thomas Hartman
What is the use case(s) for this function? lements from the front of a list.  However the criteria are somewhat complex. walk f [] = [] walk f (x:xs) = case f x                 of Just g - x : walk g xs                    Nothing - [] For each item the `predicate' f either returns

Re: [Haskell-cafe] Implicit concatenation in list comprehensions

2009-07-19 Thread Thomas Hartman
I vote for tuple sections. Very nice! I don't really see immediate places where I would use the list comprehension improvement so I guess I don't vote for that. 2009/7/19 Neil Mitchell ndmitch...@gmail.com: Hi Max, For fun, I spent a few hours yesterday implement support for this syntax in

Re: [Haskell-cafe] can there be (hash-table using) O(n) version of this (I think currently) n log n algo?

2009-07-18 Thread Thomas Hartman
Thanks Bulat. FWIW, i take it that http://www.haskell.org/haskellwiki/Shootout/Knucleotide is what Edward was referring to, with the shootouts. It seems that a lot of progress has been made but not much has been migrated back to hackage. Going back to my original question, I am now looking for

[Haskell-cafe] powerSet = filterM (const [True, False]) ... is this obfuscated haskell?

2009-07-17 Thread Thomas Hartman
on haskell reddit today powerSet = filterM (const [True, False]) is said to be beautiful / mind blowing. I just don't get it. I can play with transformations until I get powerSet [] = [[]] powerSet (x:xs) = let pxs = powerSet xs in map (x:) pxs ++ pxs which is understandable to me,

[Haskell-cafe] Re: cabal: : openFile: does not exist (No such file or directory)

2009-07-17 Thread Thomas Hartman
cabal -v3 update will give you a more verbose version of what is going wrong. cabal --help regrettably, cabal --help doesn't tell you this but there is always the man page I suppose. 2009/7/16 Tony Hannan tonyhann...@gmail.com: Hello, I'm on Ubuntu 8.10. I installed ghc 6.10.4 (from binary

Re: [Haskell-cafe] laziness blowup exercise

2009-07-17 Thread Thomas Hartman
I don't have a good answer to that, and I unable to reliably solve this type of problem, which is one reason I am posting around on haskell cafe hoping to accumulate wisdom. Here for instance I think I did t = last . take (10^6) $ repeat $ S.empty which doesn't blow up, and by process of

[Haskell-cafe] can there be (hash-table using) O(n) version of this (I think currently) n log n algo?

2009-07-17 Thread Thomas Hartman
The code below is, I think, n log n, a few seconds on a million + element list. I wonder if it's possible to get this down to O(N) by using a hashtable implemementation, or other better data structure. Further, is there a hashtable implementation for haskell that doesn't live in IO? Maybe in ST

Re: [Haskell-cafe] laziness blowup exercise

2009-07-16 Thread Thomas Hartman
the strict functions seem very nice, will they eventually make their way into http://hackage.haskell.org/packages/archive/Stream/0.3.2/doc/html/Data-Stream.html ? where is Control.Monad.StreamT? couldn't find it. 2009/7/15 Bas van Dijk v.dijk@gmail.com: On Wed, Jul 15, 2009 at 3:02 AM,

Re: [Haskell-cafe] laziness blowup exercise

2009-07-16 Thread Thomas Hartman
I played with this a bit, and ok, it seems the difference between iterate' and iterate'' is h _ = 2 tit' = head . drop 1 . iterate' h $ undefined tit'' = head . drop 1 . iterate'' h $ undefined (Bas wishes for a type system that can express the different strictness properties of these

[Haskell-cafe] another laziness blowup (this one unsolved)

2009-07-16 Thread Thomas Hartman
Is it possible to fix alternate' (the second version), or otherwise define a fast stepwise alternate that doesn't blow up on long lists? alternate just breaks up [1,2,3,4,5] into ([1,3,5],[2,4]) Thanks! {-# LANGUAGE BangPatterns #-} import Data.List import Control.Arrow import

[Haskell-cafe] Re: another laziness blowup (this one unsolved)

2009-07-16 Thread Thomas Hartman
solved. see the haskell wiki for spoiler: http://haskell.org/haskellwiki/Blow_your_mind 2009/7/16 Thomas Hartman tphya...@gmail.com: Is it possible to fix alternate' (the second version), or otherwise define a fast stepwise alternate that doesn't blow up on long lists? alternate just breaks

[Haskell-cafe] laziness blowup exercise

2009-07-14 Thread Thomas Hartman
Challenge: change one function in the following pipeline so that t doesn't blow up when executed in ghci. import qualified Data.Set as S t = last . take (10^6) . iterate f $ S.empty f s = S.delete 1 . S.insert 1 $ s Please suggest more of these types of exercises if you have them and maybe we

[Haskell-cafe] simple state monad exercises? (besides labeling trees)

2009-07-06 Thread Thomas Hartman
Can someone give some simple common scenarios where the state monad is useful, besides labeling trees? References to puzzles like those in project Euler or similar would be nice. Thanks! ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org

Re: [Haskell-cafe] Re: Need some help with an infinite list

2009-06-20 Thread Thomas Hartman
could someone explain sharing? In the code below, allstrings2 is 6X as fast as allstrings. I assume because of sharing, but I don't intuitively see a reason why. can someone give me some pointers, perhaps using debug.trace or other tools (profiling?) to show where the first version is being

[Haskell-cafe] please comment on my parser, can I do this cleaner?

2009-06-09 Thread Thomas Hartman
All I want to do is split on commas, but not the commas inside () or tags. I have been wanting to master parsec for a long time and this simple exercise looked like a good place to start. The code below does the right thing. Am I missing any tricks to make this simpler/neater? Thanks, thomas.

Re: [Haskell-cafe] please comment on my parser, can I do this cleaner?

2009-06-09 Thread Thomas Hartman
seems to be somewhat ad hoc. 2009/6/9 Daniel Fischer daniel.is.fisc...@web.de: Am Dienstag 09 Juni 2009 20:29:09 schrieb Thomas Hartman: All I want to do is split on commas, but not the commas inside () or tags. I have been wanting to master parsec for a long time and this simple exercise

Re: [Haskell-cafe] applicative challenge

2009-05-05 Thread Thomas Hartman
to approach these types of problems. Not *that* easy though, as this scenario suggests. 2009/5/5 Thomas Davie tom.da...@gmail.com: On 4 May 2009, at 23:15, Thomas Hartman wrote: {-# LANGUAGE NoMonomorphismRestriction #-} import Data.List import Control.Monad import Control.Applicative

Re: [Haskell-cafe] applicative challenge

2009-05-05 Thread Thomas Hartman
seems to be the same behavior whether in ghci or compiled with ghc. 2009/5/5 Ketil Malde ke...@malde.org: Thomas Hartman tphya...@gmail.com writes: That's slick, but is there some way to use interact twice in the same program? No :-) t10 =   let f = unlines . takeWhile (not . blank

Re: [Haskell-cafe] applicative challenge

2009-05-05 Thread Thomas Hartman
:: String - (String,String) grabby s = let (beg,end) = break null . lines $ s in (unlines beg, (unlines . drop 2 $ end)) 2009/5/5 Ketil Malde ke...@malde.org: Thomas Hartman tphya...@gmail.com writes: That's slick, but is there some way to use interact twice in the same program

using interact with state, was Re: [Haskell-cafe] applicative challenge

2009-05-05 Thread Thomas Hartman
, (unlines . drop 2 $ end)) -- And, with applicative extras: t19 = interact $ evalState f19 where f19 = paint $ grabTillBlank * grabTillBlank paint first second = first\n ++ first ++ second\n ++ second 2009/5/5 Thomas Hartman tphya...@gmail.com: interact (\s - let (first,second

Re: [Haskell-cafe] applicative challenge

2009-05-05 Thread Thomas Hartman
half-assed state for a real state solution, there's follow up here: http://groups.google.com/group/haskell-cafe/browse_thread/thread/d6143504c0e80075 2009/5/5 Thomas Hartman tphya...@gmail.com: interact (\s - let (first,second) = span (not . null) (lines s)               in unlines

[Haskell-cafe] applicative challenge

2009-05-04 Thread Thomas Hartman
{-# LANGUAGE NoMonomorphismRestriction #-} import Data.List import Control.Monad import Control.Applicative -- Can the function below be tweaked to quit on blank input, provisioned in the applicative style? -- which function(s) needs to be rewritten to make it so? -- Can you tell/guess which

Re: [Haskell-cafe] Generating random enums

2009-05-01 Thread Thomas Hartman
see http://www.mail-archive.com/haskell-cafe@haskell.org/msg38528.html for some ideas, particularly antoine latter's answer. 2009/5/1 michael rice nowg...@yahoo.com: I'm using the code below to generate random days of the week [Monday..Sunday]. Is there a better/shorter way to do this?

Re: [Haskell-cafe] Generating random enums

2009-05-01 Thread Thomas Hartman
So... I must say I am rather pleased with the following code. It allows you to use any value of type Bounded and Enum as a member of Random, or Arbitrary, which means you can quickCheck properties on it as well. For quickchecking, the code below cheats by not defining the coarbitrary funciton,

[Haskell-cafe] What to do when cabal dependencies are not your friend.

2009-05-01 Thread Thomas Hartman
I did a little write-up on an annoyance I frequently have when developing patch-tag, a happs application that has a lot of dependencies. Basically, on a virgin linux environment with the same cabal and ghc version as before, a cabal install that had previously worked, didn't work anymore. I

[Haskell-cafe] how can one load Prelude into ghci?

2009-04-27 Thread Thomas Hartman
One reason it would be nice to be able to do this, is you could then get lambdabot :src style listings of prelude function definitions by using the ghci debugger and :list for prelude functions. is this possible? so far I have tried

Re: [Haskell-cafe] ghci debugger problem with :continue. is it broken, or is it me?

2009-04-27 Thread Thomas Hartman
to debug. On balance, I think I'll frequently write my functions with lambda bound variables then. Getting better use out of the ghc debugger seems worth the few extra cycles. 2009/4/26 Bernie Pope florbit...@gmail.com: 2009/4/25 Thomas Hartman tphya...@gmail.com In the program below, can

Re: [Haskell-cafe] Haskell/JS -- better through typeclasses?

2009-04-25 Thread Thomas Hartman
I tried using the jhc javascript compiler back end a year or so ago. It was too rough to use in production, but it did output javascript from haskell. thomas. 2009/4/25 Miguel Mitrofanov miguelim...@yandex.ru: On 25 Apr 2009, at 21:53, Jason Dusek wrote:  Many Haskell/JS bridges provide

Re: [Haskell-cafe] Haskell/JS -- better through typeclasses?

2009-04-25 Thread Thomas Hartman
On second thought, it was yhc, not jhc: http://lambda-the-ultimate.org/node/1836 2009/4/25 Thomas Hartman tphya...@gmail.com: I tried using the jhc javascript compiler back end a year or so ago. It was too rough to use in production, but it did output javascript from haskell. thomas

[Haskell-cafe] ghci debugger problem with :continue. is it broken, or is it me?

2009-04-24 Thread Thomas Hartman
In the program below, can someone explain the following debugger output to me? After :continue, shouldn't I hit the f breakpoint two more times? Why do I only hit the f breakpoint once? Is this a problem in the debugger? thart...@ubuntu:~/haskell-learning/debuggercat debugger.hs -- try

Re: [Haskell-cafe] Combining sequences

2009-04-05 Thread Thomas Hartman
It's not in hugs, nor in ghc. It's just in hackage. However, by the looks of it, you should probably be able to use it in hugs. I didn't actually check this, but the cabal file didn't name any fancy extensions, so it looks pretty cross-compiler. You can just go to

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-04-04 Thread Thomas Hartman
takeListSt' = evalState . foldr k (return []) . map (State . splitAt) where k m m'= cutNull $ do x-m; xs-m'; return (x:xs) cutNull m = do s-get; if null s then return [] else m Not only is ths not that elegant anymore, I think it *still* has a bug, stack overflow against

Re: [Haskell-cafe] happstack example code wanted

2009-04-04 Thread Thomas Hartman
Johannes, You'll have a better response if you post to the happs list. Have you had a look at tutorial.happstack.com? Thomas. 2009/4/4 Johannes Waldmann waldm...@imn.htwk-leipzig.de: Hi, I'm thinking of using happstack for a simple online registration system. [ Customer gives Name and

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-04-04 Thread Thomas Hartman
Thanks Claus, Indeed the problem was that I was using the Strict state monad, with lazy state it does the right thing when run through testP. I will try and get back to this thread if I manage the derivation which proves (or at least supports) that the two versions are equivalent. 2009/4/4

[Haskell-cafe] Is Text.XHtml.Table usable?

2009-03-29 Thread Thomas Hartman
I was playing with Text.XHtml.Table but couldn't use it to output tables. ( cell . toHtml $ a ) `beside` (cell . toHtml $ b ) tr a b /tr already seems wrong -- should be two cells, right? And the result doesn't get embedded in a table tag? Is there something I'm missing? Working code

Re: mapM as a Space Leak (Was: [Haskell-cafe] about Haskell code written to be too smart)

2009-03-26 Thread Thomas Hartman
I wonder if JHC or some other compiler might work better with these examples? Are you saying that different compilers might give different answers? Yikes! Too clever indeed! 2009/3/26 rocon...@theorem.ca: On Wed, 25 Mar 2009, Thomas Hartman wrote: With the state version, there's a lot

Re: mapM as a Space Leak (Was: [Haskell-cafe] about Haskell code written to be too smart)

2009-03-26 Thread Thomas Hartman
, 2009-03-26 at 12:29 -0700, Thomas Hartman wrote: I wonder if JHC or some other compiler might work better with these examples? Are you saying that different compilers might give different answers? Yikes! Too clever indeed! No, they might produce code with different performance

Re: [Haskell-cafe] Really need some help understanding a solution

2009-03-26 Thread Thomas Hartman
Luke, does your explanation to Guenther have anything to do with coinduction? -- the property that a producer gives a little bit of output at each step of recursion, which a consumer can than crunch in a lazy way? I find that coinduction seems to figure frequently in algos that process a stream.

Re: [Haskell-cafe] Really need some help understanding a solution

2009-03-26 Thread Thomas Hartman
Re that link: search for wren's comments containing it is however nicely coinductive 2009/3/26 Thomas Hartman tphya...@gmail.com: Luke, does your explanation to Guenther have anything to do with coinduction? -- the property that a producer gives a little bit of output at each step of recursion

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Thomas Hartman
What about import Data.List partAt n xs =  let (beg,end) = splitAt n xs  in beg : ( case end of               [] - []               xs - partAt n xs) t = partAt 3 [1..10] It's tail recursive (I think!) and should be pretty easy to understand even for a beginner, no? 2009/3/24 Manlio Perillo

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Thomas Hartman
sorry, wrong function. should be partitions [] xs = [] partitions (n:parts) xs = let (beg,end) = splitAt n xs in beg : ( case end of [] - [] xs - partitions parts xs) t = partitions [1,2,3] [1..10] which is not quite as nice, I admit. 2009/3/25 Thomas

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Thomas Hartman
Are you saying there's a problem with this implementation? It's the Yes, there is actually a problem with this implementation. import Data.List import Control.Monad.State import Debug.Trace.Helpers partitions [] xs = [] partitions (n:parts) xs = let (beg,end) = splitAt n xs in beg : (

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Thomas Hartman
as a hobby, but just don't have comfort in certain monads and idioms. 2009/3/25 Thomas Hartman tphya...@gmail.com: Are you saying there's a problem with this implementation? It's the Yes, there is actually a problem with this implementation. import Data.List import Control.Monad.State import

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Thomas Hartman
Since this thread is ostensibly about haskell style, it should also be about haskell style *today*. As I think Yitz noted earlier, this is a moving target. Adoption of haskell by the masses -- moving. Skill of haskell hordes -- moving. Abstractions available as part of idiomatic haskell, and

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Thomas Hartman
Not only is your simpler function easier to read, it is also more correct. partitionsHubris xs ns = zipWith take ns . init $ scanl (flip drop) xs ns partitionsBeginner :: [Int] - [a] - [[a]] partitionsBeginner [] _ = [] partitionsBeginner _ [] = [] partitionsBeginner (n : ns)

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Thomas Hartman
s/Pattern matching is awesome language feature. use it! /Pattern matching is awesome language feature. Don't be ashamed to use it! / :) 2009/3/25 Thomas Hartman tphya...@gmail.com: Not only is your simpler function easier to read, it is also more correct. partitionsHubris xs ns = zipWith

Re: [Haskell-cafe] about Haskell code written to be too smart

2009-03-25 Thread Thomas Hartman
. pf ( take 1000 [3,7..] ) $ [1..10] , show . pf [3,7,11,15] $ ( take (10^6) [1..]) , show . head . last $ pf (take 1000 $ [3,3..]) [1..10^6] ] (no infinite lists, just long lists) 2009/3/25 Dan Piponi dpip...@gmail.com: On Wed, Mar 25, 2009 at 12:44 PM, Thomas

[Haskell-cafe] MissingH bracketCD (aka bracketCWD) bug -- this is the infamous lazy io, right?

2009-03-23 Thread Thomas Hartman
I got bitten by a bug (well, I call it bug) in bracketCD from HSH/MissingH demonstrated by the following code bracketCD is very useful for sysadminny one-offs, I use it all the time, but. I suspect that unless people are very careful, this behavior will affect other users of bracketCD, in

Re: [Haskell-cafe] Re: Has anybody replicated =~ s/../../ or even something more basic for doing replacements with pcre haskell regexen?

2009-03-17 Thread Thomas Hartman
2009/3/16 ChrisK hask...@list.mightyreason.com: Let me open the discussion with all the questions I can quickly ask:  What should the subRegex function do, exactly?  (Single replacement,global replacement,once per line,...) Try to do the same thing as =~ s/../../ in perl. For a version 1:

  1   2   3   4   >