{"id":30,"date":"2007-07-29T23:24:48","date_gmt":"2007-07-30T06:24:48","guid":{"rendered":"http:\/\/www.elbeno.com\/haskell_soe_blog\/?p=30"},"modified":"2008-01-07T22:09:25","modified_gmt":"2008-01-08T06:09:25","slug":"exercise-81","status":"publish","type":"post","link":"https:\/\/www.elbeno.com\/haskell_soe_blog\/?p=30","title":{"rendered":"Exercise 8.1"},"content":{"rendered":"<pre lang=\"haskell\">oneCircle = Shape (Ellipse 1 1)\r\nmanyCircles' = [Translate (x,y) oneCircle | x <- centers, y <- centers]\r\n    where centers = [0, 2 ..] ++ [-2, -4 ..]\r\nmanyCirclesRegion = foldl Union Empty manyCircles'\r\nrectRegion = Translate (4,0) (Shape (Rectangle 10 2))\r\nfiveCircles' = rectRegion `Intersect` manyCirclesRegion<\/pre>\n<p>This is technically correct, but the problem here lies with the inability to lazy evaluate <tt>Intersect<\/tt> in a matter similar to <tt>take<\/tt>. I'm not sure this could easily be made to work: we would need to define <tt>Intersect<\/tt> differently and probably also impose an ordering constraint on <tt>Region<\/tt> composition. Even then, I think we still have an ordering problem with the positive-and-negative-infinite list evaluation, whereby a bounded <tt>Region<\/tt> and an infinite <tt>Region<\/tt> (e.g. a semi-infinite halfplane) would be incompatible (although I could be wrong about this depending on how Haskell's lazy evaluation works exactly).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>oneCircle = Shape (Ellipse 1 1) manyCircles&#8217; = [Translate (x,y) oneCircle | x<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=\/wp\/v2\/posts\/30"}],"collection":[{"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=30"}],"version-history":[{"count":0,"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=\/wp\/v2\/posts\/30\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=30"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=30"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.elbeno.com\/haskell_soe_blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=30"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}