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
https://wiki.haskell.org/Typeclassopedia | |
Functor -> Applicative -> Monad | |
Apply -----^ | |
https://github.com/purescript/purescript-control | |
Functor -> Apply -> Applicative -> Monad | |
-> Bind ----------^ |
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
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 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 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 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 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
-- Consider the function type constructor "->" in infix form: | |
-- e.g. "a -> b" is the same as "(->) a b" | |
-- Partially applied, "(->) a" is the "reader" type, | |
-- i.e. functions that "read" an 'a'. "(->) a" is a Monad - the Reader Monad. | |
-- Consider the join function: | |
join :: Monad m => m (m a) -> m a |
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
measureInner :: forall eff. JQuery -> Eff (dom :: DOM | eff) Size | |
measureInner jq = | |
size <$> innerWidth jq <*> innerHeight jq | |
foreign import innerWidth | |
""" | |
function innerWidth(ob) { | |
return function () { | |
return ob.innerWidth(); |
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
module Mappy where | |
import Control.Monad.State.Trans | |
import Data.Traversable | |
import Data.Tuple | |
import Control.Monad.State | |
import Control.Monad.State.Class | |
mapAccumL :: forall a b c t. (Traversable t) => (a -> b -> Tuple c a) -> a -> t b -> Tuple (t c) a | |
mapAccumL f s t = |
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
/** | |
Produce a monad given: | |
- point | |
and one or: | |
- bind | |
- map + join | |
So long as you have a minimum definition, the remainder of the ops will be derived. | |
You can explicitly specify any of these - e.g. you can specify point, map and bind if you like. |
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
total | |
natToFin2 : (m : Nat) -> (n : Nat) -> {p : Nat.LT m n} -> Fin n | |
natToFin2 Z (S j) = fZ | |
natToFin2 (S k) (S j) = fS (natToFin2 k j) | |
-- *natto> :r | |
-- Type checking ./natto.idr | |
-- natto.idr:17:11:Incomplete term fS (natToFin2 k j) | |
-- Metavariables: Main.natToFin2 |