Skip to content

Instantly share code, notes, and snippets.

@kenwebb
Last active March 31, 2018 02:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kenwebb/8873e8b758629c530b5164caf3c5e0f7 to your computer and use it in GitHub Desktop.
Save kenwebb/8873e8b758629c530b5164caf3c5e0f7 to your computer and use it in GitHub Desktop.
Kleisli Categories
<?xml version="1.0" encoding="UTF-8"?>
<!--Xholon Workbook http://www.primordion.com/Xholon/gwt/ MIT License, Copyright (C) Ken Webb, Fri Mar 30 2018 22:40:25 GMT-0400 (EDT)-->
<XholonWorkbook>
<Notes><![CDATA[
Xholon
------
Title: Kleisli Categories
Description:
Url: http://www.primordion.com/Xholon/gwt/
InternalName: 8873e8b758629c530b5164caf3c5e0f7
Keywords:
My Notes
--------
March 30, 2018
Ideas inspired by ref [1].
see my notebook March 30
How might I implement some of the stuff from ref[1] using Xholon.
References
----------
(1) https://bartoszmilewski.com/2014/12/23/kleisli-categories/
Kleisli Categories, Bartosz Milewski
(2) https://medium.com/@luijar/kliesli-compositions-in-javascript-7e1a7218f0c4
Kleisli Compositions in JavaScript, Luis Atencio
]]></Notes>
<_-.XholonClass>
<PhysicalSystem/>
<Space/>
<Location/>
<Sentence superClass="Attribute_String">
<SentenceUpper/>
<SentenceWords/>
</Sentence>
<Composer/>
<Processor superClass="Script">
<ToUpper/>
<ToWords/>
<Move/>
<Logging/>
</Processor>
<GenerateSentences superClass="Script"/>
</_-.XholonClass>
<xholonClassDetails>
<!-- https://www.w3schools.com/colors/colors_picker.asp?colorhex=483D8B -->
<!--<Chameleon><Color>rgb(173, 166, 216)</Color></Chameleon>
<PhysicalSystem><Color>rgb(173, 166, 216)</Color></PhysicalSystem>
<Space xhType="XhtypePureContainer"><Color>rgb(140,131,201)</Color></Space>
<Location xhType="XhtypePureContainer"><Color>rgb(140,131,201)</Color></Location>-->
<Chameleon><Color>white</Color></Chameleon>
<PhysicalSystem><Color>white</Color></PhysicalSystem>
<Space xhType="XhtypePureContainer"><Color>white</Color></Space>
<Location xhType="XhtypePureContainer"><Color>white</Color></Location>
<Sentence xhType="XhtypePurePassiveObject"><Color>rgba(140,131,201,1.0)</Color></Sentence>
<SentenceUpper xhType="XhtypePurePassiveObject"><Color>rgba(91,78,177,1.0)</Color></SentenceUpper>
<SentenceWords xhType="XhtypePurePassiveObject"><Color>rgba(72,61,139,1.0)</Color></SentenceWords>
<Composer xhType="XhtypePureActiveObject"><Color>rgb(138, 99, 61)</Color>
<port name="port" index="0" connector="../Space/Location"/>
</Composer>
<Processor><Color>rgb(138, 61, 61)</Color></Processor>
<Avatar><Color>yellow</Color></Avatar>
</xholonClassDetails>
<PhysicalSystem>
<Space><Attribute_String>
Once upon a time.
There was a cat named Licorice.
Licorice had black fur and green eyes.
He hated to go outside.
He was afraid of the dogs that walked by.
He slept all day.
Well, at least 20 hours a day.
He was bored.
His life wasn't going anywhere.
One day he decided to make a change.
He learned to count.
One
Two
Three
Four
Five
Six
Six minutes since I've been fed.
Sigh.
He learned to eat with a spoon.
I can eat so much faster this way.
But he still only got a handful of food.
And he still wasn't allowed to eat at the table.
Recently, Licorice has been studying the arcane art of getting a lot done in dreams.
It's the perfect field of study for a critter that sleeps so much.
He's had time in his dreams to study French.
Il parle francais meme que anglais.
Meow, meow, meow.
He has also leared a few words of Russian.
Я ничего не знаю.
And some other languages.
No se nada.
Je ne sais rien.
Ich weiß nichts.
我什么都不知道。
Ničesar ne vem.
Ik wit neat.
Nieko nežinau.
</Attribute_String><GenerateSentences><![CDATA[
var me, beh = {
postConfigure: function() {
me = this.cnode;
var space = me.parent();
me.println("Hello from " + me.name());
var astr = me.parent().first();
var sents = astr.text();
me.println(sents);
var sentsArr = sents.split("\n");
for (var i = 0; i < sentsArr.length; i++) {
var sent = sentsArr[i];
space.append("<Location><Sentence>" + sent + "</Sentence></Location>");
}
astr.remove();
me.remove();
}
}
//# sourceURL=GenerateSentences.js
]]></GenerateSentences></Space>
<Composer>
<!-- contains zero or more behaviors such as: toUpper toWords -->
<ToUpper roleName="u"><![CDATA[
var me, beh = {
postConfigure: function() {
me = this.cnode;
me.println("Hello from " + me.name());
},
act: function() {
//me.println(me.name() + " was here.");
if (me == me.parent().first()) {
var locNode = me.parent().port(0);
if (locNode) {
var sentNode = locNode.first();
var sent = sentNode.text();
var sentUp = sent.toUpperCase();
//me.println("SENTUP: " + sentUp);
sentNode.text(sentUp);
sentNode.xhc("SentenceUpper");
}
}
}
}
//# sourceURL=ToUpper.js
]]></ToUpper>
<ToWords roleName="w"><![CDATA[
var me, beh = {
postConfigure: function() {
me = this.cnode;
me.println("Hello from " + me.name());
},
act: function() {
//me.println(me.name() + " was here.");
if (me == me.parent().first()) {
var locNode = me.parent().port(0);
if (locNode) {
var sentNode = locNode.first();
var sent = sentNode.text();
var sentWords = sent.split(" ");
me.println(sentWords);
sentNode.text(sentWords);
sentNode.xhc("SentenceWords");
}
}
}
}
//# sourceURL=ToWords.js
]]></ToWords>
<Logging roleName="l"><![CDATA[
var me, beh = {
postConfigure: function() {
me = this.cnode;
me.println("Hello from " + me.name());
},
act: function() {
//me.println(me.name() + " was here.");
if (me == me.parent().first()) {
var locNode = me.parent().port(0);
if (locNode) {
me.println("logging: currently handling " + locNode.name());
}
}
}
}
//# sourceURL=Logging.js
]]></Logging>
<Move roleName="m"><![CDATA[
var me, beh = {
postConfigure: function() {
me = this.cnode;
me.println("Hello from " + me.name());
},
act: function() {
//me.println(me.name() + " was here.");
if (me == me.parent().first()) {
var locNode = me.parent().port(0);
if (locNode) {
me.parent().port(0, locNode.next());
}
}
me.parent().append(me.parent().first().remove()); // shuffle so d3cp anim will update
}
}
//# sourceURL=Move.js
]]></Move>
</Composer>
<Animate duration="0.25" selection="#xhgraph" xpath="./PhysicalSystem" cssStyle=".d3cpnode circle {stroke-width: 0px;} .d3cpleaf circle {stroke-width: 0px;}" efParams="{&quot;selection&quot;:&quot;#xhgraph&quot;,&quot;sort&quot;:&quot;disable&quot;,&quot;width&quot;:900,&quot;height&quot;:900,&quot;mode&quot;:&quot;tween&quot;,&quot;labelContainers&quot;:false,&quot;labelContainersOptions&quot;:&quot;center&quot;,&quot;useSymbols&quot;:true,&quot;includeId&quot;:false,&quot;includeClass&quot;:true,&quot;shape&quot;:&quot;circle&quot;,&quot;supportTouch&quot;:true}"/>
</PhysicalSystem>
<PhysicalSystembehavior implName="org.primordion.xholon.base.Behavior_gwtjs"><![CDATA[
var me, beh = {
postConfigure: function() {
me = this.cnode.parent();
this.cnode.remove();
var anim = me.xpath("Animate");
me.parent().append(anim.remove());
}
}
]]></PhysicalSystembehavior>
<SvgClient><Attribute_String roleName="svgUri"><![CDATA[data:image/svg+xml,
<svg width="100" height="50" xmlns="http://www.w3.org/2000/svg">
<g>
<title>Space</title>
<rect id="PhysicalSystem/Space" fill="#98FB98" height="50" width="50" x="25" y="0"/>
<g>
<title>Composer</title>
<rect id="PhysicalSystem/Composer" fill="#6AB06A" height="50" width="10" x="80" y="0"/>
</g>
</g>
</svg>
]]></Attribute_String><Attribute_String roleName="setup">${MODELNAME_DEFAULT},${SVGURI_DEFAULT}</Attribute_String></SvgClient>
</XholonWorkbook>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment