Re: [Haskell-cafe] What is the good way to work with list comprehension and UTCTime?

2012-09-14 Thread Karl Voelker
On Thu, Sep 13, 2012 at 10:29 PM, Magicloud Magiclouds magicloud.magiclo...@gmail.com wrote: Hi, Simple usage, I could make an instance of Enum to UTCTime, so [utcTime..] could work. But that is so stiff. How if sometimes I want to step by 1 min, sometimes I want to step by 1 sec? So I

Re: [Haskell-cafe] [ANN] Cumino 0.2 - Now supports pretty indentation through stylish-haskell

2012-09-14 Thread Alfredo Di Napoli
Ok, I've added the support for urxvt. Bear in mind that it partially support urxvt, though: it works fine if you run GVim or Vim outside an already running tmux session, otherwise it won't start. The problem is due to the fact urxvt believes that the new session is launched within the running tmux

Re: [Haskell-cafe] Is Hackage down?

2012-09-14 Thread John Wiegley
C K Kashyap ckkash...@gmail.com writes: Is it just me or is Hackage indeed been going down more frequently of late? It's not just you. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] [ANN] Cumino 0.2 - Now supports pretty indentation through stylish-haskell

2012-09-14 Thread Alfredo Di Napoli
Sorry the typo, the variable is $TMUX and controls the nesting ot tmux session. It turns out that if affect not only urxvt but also xterm and gnome-terminal. Perhaps it could be useful to unset it programmatically, I'll keep you posted if I find a workaround. A. On 14 September 2012 06:14,

Re: [Haskell-cafe] What is the good way to work with list comprehension and UTCTime?

2012-09-14 Thread Roman Cheplyaka
Consider using the time-lens package. import Data.Time.Lens import Data.Lens.Common List comprehension style: [modL seconds (+ fromIntegral n) t | n - [0..]] [modL minutes (+ n) t | n - [0..]] (you need fromIntegral for seconds, because it is of fractional type in Data.Time). iterate

Re: [Haskell-cafe] What is the good way to work with list comprehension and UTCTime?

2012-09-14 Thread Magicloud Magiclouds
This is nice. Thanks to all. On Fri, Sep 14, 2012 at 4:03 PM, Roman Cheplyaka r...@ro-che.info wrote: Consider using the time-lens package. import Data.Time.Lens import Data.Lens.Common List comprehension style: [modL seconds (+ fromIntegral n) t | n - [0..]] [modL minutes (+ n)

[Haskell-cafe] Transforming a ADT to a GADT

2012-09-14 Thread Florian Lorenzen
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Hello cafe, I have a question wrt. to GADTs and type families in GHC (7.6.1). I'd like to transform a value of an ADT to a GADT. Suppose I have the simple expression language data Exp = Lit Int | Succ Exp | IsZero Exp | If Exp Exp Exp and the

[Haskell-cafe] ANN: Cumino 0.3 - Now supports sandboxed environments (e.g, Hsenv ones)

2012-09-14 Thread Alfredo Di Napoli
Hi Cafè, I'm glat to annouce the third major improvement of my VIm plugin Cumino: https://github.com/adinapoli/cumino This one is a juicy one. If you have a sandboxed environment enabled (e.g. one created with Hsenv) and you start vim from the same shell, Cumino will automatically uses at

Re: [Haskell-cafe] Transforming a ADT to a GADT

2012-09-14 Thread Sean Leather
On Fri, Sep 14, 2012 at 12:45 PM, Florian Lorenzen wrote: I'd like to transform a value of an ADT to a GADT. Suppose I have the simple expression language data Exp = Lit Int | Succ Exp | IsZero Exp | If Exp Exp Exp and the GADT data Term t where TLit :: Int - Term Int TSucc :: Term

Re: [Haskell-cafe] Transforming a ADT to a GADT

2012-09-14 Thread Florian Lorenzen
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Dear Sean, thanks for your solution. It in the documentation of unsafeCoerce it says: It [unsafeCoerce] is generally used when you want to write a program that you know is well-typed, but where Haskell's type system is not expressive enough to prove

Re: [Haskell-cafe] Transforming a ADT to a GADT

2012-09-14 Thread Erik Hesselink
On Fri, Sep 14, 2012 at 2:01 PM, Sean Leather leat...@cs.uu.nl wrote: On Fri, Sep 14, 2012 at 12:45 PM, Florian Lorenzen wrote: I'd like to transform a value of an ADT to a GADT. Suppose I have the simple expression language data Exp = Lit Int | Succ Exp | IsZero Exp | If Exp Exp Exp

Re: [Haskell-cafe] Transforming a ADT to a GADT

2012-09-14 Thread Sean Leather
On Fri, Sep 14, 2012 at 2:27 PM, Erik Hesselink wrote: I don't think this is safe. What will happen if you evaluate typecheck (Lit 1) :: Maybe (Term Bool) Indeed! Silly me. Caught by the lure again. Thanks. Regards, Sean ___ Haskell-Cafe mailing

Re: [Haskell-cafe] Transforming a ADT to a GADT

2012-09-14 Thread Tsuyoshi Ito
Dear Florian, On Fri, Sep 14, 2012 at 6:45 AM, Florian Lorenzen florian.loren...@tu-berlin.de wrote: Now, I'd like to have a function typecheck :: Exp - Maybe (Term t) typecheck exp = ... that returns the GADT value corresponding to `exp' if `exp' is type correct. If you can add “deriving

Re: [Haskell-cafe] Transforming a ADT to a GADT

2012-09-14 Thread Erik Hesselink
On Fri, Sep 14, 2012 at 2:27 PM, Erik Hesselink hessel...@gmail.com wrote: In general, I think you have to work inside an existential. So you hide the type of the parsed Term inside an existential. If you want to apply functions to this Term, you unpack, call the function, and repack. Maybe I

Re: [Haskell-cafe] ANNOUNCE: Groundhog 0.1.0.1 - high-level database library

2012-09-14 Thread Boris Lykah
Groundhog has design very similar to Persistent, so I would choose it for comparison. I don't have much of experience of using Persistent, so some facts may be inaccurate for the newer versions. The facts are based mostly on the Persistent documentation. You may be also interested in comparison of

[Haskell-cafe] Tutorial: Haskell for the Evil Genius

2012-09-14 Thread Andrew Pennebaker
I've gotten mixed feedback from Reddit for my tutorial. It provides an overview of how functional and declarative programming in Haskell empower baddies, increasing the accuracy and efficiency of their atomic superweapons. What do you guys think of my tutorial, Haskell for the Evil Genius

Re: [Haskell-cafe] Tutorial: Haskell for the Evil Genius

2012-09-14 Thread Alex Stangl
On Fri, Sep 14, 2012 at 12:13:15PM -0400, Andrew Pennebaker wrote: I've gotten mixed feedback from Reddit for my tutorial. It provides an overview of how functional and declarative programming in Haskell empower baddies, increasing the accuracy and efficiency of their atomic superweapons. What

Re: [Haskell-cafe] Tutorial: Haskell for the Evil Genius

2012-09-14 Thread Conal Elliott
Hi Andrew, To save others the search, here's the/a reddit URL: http://www.reddit.com/r/programming/related/nhnyd/nfa_in_a_single_line_of_haskell/. The terribly misleading/mistaken remarks on fib memoization are still in your post. As hammar commented on reddit commenter, you're not memoizing in

Re: [Haskell-cafe] Either Monad and Laziness

2012-09-14 Thread Eric Velten de Melo
On 13 September 2012 20:29, wren ng thornton w...@freegeek.org wrote: On 9/12/12 5:37 PM, Francesco Mazzoli wrote: At Wed, 12 Sep 2012 12:04:31 -0300, Eric Velten de Melo wrote: It would be really awesome, though, if it were possible to use a parser written in Parsec with this, in the

Re: [Haskell-cafe] Tutorial: Haskell for the Evil Genius

2012-09-14 Thread Andrew Pennebaker
A summary of the changes I've included so far: Under Declarative, you aren't creating a named expression, 2 + 2, really. You are redefining (+). Noted and reflected in the new version. Under Lazy, your example of binding fib 30 is not a good example of memoization. With memoization you

Re: [Haskell-cafe] Tutorial: Haskell for the Evil Genius

2012-09-14 Thread Albert Y. C. Lai
On 12-09-14 05:18 PM, Andrew Pennebaker wrote: One thing I want to double check is that Haskell does, in fact, automatically memoize all pure function calls. Is this true? A simple back-of-envelope calculation that immediately raises doubts: 2 seconds on a 2 GHz computer is 4x10^9 clock

Re: [Haskell-cafe] Tutorial: Haskell for the Evil Genius

2012-09-14 Thread Alex Stangl
On Fri, Sep 14, 2012 at 05:18:24PM -0400, Andrew Pennebaker wrote: A summary of the changes I've included so far: Under Declarative, you aren't creating a named expression, 2 + 2, really. You are redefining (+). Noted and reflected in the new version. It may not be obvious to readers when

Re: [Haskell-cafe] Tutorial: Haskell for the Evil Genius

2012-09-14 Thread Andrew Pennebaker
Experiment #4: fib :: Int - Int fib n = mem !! n mem :: [Int] mem = map aux [0..] -- remark: even [Int] is not a very efficient data structure for this aux 0 = 0 aux 1 = 1 aux n = mem!!(n-1) + mem!!(n-2) main :: IO () main = mapM_ (print . fib) (replicate 10 30) Question: How

Re: [Haskell-cafe] Tutorial: Haskell for the Evil Genius

2012-09-14 Thread Corentin Dupont
Well, to make it short, I liked it! As suggestions, little things like first class functions and partial application can be easily introduced. For example the line: map (+1) [1..10] contains these concepts and it very short and expressive. On the story side, why not introducing a character? This

Re: [Haskell-cafe] Tutorial: Haskell for the Evil Genius

2012-09-14 Thread Alexander Solla
On Fri, Sep 14, 2012 at 2:18 PM, Andrew Pennebaker andrew.penneba...@gmail.com wrote: A summary of the changes I've included so far: Noted and reflected... I'm trying to convey to an audience largely composed of Java and C++ fanatics how Haskell records are much better than OOP, how GADTs

Re: [Haskell-cafe] Tutorial: Haskell for the Evil Genius

2012-09-14 Thread Andrew Pennebaker
But, Haskell records aren't better than OOP. I am not trying to be controversial here -- Haskell records would naturally implement prototype-based OOP, like JavaScript uses, if they (Haskell records) weren't so useless. This is basically why lenses were designed (i.e., to make consistent

Re: [Haskell-cafe] Tutorial: Haskell for the Evil Genius

2012-09-14 Thread Kristopher Micinski
On Fri, Sep 14, 2012 at 8:23 PM, Andrew Pennebaker andrew.penneba...@gmail.com wrote: [snip..] Does anyone know of a brief introductory Haskell tutorial that engages monads? LYAH covers monads, but it does so after a few chapters of simpler, pure function Haskell coding. I know of some brief

Re: [Haskell-cafe] Tutorial: Haskell for the Evil Genius

2012-09-14 Thread Andrew Pennebaker
Everyone in the Haskell cafe probably has a secret dream to give the best five minute monad talk. Challenge: get someone to have a competition at one of the conferences where students all give their best five minute monad talk and try to find the most comprehensible one! Haha, maybe

Re: [Haskell-cafe] Tutorial: Haskell for the Evil Genius

2012-09-14 Thread Brandon Allbery
On Fri, Sep 14, 2012 at 9:08 PM, Andrew Pennebaker andrew.penneba...@gmail.com wrote: Given that Maybe and Either don't modify state, nor do they communicate with outside interfaces, nor do they specify computation ordering, I don't understand why they're implemented as monads. Why not a

Re: [Haskell-cafe] Tutorial: Haskell for the Evil Genius

2012-09-14 Thread Joel Burget
I find the Monad instance for Maybe and Either very useful. You can do things like the following (which technically only uses the Applicative instance): Prelude Control.Applicative (*3) $ (+2) $ Just 1 Just 9 Prelude Control.Applicative (*3) $ (+2) $ Nothing Nothing Prelude Control.Applicative

Re: [Haskell-cafe] Tutorial: Haskell for the Evil Genius

2012-09-14 Thread Andrew Pennebaker
Challenge: get someone to have a competition at one of the conferences where students all give their best five minute monad talk and try to find the most comprehensible one! Challenge accepted http://www.yellosoft.us/5min/. ___ Haskell-Cafe mailing