This file contains hidden or 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
| My PL Shopping List | |
| =================== | |
| - static types | |
| - lightweight syntax for lambda expressions | |
| - type annotations on any expression | |
| - higher-kinded types | |
| - monad comprehensions (for/do) | |
| - applicative comprehensions (applicative do, idiom brackets) | |
| - functor comprehensions |
This file contains hidden or 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
| package demo.maps; | |
| import java.util.HashMap; | |
| import java.util.Map; | |
| import static demo.maps.MapUtils.P.p; | |
| public class MapUtils { | |
| private MapUtils() { |
This file contains hidden or 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
| type Pos2D = Pos2D { x : Int, y : Int } | |
| area : Pos2D -> Int | |
| area (Pos2D {x,y}) = x * y |
This file contains hidden or 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
| module Namespacing2 where | |
| type Pos2DU = { x :: Number, y :: Number } | |
| area :: Pos2DU -> Number | |
| area {x = x, y = y} = x * y | |
| data Pos2DT = Pos2DT { x :: Number, y :: Number } |
This file contains hidden or 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
| https://wiki.haskell.org/Typeclassopedia | |
| Functor -> Applicative -> Monad | |
| Apply -----^ | |
| https://github.com/purescript/purescript-control | |
| Functor -> Apply -> Applicative -> Monad | |
| -> Bind ----------^ |
This file contains hidden or 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
| package com.example; | |
| public abstract class Either<A, B> { | |
| public abstract <T> T fold(final F<A, T> af, final F<B, T> bf); | |
| private Either(){} | |
| public static <A, B> Either<A, B> a(final A a) { | |
| return new Either<A, B>() { |
This file contains hidden or 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
| Higher-kinded types in Java | |
| =========================== | |
| If we consider that types classify values, then kinds classify types. | |
| To use Haskell notation, simple java types are of kind * - the kind of types of values. | |
| Generic types (e.g. List) are of kind * -> * - this is essentially a type-level | |
| function - pass a type parameter A to the List type constructor and you get a List<A>. | |
| Higher-kinded types are (basically) of kind (* -> *) -> *. |
This file contains hidden or 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
| import java.util.function.Function; | |
| public class Blah { | |
| private Blah() { | |
| } | |
| static class A { | |
| } |
This file contains hidden or 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
| Proof of the functor laws for the Maybe functor | |
| fmap :: (a -> b) -> Maybe a -> Maybe b | |
| fmap f (Just x) = Just (f x) | |
| fmap f Nothing = Nothing | |
| Prove: | |
| fmap id = id | |
| Case 1: Just x |
This file contains hidden or 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
| module FreeDom where | |
| import Control.Monad.Free | |
| import Control.Monad.Free.Trans | |
| import DOM | |
| import DOM.HTML | |
| import DOM.HTML.Window | |
| import DOM.Node.Node | |
| import DOM.Node.Types | |
| import Data.Array |