Monad – simple example definition

Combines the following concept.

1. Functor
– Type constructor.
– Value lifting.
2. Bind
– Create a functor then unwrap -> for example, flatMap in optional in Java8.

| Leave a comment

C++14: Optional.map in Java 8 for functional programming(Monad)

Pseudo C++ example implementation of map function in optional in Java8 for functional style programming by utilizing Monad concept.

template<class T>
class optional
{
  T value;
  bool valid;

public:
  optional() : valid(false)
  optional(T value) {
    this.value = value;
    valid = true;
  }

  template<class F>
  auto map(F f) -> optional<std::decay_t<decltyp(f(value))>> {
    if (value.has_value())
        return f(value);
    return decltype(f(value))();
  }
};

Posted in C++ | Leave a comment

Java – Guava API to sort items in collection with Ordering compound example

Collection.sort(list, 
	Ordering.from((Comparator<Item>) Comparator.comparingInt(item -> item.getId()))
	.compound(Comparator.comparing(Item::getName)))
Posted in Java, Programming | Leave a comment

C++17 – new features in C++17

Nice article for C++17 features.

http://www.bfilipek.com/2017/07/cpp17-details-simplifications.html

Posted in C++, Programming | Tagged | Leave a comment

Docker – Best practice to refresh on building image

Adding the date in docker file so that user can update the data for every change.

FROM 
ENV REFRESHED_AT 2017-1-1
Posted in docker, Programming | Leave a comment

Docker – Subnet address in Ubuntu

$ sudo vi /etc/default/docker

modify the following section.
DOCKER_OPTS=”–bip 192.168.1.1/24″

Posted in docker, Programming | Leave a comment

Java – Spring boot with JAX-RS

Enabling Spring boot to use JAX-RS

https://dzone.com/articles/using-jax-rs-with-spring-boot-instead-of-mvc

http://blog.codeleak.pl/2015/01/getting-started-with-jersey-and-spring.html

Posted in Java, Programming | Leave a comment