text:
Ohio Politics
Former Rep. Betty Sutton will not run for governor
Former U.S. Rep. Betty Sutton, shown above at a Plain Dealer editorial board meeting in 2012, announced Friday that she will not run for governor in 2014.
By Henry J. Gomez, cleveland.com
CLEVELAND, Ohio -- Former U.S. Rep. Betty Sutton will not run for governor next year -- a decision that for now clears the Democratic field for Cuyahoga County Executive
Ed FitzGerald
"I will always be honored by the support and encouragement I have been given," Sutton said Friday morning in a brief emailed announcement, "but after thoughtful consideration, I have decided that I will not run for governor in 2014."
Sutton, of Copley Township, is the latest high-profile Democrat to pass on the chance to challenge Republican Gov. John Kasich. Already on the sidelines were
former Gov. Ted Strickland
U.S. Rep. Tim Ryan
of the Youngstown area.
Chris Redfern, chairman of the Ohio Democratic Party, said he knows of no other Democrat interested in the job. And while Redfern prefers an uncontested primary, he said Friday that he had no role in advising Ryan or Sutton to skip the race. He acknowledged that the open field is an advantage for FitzGerald as the party continues to hammer Kasich.
"The fact of the matter is that Ed FitzGerald is well positioned going into the spring and summer, and the party is going to continue to help on his behalf," said Redfern, who has offered assistance to all prospects for statewide office.
Democratic leaders hope that list of prospects might still include Sutton, who lost her seat in Congress last November after redistricting drew her into battle against Republican Rep. Jim Renacci. The union-friendly background and Capitol Hill experience that earned her gubernatorial buzz also would make her a strong contender for
a down-ballot race
But a Sutton adviser told The Plain Dealer that the former congresswoman has no intention of seeking another state office in 2014. Sutton did not say why she decided not to run for governor and is not yet backing anyone else for the job.
FitzGerald, the former mayor of Lakewood, filed paperwork last week that allows him to raise money and ratchet up a run against Kasich. He has stopped short of formally declaring his candidacy, labeling his early efforts as exploratory. If he goes through with the run for governor, he will not be able to seek a second term as county executive next year.
Though recent polls have shown Ryan, Strickland and Sutton with higher name-recognition among Ohio voters, FitzGerald's base in the state's largest media market and Democratic stronghold makes him an attractive candidate. His challenge will be inspiring enthusiasm among donors and activists, many of whom don't understand what a county executive does. Only one other county government in the state, Summit, operates under the watch of an elected executive.
A survey last month by Quinnipiac University put Kasich's job-approval rating at
an all-time-high of 53 percent
. The governor led FitzGerald among registered voters, 45 percent to 35 percent. But Strickland had an even bigger lead on Kasich in a Quinnipiac poll about the same time four years ago -- a 30 point cushion that became a 2 point loss.
Barring a change of heart by Ryan, Strickland or Sutton, there are few other A-list Democrats who could emerge as a threat to FitzGerald. Columbus Mayor Michael Coleman also has said he's not interested in the governor's seat.
One remaining possibility, at least in theory, is former Ohio Attorney General Richard Cordray. But Cordray is up for another term as head of the U.S. Consumer Financial Protection Bureau in Washington -- a job that keeps a lid on his political ambition. Some speculate that if Senate Republicans block Cordray's reappointment, he will return home to run.
Cordray has declined to discuss such scenarios.
FitzGerald, in an email sent by his campaign Friday, did not cast himself as the inevitable nominee.
"Betty has been a tremendous public servant for Ohio, and I'm sure she will continue to be in the future," said FitzGerald. "There is no doubt she will be a great asset to whoever the Democratic nominee for governor is."
Kasich's allies at the Ohio Republican Party have been preparing for Kasich vs. FitzGerald for months. They hope to tie FitzGerald to Democrats convicted during the federal government's investigation of county corruption. But the lead prosecutor in the case has taken the extraordinary step of emphasizing that FitzGerald is not a target of the investigation.
GOP spokesman Matt Henderson predicted 20 months of mudslinging from Democrats, saying Friday that FitzGerald will campaign "as negative as possible because he won't be able to make a case to Ohio voters for their support."


Hi, Art! How do I define what you are to me? Here's the list in short: Attractive Avant-Garde Craze Allrounder Name-Addict Fomo Individualistic Expressive Highbrow Antithetic … Now listen, for I have quite a few things to say, precisely: 11. And some questions will come up too. I hope you are ready for this.
What will the gallery of the future look like? I was in Berlin visiting the gallery EIGEN + ART to ask this and other questions. Awaiting you are various perspectives from two generations with Gerd Harry "Judy" Lybke, founder and owner of the gallery and the pioneering figure behind the Leipzig School, as well as Marie Gerbaulet, director of the LAB.
This is my selection of the most post-internet-artsy (I don't care if you call the term outdated unless you give me a better word ;), instagrammable artworks out there. Meaning lots of transparent textures, shiny surfaces and colorful appearances. My goal is pure overload. Artificial? Maybe. But enjoyable, for sure.
The distinctiveness of the Rhineland – now and in the future.
From the importance of regions, the zeitgeist in the Rhineland, to a new range of collectors and the question as to how, where and with whom galleries should be communicating today – all that in my extensive interview with the gallery owner and spokesman of the Cologne Galleries and co-organizer of the DC Open: Thomas Rehbein in Cologne.
Greenery everywhere, long paths, a garden in winter. Leif Trenkler is one of the pioneers of New Figuration in Germany, attended the Städel Academy as well as the Düsseldorf Art Academy and cultivates an attentiveness to his surroundings. As we talk together, Trenkler repeatedly plays pleasant pieces by Satie, Debussy or J.S. Bach's music for the lute.
A well-balanced presentation of established artists in an easygoing-upscale location, the unique focus on Eastern European galleries, Vienna as a surprisingly relevant location and top-notch artworks ranging from fresh discoveries to international big names ... in short: viennacontemporary 2017!
Disaster, responsibility & bravery wrapped in phenomenal colors.
Who creates what you admire?
How do artists today create?
Eva's Blog about creative people, shaping the cultural landscape around you.
Curators, Artists, Gallery Owners, Audience, Friends. Stories that might be unheard of. Because Contemporary Art is beautiful & versatile. Read more about this Blog here.


text:
layout: page
title: "ALBUMS"
description: "archive"
active: gallery
header-img: "img/gallery-bg.jpg"
images:
 - image_path: /gallery/albums/alb01.jpg
   gallery-folder: /gallery/gallery01/
   gallery-name: gallery1
   gallery-date: July 2015
 - image_path: /gallery/albums/alb02.jpg
   gallery-folder: /gallery/gallery02/
   gallery-name: gallery2
   gallery-date: June 2015
 - image_path: /gallery/albums/alb03.jpg
   gallery-folder: /gallery/gallery03/
   gallery-name: gallery3
   gallery-date: May 2015
 - image_path: /gallery/albums/alb04.jpg
   gallery-folder: /gallery/gallery04/
   gallery-name: gallery4
   gallery-date: April 2015
 - image_path: /gallery/albums/alb05.jpg
   gallery-folder: /gallery/gallery05/
   gallery-name: gallery5
   gallery-date: March 2015
 - image_path: /gallery/albums/alb06.jpg
   gallery-folder: /gallery/gallery06/
   gallery-name: gallery6
   gallery-date: February 2015
 - image_path: /gallery/albums/alb07.jpg
   gallery-folder: /gallery/gallery07/
   gallery-name: gallery7
   gallery-date: January 2015
 - image_path: /gallery/albums/alb08.jpg
   gallery-folder: /gallery/gallery08/
   gallery-name: gallery8
   gallery-date: December 2014
 - image_path: /gallery/albums/alb09.jpg
   gallery-folder: /gallery/gallery09/
   gallery-name: gallery9
   gallery-date: November 2014
---

	<meta content="charset=utf-8">
    <link rel="stylesheet" href="{{ "/css/selena.css" | prepend: site.baseurl }}">

{{page.title}}

{% for image in page.images %}

{{image.gallery-name}}

{{image.gallery-date}}

{% endfor %}

Image Source: Unsplash

redpajama_set_name: RedPajamaGithub


Every successful company is only as good as its staff and Newearth Constructions boasts some of the most accomplished, skilled and tireless construction staff in the industry.
Our workforce currently sits at over 40 personnel with each member of our team skilled in multiple disciplines to allow them to support all of our operations.
Newearth Constructions' project delivery teams include civil engineers and site supervisors / foremen as well as experienced plant operators, pipe layers and concrete workers. In addition, we employ and support a number of apprentices and new entrants to the industry, largely from the immediate region.
Further, we ensure a large proportion of our field staff have qualifications in traffic management, first aid, "spotters" tickets for working near services and confined spaces entry.
With an average length of service across the company of over 8 years – a unique record in an industry where the workforce is generally mobile, Newearth Constructions policy of promoting from within ensures high standards of project delivery are maintained.
Our construction teams also retain a key focus on safety and environmental awareness and management and drive the company's safety culture from the field.
Please visit the Careers page on our website to view current opportunities for employment with Newearth Constructions.


Trends show it is a clear victory for the BJP.
Even as the BJP is in a neck and neck battle with the Congress in Gujarat, things look much smoother for them in the Himachal Pradesh Assembly polls, where trends show that the party is sent to win.
Party workers in the state are already in the celebratory mood as Election Commission results show that the BJP has won in 1 seat while leading in 105 seats, the Congress is trailing far behind leading in only 70 seats at the moment.
However, BJP chief ministerial candidate Prem Kumar Dhumal is trailing in Sujanpur. Incumbent Chief Minister Virbhadra Singh and his son Vikramaditya are leading in their seats in Arki and Shimla Rural.
Vikramaditya Singh had earlier in the day said Congress will win, but it looks highly unlikely.
According to EC data, the incumbent CM is leading by over 4000 votes against BJP's Rattan Singh Pal. In Shimla Rural, his son is leading is also leading with over 4000 votes against BJP candidate Dr Pramod Sharma.
It's a close fight between Dhumal, who at the moment has a little over 10,000 votes, and Congress candidate Rajinder Rana who has over 12,000 votes.
The Indian Express had reported during the run up to the polls in the state that the Parivartan campaign started by Prime Minister Narendra Modi and BJP chief Amit Shah had seen success, indicating winds of change in the state.
During the last elections in 2012, Dhumal had lost against Singh with the BJP winning only 26 seats against 36 seats won by the Congress.
But feverish campaigning by the Modi-Shah duo seems to have done the magic that it did in Uttarkhand and in Uttar Pradesh.


text:
The Perils of Journalism and Child Porn
by Debbie Nathan
Bernie Ward, a San Francisco-based liberal talk show host, was indicted late last week on federal child pornography charges. His is the second such indictment brought against a media figure who then claimed he had the porn merely to do research and reporting. Meanwhile, a third journalist, a former New York Times reporter who engaged in similar behavior, has not been indicted. The inconsistency suggests that the government chooses whom to go after and whom to leave alone. And it makes clear that the media needs a First Amendment exemption or license allowing reporters to examine child pornography legally.
Before his indictment on December 6, Ward – who is 56 and married with four children—had two programs on San Francisco's KGO-AM radio. One was a nightly political and news talk show; the other aired weekly and dealt with religion. In the 1980s Ward was an award-winning general assignment and political reporter at KGO. He is also known for conducting major fundraising drives for Bay Area non-profits that help the homeless and others in need. From 1982 to 1985 he worked for then-Rep. Barbara Boxer as her chief legislative assistant. On KGO and on national talk shows, he strenuously opposed the war in Iraq and other Bush Adminstration policies. KGO billed him as "The Lion of the Left". Following his indictment, he has been put on leave from the station.
Ward's lawyer, Doron Weinberg, told the San Francisco Chronicle that Ward accessed and distributed only a small amount of child pornography three years ago, for research he was doing to write a book about hypocrisy in America. The Chronicle quoted sources familiar with the case saying that "authorities noted that Ward was monitored as he went on a chat room and sent and received images."
Indictment papers released on Friday support Ward's claim that the government was involved in the case as early as 2004 but waited years to indict.
Ward's case is strikingly similar to that of Larry Mathews, a media figure who faced child porn charges in the late 1990s. Mathews was a Washington DC-area radio reporter in his late 50s. He had won press awards and was known for covering social issues, including the problem of internet child porn. When arrested, he said he had acquired illegal material because he was impersonating a pedophile in order to do another story.
The government countered that Mathews had no notes or story assignment from a media outlet. The ACLU, National Public Radio, and other press and First Amendment organizations spoke out for him and filed supporting legal briefs. But an appellate court later ruled that journalists have no right to acquire or distribute child pornography while doing research. Mathews was convicted and served several months in a halfway house.
If convicted, San Francisco's Ward faces a maximum 15 years for each of three criminal counts.
"The government knows that Bernie was doing this for an investigation he was doing for a book," the Chronicle quoted attorney Weinberg saying. "But the government believes he violated the letter of the law, and they have gone ahead and prosecuted him….The fact that these events happened three years ago – and they are just being prosecuted – shows the fact that nobody believes that he is a child predator." The Examiner seemingly attempted to explain how Ward could have avoided prosecution by citing a federal law—which the paper mistakenly said "forgives" possession of three child pornography images if they are destroyed and promptly reported to authorities. In fact, that statute, which is part of U.S. Code 2252, allows only two images. And some legal scholars interpret 2252 as "forgiving" someone only if he or she came to possess child porn by accident rather than intentionally. A reporter deliberately researching child pornography would thus hardly qualify for "forgiveness" under 2252. In addition, the law is merely an "affirmative defense." To exercise it, one would have to first be indicted. There is no case law indicating that any journalist has ever used 2252 to justify their work after being charged with possession or distribution of child porn.
However, the statute was cited in August 2006 by the New York Times. Kurt Eichenwald, then a Times reporter, said he accidentally accessed a few illegal images while doing month's-long reporting on Internet child pornography. In a sidebar to one of Eichenwald's articles, the Times said that a law – presumably 2252– excused the reporter's encounter with the illegal material. But Eichenwald's published work implied he had accessed far more than two images.
Further, Eichenwald in 2005 obtained and used administrative sign-on privileges to explore a commercial porn website containing images of a 14-year-old boy masturbating. Eichenwald went on to write a major Times story based on reporting he did about this site and the people who ran it.
Eichenwald took the young man who ran the site to federal authorities, where he turned state's evidence against his business partners in exchange for prosecutorial immunity. As a result, four people were arrested and convicted. Eichenwald's work also led to Congressional hearings – at which he testified – where witnesses made unsubstantiated claims about the prevalence of Internet child predators and pornography. Those hearings were a run-up to passage of the 2006 Adam Walsh Act. It requires states to put children and very low-level offenders, such as public urinators and people caught with small amounts of child porn, on sexual offender registries for years – a policy that has since been condemned by Human Rights Watch. Since 9/11, the government has used unsubstantiated claims about the extent of child pornography to defend sections of the Patriot Act which intrude on internet privacy.
Eichenwald claimed he became involved with child pornography to find out about the problem. In some instances, he did not tell Times editors what he was doing. Later expose of his activities provoked intense controversy in the media world, and currently he is not working as a journalist. However, he has not been criminally prosecuted.
[ DEBBIE NATHAN has covered the Eichenwald case extensively for CounterPunch. See:
nathan04122007.html and
nathan09142007.html AC / JSC ]
If KGO's Ward is being truthful about why he was involved with child porn, the government is treating him differently than it has former Timesman Eichenwald. Is that because the feds don't consider Ward such a good friend as they do Eichenwald? Does the DOJ deliberately go after certain types of media people and leave others alone? It's too early to tell, since only three such individuals have been publicly implicated as involved with child porn. Meanwhile, the media has no way to cover the topic. To accurately describe the extent of the problem, to compare government claims with reality requires work that invites prosecution.
Journalists need some kind of system or First Amendment permit to allow them to do their reporting. Otherwise, the public will remain ignorant about what's really going on with child pornography. And media people trying to find out will risk indictment, or worse.
DEBBIE NATHAN is a New York City-based journalist who writes about sexual politics and immigration. She can be reached at naess2@gmail.com
More articles by:Debbie Nathan

redpajama_set_name: RedPajamaCommonCrawl


Welcome home! This is a better than new updated traditional 2-story home. Gorgeous laminate flooring throughout the first floor, giving an open & spacious feel, perfect for your family & friends. 3 very nice size bedrooms, along with 2 �� baths, with the master bath offering a whirlpool tub & shower. The partially finished lower level will make a great area to entertain year round.


text:
KIMELMAN: Trump's focus on higher education is promising
President Trump has made a push to bring higher education policy to the forefront of the 2020 Presidential Election
By Adam Kimelman | 04/21/2019
The President's proposals regarding higher education free speech are not only promising by themselves but show the power that students have going into the 2020 elections.
Courtesy Wikimedia Commons
In both the 2016 general election and in the first two years of the Trump Administration, higher education policy regarding important issues such as upholding free speech and reducing student debt have largely taken a back seat to more controversial topics, such as immigration or healthcare. Following the 2018 midterm elections, the president is now bringing higher education to the main stage through public speeches, executive orders and recently proposed legislation.
One of these actions is Trump's recent executive order which makes federal funding to public colleges and universities contingent on them maintaining free speech standards. These actions come at a time where free speech is under attack on colleges and universities across the United States, particularly for conservative students. The free-speech group FIRE estimates that 9 in 10 colleges restrict students' First Amendment rights. These attempts to restrict free speech include many examples – from Liberty University attempting to silence their campus newspaper to Dixie State University not allowing a student group to criticize Presidents Bush and Obama and confining them to a "free speech zone."
These administrative limits on free speech have, in part, contributed to an environment that is openly hostile to any semblance of conservative thought on college campuses. While the left used to celebrate free speech as a necessary and vibrant part of college campuses during times such as the Vietnam War, they have abandoned these principles in recent years. From "speech codes" to "free speech zones," the left — with the ACLU being a notable exception — has contributed to shutting down freedom of thought on college campuses. These regulations proposed by some colleges have led to what Harvard Professor Jill Lepore calls "an unwillingness to engage with conservative thought, an aversion to debate, and a weakened commitment to free speech."
Examples of the extreme polarization caused by the attack on free speech can be seen in the case of conservative activist Hayden Williams, who was physically assaulted at the University of California, Berkeley for expressing his beliefs. Trump chose to highlight this violent attack on free speech at the annual Conservative Political Action Conference, where he not only made the issue of free speech one of his top concerns but also invited Hayden to join him on stage and say a few words.
Our University has taken some recent actions that are worrisome in regards to limiting free speech on Grounds, such as forcing unaffiliated groups to register before exercising speech on Grounds and relegating them to specified locations. Make no mistake, this policy attempts to control the speech of those unaffiliated with the University while on Grounds, therefore limiting their First Amendment rights at a public university that their tax dollars help fund. Such restrictions could be placed on students and CIOs next. But even with these recent changes, the University thankfully has a mostly positive record on protecting free speech. This was demonstrated by their actions to help the Batten School host former Congressman Tom Garrett's town hall in 2017, despite controversy and threats of violence. The University currently receives a green-light rating from FIRE, the highest free speech rating the organization gives. With President Trump's executive order and a renewed focus on protecting free speech, hopefully, First Amendment rights will continue to be protected at the University, as well as college campuses across the nation.
In addition to his executive order on free speech, Trump has been pushing for legislation to give the Higher Education Act its first major update since 2008. While some of the new proposals are more controversial and need to be debated and resolved — such as capping the total amount students can borrow or eliminating the Public Loan Forgiveness Program — many of them are common-sense ideas that already have some support in Congress. These proposals include allowing low-income students to use Pell Grants for short-term academic programs, expanding federal aid to prisoners who are eligible for release and streamlining loan repayment. Implementation of these proposals would expand opportunity and give more choices to those who need help the most, which is something any higher education proposal must strive to do. The president and Congress should work to pass these bipartisan reforms as well as debate and resolve the more controversial aspects of the Higher Education Act proposal.
The President's proposals regarding higher education free speech are not only promising by themselves but also shows the power that students have going into the 2020 elections. With increasing student turnout during the 2018 election, Trump is clearly attempting to make gains among college students across the country, at a time when many 2020 Democratic hopefuls are attempting to do the same. The President's renewed focus on higher education is a direct example of the power of how student voting in elections and activism on Grounds can impact the national conversation for the better.
Adam Kimelman is a Viewpoint Columnist for The Cavalier Daily. He can be reached at opinion@cavalierdaily.com.
By Katherine Viti | 07/12/2019
By Hunter Hess | 07/12/2019


When He Was Born, He Was Only Given Days To Live. He Recently Celebrated His Second Birthday.
When Jaxon Strong was born without a large part of his skull, his doctors warned his parents that he would likely only have a few days to live. Jaxon, however, just recently celebrated his second birthday.
Jaxon Strong was born with microhydranencephaly, a rare brain condition that meant he was born without most of his skull and would inevitably grow up with developmental problems.
The cause of this condition isn't always possible to track, but doctors suspect it occurs after a particular gene gets mutated. Most children born with a form of anecephaly are either stillborn, or die not long after birth.
After Jaxon was born weighing only four pounds, and with this condition, his doctors only gave him a few days to live.
His mother, Brittany Buell, was "devastated," but refused to give up on her son. She created a Facebookpage for her son, as well as a GoFundMe page to raise money for Jaxon's medical bills. Many people – family, friends, and strangers – have all donated to the cause, helping the Strong family raise over $50,000.
With this monetary support and the care of world-class doctors, Jaxon has long out-lived his doctors' predictions.
On August 27, 2016, he celebrated his 2nd birthday with people from all across the globe.
Jaxon's parents shared photos and posts of their family celebration on their Facebook page – complete with shots of Jaxon swimming in the pool, as well as his pirate-themed birthday cake.
Instead of having any guests or international attendees send Jaxon gifts, the Buells asked everyone to send toiletries, canned food, and other household supplies that could be donated to the Buell's local women's shelter.
The Buells are hoping that Jaxon's supporters will continue to support the Jaxon Strong Foundation to help raise awareness and fundraise for neurological research, and that they (as well as everyone else) can celebrate many more years of life with Jaxon.


text:
{-# LANGUAGE DeriveDataTypeable, OverloadedStrings, FlexibleInstances, ScopedTypeVariables, MultiParamTypeClasses, FunctionalDependencies, TypeSynonymInstances #-}

{-|
   This module provides a simple way to use HOAS (higher order abstract syntax) to emit C++ code.

   This is an AST-free method!  It doesn't define a complete model for
   C++ code, just an easier way of emitting concretes syntax than
   using strings.

 -}

module Intel.Cnc.EasyEmit where

import Intel.Cnc.Spec.Util hiding (app, commasep)
import Intel.Cnc.Spec.AST

import Control.Monad
import qualified  Control.Monad.State.Strict as S

import Data.Data
import Data.List
import GHC.Exts -- For IsString

import StringTable.Atom
import Text.PrettyPrint.HughesPJ
import Text.PrettyPrint.HughesPJClass
import Test.HUnit

import qualified Prelude as P
import Prelude hiding ((&&), (||), (==), (/=), not, Eq
		       , Ord, (<), (<=), (>), (>=), max, min -- , compare
		      )

----------------------------------------------------------------------------------------------------
-- Monad plus HOAS for C++
----------------------------------------------------------------------------------------------------

-- | A monad for generating syntax:
--   The state consists of an accumulator for lines of syntax, plus a counter for temporary variables.
newtype EasyEmit a = EE (S.State EEState a)
type EEState = ([Doc],Int)

-- | Run a syntax-emitting computation and render it to a document.

runEasyEmit :: EasyEmit a -> (a,Doc)
runEasyEmit m = (a,b)
 where (a,_,b) = rawRunEasyEmit 0 m

-- This full version includes the counter:
rawRunEasyEmit :: Int -> EasyEmit a -> (a, Int, Doc)
rawRunEasyEmit start (EE m) = (a, cnt, vcat (reverse ls))
 where
  (a,(ls,cnt)) = S.runState m ([], start)

execEasyEmit :: EasyEmit a -> Doc
execEasyEmit = snd . runEasyEmit

evalEasyEmit :: EasyEmit a -> a
evalEasyEmit = fst . runEasyEmit

-- This runs a subcomputation only for value -- discards its emission side effects.
forValueOnly :: EasyEmit a -> EasyEmit a
forValueOnly (EE m) =
 do (ls,c) <- S.get
    let (val,(_,c2)) = S.runState m ([], c)
    S.put (ls,c2)
    return val

-- BOILERPLATE, because of newtype rather than type synonym for EasyEmit:
instance Monad EasyEmit where
  -- Whew, need to verify that this has no perfermance overhead:
  (EE ma) >>= fn = EE (ma >>= (\x -> case fn x of EE m -> m))
  return x       = EE (return x)
instance S.MonadState EEState EasyEmit where
  get   = EE S.get
  put x = EE (S.put x)

instance StringBuilder EasyEmit where
--instance StringBuilder (S.State ([Doc], Int)) where
  putS s = S.modify (\ (ls,cnt) -> (text s:ls, cnt) )
  runSB (EE m) =
      let (res, (ls,cnt)) = S.runState m ([],0)
      in (render$ vcat$ reverse ls, res)

instance ToAtom Syntax where
   toAtom d = toAtom$ deSyn d

--------------------------------------------------------------------------------
-- First, simple helpers / utilities:
--------------------------------------------------------------------------------

instance P.Eq Doc where
  -- Would be nice to memoize this!
  a == b  =  render a P.== render b

-- | The EasyEmit monad uses this Syntax type internally:
data Syntax = Syn Doc
  deriving (Show, P.Eq)

deSyn (Syn s) = s
synToStr = render . deSyn

fromInt = Syn . int

atomToSyn = Syn . text . fromAtom
strToSyn  = Syn . text

(Syn a) +++ (Syn b) = Syn (a <> b)

(Syn a) `dot`   (Syn b) = Syn (a <> text "." <> b)
(Syn a) `arrow` (Syn b) = Syn (a <> text "->" <> b)

dereference (Syn a) = Syn$ parens (text "*" <> a)
addressOf   (Syn a) = Syn$ parens (text "&" <> a)

-- Array subscript operator:
arrsub (Syn a) (Syn b) = Syn$ (a <> text "[" <> b <> text "]")

-- Adds implicit newline at the end:
addChunk :: Syntax -> EasyEmit ()
addChunk (Syn doc) =
  do (ls,c) <- S.get
     S.put (doc : ls, c)

-- A bit ugly, this adds the chunk to the end of the previous line.
addChunkPrevLine (Syn doc) =
  do (ls,c) <- S.get
     S.put $ case ls of
              []      -> (doc : ls, c)
	      (hd:tl) -> (hd <> doc : tl, c)

-- Adds the semi-colon at the end also:
addLine (Syn doc) = addChunk (Syn$ doc <> semi)

-- Also, overloading the string constants themselves is nice:
instance IsString Syntax where
    fromString s = Syn (text s)

-- instance IsString Doc where
--     fromString s = (text s)

-- Comma separate Docs either horizontally or vertically:
-- TEMP: MAKING THIS HCAT FOR NOW UNTIL I CAN FIGURE OUT SOME OF THE INDENTATION PROBELMS:
commasep ls = hcat$ intersperse (text", ") ls

-- (This version includes parens)
--pcommasep = parens . commasep
pcommasep ls = parens$ fcat$ intersperse (text", ") ls

--------------------------------------------------------------------------------
-- C++ Expressions
--------------------------------------------------------------------------------

(Syn a) ?  (Syn b) = Syn ("(" <> a <> " ? " <> b )
-- Hack, these must always be used together to get balanced parens:
(Syn a) .: (Syn b) = Syn ( a <> " : " <> b  <> ")")

-- The most important class of expressions are generated by overloaded
-- standard operators, as follows:

instance Num Syntax where
  (Syn a) + (Syn b) = Syn (parens $ a <> " + " <> b )
  (Syn a) * (Syn b) = Syn (parens $ a <> " * " <> b )
  (Syn a) - (Syn b) = Syn (parens $ a <> " - " <> b )
  abs    (Syn a) = Syn ("abs" <> parens a )
  negate (Syn a) = Syn (parens ("-" <> parens a))
  fromInteger n = Syn (text $ show n)
  -- Could implement this I suppose...
  signum _ = "__ERROR__"

instance Fractional Syntax where
  (Syn a) / (Syn b) = Syn (parens $ a <> " / " <> b )
  recip (Syn a) = Syn (parens $ "1 / " <> a )
  fromRational rat = Syn ( text$ show rat )

instance Boolean Syntax where
    (Syn a) && (Syn b) = Syn (parens $ a <> " && " <> b )
    (Syn a) || (Syn b) = Syn (parens $ a <> " || " <> b )
    not (Syn a) = Syn ("!" <> parens a )
    false = Syn "false"
    true  = Syn "true"

instance Ord Syntax Syntax where
    (Syn a) < (Syn b) = Syn (parens $ a <> " < " <> b )
    (Syn a) > (Syn b) = Syn (parens $ a <> " > " <> b )
    (Syn a) <= (Syn b) = Syn (parens $ a <> " <= " <> b )
    (Syn a) >= (Syn b) = Syn (parens $ a <> " >= " <> b )
    max (Syn a) (Syn b) = Syn ("max" <> pcommasep [a,b] )
    min (Syn a) (Syn b) = Syn ("min" <> pcommasep [a,b] )

--   conditional (Syn a) b c = Syn (parens $ a <> " ? " <> b <> ":" <> c )

instance Eq Syntax Syntax where
    (Syn a) == (Syn b) = Syn (parens $ a <> " == " <> b )

-- Use a C++ constant
constant :: String -> Syntax
constant = fromString

stringconst :: String -> Syntax
stringconst str = Syn$ dubquotes$ escapeString str

-- new :: Syntax -> [Syntax] -> Syntax
new :: Type -> [Syntax] -> Syntax
new ty args = Syn$ "new" <+> (deSyn$ function (Syn$ pPrint ty) args)

--------------------------------------------------------------------------------
-- Declaring variables
--------------------------------------------------------------------------------

-- With names:
var :: Type -> Syntax -> EasyEmit Syntax
var ty (Syn name) = do addLine (Syn (cppType ty <+> name ))
		       return (Syn name)

-- With initialization expression:
varinit :: Type -> Syntax -> Syntax -> EasyEmit Syntax
varinit ty (Syn name) (Syn rhs) =
   do addLine (Syn (cppType ty <+> name <+> "=" <+> rhs))
      return (Syn name)

-- A var declaration with a constructor invocation.
classvar :: Type -> Syntax -> [Syntax] -> EasyEmit Syntax
classvar ty (Syn name) args =
   do addLine (Syn (cppType ty <+> name <+> pcommasep (map deSyn args)))
      return (Syn name)

-- Without names:
----------------------------------------
gensym root =
   do (ls,cnt) <- S.get
      S.put (ls,cnt+1)
      return$ Syn$ root <> int cnt

tmpvar :: Type -> EasyEmit Syntax
tmpvar ty = do name <- gensym "tmp"
	       var ty name

tmpvarinit :: Type -> Syntax -> EasyEmit Syntax
tmpvarinit ty rhs =
   do name <- gensym "tmp"
      varinit ty name rhs

-- A var declaration with a constructor invocation.
tmpclassvar :: Type -> [Syntax] -> EasyEmit Syntax
tmpclassvar ty args =
   do name <- gensym "obj"
      classvar ty name args

------------------------------------------------------------
-- C++ Statements
------------------------------------------------------------

-- This is a function in the meta language that represents a function
-- in the object language.
type ObjFun = ([Syntax] -> Syntax)

-- Variable Assignment:
set :: Syntax -> Syntax -> EasyEmit ()
set (Syn x) (Syn v) = addLine$ Syn$ x <+> "=" <+> v

-- Assignment for array locations:
arrset :: Syntax -> Syntax -> Syntax -> EasyEmit ()
arrset arr i rhs = set (arr `arrsub` i) rhs

-- Assignment for a field R.x.
fieldset :: Syntax -> Syntax -> Syntax -> EasyEmit ()
fieldset arr x rhs = set (arr `dot` x) rhs

-- Function application (command context):
app :: ObjFun -> [Syntax] -> EasyEmit ()
app fn ls = addLine$ fn ls

-- A shorthand that looks C-ish:
(Syn x) += (Syn n) = addLine$ Syn$ x <+> "+=" <+> n
(Syn x) -= (Syn n) = addLine$ Syn$ x <+> "-=" <+> n

-- Comments:
--comm :: Doc -> EasyEmit ()
comm :: String -> EasyEmit ()
comm x  = addChunk$ Syn$ txt
 where
   txt = text$ maybeInit$ unlines lns -- init strips the last newline
   maybeInit [] = []
   maybeInit ls = init ls
   lns = map fn $ lines x --(render x)
   fn "" = ""
   fn other = "// " ++ other

if_ (Syn a) m1 m2 =
  do let bod1 = execEasyEmit m1
	 bod2 = execEasyEmit m2
     addChunk$ Syn$ hangbraces ("if " <> parens a) indent bod1
     addChunk$ Syn$ "else"
     addChunk$ Syn$ hangbraces (empty) indent bod2

ret (Syn x) = addLine$ Syn$ "return " <> x

assert (Syn exp) =
 do addLine$ Syn ("assert" <> pcommasep [exp])

------------------------------------------------------------
-- C++ Definitions & Declarations
------------------------------------------------------------

-- The funDef function creates a function definition as well as
-- returning a Haskell function that can be used to construct
-- applications of that function.
class FunDefable args where
  -- This is VERY painful, but need to expose separate keywords for pre- and post- the function name/args.
  funDefAttr :: String -> String -> Type -> Syntax -> [Type] -> (args -> EasyEmit ()) -> EasyEmit ObjFun

instance FunDefable ()                            where funDefAttr pre post r n ts fn = funDefShared pre post r n ts fn (\ [] -> ())
instance FunDefable Syntax                        where funDefAttr pre post r n ts fn = funDefShared pre post r n ts fn (\ [a] -> a)
instance FunDefable (Syntax,Syntax)               where funDefAttr pre post r n ts fn = funDefShared pre post r n ts fn (\ [a,b] -> (a,b))
instance FunDefable (Syntax,Syntax,Syntax)        where funDefAttr pre post r n ts fn = funDefShared pre post r n ts fn (\ [a,b,c] -> (a,b,c))
instance FunDefable (Syntax,Syntax,Syntax,Syntax) where funDefAttr pre post r n ts fn = funDefShared pre post r n ts fn (\ [a,b,c,d] -> (a,b,c,d))
instance FunDefable [Syntax]                      where funDefAttr pre post r n ts fn = funDefShared pre post r n ts fn id

-- Terrible ugliness just to deal with those darn const qualifiers:
funDef       :: FunDefable args => Type -> Syntax -> [Type] -> (args -> EasyEmit ()) -> EasyEmit ObjFun
constFunDef  :: FunDefable args => Type -> Syntax -> [Type] -> (args -> EasyEmit ()) -> EasyEmit ObjFun
inlineFunDef :: FunDefable args => Type -> Syntax -> [Type] -> (args -> EasyEmit ()) -> EasyEmit ObjFun

funDef       = funDefAttr "" ""
constFunDef  = funDefAttr "" "const"
inlineFunDef = funDefAttr "inline" ""

-- Internal helper function used above:
funDefShared pre postqualifiers retty (Syn name) tyls fn formTup  =
    do (ls,c) <- S.get
       --args <- mapM (forValueOnly . tmpvar) tyls -- Generate temp names only (emit nothing).
       args <- sequence$ take (length tyls) (repeat$ gensym "arg") -- Generate temp names only (emit nothing).
       let body = execEasyEmit (fn$ formTup args)
	   formals = map (\ (t,a) -> cppType t <+> deSyn a) (zip tyls args)
       addChunk$ Syn$
          hangbraces ((if pre P.== "" then empty else text (pre++" ")) <>
		      cppType retty <+> name <> pcommasep formals <+> (text postqualifiers))
	             indent body
--       addChunk$ "\n"
       return (\ args -> Syn$ name <> (pcommasep (map deSyn args)))

-- This applies a C++ function referred to by name (defined elsewhere):
function :: Syntax -> ObjFun
function (Syn name) =
  \ args -> Syn$ name <> (pcommasep$ map deSyn args)

-- Shortcut for applying a method given an object or object reference.
methcall :: Syntax -> Syntax -> ObjFun
methcall obj meth args = obj `dot` (function meth args)

-- Common case: for loop over a range with integer index:
------------------------------------------------------------
-- Input is [Inclusive,Exclusive) range.
forLoopSimple :: (Syntax,Syntax) -> (Syntax -> EasyEmit ()) -> EasyEmit ()
forLoopSimple (start,end) fn =
  do
     Syn var <- gensym "i"
     (ls,oldcnt) <- S.get

     let (_,newcnt,body) = rawRunEasyEmit oldcnt $ fn (Syn var)

     -- To maintain uniqueness we take the counter mods from the body.
     -- TODO: A cleaner way to do this would be to include the indent level in the state monad and NOT LEAVE IT.
     S.put (ls, newcnt)

     addChunk$ Syn$ hangbraces ("for " <> parens ( cppType TInt <+> var <+> "=" <+> deSyn start <> semi <+>
						   var <+> "<" <+> deSyn end <> semi <+>
						   var <> "++"
						 )) indent $
	            body

-- Helper used below:
a <++> b | a P.== "" = b
a <++> b | b P.== "" = a
a <++> b             = a <+> b

-- This creates a class-decl-like pattern with a ':'
-- It is parameterized by a little prefix which could be "class" or "struct" or anything else.
-- Similarly, there's a postfix which is usually ";".
classLike :: String -> String -> Syntax -> Syntax -> EasyEmit () -> EasyEmit ()
classLike prefix postfix (Syn name) (Syn inherits) m =
  do
     putD$ t prefix <++>
	   hsep (if inherits P.== empty
		 then [name]
		 else [name <+> colon, inherits])
     block m
     addChunkPrevLine$ strToSyn postfix

-- | Takes: name, inheritance expression, and a body.
cppClass :: Syntax -> Syntax -> EasyEmit () -> EasyEmit ()
cppClass = classLike "class" ";"

-- | Takes: name, inheritance expression, and a body.
cppStruct :: Syntax -> Syntax -> EasyEmit () -> EasyEmit ()
cppStruct = classLike "struct" ";"

-- Arg list is (type,argname) and init list is (name,expression/value)
cppConstructor :: Syntax -> [(Type,Syntax)] -> [(Syntax,Syntax)] -> EasyEmit () -> EasyEmit ()
cppConstructor (Syn name) args inits body =
    let fn (t,x) = pPrint t <+> deSyn x in
    classLike "" "" (Syn$ name <> parens (commasep$ map fn args))
		    (Syn$ commasep$ map (\ (a,b) -> deSyn a <> parens (deSyn b)) inits)
	      body

-- Constructor method prototypes just look like applications
constructorPrototype :: Syntax -> [Syntax] -> EasyEmit ()
constructorPrototype name args =
  app (function name) args

-- Curly-brace delimited, indented block:
-- POSSIBLY INEFFICIENT!
-- TODO: Implement this by tracking the indent level in the monad:
block :: EasyEmit () -> EasyEmit ()
block m =
  do let body = execEasyEmit m
     addChunk "{"
     addChunk$ Syn$ nest indent body
     addChunk "}"

----------------------------------------------------------------------------------------------------
-- Overloaded booleans and predicates from Lennart Augustsson:
----------------------------------------------------------------------------------------------------

-- | Generalization of the 'Bool' type.  Used by the generalized 'Eq' and 'Ord'.
class Boolean bool where
    (&&)  :: bool -> bool -> bool   -- ^Logical conjunction.
    (||)  :: bool -> bool -> bool   -- ^Logical disjunction.
    not   :: bool -> bool           -- ^Locical negation.
    false :: bool                   -- ^Truth.
    true  :: bool                   -- ^Falsity.
    fromBool :: Bool -> bool        -- ^Convert a 'Bool' to the generalized Boolean type.
    fromBool b = if b then true else false

-- Why not just make this part of the above class?
-- | Generalization of the @if@ construct.
--class (Boolean bool) => Conditional bool a where -- orig
--class (Boolean bool) => Conditional bool where
--    conditional :: bool -> a -> a -> a -- ^Pick the first argument if the 'Boolean' value is true, otherwise the second argument.

--class (Boolean bool) => Eq a bool {- x | a -> bool -} where
class (Boolean bool) => Eq a bool | a -> bool where
    (==) :: a -> a -> bool
    (/=) :: a -> a -> bool

    x /= y  =  not (x == y)
    x == y  =  not (x /= y)

--class (Conditional bool Ordering, Eq a bool) => Ord a bool | a -> bool where
--class (Conditional bool, Eq a bool) => Ord a bool | a -> bool where
class (Boolean bool, Eq a bool) => Ord a bool | a -> bool where
    (<), (<=), (>), (>=) :: a -> a -> bool
    max, min             :: a -> a -> a

-- Need to define precedence because these new operations really have nothing to do with the originals:
infix  4  ==, /=, <, <=, >=, >
infixr 3  &&
infixr 2  ||

----------------------------------------------------------------------------------------------------
-- Internal helpers:
----------------------------------------------------------------------------------------------------

----------------------------------------------------------------------------------------------------
-- Testing:
----------------------------------------------------------------------------------------------------

t1 = cppClass "foo" "bar" $ comm "body"

t2 = execEasyEmit$ funDef TInt "foo" [TInt] $ \(Syn y) ->
       do comm "Body"
	  funDef TInt "nested" [] $ \ () -> comm "Inner body"
	  return ()

ee_example :: EasyEmit ()
ee_example =
  do
     comm "\nFirst some global vars:\n "
     y <- tmpvar TInt
     x <- var TInt "x"

     bar <- funDef (TSym "void") "bar" [TInt, TInt] $ \ (z,q) -> do
	 set y (z + q)

     comm "\nA function declaration:"
     foo <- funDef TInt "foo" [TInt] $ \y -> do
	 x += (x + y * 3)
	 x -= 4
	 ret x

     let baz  = function "baz"
	 quux = fromString "quux"

     app baz [quux, quux]

     forLoopSimple (0,10) $ \i -> do
	 if_ (i == 10 || i > 100)
	     (app foo [foo [i / 10]])
	     (app foo [i ? 3 .: 4])

   --   cppClass "blah" $ do
   --       if_ (app f x) x x
   -- --      funDef "method" [TInt, TFloat] $ \(y,z) -> y + z

ee_test1 = testCase "" "Code emission example"$
	   391 ~=? (length$ render$ execEasyEmit ee_example)

tests_easyemit = testSet "EasyEmit" [ee_test1]