Summary

This post is based on “A pragmatic introduction to category theory” talk where were presented definitions of the most used term from theory category defined from the pragmatic perspective. I encourage all of you to watch slides or presentation.

Why should we bother at all?

Category theory gives us a more in-depth understanding of our code. Precisely it gives us information about how things compose together. We reason by composition and abstraction.

Defined terms of `Theory of category` in this talk

• What is the category?

It is transformation from one object to another A->B

• The most used category’s rules
• Identity law
• Composition Low: ability to combine transformation
• Associativity: operations can be grouped arbitrarily
• monoid = category with 1 object

It meets following rules:
Identity : n o id == id o n == n
Composition : forall x, y => x o y
Associativity : x o (y o z) == (x o y) o z

• functor = category in a box (e.g. Option from F#, Future from Scala, Try, List, Either) where box means that values are lifted to some context.

It meets following rules:

Identity : map(id) == id
Composition : map(g o f) == map(g) o map(f)
Associativity: map(h o g) o map(f) == map(h) o map(g o f)
*applicative = combine more boxes into one

• monad = fuse two boxes together = it is a monoid in the category of endofunctors

Abstract abstracting machines

Its summary of the keynote: “Winning the War on Error: Solving the Halting Problem and Curing Cancer”.

What can you learn?

This talk can inspire you to learn more computer science. You can use programming knowledge to solve changes in curing cancer. The presenter showed how well-known problem like halt problem could inspire to solve some issues in IT world and also solve detection of a wrong genome.

Halt problem

The halting problem is a problem which tries to answer the question: is possible to say when or if executing program has ended? Alan Turing said about it:

Thou shalt not write an algorithm which determines whether a program halts

We can’t solve this problem at all, but we can approximate some solutions and give an answer in some cases. For all unknow cases we can just say “don’t know”. To provide some partial answer, we will abstract abstracting machines.

Software engineer and predictions

The real engineer should use predictions for his design. Do we do such stuff? Matt complained about it.

He showed how he used predictions to approximate programs. He needed to find malware software for the custom Android marketplace which was installed on soldiers devices. He suggested measuring the state of a program (using static analysis) and tried to answer (partially) the halting problem with an approximation. So he suggested to write it down like:

f(program)={halt problem}
f^(program)={halt problem; dunno}

The main idea is to pass program to the Interpreter then to AAM (abstract abstracting machine) and then to Approximator (Static analysers allow programmers to bound and predict the behaviour of software without ever running it.).

What’s needed to create AAM:

• Injection function = transform program to some state
• Step function = change state to new state
• Approximation of execution (guarantee to stop at some point)
• The abstracted state corresponds to some real state

He described the state of each program using CESK (Control Environment Store Kontinuation).

The CESK machine is a state-machine in which each state has four components: a (C)ontrol component, an (E)nvironment, a (S)tore and a (K)ontinuation. One might imagine these respectively as the instruction pointer, the local variables, the heap and the stack.

Writing these things to more mathematics it will be something like this:

In bold I wrote things which he needed to approximate to achieve bounded context. After all, this transformation, it is possible to determine and predict: is program well behaving.

Genome analogy to abstracting abstract machines

What is cancer? Cancer is many rare diseases. Finding the same two cancers is hard. The problem which we need to face is curing rare diseases.

Matt found the analogy of software program to biology program:

• DNA is a collection of characters (char*) which  can accept 4 characters `A` `T“C` `G`
• DNA is encoding RNA
• RNA is encoding proteins
• many proteins are enzymes (Enzymes are functions which catalyse transformation)

From that, we conclude that genome has

• syntax
• semantics

So we can use this analogy to build AAM and detect which part of genome fails and mutate in wrong way. Matt Might has invented some algorithm to counteract some mutations.

Real life

He used described a method to find his son disease. He discovered that his son suffers from NGLY1 mutation. What was interesting the medicament which reverts was easy to buy. He tried the medicament on himself and after that, he gave it to his son and he cured him.

In that time, President Obama would like to create the precision medicine program. And he invited Matt to build a genetic telescope and try to build customise drug to diseases. They made assumptions to try cure 5 genetic diseases in 12 months, and they managed to do it. Currently, after changes in US Matt started to create a private clinic and he will develop his project.

Summary

I was on 8-9 November in London on the conference “Code Mesh”. It was a tough and very interesting conference about non-mainstream technologies. The knowledge which was presented is not something which you can directly implement into your daily work because we don’t have ideas available in our C# language. But each knowledge, in my perspective, should inspire you to do interesting stuff and we shouldn’t close just to one language. I will describe the most interesting talks.

Topics which you can inspire or interest you:

I will describe the other two topics in a short time

Intro

Hi all, today I would like to say something about automation of work. I use cmder as my standard command line. I would like to focus today on clink integration. It is the very powerful tool, which allows you among other things to add your code completions. And this post will be devoted to that. Because in my current work I use vagrant. I lacked very many suggestions of provisions and snapshots syntax support. There is some support for vagrant suggestions, but this stuff wasn’t implemented. So I started investigating and added it 😉

During my beginning of investigation how it is working. I found this directory:

`{your_path}\Cmder\vendor\clink-completions`

And I found repository related to clink-completions where I’ve contributed. So as you can see the language used for code-completion is Lua. Lua is functional and scripting language. Probably the reason why this language is chosen is that  clink already uses Lua to parse the commands:

To implement straightforward map write something like that:

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 local chris_parser = parser({ "m1" .. parser({ "m1a", "m2a"}), "m2" .. parser({ "m2a", "m2b" ..parser({"--x"})}), }, "-h" .. parser({})) --register parser under first keyword clink.arg.register_parser("chris1", chris_parser)

To run your new system suggestion just open a new command line and start typing chris1 and press tab

If you want to check graph of your parser just invoke command below:

`chris_parser:dump()`

Then on the new command line, it will show you a graph of your abstract syntax tree like this:

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 0.0 - m1 1.0 - m1a 1.0 - m2a 0.0 - m2 1.0 - m2a 1.0 - m2b 2.0 - --x 0.F - table: 000000AFCDC87FB0

Everything is easy when you need to provide just simple map. But what if you need to do something more complicated?

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 local parser = clink.arg.new_parser --declare function local function xyz() return {"a","b","c"} end local chris_parser = parser({xyz}) clink.arg.register_parser("chris", chris_parser)

The answer is: declare function which returns collection of strings. The order of code matters. So to use function which you would like to use you need to define it first.

So to provide some custom functionallity you need to use function and then you can use all of good of Lua language. Additionaly, you have also modules in module directory:

`{your_path}\Cmder\vendor\clink-completions\modules`

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 -- load module into matchers alias local matchers = require('matchers') -- use clink to get system environment clink.get_env("VAGRANT_VAGRANTFILE")
view raw load-more.lua hosted with ❤ by GitHub

When lua scripts are loaded in cmder?

Lua scripts of code-completion in cmder are loaded at each time when open new console.

If you consider file `.init.lua` in code-completion folder you will notice that every file with lua extension is taken into consider when your clink/cmder is running.

If you go to my github you can see that I’ve contributed to clink-completions and I added two things:

1. Snapshots
2. Suggest name of provisions

I did it in 3 Pull Requests:

First pull request where I did the most of stuff. The main mechanism is like this:

• Find Vagrantfile – mostly analogous as finding .git folder in git suggestions
• Find matching regex
• Return matches as collection for parser

Enhance regex for provision names

Bug fix of unclosed file

Introduction

Hi, as I said in my previous post I would like to describe here my experience from conferences. So let’s start!
I was the most amazed on DDD north by Become a chatbot builder with Microsoft Bot Framework presented by James Mann. I was surprised how fast you can create exact intelligent chatbot. The funniest thing was that I didn’t know which talk I should choose in that slot and I decided to go to it by deduction.

Microsoft Bot Framework

So Microsoft Bot Framework is a framework which integrates Bot service hosted on Microsoft Azure with the most known channels like slack, messenger, skype, etc.
The first thing to start coding is to go to the URL:
1. Download template for VS – it will allow you create project in that framework with all dependencies in nugget (SDK Bot Framework)
The primary purpose of this framework is to integrate all these channels. As self, it hasn’t got inbuild AI framework, but you can integrate it with other services from Microsoft Core Services. It provides you with an ASP.NET controller with methods where you can process text input and return your answer.
There exist three techniques in that framework which you can use
1. Question and Answers – for some specific text you return a particular answer.
2. Dialog – it gives you a possibility of context in conversation. So you can ask for some details and fill the form and do some computation depend on it.
3. FormFlows – it gives you a window with suggesting questions.
It is your responsibility for providing interpretation and prevent typos by users. The framework as self just gives you an opportunity to process messages in particular channel.

So how to make intelligent things?

James showed two tools from Microsoft Cognitive Service
It provides you with a ready solution to create an intelligent model based on your FAQ. You can feed your model with FAQ link, file or manually. Even though after feeding your model with data, you still can train your model with specific questions and choose what is the best answer. So in the end, end-user can make typos, differently expressed queries than initially and still he will get a proper answer from your chatbot.