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
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
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
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
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]?
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
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
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
*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
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
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.
, 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
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
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
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:
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
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
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
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
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
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
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
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
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
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,
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
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
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
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
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:
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
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
http://hackage.haskell.org
___
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe
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
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
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.
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
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
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
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
-- 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 =
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 $ )
= (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
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
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 =
,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
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
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
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.)
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
(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
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
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
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
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,
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
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
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
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,
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
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
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
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
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
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
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.
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
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
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
:: 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
, (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
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
{-# 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
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?
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,
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
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
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
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
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
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
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
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
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
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
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
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
, 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
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 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
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
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
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 : (
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
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
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)
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
. 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
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
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 - 100 of 360 matches
Mail list logo