Re: [Haskell-cafe] mapFst and mapSnd

2013-05-30 Thread Shachaf Ben-Kiki
On Tue, May 28, 2013 at 1:54 AM, Dominique Devriese dominique.devri...@cs.kuleuven.be wrote: Hi all, I often find myself needing the following definitions: mapPair :: (a - b) - (c - d) - (a,c) - (b,d) mapPair f g (x,y) = (f x, g y) mapFst :: (a - b) - (a,c) - (b,c) mapFst f =

Re: [Haskell-cafe] mapFst and mapSnd

2013-05-30 Thread Shachaf Ben-Kiki
On Thu, May 30, 2013 at 7:12 PM, Shachaf Ben-Kiki shac...@gmail.com wrote: One generalization of them is to lenses. For example `lens` has both, _1, _2, such that mapPair = over both, mapFst = over _1, etc., but you can also get fst = view _1, set _2 = \y' (x,_) - (x,y'), and so on. (Since

[Haskell-cafe] Haskell + RankNTypes + (forall p. p Char - p Bool) sound?

2013-03-05 Thread Shachaf Ben-Kiki
I was trying to figure out a way to write absurd :: (forall p. p Char - p Bool) - Void using only rank-n types. Someone suggested that Haskell with RankNTypes and a magic primitive of type (forall p. p Char - p Bool) might be sound (disregarding the normal ways to get ⊥, of course). Is that true?

Re: [Haskell-cafe] quotRem and divMod

2013-01-28 Thread Shachaf Ben-Kiki
On Mon, Jan 28, 2013 at 4:27 PM, Artyom Kazak artyom.ka...@gmail.com wrote: Hi! I’ve always thought that `quotRem` is faster than `quot` + `rem`, since both `quot` and `rem` are just wrappers that compute both the quotient and the remainder and then just throw one out. However, today I looked

[Haskell-cafe] Taking over ghc-core

2012-11-10 Thread Shachaf Ben-Kiki
With Don Stewart's blessing (https://twitter.com/donsbot/status/267060717843279872), I'll be taking over maintainership of ghc-core, which hasn't been updated since 2010. I'll release a version with support for GHC 7.6 later today. Shachaf ___

Re: [Haskell-cafe] Smarter do notation

2011-09-04 Thread Shachaf Ben-Kiki
On Sat, Sep 3, 2011 at 19:34, Daniel Peebles pumpkin...@gmail.com wrote: ... Of course, the fact that the return method is explicitly mentioned in my example suggests that unless we do some real voodoo, Applicative would have to be a superclass of Monad for this to make sense. But with the new

Re: [Haskell-cafe] Interactive chatbot

2009-11-04 Thread Shachaf Ben-Kiki
On Wed, Nov 4, 2009 at 3:14 PM, Jason Dagit da...@codersbase.com wrote: On Wed, Nov 4, 2009 at 2:21 PM, Torsten Otto t-otto-n...@gmx.de wrote: Hi! My students have the task to program an interactive chatbot. We have run into a problem that I can't solve either: When we read the user's

[Haskell-cafe] LinuxFest Northwest 2009

2009-01-19 Thread Shachaf Ben-Kiki
LFNW 2009 (http://linuxfestnorthwest.org/) is going to be at the end of April, and I was wondering if anyone here is going to be there, or possibly a Haskell-related presentation. Last year I met ac from #haskell there, but it would be nice if more people came, especially with the (relatively)

Re: [Haskell-cafe] Sequencing Parsers: a Simple Example

2007-12-01 Thread Shachaf Ben-Kiki
Hi (=) :: Parser a - Parser b - Parser b p = f = \inp - case p inp of [] - [] [(v, out)] - parse (f v) out based on a lot of guesswork, after the mess created by the OCR, I managed to get the above example to work syntactically but is it semantically correct? Thanks, Paul

Re: [Haskell-cafe] Best way to format a number

2007-11-20 Thread Shachaf Ben-Kiki
On Nov 20, 2007 7:07 PM, Don Stewart [EMAIL PROTECTED] wrote: You can work around it for now with: Prelude Text.Printf printf %02d\n 3 return () 03 It may be simpler to specify the type explicitly: Prelude Text.Printf printf %02d\n 3 :: IO () 03 Shachaf

Re: [Haskell-cafe] What is the role of $!?

2007-11-14 Thread Shachaf Ben-Kiki
On Nov 14, 2007 4:27 PM, Justin Bailey [EMAIL PROTECTED] wrote: It's: f $! x = x `seq` f x That is, the argument to the right of $! is forced to evaluate, and then that value is passed to the function on the left. The function itself is not strictly evaluated (i.e., f x) I don't believe.

Re: [Haskell-cafe] Type inference problem with division (/)

2007-10-30 Thread Shachaf Ben-Kiki
On 10/30/07, Tim Chevalier [EMAIL PROTECTED] wrote: On 10/30/07, noa [EMAIL PROTECTED] wrote: Hi! I have the following function: theRemainder :: [String] - [String] - Double theRemainder xs xt = sum( map additional (unique xs) ) where additional x = poccur * (inf

Re: [Haskell-cafe] Defining new operators

2007-08-10 Thread Shachaf Ben-Kiki
Hi all, Given the follwing function: owner :: Step - Scenario owner (Step id scenario action state response) = scenario Is it possible to define the owner function in such way that I can write x.owner (returning the scenario related with the Step x)? Some people use (|), which looks

Re: [Haskell-cafe] Getting lambdabot to work with 6.6.1

2007-07-17 Thread Shachaf Ben-Kiki
I also commented out arrows as a dependency in the .cabal, I think. Was that not a good idea? it seemed to work. Shachaf ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe

Re: [Haskell-cafe] Is this haskelly enough?

2007-07-17 Thread Shachaf Ben-Kiki
on, which will appear in Data.Function in the next release of base, is defined thusly: on :: (b - b - c) - (a - b) - a - a - c (*) `on` f = \x y - f x * f y You can also use Data.Ord.comparing, in this case -- comparing is just (compare `on`). From Ord.hs: -- | -- comparing p x y =

Re: [Haskell-cafe] Is this haskelly enough?

2007-07-17 Thread Shachaf Ben-Kiki
For the monadically-challenged, this is equivalent, yes-no? maxsubarrays = maximumBy (compare `on` sum) . concat . (map tails) . inits Or: maxsubarrays = maximumBy (compare `on` sum) . concatMap tails . inits (=) for lists is just (flip concatMap). Also, this is working with lists, not arrays