[Haskell-cafe] Parallel Haskell Digest 5
Parallel Haskell Digest === Edition 5 2011-08-31 Hello Haskellers! Eric here, reprising my role as Parallel Haskell Digester. Many thanks to Nick for good stewardship of the digest and nice new directions for the future. This month we have Erlang PhDs (and a postdoc), new partners, two Monad Reader articles in progress and some strategies. As usual, this digest is made possible by the [Parallel GHC Project][n0]. News -- [Scalable Erlang PostDoc and 2 PhD Studentships][n1] (8 Aug) What, Erlang?! Yes, you are reading the right digest. If you're generally into parallelism and concurrency in functional programming languages, you may be especially interested to know about this announcement from Phil Trinder. RELEASE project - A High-level Paradigm for Reliable Large-scale Server Software - is funded by the EU Framework 7 programme for 36 months from October 2011. Its aim is to scale the radical concurrency-oriented programming paradigm to build reliable general-purpose software, such as server-based systems, on massively parallel machines (100 000 cores). Word of the Month -- Last month, we had `par` and `pseq` as our twin words of the month. Let's pursue this little train of parallel thought; our next word the month is *strategy*. Strategies have been around since the 1993 paper [Algorithm + Strategy = Parallelism][asp]; that's before even we started using monads in Haskell! They've recently been revamped in Simon Marlow's [Seq no More][seq-nm] paper, and it's this version of strategies that we'll be exploring here. Strategies are built on top of the `par` and `pseq` primitives we saw in the [last digest][phd4]. They provide a nice way to express the often complicated logic we need to make the best use of parallelism in our code. Use of strategies can also help to make parallel code easier to read and maintain because they allow us to more cleanly separate the core logic from our code that which pertains to our use of parallelism. Before delving into strategies, let's take a small notational detour by introducing the `Eval` monad. Suppose we wanted a parallel version of the `map` function, something that would apply a function to each item of a list. Using the `par` and `pseq` from the last digest, we might express this function parMap :: (a - b) - [a] - [b] parMap f [] = [] parMap f (a:as) = b `par` bs `pseq` (b:bs) where b = f a bs = parMap f as If we look carefully at the code we can observe that there is something inherently sequential in the way we have expressed this parallel computation: first spark off `f a` then recurse to the tail of the list, and finally cons. The `Eval` monad builds off the insight that expressing parallelism is fundamentally (perhaps counterintuitively) about ordering things. Monads are well-suited for expressing ordering relationships, and so they have been been pressed to work for expressing parallel computation as well. data Eval a instance Monad Eval runEval :: Eval a - a rpar :: a - Eval a rseq :: a - Eval a `Eval` is just a strict identity monad, with `rpar` and `rseq` as counterparts to `par` and `pseq`. We use `Eval` to compose sequences of parallel computation, which we extract the results of by using the `runEval` function. If you're not familiar with monads, you can get away with just treating `Eval` as new notation, or rather, borrowed notation, the same that we use IO, parser combinator libraries, QuickCheck and a plethora of other useful monads. It's worth noting also that despite appearances, we are still in purely functional territory -- no IO here! -- with the notion of sequencing being limited to controlling parallelism and evaluation depth. To make use of `Eval` for our `parMap` function, we could write a version like the below. It introduces a change of type, from returning `[b]` to `Eval [b]`. In the general case, we could just use the `runEval` function to get our result back, but we are not baking it into `parMap` because we would typically want to use then function within a greater `Eval` context anyway. parMap :: (a - b) - [a] - Eval [b] parMap f [] = return [] parMap f (a:as) = do b - rpar (f a) bs - parMap f as return (b:bs) As before, this function captures the basic idea of its sequential counterpart `map`: apply function, recurse to tail, cons new head to new tail. This is a passable parallel map, but there are still two things which are unfortunate about it. First, we have repeated the implementation of map, not a big deal for such a small function but a potential maintenance problem for more complex code. Second, we have only captured one sort of parallel evaluation firing off sparks for all the cons cells, but in practice getting parallelism right requires some often
Re: [Haskell-cafe] Parallel Haskell Digest 5
On Wed, Aug 31, 2011 at 03:39, Eric Y. Kow e...@well-typed.com wrote: (Food for thought: why `parList rseq` instead of `parList r0`? Reply to the Haskell-Cafe posting if you think you know why!) Because with `r0` you're liable to just parallel evaluate to the thunk containing the computation you're trying to parallelize, and the actual computation then takes place later *outside* the parallel section? (That is, what comes out of parList is a list of the thunks passed to `r0`, otherwise unevaluated. You wrapped them in an `id` and then parallel evaluated the `id` away, real useful that. :) You need to go at least to WHNF, then it comes down to the strictness specified in what's passed to `rseq`. -- brandon s allbery allber...@gmail.com wandering unix systems administrator (available) (412) 475-9364 vm/sms ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Pointed, but not Applicative
On Sat, 27 Aug 2011, Sönke Hahn wrote: Hi! I was reading through the Typeclassopedia ([1]) and I was wondering which type could be an instance of Pointed, but not of Applicative. But I can't think of one. Any ideas? (Identity :+: Store s) is a comonad that is also instance of Pointed, but I do not believe it is an instance Applicative. newtype SemiStore s a = (Identity :+: Store s) a instance Pointed (SemiStore s) where pure a = Inl (Identity a) Coalgebras of the (Identity :+: Store s) comonad form the type of partial lenses so this isn't just an academic functor. -- Russell O'Connor http://r6.ca/ ``All talk about `theft,''' the general counsel of the American Graphophone Company wrote, ``is the merest claptrap, for there exists no property in ideas musical, literary or artistic, except as defined by statute.''___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Pointed, but not Applicative
On Wed, 31 Aug 2011, rocon...@theorem.ca wrote: On Sat, 27 Aug 2011, Sönke Hahn wrote: Hi! I was reading through the Typeclassopedia ([1]) and I was wondering which type could be an instance of Pointed, but not of Applicative. But I can't think of one. Any ideas? (Identity :+: Store s) is a comonad that is also instance of Pointed, but I do not believe it is an instance Applicative. newtype SemiStore s a = (Identity :+: Store s) a instance Pointed (SemiStore s) where pure a = Inl (Identity a) Coalgebras of the (Identity :+: Store s) comonad form the type of partial lenses so this isn't just an academic functor. Sorry I left out the newtype wrappers: newtype SemiStore s a = SemiStore ((Identity :+: Store s) a) instance Pointed (SemiStore s) where pure = SemiStore . Inl . Identity -- Russell O'Connor http://r6.ca/ ``All talk about `theft,''' the general counsel of the American Graphophone Company wrote, ``is the merest claptrap, for there exists no property in ideas musical, literary or artistic, except as defined by statute.''___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] iOS and Haskell
Here's a repository that demonstrates Lisp written in Haskell running on the iPad via Haskell-iPhone (see http://www.haskell.org/mailman/listinfo/iphone ): https://github.com/dpp/LispHaskellIPad The library is mature and the author is tremendously responsive on the Haskell-iPhone list. On Tue, Aug 30, 2011 at 9:32 PM, Vasili I. Galchin vigalc...@gmail.comwrote: Hello, I know nothing about the architecture of iOS running on an iPad. However, I have a friend who just bought the newer iPad. It seems that either C++ or Objective C is available on iPad for development(actually the icon says C++). What are the prospects of getting Haskell ported to iOS? Vasili ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe -- Lift, the simply functional web framework http://liftweb.net Simply Lift http://simply.liftweb.net Follow me: http://twitter.com/dpp Blog: http://goodstuff.im ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Off-topic: Mathematics
On 30/08/2011 09:49 PM, Jerzy Karczmarczuk wrote: Knuth admitted that he had learnt a lot while teaching things he already knew. So did Feynman. And Landau. As counter-intuitive as it may seem, explaining something to somebody else forces you to order your thoughts and think through the knowledge you already have, so that you can present it to somebody else in something resembling a coherant form. It's not unusual for this process to clarify your own knowledge. At least, that's *my* excuse for constantly talking to myself... _ ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Off-topic: Mathematics and modesty
On 30/08/2011 07:58 PM, Jerzy Karczmarczuk wrote: I think I know several mathematicians who learning that a person asking for help begins with trying to distinguish between knowledgeable, and those who just think they are, will simply - to say it politely - refuse to engage. I didn't intend to sound snobbish. It's just that there are people who will have read about XYZ in a book one time, and there are people who actually use XYZ every day of their working lives. The latter probably know a tad more about it. That's all. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Off-topic: Mathematics
Statistics questions tend to end up on http://stats.stackexchange.com/, so you could try that, too. It's a well-informed community. Jack Henahan jhena...@uvm.edu == Computer science is no more about computers than astronomy is about telescopes…. -- Michael R. Fellows and Ian Parberry == 398E692F.gpg Description: application/apple-msg-attachment On Aug 30, 2011, at 2:04 PM, Andrew Coppin wrote: On 29/08/2011 01:13 PM, Christopher Done wrote: There's also #math on freenode, but it's a scary wilderness. On 29 August 2011 13:34, Benedict Eastaughionf...@gmail.com wrote: On 29 August 2011 09:34, Andrew Coppinandrewcop...@btinternet.com wrote: This is fairly wildly off-topic but... does anybody know of a good forum where I can ask questions about mathematics and get authoritative answers? Apart from math.stackexchange.com and mathoverflow.net, which people have already mentioned, people often discuss mathematics on #haskell-blah on Freenode. I know of several places where I can ask maths questions and half a dozen people will take guesses at what the correct solution might be. I haven't yet found anywhere where I can say when would a chi-squared test be more appropriate than a KS test? and get an informed, knowledgeable answer. (Answers from people who /know/ what they're talking about rather than just /think/ they know.) Anyway, from this thread I've got the names of a few places to start looking. And that's really what I was hoping for. Thanks for the tips. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe signature.asc Description: Message signed with OpenPGP using GPGMail ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Deriving laws by systematic transformations
Studying Wadler's Comprehending Monads and Theorems for free!, I've been unable to derive law (iv) and I'm not sure about (iii). Will appreciate a pointer to similar examples or a massive hint. Here's my attempt at (iii): map f . unit x = map f [x] = [f x] = unit (f x) = (unit . f) x map f . unit = unit .f From the Monads article: unit :: x - M x join :: M (M x) - M x For example, unit 3 = [3] and join [[1,2], [3]] = [1,2,3] (iii) map f . unit = unit . f (iv) map f . join = join . map (map f) Laws (iii) and (iv) may be derived by systematic transformations of the polymorphic types of unit and join. ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Project Euler: request for comments
Very interesting. But for my taste I would do a cosmetic change. I tend to find it more readable when function calls are written vertically when they have with a great number of parameters or a lot of parens like here. listof4tuples xs = zip4 xs (tail xs) (tail (tail xs)) (tail (tail (tail xs))) On Tue, Aug 30, 2011 at 1:41 PM, KC kc1...@gmail.com wrote: You might like this zipping folding version. Explicit recursion has the disadvantage that one has to read the entire function in order to figure out what's going on; whereas using the higher order functions makes things much easier to grasp. listof4tuples xs = (zip4 xs (tail xs) (tail (tail xs)) (tail (tail (tail xs prods xs = map prods4 (listof4tuples xs) prods4 (t,u,v,w) = t*u*v*w maxprods4 xs = maximum $ prods xs On Mon, Aug 29, 2011 at 9:40 AM, Oscar Picasso oscarpica...@gmail.com wrote: Got it. f :: [Int] - Int f (t:u:v:xs) = helper t u v xs helper :: Int - Int - Int - [Int] - Int helper t u v (w:ws) | ws == [] = t*u*v*w | otherwise = max (t*u*v*w) (f (u:v:w:ws)) I tend to overlook mutual recursion in my toolbox. Thanks for the nnlightenment. On Sun, Aug 28, 2011 at 4:54 PM, KC kc1...@gmail.com wrote: Try something like the following: -- Project Euler 11 -- In the 20×20 grid below, four numbers along a diagonal line have been marked in red. -- snip -- The product of these numbers is 26 × 63 × 78 × 14 = 1788696. -- What is the greatest product of four adjacent numbers in any direction (up, down, left, right, or diagonally) in the 20×20 grid? import Data.List -- Doing the one dimensional case. f011 :: [Int] - Int f011 (t:u:v:xs) = f011helper t u v xs f011helper :: Int - Int - Int - [Int] - Int f011helper t u v (w:ws) | ws == [] = t*u*v*w | otherwise = yada nada mada -- What are yada nada mada? -- The 20x20 grid case will become: f0112D :: [[Int]] - Int -- where [[Int]] is a list of lists of rows, columns, major diagonals, minor diagonals. On Sun, Aug 28, 2011 at 5:10 AM, Oscar Picasso oscarpica...@gmail.com wrote: No. The answer I posted is not good. It worked, by chance, on a couple of small examples I tried but it could end up comparing sequence of 4 numbers that where not initially adjacent. On Sun, Aug 28, 2011 at 12:32 AM, Oscar Picasso oscarpica...@gmail.com wrote: Maybe this? f x@(a:b:c:d:[]) = x f (a:b:c:d:e:ys) = if e = a then f (b:c:d:e:ys) else f (a:b:c:d:ys) On Sat, Aug 27, 2011 at 8:26 PM, KC kc1...@gmail.com wrote: Think of the simplest version of the problem that isn't totally trivial. e.g. A one dimensional list of numbers. What would you do? Note: you only want to touch each element once. The 2 dimensional case could be handled by putting into lists: rows, columns, major diagonals, and minor diagonals. This isn't the fastest way of doing the problem but it has the advantage of avoiding indexitis. On Fri, Aug 26, 2011 at 6:15 PM, Oscar Picasso oscarpica...@gmail.com wrote: Like: 20*19*21*18 is bigger than 100*100*3*2 ? If so I need to think about how to formalize it. Thanks for the hint. On Fri, Aug 26, 2011 at 8:55 PM, KC kc1...@gmail.com wrote: Is Problem 11 the 4 consecutive #'s problem? If so what must be true for 4 #'s to have a large product? Hint: x * y * z * 2 is that going to be larger? -- -- Regards, KC -- -- Regards, KC -- -- Regards, KC -- -- Regards, KC ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Project Euler: request for comments
In that case, maybe we could just get rid of the helper function and just write: g (t:u:v:w:[]) = t*u*v*w g (t:u:v:w:ws) = max (t*u*v*w) (g (u:v:w:ws)) By the way, what make you think that mutual recursion would use more stack space than single recursion? Oscar On Tue, Aug 30, 2011 at 7:19 PM, KC kc1...@gmail.com wrote: You also don't need mutual recursion for this explicit recursion since I imagine it would use up more stack space. -- Doing the one dimensional case. f011 :: [Int] - Int f011 (t:u:v:xs) = f011helper t u v xs f011helper :: Int - Int - Int - [Int] - Int f011helper t u v (w:ws) | ws == [] = t*u*v*w | otherwise = max (t*u*v*w) (f011helper u v w ws) -- Note: f011helper does not call f011. On Mon, Aug 29, 2011 at 9:40 AM, Oscar Picasso oscarpica...@gmail.com wrote: Got it. f :: [Int] - Int f (t:u:v:xs) = helper t u v xs helper :: Int - Int - Int - [Int] - Int helper t u v (w:ws) | ws == [] = t*u*v*w | otherwise = max (t*u*v*w) (f (u:v:w:ws)) I tend to overlook mutual recursion in my toolbox. Good going! :) Thanks for the enlightenment. On Sun, Aug 28, 2011 at 4:54 PM, KC kc1...@gmail.com wrote: Try something like the following: -- Project Euler 11 -- In the 20×20 grid below, four numbers along a diagonal line have been marked in red. -- snip -- The product of these numbers is 26 × 63 × 78 × 14 = 1788696. -- What is the greatest product of four adjacent numbers in any direction (up, down, left, right, or diagonally) in the 20×20 grid? import Data.List -- Doing the one dimensional case. f011 :: [Int] - Int f011 (t:u:v:xs) = f011helper t u v xs f011helper :: Int - Int - Int - [Int] - Int f011helper t u v (w:ws) | ws == [] = t*u*v*w | otherwise = yada nada mada -- What are yada nada mada? -- The 20x20 grid case will become: f0112D :: [[Int]] - Int -- where [[Int]] is a list of lists of rows, columns, major diagonals, minor diagonals. -- -- Regards, KC ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Data structure
Hi guys, I want to compare data structure between Haskell, Java, Lisp and C. I am wondering if I could compare list comprehention in haskell with the vector class in Java, macros in common lisp and dynamic arrays in C. Thanks, Julita ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
[Haskell-cafe] Haskell Weekly News: Issue 197
Welcome to issue 197 the HWN, a newsletter covering developments in the Haskell community. This release covers the week of August 21 to 27, 2011. [1] http://goo.gl/8hDku Announcements Liyang HU announced HakkaTaikai, a Haskell hackathon in Tokyo, on Sunday September 25th, 2011. [2] http://goo.gl/tJ4F4 Qiuchi Jian wondered if anyone would be interested in joining him in translating the 2010 Haskell Report into Chinese. [3] http://goo.gl/QDdeF Johan Tibell announced the results of this year's State of Haskell survey. [4] http://goo.gl/26Evg New and Updated Projects * network-address (New - Sebastian Nowicki) Provides data structures for IP addresses as well as subnetworks. [5] http://goo.gl/LTuUK * shelltestrunner (Update - Simon Michael) Tests command-line programs or arbitrary shell commands. [6] http://goo.gl/uKHMo * netwire (Update - Ertugrul Soeylemez) An arrowized functional reactive programming library written with networking applications in mind. [7] http://goo.gl/yM0hy * instinct (New - Ertugrul Soeylemez) Library for neural networks. [8] http://goo.gl/yM0hy Quotes of the Week * elliott: i'm here to prove theorems and compile code and I'm all out of code * shachaf: To deepSeq is a fundamental right * djahandarie: I wonder if De Bruijn was any good at remembering names. * JaffaCake: In the beginning there were 8 registers, and That Was Enough For Everyone. * frezik: The compiler accepted it, why can't you? * Cale: the units of the monoids in the algebras for the monoid monad * _Ray_: fucking hell, math and cs need to stop having awesome interesting things. it's ruining my life. * accel: next time I'll read a few research papers before I start trolling hakell * ddarius: isJust :: Maybe a - Bool; isJust = unsafeCoerce Top Reddit Stories * Interested in a 2nd edition of Real World Haskell? Domain: self.haskell, Score: 130, Comments: 33 On Reddit: [9] http://goo.gl/fNS6P Original: [10] http://goo.gl/fNS6P * GHC on ARM: Merged into GHC HEAD Domain: ghcarm.wordpress.com, Score: 78, Comments: 7 On Reddit: [11] http://goo.gl/BvFvX Original: [12] http://goo.gl/ZKDYx * Why Haskell is Kinda Cool Domain: amtal.github.com, Score: 56, Comments: 27 On Reddit: [13] http://goo.gl/9ealD Original: [14] http://goo.gl/0AJIn * Haskell for Kids: Week 2! Domain: cdsmith.wordpress.com, Score: 55, Comments: 20 On Reddit: [15] http://goo.gl/0Qm5z Original: [16] http://goo.gl/DzdUy * Results from the State of Haskell, 2011 Survey Domain: blog.johantibell.com, Score: 54, Comments: 18 On Reddit: [17] http://goo.gl/BAQye Original: [18] http://goo.gl/l6sc1 * PyPy: We need Software Transactional Memory Domain: morepypy.blogspot.com, Score: 49, Comments: 2 On Reddit: [19] http://goo.gl/6dPjT Original: [20] http://goo.gl/kNCma * mmmodularity! - A modular package language for Haskell Domain: skilpat.tumblr.com, Score: 48, Comments: 8 On Reddit: [21] http://goo.gl/6dfSf Original: [22] http://goo.gl/os9IJ * A Tutorial Introduction to the Lambda Calculus Domain: utdallas.edu, Score: 34, Comments: 9 On Reddit: [23] http://goo.gl/OtPrs Original: [24] http://goo.gl/zTIx4 * Functional representation of Rubik's cube Domain: pnyf.inf.elte.hu, Score: 30, Comments: 3 On Reddit: [25] http://goo.gl/TMOnc Original: [26] http://goo.gl/EoYbu * monad-control, for more flexible transformers Domain: yesodweb.com, Score: 27, Comments: 14 On Reddit: [27] http://goo.gl/XF6GZ Original: [28] http://goo.gl/ijd6V * A different haskell emacs mode (work in progress) Domain: chrisdone.com, Score: 26, Comments: 5 On Reddit: [29] http://goo.gl/lfmxF Original: [30] http://goo.gl/7qvho Top StackOverflow Questions * Haskell: How does non-strict and lazy differ? votes: 25, answers: 5 Read on SO: [31] http://goo.gl/2KJVY * forall in Scala votes: 18, answers: 5 Read on SO: [32] http://goo.gl/ejOwF * What is the name of this monad-like functional programming pattern? votes: 16, answers: 1 Read on SO: [33] http://goo.gl/Rv1BC * Is (reverse . f . reverse) efficient? votes: 11, answers: 4 Read on SO: [34] http://goo.gl/U7qLu * Haskell Space Overflow votes: 8, answers: 4 Read on SO: [35] http://goo.gl/5uBY2 * How to write recursive lambda expression in Haskell? votes: 8, answers: 2 Read on SO: [36] http://goo.gl/TokK2 * Is the random number generator in Haskell thread-safe? votes: 8, answers: 4 Read on SO: [37] http://goo.gl/ERVpl * How can I create a tuple where each of the members are compared by an expression? votes: 7, answers: 5 Read on SO: [38] http://goo.gl/BiUpC * Haskell cartesian
[Haskell-cafe] Is it a bug in haskell-src-meta package?
Hi, all parseExp (,) 3 4 = Right (AppE (AppE (ConE GHC.Unit.(,)) (LitE (IntegerL 3))) (LitE (IntegerL 4))) where's GHC.Unit.(,) ? Many thanks best, bob ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is it a bug in haskell-src-meta package?
On 1 September 2011 11:19, bob zhang bobzhang1...@gmail.com wrote: Hi, all parseExp (,) 3 4 = Right (AppE (AppE (ConE GHC.Unit.(,)) (LitE (IntegerL 3))) (LitE (IntegerL 4))) where's GHC.Unit.(,) ? GHC.Unit (like all GHC.* modules) is an internal module used by GHC to implement base, containers, etc. The actual definitions of tuples in the Prelude come from Data.Unit, which for GHC are just re-exported from GHC.Unit: http://haskell.org/ghc/docs/latest/html/libraries/base/src/Data-Tuple.html -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is it a bug in haskell-src-meta package?
于 11-8-31 下午10:01, Ivan Lazar Miljenovic 写道: On 1 September 2011 11:19, bob zhangbobzhang1...@gmail.com wrote: Hi, all parseExp (,) 3 4 = Right (AppE (AppE (ConE GHC.Unit.(,)) (LitE (IntegerL 3))) (LitE (IntegerL 4))) where's GHC.Unit.(,) ? GHC.Unit (like all GHC.* modules) is an internal module used by GHC to implement base, containers, etc. The actual definitions of tuples in the Prelude come from Data.Unit, which for GHC are just re-exported from GHC.Unit: http://haskell.org/ghc/docs/latest/html/libraries/base/src/Data-Tuple.html Thanks for your quick-reply. I tried this does not work.(simplified) in quasiquoter. import Control.Arrow import Control.Applicative import Prelude hiding ((.), id) import Control.Monad import Control.Category import Data.Derive.All import Data.DeriveTH import Test.QuickCheck import Language.Haskell.TH.Quote import Language.Haskell.TH.Syntax import Language.Haskell.TH.Lib import Language.Haskell.Meta hs = QuasiQuoter { quoteExp = either fail return . parseExp } top-level--- [hs| (,) 3 4 |] will not compile do you know how to fix it ? Thank you ! Best, bob ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is it a bug in haskell-src-meta package?
于 11-8-31 下午10:01, Ivan Lazar Miljenovic 写道: On 1 September 2011 11:19, bob zhangbobzhang1...@gmail.com wrote: Hi, all parseExp (,) 3 4 = Right (AppE (AppE (ConE GHC.Unit.(,)) (LitE (IntegerL 3))) (LitE (IntegerL 4))) where's GHC.Unit.(,) ? GHC.Unit (like all GHC.* modules) is an internal module used by GHC to implement base, containers, etc. The actual definitions of tuples in the Prelude come from Data.Unit, which for GHC are just re-exported from GHC.Unit: http://haskell.org/ghc/docs/latest/html/libraries/base/src/Data-Tuple.html Hi, I tried ghc-pkg find-module GHC.Unit -- ghc-prim-0.2.0 :browse GHC.Unit data () = () could not find the function (,) exposed, thanks ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is it a bug in haskell-src-meta package?
On 1 September 2011 12:29, bob zhang bobzhang1...@gmail.com wrote: 于 11-8-31 下午10:01, Ivan Lazar Miljenovic 写道: On 1 September 2011 11:19, bob zhangbobzhang1...@gmail.com wrote: Hi, all parseExp (,) 3 4 = Right (AppE (AppE (ConE GHC.Unit.(,)) (LitE (IntegerL 3))) (LitE (IntegerL 4))) where's GHC.Unit.(,) ? GHC.Unit (like all GHC.* modules) is an internal module used by GHC to implement base, containers, etc. The actual definitions of tuples in the Prelude come from Data.Unit, which for GHC are just re-exported from GHC.Unit: http://haskell.org/ghc/docs/latest/html/libraries/base/src/Data-Tuple.html Hi, I tried ghc-pkg find-module GHC.Unit -- ghc-prim-0.2.0 :browse GHC.Unit data () = () could not find the function (,) exposed, thanks Reading the source of Data.Tuple more, it seems that I misunderstood what was going on. GHC.Tuple [1] defines the tuples; GHC.Unit [2] just defines () [1]: http://haskell.org/ghc/docs/latest/html/libraries/ghc-prim-0.2.0.0/GHC-Tuple.html [2]: http://haskell.org/ghc/docs/latest/html/libraries/ghc-prim-0.2.0.0/GHC-Unit.html As such, this may very well be a bug somewhere, either haskell-src-meta, template-haskell, or elsewhere. May I ask though why you're trying to use (,) as an explicit constructor in a quasi-quotation? -- Ivan Lazar Miljenovic ivan.miljeno...@gmail.com IvanMiljenovic.wordpress.com ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe
Re: [Haskell-cafe] Is it a bug in haskell-src-meta package?
于 11-8-31 下午10:35, Ivan Lazar Miljenovic 写道: May I ask though why you're trying to use (,) as an explicit constructor in a quasi-quotation? Thanks for your reply. I just generated some code this way, and it does not work. this style is common in applicative functor, right? Best, bob ___ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe