https://groups.google.com/d/msg/scala-user/Z54ncnC7XKA/AKfUwF5qDk0J
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
/* __ *\ | |
** ________ ___ / / ___ __ ____ Scala.js tools ** | |
** / __/ __// _ | / / / _ | __ / // __/ (c) 2013-2017, LAMP/EPFL ** | |
** __\ \/ /__/ __ |/ /__/ __ |/_// /_\ \ http://scala-js.org/ ** | |
** /____/\___/_/ |_/____/_/ | |__/ /____/ ** | |
** |/____/ ** | |
\* */ | |
package org.scalajs.core.tools.linker.backend.emitter |
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 scalaz._ | |
import Scalaz._ | |
object monads { | |
def fix[A](f: (=> A) => A): A = f(fix(f)) //> fix: [A](f: => A => A)A | |
type Gen[A] = (=> A) => A | |
def gFib: Gen[Int => Int] = (self) => n => |
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
/** | |
* In classic Scala implementation of hierarchies of Category theory laws (scalaz/cats), the dependency between | |
* different laws is encoded using inheritance (https://github.com/typelevel/cats/blob/master/core/src/main/scala/cats/Monad.scala#L14) | |
* | |
* This approach creates well-known issues: for example, a Monad is able to _derive_ an Applicative. | |
* So sometimes, you don't have the Applicative you want but the one derived from the Monad or it doesn't | |
* compile because you have 2 Applicatives in your implicit scope. | |
* | |
* Alois Cochard has proposed a new model to represent that in (scato project)[https://github.com/aloiscochard/scato] or | |
* (scalaz/8.0.x)[https://github.com/scalaz/scalaz/blob/series/8.0.x/base/src/main/scala/typeclass/Monad.scala] branch. |
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
// Basic shapeless-style HList | |
sealed trait HList | |
sealed trait HNil extends HList { | |
def ::[H](h : H) = Test.::(h, this) | |
} | |
final case object HNil extends HNil | |
final case class ::[+H, +T <: HList](head : H, tail : T) extends HList |
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
{-# LANGUAGE OverloadedStrings #-} | |
module Main where | |
import Network.Wai (pathInfo, Request, requestMethod, Response, responseLBS, ResponseReceived) | |
import Network.Wai.Handler.Warp (run) | |
import Network.HTTP.Types (status200, status401) | |
-- note: type Application = Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived | |
application :: Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived |
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
{-# LANGUAGE BangPatterns #-} | |
{-# LANGUAGE DeriveFunctor #-} | |
{-# LANGUAGE LambdaCase #-} | |
{-# LANGUAGE RankNTypes #-} | |
{-# LANGUAGE RecordWildCards #-} | |
import Control.Comonad | |
import Control.Comonad.Cofree | |
import Control.Monad | |
import Control.Monad.ST |
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 App.Counter where | |
import Prelude (($), (+), (-), (*), (/), (>), const, show) | |
import Data.Array ((..), (:), mapWithIndex) | |
import Data.Int (toNumber, floor) | |
import Math (sin, cos, pi ) | |
import Pux.Html (Html, div, span, button, text, canvas, svg, circle, line ) | |
import Pux.Html.Attributes (width, height, viewBox, cx, cy, r, fill, x1, y1, x2, y2, stroke, strokeWidth) | |
import Pux.Html.Events (onClick) |
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
{-# LANGUAGE InstanceSigs #-} | |
module Chapter26 where | |
import Control.Monad (liftM) | |
newtype MaybeT m a = MaybeT' { runMaybeT :: m (Maybe a) } | |
instance (Functor m) => Functor (MaybeT m) where | |
fmap f (MaybeT' ma) = MaybeT' $ (fmap . fmap) f ma |