Visar inlägg med etikett example. Visa alla inlägg
Visar inlägg med etikett example. Visa alla inlägg

2016-10-13

Scala Request Uri Combinator Parser

URI Combinator Parser

In my last blog I created a URL parser but the HttpServletRequest is providing only path and query with the method getRequestUri() so I made a request URI parser too.

Code

This code needs the URL parser, see below.

See

Link to the URL parser:
https://gist.github.com/AIMMOTH/b9903387cdf6b9377e9a7f6ca8887281

2016-10-11

Javascript monad Maybe with Monet



The Monad Maybe

Maybe aka option or optional is very useful for preventing null. Using the Javascript library Monet it's quite easy to use this monad.

Preventing null

You have a variable but don't know if it's null. With Maybe, you wrap it and test if it is "some".

Transform or map

Monads are also useful to transform a value to another. Think of this example:
Each step is instancing a variable and making a "halt". With a monad, you can "go with the flow" and do it all in one step:

Sample

https://jsfiddle.net/yapdd5xv/15/