https://tutorials.ubuntu.com/tutorial/tutorial-create-a-usb-stick-on-ubuntu#0
package net.vectos | |
import cats.arrow.Category | |
import io.circe.Json | |
import shapeless._ | |
import scala.language.higherKinds | |
object algebra { | |
sealed trait JsonGrammarF[F[-_,+_]] extends Category[F] { |
{-# LANGUAGE MultiParamTypeClasses, FunctionalDependencies #-} | |
import Control.Monad | |
import Control.Monad.Free | |
class (Functor f, Functor g, Functor h) => Compose f g h | f g -> h where | |
compose :: f x -> g y -> Free h (Free f x, Free g y) | |
compose f g = return (liftF f, liftF g) | |
composeF :: Compose f g h => Free f x -> Free g x -> Free h x |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
Every once in a while I am faced with someone who denies that the rational numbers (or fractions, or pairs of integers) can be put into a bijective correspondence with natural numbers. To deal with the situation, I coded up the bijection. So now I can just say: "Really? Interesting. Please provide a pair of numbers (i,j)
which is not enumerated by f
, as defined in my gist." I am still waiting for a valid counter-example.
Anyhow, here is a demo of f
and g
at work. I am using the Python version, but a Haskell variant is included as well.
The 100-th pair is:
>>> f(100)
(10, 4)
{-# LANGUAGE TypeFamilies #-} | |
import Data.Function (on) | |
import Control.Applicative | |
data EventData e = EventData { | |
eventId :: Int, | |
body :: Event e | |
} |
/** | |
* <b>Fixed Point Combinator is:</b> | |
* Y = λf.(λx.f (x x)) (λx.f (x x)) | |
* | |
* <b>Proof of correctness:</b> | |
* Y g = (λf . (λx . f (x x)) (λx . f (x x))) g (by definition of Y) | |
* = (λx . g (x x)) (λx . g (x x)) (β-reduction of λf: applied main function to g) | |
* = (λy . g (y y)) (λx . g (x x)) (α-conversion: renamed bound variable) | |
* = g ((λx . g (x x)) (λx . g (x x))) (β-reduction of λy: applied left function to right function) | |
* = g (Y g) (by second equality) [1] |
One of the goals of Play2 architecture is to provide a programming model for what is called Realtime Web Applications.
Realtime Web Applications are applications that make use of Websockets, Server Sent Events, Comet or other protocols offering/simulating an open socket between the browser and the server for continuous communication. Basically, these applications let users work with information as it is published - without having to periodically ping the service.
There are quite a few web frameworks that target the development of this type of application: but usually the solution is to simply provide an API that allows developers to push/receive messages from/to an open channel, something like: