Re: [Haskell-cafe] A practical Haskell puzzle
There were a number of emails discussing what a type-safe list solution would like look. This was the approach that first came to mind when I read your email (but I've had my head in Agda lately) http://hpaste.org/44469/software_stack_puzzle I've written up a minimal working example of this approach for those that are curious. As for the Haskell98 approach, I'd love to see a solution that didn't require deserialization/serialization at each layer boundary. This sounds like a case for the techniques used in list fusion, but GHC RULES are hardly Haskell98 :-) I'd also like to avoid cramming all of the possible layer input and output types into one giant ADT in such a solution. -- Eric Mertens ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Umlauts in command line arguments
Hello, On Sun, May 31, 2009 at 5:24 PM, GüŸnther Schmidt gue.schm...@web.de wrote: When a command line argument contains an umlaut that argument gets garbled. I'm using ghc 6.10.2 on Win XP. Are there any known solutions for this problem? Your question has inspired me to add a System.Environment.UTF8 module to utf8-string 0.3.5 This module behaves like the System.IO.UTF8 wrapper. -- Eric Mertens ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Ackermann Function Memoization, GHC Weird Output or Bug?
Smaller example of this behavior: array ((0,0),(1,1)) [((1,1),6)] ! (0,3) 6 -- Eric Mertens ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is this haskelly enough?
On 7/17/07, James Hunt [EMAIL PROTECTED] wrote: As a struggling newbie, I've started to try various exercises in order to improve. I decided to try the latest Ruby Quiz (http://www.rubyquiz.com/quiz131.html) in Haskell. Would someone be kind enough to cast their eye over my code? I get the feeling there's a better way of doing it! subarrays :: [a] - [[a]] subarrays [] = [[]] subarrays xs = (sa xs) ++ subarrays (tail xs) where sa xs = [ys | n - [1..length xs], ys - [(take n xs)]] Check out the functions in Data.List inits :: [a] - [[a]] tails :: [a] - [[a]] also, in a list comprehension, rather than: ys - [x] consider: let ys = x in this specific case: [take n xs | n - [1..length xs]] would be even better (though using inits and tails to accomplish this would be best of all) maxsubarrays :: [Integer] - [Integer] maxsubarrays xs = msa [] (subarrays xs) where msa m [] = m msa m (x:xs) | sum x sum m = msa x xs | otherwise = msa m xs --for testing: should return [2, 5, -1, 3] main = maxsubarrays [-1, 2, 5, -1, 3, -2, 1] This problem lends itself to being solved with Dynamic Programming and can be solved in a single pass of the input list. (Rather than supply the answer I'll encourage you to seek it out) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is this haskelly enough?
James, In my earlier post I mentioned that you should find a dynamic programming approach to this problem. My solution is presented below, so you've been warned if you are still working this out: === READ ABOVE === import Data.List (foldl') solve = snd . foldl' aux (0, 0) where aux (cur, best) x = (max 0 cur', max best cur') where cur' = cur + x -- Eric Mertens ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] ANNOUNCE: utf8-string-0.1
Hello, I'd like to announce that I have posted a UTF-8 encoding/decoding library to hackage. This library also includes replacements for most of the System.IO namespace under System.IO.UTF8. This library detects overlong sequences, and replaces invalid code-points and invalid encodings with the replacement character '\xfffd'. The following file was used to ensure that the decoder was considered safe: http://www.cl.cam.ac.uk/~mgk25/ucs/examples/UTF-8-test.txt utf8-string can be found on hackage: http://hackage.haskell.org/cgi-bin/hackage-scripts/package/utf8-string-0.1 source code is available via: darcs get http://code.haskell.org/utf8-string/ -- Eric Mertens ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to write elegant Haskell programms? (long posting)
-- Here's my contribution to the Haskell way to do it import Directory (renameFile) import System.FilePath import System.Path.Glob (glob) import System.Time basenames= [ mail.log, thttpd.log ] logdir = /var/log archivedir = /var/log/archive main = forM_ bases $ \base - do olds - glob $ logdir / base . *.gz forM_ olds $ \old - do now - timestamp old let new = archivedir / basename . now . gz printf mv %s %s old new renameFile old new timestamp f = do t - getModificationTime return $ formatCalendarTime defaultTimeLocale %Y%m%d (toUTCTime t) ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] How to write elegant Haskell programms? (long posting)
-- here was my original before I allowed someone (no names) to mangle mine for me ;) import Control.Monad (liftM, forM_) import Directory (getModificationTime, renameFile) import Text.Printf (printf) import System.FilePath ((/),(.)) import System.Locale (defaultTimeLocale) import System.Path.Glob (glob) import System.Time (toUTCTime, formatCalendarTime, getClockTime, ClockTime) basenames = [mail.log, thttpd.log ] logdir= /var/log main = forM_ basenames $ \ basename - do oldnames - glob (logdir / basename . *.gz) forM_ oldnames $ \ oldname - do now - timestamp oldname let newname = logdir / archive / basename . now . gz printf mv %s %s oldname newname renameFile oldname newname timestamp path = do t - getModificationTime path return $ formatCalendarTime defaultTimeLocale %Y%m%d $ toUTCTime t ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Announce: hpaste
Hello, I am pleased to announce hpaste, the Haskell Paste-bin. Over the course of this week many of the active #haskell members and I have been developing this application to provide #haskell with a reliable paste bot whose features are tuned to the needs of the channel. Everyone is invited to see hpaste for themselves at http://hpaste.ath.cx:8000 hpaste.org has been registered, and in a few days time will be the permanent home of hpaste. An example of how hpaste was recently used to teach can be seen at http://hpaste.ath.cx:8000/43 A paste-bin is a place for IRC users to paste and annotate code snippets in a stable environment. This keep users from flooding the channel and saves users from having to scroll back constantly to review a paste. hpaste uses haskell syntax coloring (provided by hscolour) and is able to generate a color-coded diff of two pastes to give users an additional tool to share and teach. This project was a wonderful way for me to learn both the old and new HAppS APIs which have both proven to be quite powerful. In addition to providing a web-interface, hpaste is able to announce new pastes to the IRC channel via a bot based on Don Stewart's IRC bot tutorial. darcs has been instrumental in this colaborative effort, and the hpaste source is available with: darcs get --partial http://www.scannedinavian.com/~eric/hpaste Feedback is both encouraged and welcomed! -- Eric Mertens [EMAIL PROTECTED] ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe