Skip to content

Commit

Permalink
Merge pull request scalaz#203 into scalaz-seven
Browse files Browse the repository at this point in the history
  • Loading branch information
larsrh committed Dec 20, 2012
2 parents 86bcde7 + da692cf commit 56d36c0
Show file tree
Hide file tree
Showing 24 changed files with 869 additions and 387 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ tags
*~
*#
z_local.sbt
.DS_Store
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ object BooleanLatch {
override def release() = sync release 0
override def await() = sync acquireInterruptibly 0
}
}
}
2 changes: 1 addition & 1 deletion core/src/main/scala/scalaz/Bitraverse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ trait Bitraverse[F[_, _]] extends Bifunctor[F] with Bifoldable[F] { self =>
def traverseSTrampoline[S, G[_] : Applicative, A, B, C, D](fa: F[A, B])(f: A => State[S, G[C]])(g: B => State[S, G[D]]): State[S, G[F[C, D]]] = {
import Free._
implicit val A = StateT.stateTMonadState[S, Trampoline].compose(Applicative[G])
bitraverse[({type λ[α]=StateT[Trampoline, S, G[α]]})#λ, A, B, C, D](fa)(f(_: A).lift[Trampoline])(g(_: B).lift[Trampoline]).unliftId[Trampoline, G[F[C, D]]]
bitraverse[({type λ[α]=StateT[Trampoline, S, G[α]]})#λ, A, B, C, D](fa)(f(_: A).lift[Trampoline])(g(_: B).lift[Trampoline]).unliftId[Trampoline, G[F[C, D]], S, S]
}

/** Bitraverse `fa` with a `Kleisli[G, S, C]` and `Kleisli[G, S, D]`, internally using a `Trampoline` to avoid stack overflow. */
Expand Down
2 changes: 2 additions & 0 deletions core/src/main/scala/scalaz/Cojoin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ object Cojoin {
self: Cobind[F] =>

def cojoin[A](fa: F[A]): F[F[A]] = cobind(fa)(fa => fa)

override def extend[A, B](a: F[A])(f: F[A] => B): F[B] = cobind(a)(f)
}

////
Expand Down
17 changes: 13 additions & 4 deletions core/src/main/scala/scalaz/ComonadCoState.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,20 @@ package scalaz
trait ComonadStore[F[_, _], S] extends Comonad[({type f[x]=F[S,x]})#f] {
def pos[A](w: F[S, A]): S
def peek[A](s: S, w: F[S, A]): A
def peeks[A](s: S => S, w: F[S, A]): A
def seek[A](s: S, w: F[S, A]): F[S, A]
def seeks[A](s: S => S, w: F[S, A]): F[S, A]

def peeks[A](s: S => S, w: F[S, A]): A =
peek(s(pos(w)), w)

def seek[A](s: S, w: F[S, A]): F[S, A] =
peek(s, cojoin(w))

def seeks[A](s: S => S, w: F[S, A]): F[S, A] =
peeks(s, cojoin(w))

def experiment[G[_], A](s: S => G[S], w: F[S, A])(implicit FG: Functor[G]): G[A] =
FG.map(s(pos(w)))(peek(_, w))
}

object ComonadStore {
def apply[F[_,_],S](implicit F: ComonadStore[F, S]) = F
def apply[F[_, _],S](implicit F: ComonadStore[F, S]): ComonadStore[F, S] = F
}
4 changes: 4 additions & 0 deletions core/src/main/scala/scalaz/ComonadTrans.scala
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,7 @@ object ComonadTrans {
trait Cohoist[F[_[_], _]] extends ComonadTrans[F] {
def cohoist[M[_], N[_]: Comonad](f: M ~> N): ({type f[x] = F[M, x]})#f ~> ({type f[x] = F[N, x]})#f
}

object Cohoist {
def apply[F[_[_], _]](implicit F: Cohoist[F]): Cohoist[F] = F
}
455 changes: 281 additions & 174 deletions core/src/main/scala/scalaz/Lens.scala

Large diffs are not rendered by default.

Loading

0 comments on commit 56d36c0

Please sign in to comment.