text:
#include "main.hpp"

std::string serverURL;
LogQueue* lgQu = new LogQueue();
std::vector<std::string> downloadVec;
double dlProg = 10;
double addProg = 0;
std::future<void> future = std::async(std::launch::async, [] {});
double clsTDP = 1;

std::string calc_sha256(char* path)
{
	std::ifstream input(path, std::ios::binary);
	std::ostringstream buffer;
	buffer << input.rdbuf();
	return str_sha256(buffer.str());
}

std::string str_sha256(const std::string str)
{
	unsigned char hash[SHA256_DIGEST_LENGTH];
	SHA256_CTX sha256;
	SHA256_Init(&sha256);
	SHA256_Update(&sha256, str.c_str(), str.size());
	SHA256_Final(hash, &sha256);
	std::stringstream ss;
	for (int i = 0; i < SHA256_DIGEST_LENGTH; i++)
	{
		ss << std::hex << std::setw(2) << std::setfill('0') << (int)hash[i];
	}
	return ss.str();
}

void playMesa()
{
	ShellExecute(NULL, "open", "MeltingSaga/MeltingSaga.exe", NULL, NULL, SW_SHOWDEFAULT);
}

void updateMesa(int* step)
{
	switch (*step)
	{
		case 0:
		{
			addLog("<color:255,255,255>Download : remote.upd [ <color:0,255,0>...<color:255,255,255> ]");
			break;
		}
		case 1:
		{
			fn::Curl::downloadFile(serverURL + "remote.upd", "remote.upd");
			setBarPercent(5);
			setLog("<color:255,255,255>Download : remote.upd [ <color:0,255,0>Done<color:255,255,255> ]");
			break;
		}
		case 2:
		{
			addLog("<color:255,255,255>Checking local files checksum [ <color:0,255,0>...<color:255,255,255> ]");
			break;
		}
		case 3:
		{

				future = std::async(std::launch::async, [] {
					std::ifstream remoteChecksumFile("remote.upd");
					std::string remoteChecksum((std::istreambuf_iterator<char>(remoteChecksumFile)), std::istreambuf_iterator<char>());
					std::vector<std::string> allLines = fn::String::split(remoteChecksum, "\n");

					for (int i = 0; i < allLines.size(); i++)
					{
						std::string cPath = fn::String::split(allLines[i], ":")[1];
						std::string cSum = fn::String::split(allLines[i], ":")[0];
						if (calc_sha256(&cPath[0u]) == "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855" || calc_sha256(&cPath[0u]) != &cSum[0u])
						{
							downloadVec.push_back(cPath);
						}
					}
				});

			break;
		}
		case 4:
		{
			std::_Future_status status = future.wait_for(std::chrono::milliseconds(0));
			if (status == std::future_status::ready)
			{
				setBarPercent(10);
				setLog("<color:255,255,255>Checking local files checksum [ <color:0,255,0>Done<color:255,255,255> ]");
				dlProg = 10;
				if (downloadVec.size() > 0)
					addProg = (double)90 / (double)(downloadVec.size());
				else
					addProg = 0;
			}
			else
			{
				std::string crTD = "";
				for (int i = 0; i < (int)clsTDP; i++)
				{
					crTD += ".";
				}
				clsTDP += 0.001;
				if (clsTDP > 4)
				{
					clsTDP = 1;
				}
				setLog("<color:255,255,255>Checking local files checksum [ <color:0,255,0>" + crTD + "<color:255,255,255> ]");
				*step = *step - 1;
			}
			break;
		}
		default:
		{
			if (*step - 5 < downloadVec.size())
			{
				std::_Future_status status = future.wait_for(std::chrono::milliseconds(0));
				if (status == std::future_status::ready)
				{
					if (*step - 5 != 0)
					{
						setLog("<color:255,255,255>Downloading : " + downloadVec[*step - 6] + "[ <color:0,255,0>Done<color:255,255,255> ]");
					}
					std::string toDl = downloadVec[*step - 5];
					addLog("<color:255,255,255>Downloading : " + toDl + "[ <color:0,255,0>...<color:255,255,255> ]");
					std::cout << serverURL + toDl << std::endl;
					std::vector<std::string> splittedPath = fn::String::split(toDl, "/");
					std::string dirPath = fn::Vector::join(splittedPath, "/", 0, 1);
					boost::filesystem::create_directories(dirPath);
					future = std::async(std::launch::async, [toDl] {
						fn::Curl::downloadFile(serverURL + toDl, toDl);
					});
					dlProg += addProg;
					setBarPercent(dlProg);
				}
				else
				{
					*step = *step - 1;
				}

			}
			else
			{
				if (*step - 5 != 0)
				{
					setLog("<color:255,255,255>Downloading : " + downloadVec[*step - 6] + "[ <color:0,255,0>Done<color:255,255,255> ]");
				}
				*step = -2;
				addLog("<color:0,255,0>Update Done !");
				GUI::Widget::getWidgetByID<GUI::Button>("updateBtn")->changeText("Play", sf::Color::White, sf::Text::Style::Regular);
				GUI::Widget::getWidgetByID<GUI::Button>("updateBtn")->bindFunction(&playMesa);
				downloadVec.clear();
				setBarPercent(100);
			}
			break;
		}
	}
	*step = *step + 1;
}

void setBarPercent(int percent)
{
	GUI::Widget::getWidgetByID<GUI::LoadingBar>("updateBar")->fill(percent, 0.05);
	GUI::Widget::getWidgetByID<GUI::Label>("updateBarLbl")->setText(std::to_string(percent) + "%", sf::Color::White);
}

void addLog(std::string content)
{
	std::cout << content << std::endl;
	lgQu->push_back(content);
	GUI::Widget::getWidgetByID<GUI::Label>("logsContLbl")->setComplexText(lgQu->returnComplexText());
}

void setLog(std::string content)
{
	lgQu->set(content);
	GUI::Widget::getWidgetByID<GUI::Label>("logsContLbl")->setComplexText(lgQu->returnComplexText());
}

int main()
{
	DataParser configFile;
	configFile.parseFile("Data/config.cfg.msd", true);
	bool useLog = true;
	std::string logFile = "log.txt";
	if (configFile.attributeExists("LauncherConfig", "", "useLog")) configFile.getAttribute("LauncherConfig", "", "useLog")->getData(&useLog);
	if (configFile.attributeExists("LauncherConfig", "", "logFile")) configFile.getAttribute("LauncherConfig", "", "logFile")->getData(&logFile);
	configFile.getAttribute("LauncherConfig", "", "serverURL")->getData(&serverURL);

	if (useLog)
	{
		std::ofstream out(logFile);
		std::streambuf *coutbuf = std::cout.rdbuf();
		std::cout.rdbuf(out.rdbuf());
	}

	fn::Coord::width = 800; fn::Coord::height = 600;
	fn::Coord::baseWidth = 800; fn::Coord::baseHeight = 600;
	sf::RenderWindow window(sf::VideoMode(800, 600), "", sf::Style::None);
	window.setMouseCursorVisible(false);
	sf::RectangleShape windowBorder(sf::Vector2f(798, 598));
	windowBorder.setPosition(1, 1); windowBorder.setFillColor(sf::Color(40, 40, 40)); windowBorder.setOutlineColor(sf::Color::White); windowBorder.setOutlineThickness(1);
	sf::Vertex linetop[] = { sf::Vertex(sf::Vector2f(0, 60)), sf::Vertex(sf::Vector2f(800, 60)) };
	sf::Vertex linemiddle[] = { sf::Vertex(sf::Vector2f(0, 450)), sf::Vertex(sf::Vector2f(800, 450)) };
	sf::Vertex linebottom[] = { sf::Vertex(sf::Vector2f(0, 550)), sf::Vertex(sf::Vector2f(800, 550)) };

	sf::Event sfevent;
	GUI::Container* gui = new GUI::Container(&sfevent, &window, 800, 600);
	GUI::WidgetContainer* mainContainer = gui->createWidgetContainer("main", 1, 0, 0, 800, 600, GUI::ContainerMovement::Fixed, 0, 0);
	GUI::WidgetContainer* infoContainer = gui->createWidgetContainer("info", 1, 0, 60, 800, 390, GUI::ContainerMovement::Fixed, 0, 0);
	GUI::WidgetContainer* stgsContainer = gui->createWidgetContainer("stgs", 1, 0, 60, 800, 390, GUI::ContainerMovement::Fixed, 0, 0);
	GUI::WidgetContainer* logsContainer = gui->createWidgetContainer("logs", 1, 0, 450, 800, 100, GUI::ContainerMovement::Fixed, 0, 0);

	Cursor curs;
	curs.initialize(&window);

	sf::Font font;
	font.loadFromFile("Data/Fonts/weblysleekuil.ttf");

	//Main UI
	gui->createLabel("main", "titleLbl", 10, 10, "Melting Saga Updater", "weblysleekuil.ttf", 32, sf::Color::White);
	gui->createLabel("main", "updaterVerLbl", 400, 10, "Updater : <Nightly> v1.0.6", "weblysleekuil.ttf", 12, sf::Color::White);
	gui->createLabel("main", "updaterVerLbl", 400, 30, "Game : <Nightly> v0.0.1", "weblysleekuil.ttf", 12, sf::Color::White);
	gui->createCheckbox("main", "settingsBtn", 700, 15, "SETTINGS", false);
	gui->createButton("main", "quitBtn", 750, 15, true, true, "QUIT");
	gui->createButton("main", "updateBtn", 600, 560, true, true, "GREY");
	gui->createLoadingBar("main", "updateBar", 10, 560, "UPDATER");
	gui->createLabel("main", "updateBarLbl", 300, 560, "0%", "weblysleekuil.ttf", 24, sf::Color::White);
	GUI::ButtonEvent* updBtn = GUI::Widget::getWidgetByID<GUI::Button>("updateBtn")->getHook();
	std::thread* tupd = nullptr;

	//Infos UI
	fn::Curl::downloadFile(serverURL + "changelog.txt", "changelog.txt");
	gui->createLabel("info", "updateInfosTitleLbl", 10, 10, "Update Informations : ", "weblysleekuil.ttf", 24, sf::Color::Cyan);
	gui->createLabel("info", "updateInfosContLbl", 30, 45, "", "weblysleekuil.ttf", 16, sf::Color::White);
	std::ifstream changelogFile("changelog.txt");
	std::string updateContent((std::istreambuf_iterator<char>(changelogFile)),
		std::istreambuf_iterator<char>());
	GUI::Widget::getWidgetByID<GUI::Label>("updateInfosContLbl")->setComplexText(updateContent);
	infoContainer->addScrollBar();

	//Settings UI
	gui->createLabel("stgs", "settingsTitleLbl", 10, 10, "Settings : ", "weblysleekuil.ttf", 24, sf::Color::Cyan);
	gui->createCheckbox("stgs", "settingsSaveLogCB", 30, 45, "GREY", false);
	gui->createLabel("stgs", "settingsSaveLogLbl", 55, 43, "Save log.txt", "weblysleekuil.ttf", 16, sf::Color::White);
	gui->createLabel("stgs", "settingsCustomUrlLbl", 30, 70, "Custom URL : ", "weblysleekuil.ttf", 16, sf::Color::White);
	gui->createTextInput("stgs", "settingsCustomUrlE", 130, 70, serverURL, "weblysleekuil.ttf", 16, sf::Color::White, "GREY");

	//Logs UI
	gui->createLabel("logs", "logsTitleLbl", 10, 10, "Logs : ", "weblysleekuil.ttf", 24, sf::Color::Cyan);
	gui->createLabel("logs", "logsContLbl", 30, 45, "", "weblysleekuil.ttf", 16, sf::Color::White);
	addLog("<color:255,255,255>Connection to MeSa Server : " + serverURL +  " [ <color:0,255,0>Done<color:255,255,255> ]");
	addLog("<color:255,255,255>Download : changelog.txt [ <color:0,255,0>Done<color:255,255,255> ]");

	GUI::ButtonEvent* appQuitBool = GUI::Widget::getWidgetByID<GUI::Button>("quitBtn")->getHook();
	bool* appSettingsBool = GUI::Widget::getWidgetByID<GUI::Checkbox>("settingsBtn")->getHook();
	GUI::Widget::getWidgetByID<GUI::Button>("updateBtn")->setText("Update", "weblysleekuil.ttf", sf::Color::White, 18, true, 0, -3);
	GUI::Widget::getWidgetByID<GUI::LoadingBar>("updateBar")->fill(0, 0);
	sf::Vector2i grabbedOffset;
	int cstep = -1;

	bool grabbedWindow = false;
	while (window.isOpen())
	{
		while (window.pollEvent(sfevent))
		{
			if (sfevent.type == sf::Event::Closed)
				window.close();
			else if (sfevent.type == sf::Event::KeyPressed)
			{
				if (sfevent.key.code == sf::Keyboard::Escape)
					window.close();
			}
			else if (sfevent.type == sf::Event::MouseButtonPressed)
			{
				if (sf::Mouse::getPosition().y - window.getPosition().y < 60 && sf::Mouse::getPosition().x - window.getPosition().x < 680)
				{
					if (sfevent.mouseButton.button == sf::Mouse::Left)
					{
						grabbedOffset = window.getPosition() - sf::Mouse::getPosition();
						grabbedWindow = true;
					}
				}
			}
			else if (sfevent.type == sf::Event::MouseButtonReleased)
			{
				if (sfevent.mouseButton.button == sf::Mouse::Left)
					grabbedWindow = false;
			}
			else if (sfevent.type == sf::Event::MouseMoved)
			{
				if (grabbedWindow)
					window.setPosition(sf::Mouse::getPosition() + grabbedOffset);
			}
		}

		if (*updBtn == GUI::ButtonEvent::Clicked && cstep < 0) cstep++;
		if (cstep >= 0) updateMesa(&cstep);

		gui->updateAllContainer();
		curs.update();
		if (*appQuitBool == GUI::ButtonEvent::Pressed) {window.close();}
		if (*appSettingsBool) { gui->getContainerByContainerName("info")->setDisplayed(false); gui->getContainerByContainerName("stgs")->setDisplayed(true); }
		else { gui->getContainerByContainerName("info")->setDisplayed(true); gui->getContainerByContainerName("stgs")->setDisplayed(false); }

		window.clear(sf::Color(40, 40, 40));
		window.draw(windowBorder);
		gui->drawAllContainer(&window);
		window.draw(linetop, 2, sf::Lines); window.draw(linemiddle, 2, sf::Lines); window.draw(linebottom, 2, sf::Lines);
		window.draw(*curs.getSprite());
		window.display();
	}
}

void LogQueue::push_back(std::string content)
{
	logContent.push_back(content);
	if (logContent.size() > 2)
		logContent.erase(logContent.begin());
}

void LogQueue::set(std::string content)
{
	logContent[logContent.size() - 1] = content;
}

std::string LogQueue::returnComplexText()
{
	std::string complexText;
	for (int i = 0; i < logContent.size(); i++)
	{
		complexText += logContent[i] + "\n";
	}
	return complexText;
}


text:
package org.scalatest.finders;

import java.util.ArrayList;
import java.util.List;

public class FeatureSpecFinder implements Finder {

  @Override
  public Selection find(AstNode node) {
    Selection result = null;
    while (result == null) {
      if (node instanceof MethodInvocation) {
        MethodInvocation invocation = (MethodInvocation) node;
        String name = invocation.name();
        AstNode[] args = invocation.args();
        if (isScenarioRef(name) && args.length > 0 && args[0].canBePartOfTestName()) {
          AstNode parent = invocation.parent();
          if (parent instanceof ConstructorBlock)
            result = new Selection(parent.className(), "Scenario: " + args[0].toString(), new String[] { "Scenario: " + args[0].toString() });
          else if (parent instanceof MethodInvocation) {
            MethodInvocation parentInvocation = (MethodInvocation) parent;
            String parentName = parentInvocation.name();
            AstNode[] parentArgs = parentInvocation.args();
            if (isFeatureRef(parentName) && parentArgs.length > 0 && parentArgs[0].canBePartOfTestName()) {
              String testName = "Feature: " + parentArgs[0] + " Scenario: " + args[0];
              result = new Selection(parentInvocation.className(), testName, new String[] { testName });
            }
            else {
              if (node.parent() != null)
                node = node.parent();
              else
                break;
            }
          }
          else {
            if (node.parent() != null)
              node = node.parent();
            else
              break;
          }
        }
        else if (isFeatureRef(name) && args.length > 0 && args[0].canBePartOfTestName()) {
          AstNode parent = invocation.parent();
          if (parent instanceof ConstructorBlock) {
            String featureText = "Feature: " + args[0];
            List<String> testNameList = new ArrayList<>();
            AstNode[] children = invocation.children();
            for (AstNode childNode : children) {
              if (childNode instanceof MethodInvocation
                  && (isScenarioRef(childNode.name()))
                  && ((MethodInvocation) childNode).args().length > 0
                  && ((MethodInvocation) childNode).args()[0] instanceof StringLiteral) {
                  MethodInvocation child = (MethodInvocation) childNode;
                  if (child.args()[0].canBePartOfTestName()) {
                    testNameList.add(featureText + " Scenario: " + child.args()[0]);
                  }
              }
            }
            result = new Selection(invocation.className(), featureText, testNameList.toArray(new String[0]));
          }
          else {
            if (node.parent() != null)
              node = node.parent();
            else
              break;
          }
        }
        else {
          if (node.parent() != null)
            node = node.parent();
          else
            break;
        }
      }
      else {
        if (node.parent() != null)
          node = node.parent();
        else
          break;
      }
    }
    return result;
  }

  private boolean isFeatureRef(String refName) {
    return refName.equals("feature") || refName.equals("Feature");
  }

  private boolean isScenarioRef(String refName) {
    return refName.equals("scenario") || refName.equals("Scenario");
  }
}

redpajama_set_name: RedPajamaGithub


text:
#include "duc_2ch.h"

#if 1
//______________________________________________________________________________
void duc_2ch ( DATA_T din_i[L_INPUT],
	           DATA_T din_q[L_INPUT],
			   DATA_T dout[L_OUTPUT],
               incr_t incr ) {

//#pragma HLS interface ap_fifo depth=L_INPUT  port=din_i
//#pragma HLS interface ap_fifo depth=L_INPUT  port=din_q
//#pragma HLS interface ap_fifo depth=L_OUTPUT port=dout_i
//#pragma HLS interface ap_fifo depth=L_OUTPUT port=dout_q

//#pragma HLS interface ap_ctrl_none port=return  // to avoid bubble

//#pragma HLS interface s_axilite port=incr
#pragma HLS interface ap_stable port=incr

#pragma HLS interface axis depth=300  port=din_i
#pragma HLS interface axis depth=300  port=din_q
#pragma HLS interface axis depth=4800 port=dout

#pragma HLS dataflow

static duc_2ch_class<L_INPUT> f0;

DATA_T dout_i[L_OUTPUT];
DATA_T dout_q[L_OUTPUT];
dds_t  dds_cos[L_OUTPUT];
dds_t  dds_sin[L_OUTPUT];

f0.process(din_i, dout_i, din_q, dout_q);
dds_frame(incr, dds_cos, dds_sin);
mixer(dds_cos, dds_sin, dout_i, dout_q, dout);

}

#endif

//______________________________________________________________________________
void mixer ( dds_t dds_cos[L_OUTPUT],
             dds_t dds_sin[L_OUTPUT],
	         DATA_T dout_i[L_OUTPUT],
	         DATA_T dout_q[L_OUTPUT],
			 DATA_T dout[L_OUTPUT]) {

static DATA_T dout_tmp;

L1: for(int i=0;i<L_OUTPUT;i++) {
#pragma HLS pipeline rewind
    dout[i]  = dout_tmp;
    dout_tmp = dout_i[i] * dds_cos[i] - dout_q[i] * dds_sin[i];
}

}

#if 0
//______________________________________________________________________________
// no DDS

void duc_2ch ( DATA_T din_i[L_INPUT], DATA_T dout_i[L_OUTPUT],
               DATA_T din_q[L_INPUT], DATA_T dout_q[L_OUTPUT] ) {

//#pragma HLS interface ap_fifo depth=L_INPUT  port=din_i
//#pragma HLS interface ap_fifo depth=L_INPUT  port=din_q
//#pragma HLS interface ap_fifo depth=L_OUTPUT port=dout_i
//#pragma HLS interface ap_fifo depth=L_OUTPUT port=dout_q

#pragma HLS interface ap_ctrl_none port=return

#pragma HLS interface axis depth=300  port=din_i
#pragma HLS interface axis depth=300  port=din_q
#pragma HLS interface axis depth=4800 port=dout_i
#pragma HLS interface axis depth=4800 port=dout_q

static duc_2ch_class<L_INPUT> f0;

f0.process(din_i, dout_i, din_q, dout_q);

}

#endif


text:
import floatToPageNum from './../../utils/floatToPageNum';
import pageNumToFloat from './../../utils/pageNumToFloat';
import FRACTION_LENGTH from './../../constants/fractionLength';

export default async function updateEntry(event, rawData) {

  const {Entry} = this.params.models;
  const {id, data} = rawData;

  const sourceEntry = data.sourceEntry;
  const pageNum = pageNumToFloat(data.pageNum, FRACTION_LENGTH) || '';

  delete data.entryId;
  delete data.folderId;
  delete data.sourceEntry;
  delete data.id;
  delete data.pageNum;

  await Entry.update({id}, {sourceEntry, pageNum, data});
  const entry = await Entry.findOne({id});

  entry.pageNum = floatToPageNum(entry.pageNum, FRACTION_LENGTH);

  this.resolve(entry);
}


text:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
	xmlns:android="http://schemas.android.com/apk/res/android"
	xmlns:tools="http://schemas.android.com/tools"
	android:layout_width="match_parent"
	android:layout_height="match_parent"
	android:orientation="vertical">

	<ListView
		android:id="@+id/statsList"
		android:layout_width="match_parent"
		android:layout_height="0dip"
		android:layout_alignParentTop="true"
		android:layout_alignParentBottom="true" />

</RelativeLayout>


text:
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE FlexibleInstances #-}
module Mapnik.Lens where

import Mapnik.TH
import qualified Mapnik.Map as Map
import Mapnik.Common hiding (maxx,maxy,minx,miny)
import Mapnik.Layer
import Mapnik.Color
import Mapnik.ImageFilter
import Mapnik.Rule
import Mapnik.Style
import Mapnik.Parameter
import Mapnik.Datasource
import Mapnik.Symbolizer

import Control.Lens
import qualified Data.HashMap.Strict as M
import Data.Bits
import Data.Text (Text)
import Data.Word (Word8)

class HasStyleLst     s a | s -> a where styleLst :: Lens' s a
class HasParameters   s a | s -> a where parameters :: Lens' s a
class HasRed          s a | s -> a where red :: Lens' s a
class HasGreen        s a | s -> a where green :: Lens' s a
class HasBlue         s a | s -> a where blue :: Lens' s a
class HasAlpha        s a | s -> a where alpha :: Lens' s a

-- Needs to be declared First so Traversal's are created instead of Lens'es
makeMapnikFields ''Symbolizer

makeMapnikFields ''Layer
makeMapnikFields ''Map.Map
makeMapnikFields ''Rule
makeMapnikFields ''Style
makeMapnikFields ''Format
makeMapnikFields ''TextProperties
makeMapnikFields ''TextPlacements
makeMapnikFields ''SimplePlacementPosition
makeMapnikFields ''TextFormatProperties
makeMapnikFields ''TextLayoutProperties
makeMapnikFields ''TextSymProperties
makeMapnikFields ''GroupSymProperties
makeMapnikFields ''GroupRule
makeMapnikFields ''GroupLayout
makeMapnikFields ''Colorizer
makeMapnikFields ''Stop
makeMapnikFields ''Box
makeMapnikFields ''ImageRgba8
makeMapnikFields ''ColorStop
makePrisms ''Value
makePrisms ''Symbolizer
makePrisms ''Prop
makePrisms ''Format
makePrisms ''GroupLayout
makePrisms ''Font
makePrisms ''ImageFilter
makePrisms ''TextPlacements

--------------------------------------------------------------------------
-- Instances
--------------------------------------------------------------------------

instance HasStyleLst (Map.Map s) [(StyleName,Style)] where
  styleLst = lens (M.toList . Map.styles)
                  (\s a -> s { Map.styles = M.fromList a})

instance HasParameters Datasource (M.HashMap Text Value) where
  parameters = lens (\(Datasource s) -> s) (const Datasource)

instance HasRed Color Word8 where
  red   = lens (\(RGBA r _ _ _) -> r) (\(RGBA _ g b a) r -> RGBA r g b a)
  {-# INLINE red #-}
instance HasGreen Color Word8 where
  green = lens (\(RGBA _ g _ _) -> g) (\(RGBA r _ b a) g -> RGBA r g b a)
  {-# INLINE green #-}
instance HasBlue Color Word8 where
  blue  = lens (\(RGBA _ _ b _) -> b) (\(RGBA r g _ a) b -> RGBA r g b a)
  {-# INLINE blue #-}
instance HasAlpha Color Word8 where
  alpha = lens (\(RGBA _ _ _ a) -> a) (\(RGBA r g b _) a -> RGBA r g b a)
  {-# INLINE alpha #-}

instance HasWidth Box Double where
  width = lens (\b -> b^.maxx - b^.minx) (\b w -> b & maxx .~ (b^.minx + w))
  {-# INLINE width #-}

instance HasHeight Box Double where
  height = lens (\b -> b^.maxy - b^.miny) (\b h -> b & maxy .~ (b^.miny + h))
  {-# INLINE height #-}

#define COLOR_LENS(cname, name, off) \
instance cname PixelRgba8 Word8 where {\
  {-# INLINE name #-}; \
  name = lens \
    (fromIntegral . (.&. 0xFF) . (`unsafeShiftR` off) . unRgba8) \
    (\(PixelRgba8 c) v -> PixelRgba8 (c .&. complement (0xFF `unsafeShiftL` off) .|. (fromIntegral v `unsafeShiftL` off))) \
  };

COLOR_LENS(HasRed,   red,    0)
COLOR_LENS(HasGreen, green,  8)
COLOR_LENS(HasBlue,  blue,  16)
COLOR_LENS(HasAlpha, alpha, 24)


text:
namespace Microsoft.Skype.UCWA.Models
{
    /// <summary>
    /// Represents a system-created group of contacts that the user pins or that the user frequently communicates and collaborates with.
    /// An application can subscribe to updates from members of this group. Updates include presence, location, or note changes for a specific contact. Currently, pinnedGroup is a read-only resource and can be managed by other endpoints. An application must call startOrRefreshSubscriptionToContactsAndGroups before it can receive events when a pinnedGroup is created, modified, or removed.
    /// </summary>
    public class PinnedGroup : Group
    {
    }
}