From 272444f84d1ee6cf5c0c5b5a66c15230d123ab5c Mon Sep 17 00:00:00 2001 From: David Hoyt Date: Thu, 21 Feb 2019 16:23:25 -0800 Subject: [PATCH 1/8] Port to SBT v1 and mdoc. --- .gitignore | 5 +- .travis.yml | 12 ++-- README.md | 2 +- build.sbt | 71 +++++++++++-------- .../src/main/scala/matryoshka/Based.scala | 2 +- .../main/scala/matryoshka/Birecursive.scala | 2 +- .../main/scala/matryoshka/BirecursiveT.scala | 2 +- .../main/scala/matryoshka/Corecursive.scala | 2 +- .../main/scala/matryoshka/CorecursiveT.scala | 2 +- .../src/main/scala/matryoshka/Delay.scala | 2 +- .../src/main/scala/matryoshka/Embed.scala | 2 +- .../src/main/scala/matryoshka/EqualT.scala | 2 +- .../src/main/scala/matryoshka/Hole.scala | 2 +- .../src/main/scala/matryoshka/Merge.scala | 2 +- .../src/main/scala/matryoshka/Nested.scala | 2 +- .../src/main/scala/matryoshka/Recursive.scala | 2 +- .../main/scala/matryoshka/RecursiveT.scala | 2 +- .../src/main/scala/matryoshka/ShowT.scala | 2 +- .../src/main/scala/matryoshka/data/Fix.scala | 2 +- .../src/main/scala/matryoshka/data/Mu.scala | 2 +- .../src/main/scala/matryoshka/data/Nu.scala | 2 +- .../main/scala/matryoshka/data/cofree.scala | 2 +- .../scala/matryoshka/data/disjunction.scala | 2 +- .../main/scala/matryoshka/data/either.scala | 2 +- .../src/main/scala/matryoshka/data/free.scala | 2 +- .../src/main/scala/matryoshka/data/id.scala | 2 +- .../main/scala/matryoshka/data/ilist.scala | 2 +- .../src/main/scala/matryoshka/data/list.scala | 2 +- .../main/scala/matryoshka/data/maybe.scala | 2 +- .../src/main/scala/matryoshka/data/nel.scala | 2 +- .../main/scala/matryoshka/data/option.scala | 2 +- .../main/scala/matryoshka/data/package.scala | 2 +- .../matryoshka/implicits/AlgebraOps.scala | 2 +- .../matryoshka/implicits/CoalgebraOps.scala | 2 +- .../scala/matryoshka/implicits/IdOps.scala | 2 +- .../scala/matryoshka/implicits/package.scala | 2 +- .../instances/fixedpoint/package.scala | 2 +- .../src/main/scala/matryoshka/package.scala | 2 +- .../scala/matryoshka/patterns/AndMaybe.scala | 2 +- .../scala/matryoshka/patterns/CoEnv.scala | 2 +- .../main/scala/matryoshka/patterns/Diff.scala | 2 +- .../scala/matryoshka/patterns/Diffable.scala | 2 +- .../main/scala/matryoshka/patterns/EnvT.scala | 2 +- .../scala/matryoshka/patterns/ListF.scala | 2 +- .../patterns/PotentialFailure.scala | 2 +- .../scala/matryoshka/patterns/package.scala | 2 +- .../{tut => mdoc}/docs/01-Getting-Started.md | 6 +- .../{tut => mdoc}/docs/02-A-First-Example.md | 41 ++++++----- .../main/{tut => mdoc}/docs/03-Algebras.md | 10 +-- .../docs/04-Recursion-Schemes.md | 23 +++--- docs/src/main/{tut => mdoc}/index.md | 0 project/build.properties | 2 +- project/plugins.sbt | 15 ++-- project/project/plugins.sbt | 5 ++ .../matryoshka/scalacheck/arbitrary.scala | 2 +- .../scala/matryoshka/scalacheck/cogen.scala | 2 +- .../scala/matryoshka/scalacheck/shrink.scala | 2 +- .../src/test/scala/matryoshka/data/fix.scala | 2 +- .../src/test/scala/matryoshka/data/mu.scala | 2 +- .../src/test/scala/matryoshka/data/nu.scala | 2 +- .../scala/matryoshka/example/Example.scala | 2 +- .../test/scala/matryoshka/example/btree.scala | 2 +- .../test/scala/matryoshka/example/expr.scala | 2 +- .../scala/matryoshka/example/intList.scala | 2 +- .../scala/matryoshka/example/mathExpr.scala | 2 +- .../test/scala/matryoshka/example/nat.scala | 2 +- .../src/test/scala/matryoshka/exp/Exp.scala | 2 +- .../test/scala/matryoshka/exp/package.scala | 2 +- .../src/test/scala/matryoshka/exp2/Exp2.scala | 2 +- .../test/scala/matryoshka/exp2/package.scala | 2 +- .../matryoshka/helpers/AlgebraChecks.scala | 2 +- .../scala/matryoshka/helpers/package.scala | 11 +-- .../instances/fixedpoint/list.scala | 2 +- .../matryoshka/instances/fixedpoint/nat.scala | 2 +- .../instances/fixedpoint/partial.scala | 2 +- .../instances/fixedpoint/stream.scala | 2 +- .../scala/matryoshka/patterns/andMaybe.scala | 2 +- .../scala/matryoshka/patterns/coenv.scala | 2 +- .../test/scala/matryoshka/patterns/diff.scala | 2 +- .../test/scala/matryoshka/patterns/envt.scala | 2 +- .../scala/matryoshka/patterns/listF.scala | 2 +- .../patterns/potentialFailure.scala | 2 +- .../matryoshka/runners/BirecRunner.scala | 2 +- .../matryoshka/runners/CorecRunner.scala | 2 +- .../scala/matryoshka/runners/RecRunner.scala | 2 +- .../scala/matryoshka/runners/package.scala | 7 +- .../src/test/scala/matryoshka/spec.scala | 4 +- .../src/test/scala/matryoshka/zygoSpec.scala | 2 +- 88 files changed, 194 insertions(+), 166 deletions(-) rename docs/src/main/{tut => mdoc}/docs/01-Getting-Started.md (81%) rename docs/src/main/{tut => mdoc}/docs/02-A-First-Example.md (90%) rename docs/src/main/{tut => mdoc}/docs/03-Algebras.md (96%) rename docs/src/main/{tut => mdoc}/docs/04-Recursion-Schemes.md (97%) rename docs/src/main/{tut => mdoc}/index.md (100%) create mode 100644 project/project/plugins.sbt diff --git a/.gitignore b/.gitignore index 7cc6dee5..c0d32132 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -project/project +!.gitignore +project/project/target project/target target core/target @@ -13,4 +14,4 @@ tmp *.swp tags .ensime -.ensime_cache \ No newline at end of file +.ensime_cache diff --git a/.travis.yml b/.travis.yml index 75a95699..e392be3c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,19 +1,15 @@ language: scala scala: - - 2.11.8 - - 2.12.1 + - 2.11.12 + - 2.12.8 jdk: - oraclejdk8 - - openjdk7 -matrix: - exclude: # NB: Scala 2.12 requires JDK 8 - - scala: 2.12.1 - jdk: openjdk7 + - openjdk8 sudo: false script: - sbt checkHeaders - - sbt coverage doc test tut + - sbt coverage doc test mdoc - sbt coverageReport - sbt clean transferPublishAndTagResources - scripts/publishAndTag 'slamdata/matryoshka' diff --git a/README.md b/README.md index 2b5380ce..300fc9d5 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Generalized folds, unfolds, and traversals for fixed point data structures in Sc 1. Add a dependency ```scala -libraryDependencies += "com.slamdata" %% "matryoshka-core" % "0.18.3" +libraryDependencies += "com.slamdata" %% "matryoshka-core" % "0.21.5" ``` Optionally, you can also depend on `matryoshka-scalacheck` to get `Arbitrary`/`Cogen`/`Shrink` instances for a bunch of pattern functors and fixed points. diff --git a/build.sbt b/build.sbt index 519bf7ae..f5ce4be9 100644 --- a/build.sbt +++ b/build.sbt @@ -1,29 +1,33 @@ -import org.scalajs.sbtplugin.ScalaJSCrossVersion import scoverage._ -import sbt._ -import Keys._ -import slamdata.SbtSlamData.transferPublishAndTagResources +import sbt._, Keys._ +import sbtcrossproject.CrossPlugin.autoImport.crossProject -lazy val monocleVersion = "1.4.0" -lazy val scalazVersion = "7.2.15" +lazy val scala2_12 = "2.12.8" +lazy val scala2_11 = "2.11.12" + +lazy val monocleVersion = "1.5.0" +lazy val scalazVersion = "7.2.27" + +lazy val supportedScalaVersions = List(scala2_12, scala2_11) + +ThisBuild / scalaVersion := scala2_12 + +ThisBuild / crossScalaVersions := supportedScalaVersions lazy val standardSettings = commonBuildSettings ++ Seq( - logBuffered in Compile := false, - logBuffered in Test := false, + Compile / logBuffered := false, + Test / logBuffered := false, updateOptions := updateOptions.value.withCachedResolution(true), exportJars := true, organization := "com.slamdata", ScoverageKeys.coverageHighlighting := true, - scalacOptions in (Compile, doc) ++= Seq("-groups", "-implicits"), - wartremoverWarnings in (Compile, compile) --= Seq( - Wart.PublicInference, // TODO: enable incrementally — currently results in many errors - Wart.ImplicitParameter), // see wartremover/wartremover#350 & #351 - + Compile / doc / scalacOptions ++= Seq("-groups", "-implicits"), + Compile / compile / wartremoverWarnings -= Wart.ImplicitParameter, // see wartremover/wartremover#350 & #351 libraryDependencies ++= Seq( - "com.slamdata" %% "slamdata-predef" % "0.0.6", + "com.slamdata" %% "slamdata-predef" % "0.0.7", "com.github.julien-truffaut" %%% "monocle-core" % monocleVersion % "compile, test", "org.scalaz" %%% "scalaz-core" % scalazVersion % "compile, test", - "com.github.mpilquist" %%% "simulacrum" % "0.11.0" % "compile, test")) + "com.github.mpilquist" %%% "simulacrum" % "0.15.0" % "compile, test")) lazy val publishSettings = commonPublishSettings ++ Seq( organizationName := "SlamData Inc.", @@ -34,48 +38,59 @@ lazy val publishSettings = commonPublishSettings ++ Seq( url("https://github.com/slamdata/matryoshka"), "scm:git@github.com:slamdata/matryoshka.git"))) -lazy val root = Project("root", file(".")) +lazy val root = project.in(file(".")) .settings(name := "matryoshka") .settings(standardSettings ++ noPublishSettings: _*) - .settings(transferPublishAndTagResources) - .settings(console := (console in replJVM).value) + .settings( + console := (console in replJVM).value, + crossScalaVersions := Nil, + releaseCrossBuild := false + ) .aggregate( coreJS, scalacheckJS, testsJS, coreJVM, scalacheckJVM, testsJVM, docs) .enablePlugins(AutomateHeaderPlugin) -lazy val core = crossProject.in(file("core")) +lazy val core = crossProject(JVMPlatform, JSPlatform).in(file("core")) .settings(name := "matryoshka-core") .settings(standardSettings ++ publishSettings: _*) .enablePlugins(AutomateHeaderPlugin) -lazy val scalacheck = crossProject +lazy val scalacheck = crossProject(JVMPlatform, JSPlatform) .dependsOn(core) .settings(name := "matryoshka-scalacheck") .settings(standardSettings ++ publishSettings: _*) .settings(libraryDependencies ++= Seq( // NB: Needs a version of Scalacheck with rickynils/scalacheck#301. "org.scalacheck" %% "scalacheck" % "1.14.0-861f58e-SNAPSHOT", - "org.scalaz" %% "scalaz-scalacheck-binding" % (scalazVersion + "-scalacheck-1.13"))) + "org.scalaz" %% "scalaz-scalacheck-binding" % (scalazVersion + "-scalacheck-1.14"))) .enablePlugins(AutomateHeaderPlugin) -lazy val tests = crossProject +lazy val tests = crossProject(JVMPlatform, JSPlatform) .settings(name := "matryoshka-tests") .dependsOn(core, scalacheck) .settings(standardSettings ++ noPublishSettings: _*) .settings(libraryDependencies ++= Seq( "com.github.julien-truffaut" %% "monocle-law" % monocleVersion % Test, - "org.typelevel" %% "scalaz-specs2" % "0.5.0" % Test, - "org.specs2" %% "specs2-core" % "3.8.7" % Test)) + "org.typelevel" %% "scalaz-specs2" % "0.5.2" % Test, + "org.specs2" %% "specs2-core" % "4.3.5" % Test)) .enablePlugins(AutomateHeaderPlugin) lazy val docs = project .settings(name := "matryoshka-docs") - .dependsOn(coreJVM) .settings(standardSettings ++ noPublishSettings: _*) - .settings(tutScalacOptions --= Seq("-Yno-imports", "-Ywarn-unused-import")) - .enablePlugins(MicrositesPlugin) + .dependsOn(coreJVM) + .enablePlugins(MdocPlugin, MicrositesPlugin) + .settings( + //Compile / scalacOptions --= List("-Yno-imports", "-Ywarn-unused-import"), + Compile / scalacOptions -= "-Yno-imports", + Compile / scalacOptions -= "-Ywarn-unused-import", + mdocIn := file("docs/src/main/mdoc/"), + mdocVariables := Map( + "VERSION" -> version.value + ) + ) .settings( micrositeName := "Matryoshka", micrositeDescription := "Generalized folds, unfolds, and traversals for fixed point data structures in Scala.", @@ -89,7 +104,7 @@ lazy val docs = project /** A project just for the console. * Applies only the settings necessary for that purpose. */ -lazy val repl = crossProject dependsOn (tests % "compile->test") settings standardSettings settings ( +lazy val repl = crossProject(JVMPlatform, JSPlatform) dependsOn (tests % "compile->test") settings standardSettings settings ( console := (console in Test).value, scalacOptions --= Seq("-Yno-imports", "-Ywarn-unused-import"), initialCommands in console += """ diff --git a/core/shared/src/main/scala/matryoshka/Based.scala b/core/shared/src/main/scala/matryoshka/Based.scala index c46df778..1bbfe7ae 100644 --- a/core/shared/src/main/scala/matryoshka/Based.scala +++ b/core/shared/src/main/scala/matryoshka/Based.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/Birecursive.scala b/core/shared/src/main/scala/matryoshka/Birecursive.scala index 5005c533..7a912adc 100644 --- a/core/shared/src/main/scala/matryoshka/Birecursive.scala +++ b/core/shared/src/main/scala/matryoshka/Birecursive.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/BirecursiveT.scala b/core/shared/src/main/scala/matryoshka/BirecursiveT.scala index 7de634f5..5ae29137 100644 --- a/core/shared/src/main/scala/matryoshka/BirecursiveT.scala +++ b/core/shared/src/main/scala/matryoshka/BirecursiveT.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/Corecursive.scala b/core/shared/src/main/scala/matryoshka/Corecursive.scala index f25f2165..14e3b35f 100644 --- a/core/shared/src/main/scala/matryoshka/Corecursive.scala +++ b/core/shared/src/main/scala/matryoshka/Corecursive.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/CorecursiveT.scala b/core/shared/src/main/scala/matryoshka/CorecursiveT.scala index dc4101bf..daefb9fc 100644 --- a/core/shared/src/main/scala/matryoshka/CorecursiveT.scala +++ b/core/shared/src/main/scala/matryoshka/CorecursiveT.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/Delay.scala b/core/shared/src/main/scala/matryoshka/Delay.scala index 29a5fb56..7b2e9c02 100644 --- a/core/shared/src/main/scala/matryoshka/Delay.scala +++ b/core/shared/src/main/scala/matryoshka/Delay.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/Embed.scala b/core/shared/src/main/scala/matryoshka/Embed.scala index 095dbad6..dbccce03 100644 --- a/core/shared/src/main/scala/matryoshka/Embed.scala +++ b/core/shared/src/main/scala/matryoshka/Embed.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/EqualT.scala b/core/shared/src/main/scala/matryoshka/EqualT.scala index 0451b484..e67a77fc 100644 --- a/core/shared/src/main/scala/matryoshka/EqualT.scala +++ b/core/shared/src/main/scala/matryoshka/EqualT.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/Hole.scala b/core/shared/src/main/scala/matryoshka/Hole.scala index cfc21dac..1a412a9b 100644 --- a/core/shared/src/main/scala/matryoshka/Hole.scala +++ b/core/shared/src/main/scala/matryoshka/Hole.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/Merge.scala b/core/shared/src/main/scala/matryoshka/Merge.scala index 11c7d423..9369a6ba 100644 --- a/core/shared/src/main/scala/matryoshka/Merge.scala +++ b/core/shared/src/main/scala/matryoshka/Merge.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/Nested.scala b/core/shared/src/main/scala/matryoshka/Nested.scala index fc45d233..16aa3c12 100644 --- a/core/shared/src/main/scala/matryoshka/Nested.scala +++ b/core/shared/src/main/scala/matryoshka/Nested.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/Recursive.scala b/core/shared/src/main/scala/matryoshka/Recursive.scala index 99f2ce03..cdc25ba1 100644 --- a/core/shared/src/main/scala/matryoshka/Recursive.scala +++ b/core/shared/src/main/scala/matryoshka/Recursive.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/RecursiveT.scala b/core/shared/src/main/scala/matryoshka/RecursiveT.scala index 24809114..89c3e0c0 100644 --- a/core/shared/src/main/scala/matryoshka/RecursiveT.scala +++ b/core/shared/src/main/scala/matryoshka/RecursiveT.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/ShowT.scala b/core/shared/src/main/scala/matryoshka/ShowT.scala index e99815a6..aae79e66 100644 --- a/core/shared/src/main/scala/matryoshka/ShowT.scala +++ b/core/shared/src/main/scala/matryoshka/ShowT.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/data/Fix.scala b/core/shared/src/main/scala/matryoshka/data/Fix.scala index de29b2cc..ef3cc157 100644 --- a/core/shared/src/main/scala/matryoshka/data/Fix.scala +++ b/core/shared/src/main/scala/matryoshka/data/Fix.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/data/Mu.scala b/core/shared/src/main/scala/matryoshka/data/Mu.scala index 2e859ed4..b8e69a8b 100644 --- a/core/shared/src/main/scala/matryoshka/data/Mu.scala +++ b/core/shared/src/main/scala/matryoshka/data/Mu.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/data/Nu.scala b/core/shared/src/main/scala/matryoshka/data/Nu.scala index 6644ae91..2e9c1c71 100644 --- a/core/shared/src/main/scala/matryoshka/data/Nu.scala +++ b/core/shared/src/main/scala/matryoshka/data/Nu.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/data/cofree.scala b/core/shared/src/main/scala/matryoshka/data/cofree.scala index 6a79e4e8..dbdd4347 100644 --- a/core/shared/src/main/scala/matryoshka/data/cofree.scala +++ b/core/shared/src/main/scala/matryoshka/data/cofree.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/data/disjunction.scala b/core/shared/src/main/scala/matryoshka/data/disjunction.scala index cc009a34..c758fa3c 100644 --- a/core/shared/src/main/scala/matryoshka/data/disjunction.scala +++ b/core/shared/src/main/scala/matryoshka/data/disjunction.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/data/either.scala b/core/shared/src/main/scala/matryoshka/data/either.scala index 930a09b3..247c66ef 100644 --- a/core/shared/src/main/scala/matryoshka/data/either.scala +++ b/core/shared/src/main/scala/matryoshka/data/either.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/data/free.scala b/core/shared/src/main/scala/matryoshka/data/free.scala index bc7e7909..bfbd77b1 100644 --- a/core/shared/src/main/scala/matryoshka/data/free.scala +++ b/core/shared/src/main/scala/matryoshka/data/free.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/data/id.scala b/core/shared/src/main/scala/matryoshka/data/id.scala index 6730633d..3e16ccde 100644 --- a/core/shared/src/main/scala/matryoshka/data/id.scala +++ b/core/shared/src/main/scala/matryoshka/data/id.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/data/ilist.scala b/core/shared/src/main/scala/matryoshka/data/ilist.scala index 0c600d15..ae8078a9 100644 --- a/core/shared/src/main/scala/matryoshka/data/ilist.scala +++ b/core/shared/src/main/scala/matryoshka/data/ilist.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/data/list.scala b/core/shared/src/main/scala/matryoshka/data/list.scala index 6ea8438f..cbbd99f8 100644 --- a/core/shared/src/main/scala/matryoshka/data/list.scala +++ b/core/shared/src/main/scala/matryoshka/data/list.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/data/maybe.scala b/core/shared/src/main/scala/matryoshka/data/maybe.scala index c08fc035..e6601263 100644 --- a/core/shared/src/main/scala/matryoshka/data/maybe.scala +++ b/core/shared/src/main/scala/matryoshka/data/maybe.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/data/nel.scala b/core/shared/src/main/scala/matryoshka/data/nel.scala index cd27d92d..af296aa8 100644 --- a/core/shared/src/main/scala/matryoshka/data/nel.scala +++ b/core/shared/src/main/scala/matryoshka/data/nel.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/data/option.scala b/core/shared/src/main/scala/matryoshka/data/option.scala index 6586060b..d840338e 100644 --- a/core/shared/src/main/scala/matryoshka/data/option.scala +++ b/core/shared/src/main/scala/matryoshka/data/option.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/data/package.scala b/core/shared/src/main/scala/matryoshka/data/package.scala index 1263f867..1daf9c50 100644 --- a/core/shared/src/main/scala/matryoshka/data/package.scala +++ b/core/shared/src/main/scala/matryoshka/data/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/implicits/AlgebraOps.scala b/core/shared/src/main/scala/matryoshka/implicits/AlgebraOps.scala index 6469c811..1357b96c 100644 --- a/core/shared/src/main/scala/matryoshka/implicits/AlgebraOps.scala +++ b/core/shared/src/main/scala/matryoshka/implicits/AlgebraOps.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/implicits/CoalgebraOps.scala b/core/shared/src/main/scala/matryoshka/implicits/CoalgebraOps.scala index 292e3f83..ca27d869 100644 --- a/core/shared/src/main/scala/matryoshka/implicits/CoalgebraOps.scala +++ b/core/shared/src/main/scala/matryoshka/implicits/CoalgebraOps.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/implicits/IdOps.scala b/core/shared/src/main/scala/matryoshka/implicits/IdOps.scala index 51e1bdb5..c7aac6d8 100644 --- a/core/shared/src/main/scala/matryoshka/implicits/IdOps.scala +++ b/core/shared/src/main/scala/matryoshka/implicits/IdOps.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/implicits/package.scala b/core/shared/src/main/scala/matryoshka/implicits/package.scala index 01d9d0a6..43d584a9 100644 --- a/core/shared/src/main/scala/matryoshka/implicits/package.scala +++ b/core/shared/src/main/scala/matryoshka/implicits/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/instances/fixedpoint/package.scala b/core/shared/src/main/scala/matryoshka/instances/fixedpoint/package.scala index 84235cbf..a4a2dd42 100644 --- a/core/shared/src/main/scala/matryoshka/instances/fixedpoint/package.scala +++ b/core/shared/src/main/scala/matryoshka/instances/fixedpoint/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/package.scala b/core/shared/src/main/scala/matryoshka/package.scala index fec865ca..4061875f 100644 --- a/core/shared/src/main/scala/matryoshka/package.scala +++ b/core/shared/src/main/scala/matryoshka/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/patterns/AndMaybe.scala b/core/shared/src/main/scala/matryoshka/patterns/AndMaybe.scala index e9688e6e..e43b6ec7 100644 --- a/core/shared/src/main/scala/matryoshka/patterns/AndMaybe.scala +++ b/core/shared/src/main/scala/matryoshka/patterns/AndMaybe.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/patterns/CoEnv.scala b/core/shared/src/main/scala/matryoshka/patterns/CoEnv.scala index a7e6ed89..f7adcb00 100644 --- a/core/shared/src/main/scala/matryoshka/patterns/CoEnv.scala +++ b/core/shared/src/main/scala/matryoshka/patterns/CoEnv.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/patterns/Diff.scala b/core/shared/src/main/scala/matryoshka/patterns/Diff.scala index ceebb0dd..519d39e2 100644 --- a/core/shared/src/main/scala/matryoshka/patterns/Diff.scala +++ b/core/shared/src/main/scala/matryoshka/patterns/Diff.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/patterns/Diffable.scala b/core/shared/src/main/scala/matryoshka/patterns/Diffable.scala index 59dc339d..0a84b0f6 100644 --- a/core/shared/src/main/scala/matryoshka/patterns/Diffable.scala +++ b/core/shared/src/main/scala/matryoshka/patterns/Diffable.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/patterns/EnvT.scala b/core/shared/src/main/scala/matryoshka/patterns/EnvT.scala index e1720244..64dae954 100644 --- a/core/shared/src/main/scala/matryoshka/patterns/EnvT.scala +++ b/core/shared/src/main/scala/matryoshka/patterns/EnvT.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/patterns/ListF.scala b/core/shared/src/main/scala/matryoshka/patterns/ListF.scala index 81927069..4f422c33 100644 --- a/core/shared/src/main/scala/matryoshka/patterns/ListF.scala +++ b/core/shared/src/main/scala/matryoshka/patterns/ListF.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/patterns/PotentialFailure.scala b/core/shared/src/main/scala/matryoshka/patterns/PotentialFailure.scala index 54f764f7..e3ac78c1 100644 --- a/core/shared/src/main/scala/matryoshka/patterns/PotentialFailure.scala +++ b/core/shared/src/main/scala/matryoshka/patterns/PotentialFailure.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/core/shared/src/main/scala/matryoshka/patterns/package.scala b/core/shared/src/main/scala/matryoshka/patterns/package.scala index c6977e71..a1d57e02 100644 --- a/core/shared/src/main/scala/matryoshka/patterns/package.scala +++ b/core/shared/src/main/scala/matryoshka/patterns/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/docs/src/main/tut/docs/01-Getting-Started.md b/docs/src/main/mdoc/docs/01-Getting-Started.md similarity index 81% rename from docs/src/main/tut/docs/01-Getting-Started.md rename to docs/src/main/mdoc/docs/01-Getting-Started.md index 2c5b6ec6..f04d2e75 100644 --- a/docs/src/main/tut/docs/01-Getting-Started.md +++ b/docs/src/main/mdoc/docs/01-Getting-Started.md @@ -6,17 +6,17 @@ title: Getting Started ## {{ page.title }} ```scala -libraryDependencies += "com.slamdata" %% "matryoshka-core" % "0.22.0" +libraryDependencies += "com.slamdata" %% "matryoshka-core" % "@VERSION@" ``` -```tut:silent +```scala import matryoshka._ import matryoshka.implicits._ ``` To use a specific fixed-point type (like `Mu`, `Nu`, or `Fix`), you will also need -```tut:silent +```scala import matryoshka.data._ ``` diff --git a/docs/src/main/tut/docs/02-A-First-Example.md b/docs/src/main/mdoc/docs/02-A-First-Example.md similarity index 90% rename from docs/src/main/tut/docs/02-A-First-Example.md rename to docs/src/main/mdoc/docs/02-A-First-Example.md index e3ec0114..96fa77ac 100644 --- a/docs/src/main/tut/docs/02-A-First-Example.md +++ b/docs/src/main/mdoc/docs/02-A-First-Example.md @@ -9,7 +9,7 @@ So, if you’re reading this, you _probably_ already have an AST or other recurs So, let’s start with a simple version of what you may already have. Here’s an AST representing a few arithmethic operations. Like most ASTs, it’s recursive – the case classes refer directly to the abstract class they’re extending. -```tut:book +```scala mdoc sealed abstract class Arithmetic final case class Number(v: Double) extends Arithmetic final case class Add(a: Arithmetic, b: Arithmetic) extends Arithmetic @@ -20,7 +20,7 @@ final case class Divide(a: Arithmetic, b: Arithmetic) extends Arithmetic We gain a lot of flexibility by _separating_ that recursion from the AST. We do this with the Stephen Compall mantra of “add a type parameter!” -```tut:book +```scala mdoc sealed abstract class ArithmeticF[A] final case class NumberF[A](v: Double) extends ArithmeticF[A] final case class AddF[A](a: A, b: A) extends ArithmeticF[A] @@ -31,8 +31,8 @@ final case class DivideF[A](a: A, b: A) extends ArithmeticF[A] So, everywhere that referred to `Arithmetic` before now just refers to `A`, and we can fill that with whatever type we want. And, with a type parameter, come the type class instances (this should be derivable, but doesn’t yet exist in shapeless-contrib) -```tut:book -import scalaz.{Divide => _, _}, Scalaz._ +```scala mdoc:silent +import scalaz._, Scalaz._ implicit val traverse: Traverse[ArithmeticF] = new Traverse[ArithmeticF] { def traverseImpl[G[_], A, B] @@ -40,7 +40,7 @@ implicit val traverse: Traverse[ArithmeticF] = new Traverse[ArithmeticF] { (f: A => G [B]) (implicit G: Applicative[G]) = fa match { - case NumberF(v) => G.point(NumberF(v)) + case NumberF(v) => G.point(NumberF(v)) case AddF(a, b) => (f(a) ⊛ f(b))(AddF(_, _)) case SubtractF(a, b) => (f(a) ⊛ f(b))(SubtractF(_, _)) case MultiplyF(a, b) => (f(a) ⊛ f(b))(MultiplyF(_, _)) @@ -51,14 +51,14 @@ implicit val traverse: Traverse[ArithmeticF] = new Traverse[ArithmeticF] { Now is when we start wanting to take advantage of Matryoshka, so let’s bring it into scope. -```tut:book +```scala mdoc:silent import matryoshka._ import matryoshka.implicits._ ``` Since you already have your recursive AST, you also have code that uses it, and the last thing you want to do when trying a new tool is have to rewrite the code you already have. So, we’ll keep your AST and your code – all you have to do is define the relationship between the original AST and the new one, which we’ll do like this: -```tut:book +```scala mdoc:silent val arithmeticCoalgebra: Coalgebra[ArithmeticF, Arithmetic] = { case Number(v) => NumberF(v) case Add(a, b) => AddF(a, b) @@ -83,8 +83,8 @@ All that this does is define the mapping between the directly-recursive structur With this relationship established, we now have access to all the power of recursion schemes. -```tut:book -val pprint: Algebra[ArithmeticF, String] = { +```scala mdoc:silent +val prettyPrint: Algebra[ArithmeticF, String] = { case NumberF(v) => v.toString case AddF(a, b) => s"($a) + ($b)" case SubtractF(a, b) => s"($a) - ($b)" @@ -93,15 +93,16 @@ val pprint: Algebra[ArithmeticF, String] = { } ``` -```tut +```scala mdoc val expr: Arithmetic = Add(Multiply(Number(3), Divide(Number(4), Number(5))), Number(6)) -Recursive[Arithmetic].cata(expr)(pprint) + +Recursive[Arithmetic].cata(expr)(prettyPrint) ``` **NB**: This is just a simple example. There are much better ways to print ASTs (which also take advantage of Matryoshka), but they are too complicated for this example. -```tut:book +```scala mdoc:silent val eval: Algebra[ArithmeticF, Double] = { case NumberF(v) => v case AddF(a, b) => a + b @@ -111,23 +112,23 @@ val eval: Algebra[ArithmeticF, Double] = { } ``` -```tut +```scala mdoc Recursive[Arithmetic].cata(expr)(eval) ``` So, that’s two simple examples where we don’t have to think about recursion at all – only one level of the operation at a time. But, we can now use this to gain some efficiency: -```tut +```scala mdoc Recursive[Arithmetic].cata( expr)( - Zip[Algebra[ArithmeticF, ?]].zip(eval, pprint)) + Zip[Algebra[ArithmeticF, ?]].zip(eval, prettyPrint)) ``` Now we’ve generated _both_ values, but we only traversed the tree once. This is a pattern we see a lot in recursion schemes – ways to compose operations at the algebra level, such that we can do multiple operations in a single pass. And there are a bunch of “algebra transformations”, which massage these algebras into the shapes needed for different kinds of composition, so you don’t need to think about that at the point at which the algebra is defined. -A better pprint: +A better `prettyPrint`: -```tut:book +```scala mdoc:silent val precedence: ArithmeticF[_] => Int = { case NumberF(_) => 0 case AddF(_, _) => 3 @@ -145,15 +146,17 @@ def buildOp s"$newA $op $newB" } -val pprintʹ: GAlgebra[(Int, ?), ArithmeticF, String] = { +val prettyPrintʹ: GAlgebra[(Int, ?), ArithmeticF, String] = { case NumberF(v) => v.toString case AddF(a, b) => buildOp(3, a, "+", b) case SubtractF(a, b) => buildOp(4, a, "-", b) case MultiplyF(a, b) => buildOp(1, a, "*", b) case DivideF(a, b) => buildOp(2, a, "/", b) } +``` -Recursive[Arithmetic].zygo(expr)(precedence, pprintʹ) +```scala mdoc +Recursive[Arithmetic].zygo(expr)(precedence, prettyPrintʹ) ``` And now our pretty-printer only inserts necessary parens. diff --git a/docs/src/main/tut/docs/03-Algebras.md b/docs/src/main/mdoc/docs/03-Algebras.md similarity index 96% rename from docs/src/main/tut/docs/03-Algebras.md rename to docs/src/main/mdoc/docs/03-Algebras.md index 69cbca1a..4bf7dcca 100644 --- a/docs/src/main/tut/docs/03-Algebras.md +++ b/docs/src/main/mdoc/docs/03-Algebras.md @@ -3,7 +3,7 @@ layout: docs title: Algebras --- -```tut:book +```scala mdoc import matryoshka._ import matryoshka.data._ import matryoshka.implicits._ @@ -16,7 +16,7 @@ or, “I know what algebra is, and these ain’t it.” The algebras (and coalgebras, etc.) are more properly known as “F-algebras”. To connect these back to the algebra we’re all generally familiar with from school, let’s look at a simple ADT – -```tut:silent +```scala mdoc:silent sealed trait Expr[A] final case class Mul[A](a: A, b: A) extends Expr[A] final case class Add[A](a: A, b: A) extends Expr[A] @@ -37,7 +37,7 @@ implicit val exprTraverse: Traverse[Expr] = new Traverse[Expr] { We can write out a simple expression -```tut:book +```scala mdoc:silent val expr = Add(Mul(Add(Num[Mu[Expr]](2).embed, Num[Mu[Expr]](3).embed).embed, Num[Mu[Expr]](4).embed).embed, Add(Mul(Num[Mu[Expr]](5).embed, Num[Mu[Expr]](6).embed).embed, Num[Mu[Expr]](7).embed).embed).embed ``` @@ -52,7 +52,7 @@ Now, how do we solve / evaluate this? If you’re anything like me, you take a f So, there are two aspects to this. First, there are some simple rules: -```tut:book +```scala mdoc:silent val eval: Algebra[Expr, Int] = { // 1. + means to add two numbers together case Add(x, y) => x + y @@ -66,7 +66,7 @@ Hey, look at that – this evaluation rule is an “algebra”. And it’s just The second aspect involves applying these rules from most deeply nested expressions out. -```tut:book +```scala mdoc expr.cata(eval) ``` There it is. You’ve got an algebra and applied it. diff --git a/docs/src/main/tut/docs/04-Recursion-Schemes.md b/docs/src/main/mdoc/docs/04-Recursion-Schemes.md similarity index 97% rename from docs/src/main/tut/docs/04-Recursion-Schemes.md rename to docs/src/main/mdoc/docs/04-Recursion-Schemes.md index 8af8e925..42c71b9c 100644 --- a/docs/src/main/tut/docs/04-Recursion-Schemes.md +++ b/docs/src/main/mdoc/docs/04-Recursion-Schemes.md @@ -3,11 +3,10 @@ layout: docs title: Recursion Schemes --- -```tut:book +```scala mdoc:silent import matryoshka._, implicits._, data._ -import scalaz._, Scalaz._ +import scalaz._ ``` - # {{ page.title }} @@ -25,7 +24,7 @@ Lets build an intuition of how each kind of scheme walks through a given recursi We'll use a very simple binary tree with `Int` labelling each node and leaf. -```tut:silent +```scala mdoc:silent sealed trait Tree[A] final case class Node[A](label: Int, left: A, right: A) extends Tree[A] final case class Leaf[A](label: Int) extends Tree[A] @@ -35,7 +34,7 @@ final case class EmptyTree[A]() extends Tree[A] To use that as our recursive structure, we'll need to provide at least a `Functor` instance for it (we'll see why this is important soon). Some schemes have greater needs and require a more powerful `Traverse` instance. -```tut:silent +```scala mdoc:silent implicit val treeFunctor: Functor[Tree] = new Functor[Tree] { def map[A, B](fa: Tree[A])(f: A => B): Tree[B] = fa match { case Node(label, l, r) => Node(label, f(l), f(r)) @@ -47,7 +46,7 @@ implicit val treeFunctor: Functor[Tree] = new Functor[Tree] { Now we can (almost) easily create a simple binary search tree: -```tut:silent +```scala mdoc:silent // 42 // / \ // 28 83 @@ -77,7 +76,7 @@ The simplest possible fold is `cata`. It applies an `Algebra[F, A]` "bottom-up" Let's use a (very) dirty trick to show in which order `cata` traverses the nodes of our above `tree`. -```tut:book +```scala mdoc // This is very bad! // Kids, don't use side-effects like this at home val printLabels: Algebra[Tree, Unit] = { @@ -99,7 +98,7 @@ Using a classic recursive approach, starting from a `Node`, we would recursively But recursion schemes are all about abstracting recursive traversals, right? So using `cata`, we only need to define **what** we want to do with each node of our tree, we don't need to specify **how** we traverse the whole tree. -```tut:silent +```scala mdoc:silent val merge: Algebra[Tree, List[Int]] = { case Node(i, l, r) => l ++ List(i) ++ r case Leaf(i) => List(i) @@ -107,7 +106,7 @@ val merge: Algebra[Tree, List[Int]] = { } ``` Using this algebra with a `cata` on our `tree` should yield the ordered list of the labels of each node/leaf. -```tut:book +```scala mdoc tree.cata(merge) ``` Tadaaaa! @@ -122,7 +121,7 @@ By duality, it's easy to see that unfolds work "top-down". In other words, an un For example, let's use an unfold to produce a binary search tree from a list of integers. Given a list, we partition its tail depending on whereas its elements are smaller or greater than the head of the original list. Using that we can build a `Node(head, smaller, greater)` and let `ana` recursively build trees for the `smaller` and `greater` list. -```tut:silent +```scala mdoc:silent val split: Coalgebra[Tree, List[Int]] = { case Nil => EmptyTree() case head :: Nil => Leaf(head) @@ -133,7 +132,7 @@ val split: Coalgebra[Tree, List[Int]] = { ``` If you squint hard enough, you might convince yourself that this indeed produces a binary search tree for our input list. -```tut:book +```scala mdoc List(42, 45, 28, 32, 12, 48).ana[Fix[Tree]](split) ``` @@ -147,7 +146,7 @@ In other words, in our tree example, `hylo` would only build a branch of the tre We can use the coalgebra and algebra we defined above to transform a `List[Int]` into a `List[Int]`, this would (partially) build a binary search tree from the input list and traverse the elements of that tree in ascending order, effecively sorting the whole list. -```tut:book +```scala mdoc List(42, 45, 28, 32, 42, 12, 48, 1, 64, 8, 0).hylo(merge, split) ``` diff --git a/docs/src/main/tut/index.md b/docs/src/main/mdoc/index.md similarity index 100% rename from docs/src/main/tut/index.md rename to docs/src/main/mdoc/index.md diff --git a/project/build.properties b/project/build.properties index c091b86c..c0bab049 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.16 +sbt.version=1.2.8 diff --git a/project/plugins.sbt b/project/plugins.sbt index 0cab992b..6f752381 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,9 +1,14 @@ resolvers += Resolver.sonatypeRepo("releases") +resolvers += Resolver.bintrayRepo("slamdata-inc", "maven-public") -addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.0.2") -addSbtPlugin("com.fortysevendeg" % "sbt-microsites" % "0.3.3") -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.22") +addSbtCoursier + +addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.6.0") + +addSbtPlugin("com.47deg" % "sbt-microsites" % "0.8.0") +addSbtPlugin("org.scalameta" % "sbt-mdoc" % "1.2.10") +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.26") addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.1") addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.3.2") -addSbtPlugin("com.slamdata" % "sbt-slamdata" % "0.5.6") -addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.1") +addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.2") +addSbtPlugin("com.slamdata" % "sbt-slamdata" % "2.4.1") diff --git a/project/project/plugins.sbt b/project/project/plugins.sbt new file mode 100644 index 00000000..1b456b5a --- /dev/null +++ b/project/project/plugins.sbt @@ -0,0 +1,5 @@ +resolvers += Resolver.sonatypeRepo("releases") +resolvers += Resolver.bintrayRepo("slamdata-inc", "maven-public") + +addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.1.0-M9") +//addSbtPlugin("com.slamdata" % "sbt-slamdata" % "2.4.1") diff --git a/scalacheck/shared/src/main/scala/matryoshka/scalacheck/arbitrary.scala b/scalacheck/shared/src/main/scala/matryoshka/scalacheck/arbitrary.scala index beec91f8..2be7f5f1 100644 --- a/scalacheck/shared/src/main/scala/matryoshka/scalacheck/arbitrary.scala +++ b/scalacheck/shared/src/main/scala/matryoshka/scalacheck/arbitrary.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/scalacheck/shared/src/main/scala/matryoshka/scalacheck/cogen.scala b/scalacheck/shared/src/main/scala/matryoshka/scalacheck/cogen.scala index 1b157712..55c4d1f3 100644 --- a/scalacheck/shared/src/main/scala/matryoshka/scalacheck/cogen.scala +++ b/scalacheck/shared/src/main/scala/matryoshka/scalacheck/cogen.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/scalacheck/shared/src/main/scala/matryoshka/scalacheck/shrink.scala b/scalacheck/shared/src/main/scala/matryoshka/scalacheck/shrink.scala index 4712eeb3..ce835dea 100644 --- a/scalacheck/shared/src/main/scala/matryoshka/scalacheck/shrink.scala +++ b/scalacheck/shared/src/main/scala/matryoshka/scalacheck/shrink.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/data/fix.scala b/tests/shared/src/test/scala/matryoshka/data/fix.scala index ad8a04b8..76b439d2 100644 --- a/tests/shared/src/test/scala/matryoshka/data/fix.scala +++ b/tests/shared/src/test/scala/matryoshka/data/fix.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/data/mu.scala b/tests/shared/src/test/scala/matryoshka/data/mu.scala index 7d750f13..4cd5729d 100644 --- a/tests/shared/src/test/scala/matryoshka/data/mu.scala +++ b/tests/shared/src/test/scala/matryoshka/data/mu.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/data/nu.scala b/tests/shared/src/test/scala/matryoshka/data/nu.scala index ffd9e3ab..e1ab5220 100644 --- a/tests/shared/src/test/scala/matryoshka/data/nu.scala +++ b/tests/shared/src/test/scala/matryoshka/data/nu.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/example/Example.scala b/tests/shared/src/test/scala/matryoshka/example/Example.scala index c5283dba..dc6d8372 100644 --- a/tests/shared/src/test/scala/matryoshka/example/Example.scala +++ b/tests/shared/src/test/scala/matryoshka/example/Example.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/example/btree.scala b/tests/shared/src/test/scala/matryoshka/example/btree.scala index 8558904f..7e550789 100644 --- a/tests/shared/src/test/scala/matryoshka/example/btree.scala +++ b/tests/shared/src/test/scala/matryoshka/example/btree.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/example/expr.scala b/tests/shared/src/test/scala/matryoshka/example/expr.scala index 67fada7c..37b24082 100644 --- a/tests/shared/src/test/scala/matryoshka/example/expr.scala +++ b/tests/shared/src/test/scala/matryoshka/example/expr.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/example/intList.scala b/tests/shared/src/test/scala/matryoshka/example/intList.scala index 99f2ad95..a76105a2 100644 --- a/tests/shared/src/test/scala/matryoshka/example/intList.scala +++ b/tests/shared/src/test/scala/matryoshka/example/intList.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/example/mathExpr.scala b/tests/shared/src/test/scala/matryoshka/example/mathExpr.scala index ac18247f..63bcaa34 100644 --- a/tests/shared/src/test/scala/matryoshka/example/mathExpr.scala +++ b/tests/shared/src/test/scala/matryoshka/example/mathExpr.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/example/nat.scala b/tests/shared/src/test/scala/matryoshka/example/nat.scala index 462394f6..ffb970e8 100644 --- a/tests/shared/src/test/scala/matryoshka/example/nat.scala +++ b/tests/shared/src/test/scala/matryoshka/example/nat.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/exp/Exp.scala b/tests/shared/src/test/scala/matryoshka/exp/Exp.scala index 28bbdb0d..173e79c6 100644 --- a/tests/shared/src/test/scala/matryoshka/exp/Exp.scala +++ b/tests/shared/src/test/scala/matryoshka/exp/Exp.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/exp/package.scala b/tests/shared/src/test/scala/matryoshka/exp/package.scala index 400dac31..ee141438 100644 --- a/tests/shared/src/test/scala/matryoshka/exp/package.scala +++ b/tests/shared/src/test/scala/matryoshka/exp/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/exp2/Exp2.scala b/tests/shared/src/test/scala/matryoshka/exp2/Exp2.scala index 2aa8a7d4..d58f7238 100644 --- a/tests/shared/src/test/scala/matryoshka/exp2/Exp2.scala +++ b/tests/shared/src/test/scala/matryoshka/exp2/Exp2.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/exp2/package.scala b/tests/shared/src/test/scala/matryoshka/exp2/package.scala index 24e236f8..3437f7b0 100644 --- a/tests/shared/src/test/scala/matryoshka/exp2/package.scala +++ b/tests/shared/src/test/scala/matryoshka/exp2/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/helpers/AlgebraChecks.scala b/tests/shared/src/test/scala/matryoshka/helpers/AlgebraChecks.scala index 1df9c32a..78167182 100644 --- a/tests/shared/src/test/scala/matryoshka/helpers/AlgebraChecks.scala +++ b/tests/shared/src/test/scala/matryoshka/helpers/AlgebraChecks.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/helpers/package.scala b/tests/shared/src/test/scala/matryoshka/helpers/package.scala index 3d300274..7eb5c22e 100644 --- a/tests/shared/src/test/scala/matryoshka/helpers/package.scala +++ b/tests/shared/src/test/scala/matryoshka/helpers/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,11 +21,14 @@ import slamdata.Predef._ import matryoshka.exp._ import org.scalacheck._ -import org.specs2.mutable._ -import org.typelevel.discipline.specs2.mutable._ import scalaz._, Scalaz._ -package object helpers extends SpecificationLike with Discipline { +package object helpers { + implicit object apGen extends Applicative[Gen] { + override def point[A](a: => A): Gen[A] = Gen.delay(Gen.const(a)) + override def ap[A, B](fa: => Gen[A])(f: => Gen[A => B]): Gen[B] = fa.flatMap(a => f.map(fn => fn(a))) + } + def foldableCogen[F[_]: Foldable]: Delay[Cogen, F] = new Delay[Cogen, F] { def apply[A](cog: Cogen[A]): Cogen[F[A]] = diff --git a/tests/shared/src/test/scala/matryoshka/instances/fixedpoint/list.scala b/tests/shared/src/test/scala/matryoshka/instances/fixedpoint/list.scala index 5dc502b8..68a9f9f4 100644 --- a/tests/shared/src/test/scala/matryoshka/instances/fixedpoint/list.scala +++ b/tests/shared/src/test/scala/matryoshka/instances/fixedpoint/list.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/instances/fixedpoint/nat.scala b/tests/shared/src/test/scala/matryoshka/instances/fixedpoint/nat.scala index 17fb7dd1..08bdc93f 100644 --- a/tests/shared/src/test/scala/matryoshka/instances/fixedpoint/nat.scala +++ b/tests/shared/src/test/scala/matryoshka/instances/fixedpoint/nat.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/instances/fixedpoint/partial.scala b/tests/shared/src/test/scala/matryoshka/instances/fixedpoint/partial.scala index ee0d12c9..f729cfe0 100644 --- a/tests/shared/src/test/scala/matryoshka/instances/fixedpoint/partial.scala +++ b/tests/shared/src/test/scala/matryoshka/instances/fixedpoint/partial.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/instances/fixedpoint/stream.scala b/tests/shared/src/test/scala/matryoshka/instances/fixedpoint/stream.scala index 80e3994d..30f6ef6c 100644 --- a/tests/shared/src/test/scala/matryoshka/instances/fixedpoint/stream.scala +++ b/tests/shared/src/test/scala/matryoshka/instances/fixedpoint/stream.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/patterns/andMaybe.scala b/tests/shared/src/test/scala/matryoshka/patterns/andMaybe.scala index b8228468..a602a9dd 100644 --- a/tests/shared/src/test/scala/matryoshka/patterns/andMaybe.scala +++ b/tests/shared/src/test/scala/matryoshka/patterns/andMaybe.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/patterns/coenv.scala b/tests/shared/src/test/scala/matryoshka/patterns/coenv.scala index 456e811e..ae81913d 100644 --- a/tests/shared/src/test/scala/matryoshka/patterns/coenv.scala +++ b/tests/shared/src/test/scala/matryoshka/patterns/coenv.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/patterns/diff.scala b/tests/shared/src/test/scala/matryoshka/patterns/diff.scala index 504a4472..8c485d76 100644 --- a/tests/shared/src/test/scala/matryoshka/patterns/diff.scala +++ b/tests/shared/src/test/scala/matryoshka/patterns/diff.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/patterns/envt.scala b/tests/shared/src/test/scala/matryoshka/patterns/envt.scala index 55b03680..487593f2 100644 --- a/tests/shared/src/test/scala/matryoshka/patterns/envt.scala +++ b/tests/shared/src/test/scala/matryoshka/patterns/envt.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/patterns/listF.scala b/tests/shared/src/test/scala/matryoshka/patterns/listF.scala index baca72fc..2e55ae19 100644 --- a/tests/shared/src/test/scala/matryoshka/patterns/listF.scala +++ b/tests/shared/src/test/scala/matryoshka/patterns/listF.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/patterns/potentialFailure.scala b/tests/shared/src/test/scala/matryoshka/patterns/potentialFailure.scala index 8d5cdab0..37a9b707 100644 --- a/tests/shared/src/test/scala/matryoshka/patterns/potentialFailure.scala +++ b/tests/shared/src/test/scala/matryoshka/patterns/potentialFailure.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/runners/BirecRunner.scala b/tests/shared/src/test/scala/matryoshka/runners/BirecRunner.scala index 79af729b..4399f5ff 100644 --- a/tests/shared/src/test/scala/matryoshka/runners/BirecRunner.scala +++ b/tests/shared/src/test/scala/matryoshka/runners/BirecRunner.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/runners/CorecRunner.scala b/tests/shared/src/test/scala/matryoshka/runners/CorecRunner.scala index ccb2859c..a03f490a 100644 --- a/tests/shared/src/test/scala/matryoshka/runners/CorecRunner.scala +++ b/tests/shared/src/test/scala/matryoshka/runners/CorecRunner.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/runners/RecRunner.scala b/tests/shared/src/test/scala/matryoshka/runners/RecRunner.scala index b664722c..40f42708 100644 --- a/tests/shared/src/test/scala/matryoshka/runners/RecRunner.scala +++ b/tests/shared/src/test/scala/matryoshka/runners/RecRunner.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/tests/shared/src/test/scala/matryoshka/runners/package.scala b/tests/shared/src/test/scala/matryoshka/runners/package.scala index e17cfbb6..f9ffe76e 100644 --- a/tests/shared/src/test/scala/matryoshka/runners/package.scala +++ b/tests/shared/src/test/scala/matryoshka/runners/package.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,10 +21,11 @@ import matryoshka.implicits._ import org.specs2.execute._ import org.specs2.matcher._ -import org.specs2.mutable.SpecificationLike import scalaz._ -package object runners extends SpecificationLike { +package object runners { + import MatchResultCombinators._ + def testRec[F[_], A](t: Fix[F], r: RecRunner[F, A])(implicit F: Functor[F]) : MatchResult[A] = { r.run[Fix[F]].apply(t) and diff --git a/tests/shared/src/test/scala/matryoshka/spec.scala b/tests/shared/src/test/scala/matryoshka/spec.scala index 2acc4a47..d1f549de 100644 --- a/tests/shared/src/test/scala/matryoshka/spec.scala +++ b/tests/shared/src/test/scala/matryoshka/spec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -36,7 +36,7 @@ import org.typelevel.discipline.specs2.mutable._ import scalaz.{Apply => _, _}, Scalaz._ import scalaz.scalacheck.ScalazProperties._ -class ExpSpec extends Specification { +class ExpSpec extends Specification with Discipline { // NB: These are just a sanity check that the data structure created for the // tests is lawful. "Exp" >> { diff --git a/tests/shared/src/test/scala/matryoshka/zygoSpec.scala b/tests/shared/src/test/scala/matryoshka/zygoSpec.scala index d6991710..e06577c8 100644 --- a/tests/shared/src/test/scala/matryoshka/zygoSpec.scala +++ b/tests/shared/src/test/scala/matryoshka/zygoSpec.scala @@ -1,5 +1,5 @@ /* - * Copyright 2014–2017 SlamData Inc. + * Copyright 2014–2018 SlamData Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. From fbfade864b6349d995a442afeac09c1e549f43bc Mon Sep 17 00:00:00 2001 From: David Hoyt Date: Thu, 21 Feb 2019 13:45:50 -0800 Subject: [PATCH 2/8] Address wart remover issues and provide return types for public methods. --- .../src/main/scala/matryoshka/Based.scala | 3 + .../main/scala/matryoshka/Birecursive.scala | 7 +- .../main/scala/matryoshka/BirecursiveT.scala | 2 +- .../main/scala/matryoshka/CorecursiveT.scala | 2 +- .../src/main/scala/matryoshka/EqualT.scala | 1 + .../src/main/scala/matryoshka/Merge.scala | 1 + .../src/main/scala/matryoshka/Recursive.scala | 11 ++- .../main/scala/matryoshka/RecursiveT.scala | 2 +- .../src/main/scala/matryoshka/ShowT.scala | 1 + .../scala/matryoshka/implicits/IdOps.scala | 30 +++---- .../scala/matryoshka/implicits/package.scala | 3 +- .../instances/fixedpoint/package.scala | 48 +++++----- .../src/main/scala/matryoshka/package.scala | 89 ++++++++++--------- .../scala/matryoshka/patterns/AndMaybe.scala | 9 +- .../scala/matryoshka/patterns/CoEnv.scala | 11 +-- .../scala/matryoshka/patterns/Diffable.scala | 3 + .../main/scala/matryoshka/patterns/EnvT.scala | 13 +-- .../scala/matryoshka/patterns/ListF.scala | 15 ++-- .../scala/matryoshka/scalacheck/shrink.scala | 6 +- 19 files changed, 141 insertions(+), 116 deletions(-) diff --git a/core/shared/src/main/scala/matryoshka/Based.scala b/core/shared/src/main/scala/matryoshka/Based.scala index 1bbfe7ae..697b63cc 100644 --- a/core/shared/src/main/scala/matryoshka/Based.scala +++ b/core/shared/src/main/scala/matryoshka/Based.scala @@ -27,3 +27,6 @@ import simulacrum.typeclass @typeclass trait Based[T] { type Base[A] } + +@java.lang.SuppressWarnings(scala.Array("org.wartremover.warts.PublicInference")) +object Based diff --git a/core/shared/src/main/scala/matryoshka/Birecursive.scala b/core/shared/src/main/scala/matryoshka/Birecursive.scala index 7a912adc..9952d469 100644 --- a/core/shared/src/main/scala/matryoshka/Birecursive.scala +++ b/core/shared/src/main/scala/matryoshka/Birecursive.scala @@ -191,10 +191,10 @@ object Birecursive { def embed(ft: F[T])(implicit F: Functor[F]) = φ(ft) } - def iso[T, F[_]: Functor](implicit T: Birecursive.Aux[T, F]) = + def iso[T, F[_]: Functor](implicit T: Birecursive.Aux[T, F]): AlgebraIso[F, T] = AlgebraIso[F, T](T.embed(_))(T.project(_)) - def lambekIso[T, F[_]: Functor](implicit T: Birecursive.Aux[T, F]) = + def lambekIso[T, F[_]: Functor](implicit T: Birecursive.Aux[T, F]): AlgebraIso[F, T] = AlgebraIso[F, T](T.colambek(_))(T.lambek(_)) def equal[T, F[_]: Traverse] @@ -257,7 +257,8 @@ object Birecursive { : M[T] = typeClassInstance.topDownCataM[M, A](self, a)(f) object transPrepro { - def apply[U] = new PartiallyApplied[U] + def apply[U]: PartiallyApplied[U] = new PartiallyApplied[U] + final class PartiallyApplied[U] { def apply[G[_]: Functor] (e: F ~> F, f: Transform[U, F, G]) diff --git a/core/shared/src/main/scala/matryoshka/BirecursiveT.scala b/core/shared/src/main/scala/matryoshka/BirecursiveT.scala index 5ae29137..ce525ba3 100644 --- a/core/shared/src/main/scala/matryoshka/BirecursiveT.scala +++ b/core/shared/src/main/scala/matryoshka/BirecursiveT.scala @@ -25,5 +25,5 @@ package matryoshka trait BirecursiveT[T[_[_]]] extends RecursiveT[T] with CorecursiveT[T] object BirecursiveT { - def apply[T[_[_]]](implicit instance: BirecursiveT[T]) = instance + def apply[T[_[_]]](implicit instance: BirecursiveT[T]): BirecursiveT[T] = instance } diff --git a/core/shared/src/main/scala/matryoshka/CorecursiveT.scala b/core/shared/src/main/scala/matryoshka/CorecursiveT.scala index daefb9fc..bc7d6b81 100644 --- a/core/shared/src/main/scala/matryoshka/CorecursiveT.scala +++ b/core/shared/src/main/scala/matryoshka/CorecursiveT.scala @@ -31,5 +31,5 @@ trait CorecursiveT[T[_[_]]] { } object CorecursiveT { - def apply[T[_[_]]](implicit instance: CorecursiveT[T]) = instance + def apply[T[_[_]]](implicit instance: CorecursiveT[T]): CorecursiveT[T] = instance } diff --git a/core/shared/src/main/scala/matryoshka/EqualT.scala b/core/shared/src/main/scala/matryoshka/EqualT.scala index e67a77fc..b626b183 100644 --- a/core/shared/src/main/scala/matryoshka/EqualT.scala +++ b/core/shared/src/main/scala/matryoshka/EqualT.scala @@ -30,6 +30,7 @@ import simulacrum._ Equal.equal[T[F]](equal[F](_, _)(Functor[F], delay)) } +@java.lang.SuppressWarnings(scala.Array("org.wartremover.warts.PublicInference")) object EqualT { def recursiveT[T[_[_]]: RecursiveT]: EqualT[T] = new EqualT[T] { def equal[F[_]: Functor] diff --git a/core/shared/src/main/scala/matryoshka/Merge.scala b/core/shared/src/main/scala/matryoshka/Merge.scala index 9369a6ba..cbfa80fa 100644 --- a/core/shared/src/main/scala/matryoshka/Merge.scala +++ b/core/shared/src/main/scala/matryoshka/Merge.scala @@ -35,6 +35,7 @@ import scalaz._, Scalaz._ merge(fa, fb).map(_ ∘ g.tupled) } +@java.lang.SuppressWarnings(scala.Array("org.wartremover.warts.PublicInference")) object Merge { implicit def fromTraverse[F[_]: Traverse](implicit E: Equal[F[Unit]]): Merge[F] = diff --git a/core/shared/src/main/scala/matryoshka/Recursive.scala b/core/shared/src/main/scala/matryoshka/Recursive.scala index cdc25ba1..f989f20e 100644 --- a/core/shared/src/main/scala/matryoshka/Recursive.scala +++ b/core/shared/src/main/scala/matryoshka/Recursive.scala @@ -171,7 +171,7 @@ trait Recursive[T] extends Based[T] { self => def gcataZygo[W[_]: Comonad, A, B] (t: T) (k: DistributiveLaw[Base, W], f: GAlgebra[W, Base, B], g: GAlgebra[(B, ?), Base, A]) - (implicit BF: Functor[Base], BU: Unzip[Base]) = + (implicit BF: Functor[Base], BU: Unzip[Base]): A = gcata[(W[B], ?), A]( t)( distZygo(fwa => k(fwa.map(_.cojoin)).map(f)), @@ -506,7 +506,8 @@ object Recursive { typeClassInstance.convertTo[R](self) object transCata { - def apply[U] = new PartiallyApplied[U] + def apply[U]: PartiallyApplied[U] = new PartiallyApplied[U] + final class PartiallyApplied[U] { def apply[G[_]: Functor] (f: F[U] => G[U]) @@ -517,7 +518,8 @@ object Recursive { } object transPostpro { - def apply[U] = new PartiallyApplied[U] + def apply[U]: PartiallyApplied[U] = new PartiallyApplied[U] + final class PartiallyApplied[U] { def apply[G[_]: Functor] (e: G ~> G, f: Transform[T, F, G]) @@ -528,7 +530,8 @@ object Recursive { } object transPara { - def apply[U] = new PartiallyApplied[U] + def apply[U]: PartiallyApplied[U] = new PartiallyApplied[U] + final class PartiallyApplied[U] { def apply[G[_]: Functor] (f: AlgebraicGTransform[(T, ?), U, F, G]) diff --git a/core/shared/src/main/scala/matryoshka/RecursiveT.scala b/core/shared/src/main/scala/matryoshka/RecursiveT.scala index 89c3e0c0..bd64107b 100644 --- a/core/shared/src/main/scala/matryoshka/RecursiveT.scala +++ b/core/shared/src/main/scala/matryoshka/RecursiveT.scala @@ -35,5 +35,5 @@ trait RecursiveT[T[_[_]]] extends Serializable { } object RecursiveT { - def apply[T[_[_]]](implicit instance: RecursiveT[T]) = instance + def apply[T[_[_]]](implicit instance: RecursiveT[T]): RecursiveT[T] = instance } diff --git a/core/shared/src/main/scala/matryoshka/ShowT.scala b/core/shared/src/main/scala/matryoshka/ShowT.scala index aae79e66..351882ec 100644 --- a/core/shared/src/main/scala/matryoshka/ShowT.scala +++ b/core/shared/src/main/scala/matryoshka/ShowT.scala @@ -34,6 +34,7 @@ import simulacrum._ Show.show[T[F]](show[F](_)(Functor[F], delay)) } +@java.lang.SuppressWarnings(scala.Array("org.wartremover.warts.PublicInference")) object ShowT { def recursiveT[T[_[_]]: RecursiveT]: ShowT[T] = new ShowT[T] { override def show[F[_]: Functor](tf: T[F])(implicit del: Delay[Show, F]) = diff --git a/core/shared/src/main/scala/matryoshka/implicits/IdOps.scala b/core/shared/src/main/scala/matryoshka/implicits/IdOps.scala index c7aac6d8..35d88f18 100644 --- a/core/shared/src/main/scala/matryoshka/implicits/IdOps.scala +++ b/core/shared/src/main/scala/matryoshka/implicits/IdOps.scala @@ -29,7 +29,7 @@ sealed class IdOps[A](self: A) { matryoshka.hyloM(self)(f, g) object ghylo { - def apply[W[_], N[_]] = new PartiallyApplied[W, N] + def apply[W[_], N[_]]: PartiallyApplied[W, N] = new PartiallyApplied[W, N] final class PartiallyApplied[W[_], N[_]] { def apply[F[_]: Functor, B] @@ -37,7 +37,7 @@ sealed class IdOps[A](self: A) { n: DistributiveLaw[N, F], f: GAlgebra[W, F, B], g: GCoalgebra[N, F, A]) - (implicit W: Comonad[W], N: Monad[N]) = + (implicit W: Comonad[W], N: Monad[N]): B = matryoshka.ghylo(self)(w, n, f, g) } } @@ -71,7 +71,7 @@ sealed class IdOps[A](self: A) { matryoshka.coelgot(self)(φ, ψ) object coelgotM { - def apply[M[_]] = new PartiallyApplied[M] + def apply[M[_]]: PartiallyApplied[M] = new PartiallyApplied[M] final class PartiallyApplied[M[_]] { def apply[F[_]: Traverse, B](φ: ElgotAlgebraM[(A, ?), M, F, B], ψ: CoalgebraM[M, F, A])(implicit M: Monad[M]): @@ -81,7 +81,7 @@ sealed class IdOps[A](self: A) { } object ana { - def apply[T] = new PartiallyApplied[T] + def apply[T]: PartiallyApplied[T] = new PartiallyApplied[T] final class PartiallyApplied[T] { def apply[F[_]: Functor] @@ -93,7 +93,7 @@ sealed class IdOps[A](self: A) { } object anaM { - def apply[T] = new PartiallyApplied[T] + def apply[T]: PartiallyApplied[T] = new PartiallyApplied[T] final class PartiallyApplied[T] { def apply[M[_]: Monad, F[_]: Traverse] @@ -105,7 +105,7 @@ sealed class IdOps[A](self: A) { } object gana { - def apply[T] = new PartiallyApplied[T] + def apply[T]: PartiallyApplied[T] = new PartiallyApplied[T] final class PartiallyApplied[T] { def apply[N[_]: Monad, F[_]: Functor] @@ -117,7 +117,7 @@ sealed class IdOps[A](self: A) { } object ganaM { - def apply[T] = new PartiallyApplied[T] + def apply[T]: PartiallyApplied[T] = new PartiallyApplied[T] final class PartiallyApplied[T] { def apply[N[_]: Monad: Traverse, M[_]: Monad, F[_]: Traverse] @@ -129,7 +129,7 @@ sealed class IdOps[A](self: A) { } object elgotAna { - def apply[T] = new PartiallyApplied[T] + def apply[T]: PartiallyApplied[T] = new PartiallyApplied[T] final class PartiallyApplied[T] { def apply[N[_]: Monad, F[_]: Functor] @@ -141,7 +141,7 @@ sealed class IdOps[A](self: A) { } object apo { - def apply[T] = new PartiallyApplied[T] + def apply[T]: PartiallyApplied[T] = new PartiallyApplied[T] final class PartiallyApplied[T] { def apply[F[_]: Functor] @@ -153,7 +153,7 @@ sealed class IdOps[A](self: A) { } object apoM { - def apply[T] = new PartiallyApplied[T] + def apply[T]: PartiallyApplied[T] = new PartiallyApplied[T] final class PartiallyApplied[T] { def apply[M[_]: Monad, F[_]: Traverse] @@ -165,7 +165,7 @@ sealed class IdOps[A](self: A) { } object gapo { - def apply[T] = new PartiallyApplied[T] + def apply[T]: PartiallyApplied[T] = new PartiallyApplied[T] final class PartiallyApplied[T] { def apply[F[_]: Functor, B] @@ -177,7 +177,7 @@ sealed class IdOps[A](self: A) { } object elgotApo { - def apply[T] = new PartiallyApplied[T] + def apply[T]: PartiallyApplied[T] = new PartiallyApplied[T] final class PartiallyApplied[T] { def apply[F[_]: Functor] @@ -189,7 +189,7 @@ sealed class IdOps[A](self: A) { } object postpro { - def apply[T] = new PartiallyApplied[T] + def apply[T]: PartiallyApplied[T] = new PartiallyApplied[T] final class PartiallyApplied[T] { def apply[F[_]: Functor] @@ -201,7 +201,7 @@ sealed class IdOps[A](self: A) { } object gpostpro { - def apply[T] = new PartiallyApplied[T] + def apply[T]: PartiallyApplied[T] = new PartiallyApplied[T] final class PartiallyApplied[T] { def apply[N[_]: Monad, F[_]: Functor] @@ -213,7 +213,7 @@ sealed class IdOps[A](self: A) { } object futu { - def apply[T] = new PartiallyApplied[T] + def apply[T]: PartiallyApplied[T] = new PartiallyApplied[T] final class PartiallyApplied[T] { def apply[F[_]: Functor] diff --git a/core/shared/src/main/scala/matryoshka/implicits/package.scala b/core/shared/src/main/scala/matryoshka/implicits/package.scala index 43d584a9..7ec92749 100644 --- a/core/shared/src/main/scala/matryoshka/implicits/package.scala +++ b/core/shared/src/main/scala/matryoshka/implicits/package.scala @@ -48,7 +48,8 @@ package object implicits matryoshka.transHylo(self)(φ, ψ) object transAna { - def apply[U] = new PartiallyApplied[U] + def apply[U]: PartiallyApplied[U] = new PartiallyApplied[U] + final class PartiallyApplied[U] { def apply[G[_]: Functor] (f: F[T] => G[T]) diff --git a/core/shared/src/main/scala/matryoshka/instances/fixedpoint/package.scala b/core/shared/src/main/scala/matryoshka/instances/fixedpoint/package.scala index a4a2dd42..70c15307 100644 --- a/core/shared/src/main/scala/matryoshka/instances/fixedpoint/package.scala +++ b/core/shared/src/main/scala/matryoshka/instances/fixedpoint/package.scala @@ -36,38 +36,38 @@ package object fixedpoint { type Nat = Mu[Option] object Nat { - def zero[N](implicit N: Corecursive.Aux[N, Option]) = none[N].embed + def zero[N](implicit N: Corecursive.Aux[N, Option]): N = none[N].embed - def succ[N](prev: N)(implicit N: Corecursive.Aux[N, Option]) = + def succ[N](prev: N)(implicit N: Corecursive.Aux[N, Option]): N = some(prev).embed - def one[N](implicit N: Corecursive.Aux[N, Option]) = succ(zero) + def one[N](implicit N: Corecursive.Aux[N, Option]): N = succ(zero) val fromInt: CoalgebraM[Option, Option, Int] = x => if (x < 0) None else Some(if (x > 0) (x - 1).some else None) // NB: This isn’t defined via `AlgebraPrism` because it only holds across a // recursive structure. - def intPrism[T](implicit T: Birecursive.Aux[T, Option]) = + def intPrism[T](implicit T: Birecursive.Aux[T, Option]): Prism[Int, T] = Prism[Int, T](_.anaM[T](fromInt))(_.cata(height)) } implicit class RecursiveOptionOps[T] (self: T) (implicit T: Recursive.Aux[T, Option]) { - def toInt = self.cata(height) + def toInt: Int = self.cata(height) } implicit class CorecursiveOptionOps[T] (self: T) (implicit T: Corecursive.Aux[T, Option]) { - def succ = Nat.succ(self) + def succ: T = Nat.succ(self) } implicit class BirecursiveOptionOps[T] (self: T) (implicit T: Birecursive.Aux[T, Option]) { - def +(other: T) = other.cata[T] { + def +(other: T): T = other.cata[T] { case None => self case o => o.embed } @@ -84,21 +84,24 @@ package object fixedpoint { type Cofree[F[_], A] = Mu[EnvT[A, F, ?]] type List[A] = Mu[ListF[A, ?]] object List { - def apply[A](elems: A*) = + def apply[A](elems: A*): List[A] = elems.toList.ana[Mu[ListF[A, ?]]](ListF.listIso[A].reverseGet) - def tuple[A](elem: => A) = λ[Option ~> ListF[A, ?]] { - case None => NilF() - case Some(b) => ConsF(elem, b) - } + def tuple[A](elem: => A): Option ~> ListF[A, ?] = + λ[Option ~> ListF[A, ?]] { + case None => NilF() + case Some(b) => ConsF(elem, b) + } - def forget[A] = λ[ListF[A, ?] ~> Option] { - case NilF() => None - case ConsF(_, t) => t.some - } + def forget[A]: ListF[A, ?] ~> Option = + λ[ListF[A, ?] ~> Option] { + case NilF() => None + case ConsF(_, t) => t.some + } object fill { - def apply[L] = new PartiallyApplied[L] + def apply[L]: PartiallyApplied[L] = new PartiallyApplied[L] + class PartiallyApplied[L] { def apply[N, A] (n: N) @@ -171,7 +174,7 @@ package object fixedpoint { implicit class RecursiveAndMaybeOps[T, A] (self: T) (implicit T: Recursive.Aux[T, AndMaybe[A, ?]]) { - def toPossiblyEmpty[L](implicit L: Corecursive.Aux[L, ListF[A, ?]]) = + def toPossiblyEmpty[L](implicit L: Corecursive.Aux[L, ListF[A, ?]]): L = self.transApo[L, ListF[A, ?]] { case Indeed(a, b) => ConsF(a, b.right) case Only(a) => ConsF(a, NilF[A, L]().embed.left) @@ -183,7 +186,7 @@ package object fixedpoint { type Stream[A] = Nu[(A, ?)] object Stream { - def matchesFirst[A, B](cond: A => Boolean) = + def matchesFirst[A, B](cond: A => Boolean): (A, ?) ~> (A \/ ?) = λ[(A, ?) ~> (A \/ ?)] { case (h, t) => if (cond(h)) h.left else t.right } @@ -201,9 +204,9 @@ package object fixedpoint { /** Colists are simply streams that may terminate, so a stream is easily * converted to a Colist that doesn’t terminate. */ - def toConsF[A] = λ[(A, ?) ~> ListF[A, ?]](p => ConsF(p._1, p._2)) + def toConsF[A]: (A, ?) ~> ListF[A, ?] = λ[(A, ?) ~> ListF[A, ?]](p => ConsF(p._1, p._2)) - def toIndeed[A] = λ[(A, ?) ~> AndMaybe[A, ?]](p => Indeed(p._1, p._2)) + def toIndeed[A]: (A, ?) ~> AndMaybe[A, ?] = λ[(A, ?) ~> AndMaybe[A, ?]](p => Indeed(p._1, p._2)) } implicit class RecursiveTuple2Ops[T, A](self: T)(implicit T: Recursive.Aux[T, (A, ?)]) { @@ -239,7 +242,8 @@ package object fixedpoint { }.merge object take { - def apply[L] = new PartiallyApplied[L] + def apply[L]: PartiallyApplied[L] = new PartiallyApplied[L] + class PartiallyApplied[L] { def apply[N](n: N)(implicit N: Recursive.Aux[N, Option], L: Corecursive.Aux[L, ListF[A, ?]]) : L = diff --git a/core/shared/src/main/scala/matryoshka/package.scala b/core/shared/src/main/scala/matryoshka/package.scala index 4061875f..5b546129 100644 --- a/core/shared/src/main/scala/matryoshka/package.scala +++ b/core/shared/src/main/scala/matryoshka/package.scala @@ -193,21 +193,21 @@ package object matryoshka { */ def foldIso[T, F[_]: Functor, A] (alg: AlgebraIso[F, A]) - (implicit T: Birecursive.Aux[T, F]) = + (implicit T: Birecursive.Aux[T, F]): Iso[T, A] = Iso[T, A](_.cata(alg.get))(_.ana[T](alg.reverseGet)) /** There is a fold prism for any AlgebraPrism. */ def foldPrism[T, F[_]: Traverse, A] (alg: AlgebraPrism[F, A]) - (implicit T: Birecursive.Aux[T, F]) = + (implicit T: Birecursive.Aux[T, F]): Prism[T, A] = Prism[T, A](T.cataM(_)(alg.getOption))(_.ana[T](alg.reverseGet)) /** There is an unfold prism for any CoalgebraPrism. */ def unfoldPrism[T, F[_]: Traverse, A] (coalg: CoalgebraPrism[F, A]) - (implicit T: Birecursive.Aux[T, F]) = + (implicit T: Birecursive.Aux[T, F]): Prism[A, T] = Prism[A, T](_.anaM[T](coalg.getOption))(_.cata(coalg.reverseGet)) /** A NaturalTransformation that sequences two types @@ -363,7 +363,8 @@ package object matryoshka { * @group refolds */ object coelgotM { - def apply[M[_]] = new PartiallyApplied[M] + def apply[M[_]]: PartiallyApplied[M] = new PartiallyApplied[M] + final class PartiallyApplied[M[_]] { def apply[F[_], A, B] (a: A) @@ -413,9 +414,9 @@ package object matryoshka { * * @group dist */ - def distApplicative[F[_]: Traverse, G[_]: Applicative] = + def distApplicative[F[_]: Traverse, G[_]: Applicative]: (F ∘ G)#λ ~> (G ∘ F)#λ = new DistributiveLaw[F, G] { - def apply[A](fga: F[G[A]]) = fga.sequence + def apply[A](fga: F[G[A]]): G[F[A]] = fga.sequence } /** A general [[DistributiveLaw]] for the case where the [[scalaz.Comonad]] is @@ -423,18 +424,18 @@ package object matryoshka { * * @group dist */ - def distDistributive[F[_]: Functor, G[_]: Distributive] = + def distDistributive[F[_]: Functor, G[_]: Distributive]: (F ∘ G)#λ ~> (G ∘ F)#λ = new DistributiveLaw[F, G] { - def apply[A](fga: F[G[A]]) = fga.cosequence + def apply[A](fga: F[G[A]]): G[F[A]] = fga.cosequence } /** * * @group dist */ - def distZygo[F[_]: Functor, B](g: Algebra[F, B]) = + def distZygo[F[_]: Functor, B](g: Algebra[F, B]): DistributiveLaw[F, (B, ?)] = new DistributiveLaw[F, (B, ?)] { - def apply[α](m: F[(B, α)]) = (g(m ∘ (_._1)), m ∘ (_._2)) + def apply[α](m: F[(B, α)]): (B, F[α]) = (g(m ∘ (_._1)), m ∘ (_._2)) } /** @@ -442,9 +443,9 @@ package object matryoshka { * @group dist */ def distZygoM[F[_]: Functor, M[_]: Monad, B]( - g: AlgebraM[M, F, B], k: DistributiveLaw[F, M]) = + g: AlgebraM[M, F, B], k: DistributiveLaw[F, M]): DistributiveLaw[F, (M ∘ (B, ?))#λ] = new DistributiveLaw[F, (M ∘ (B, ?))#λ] { - def apply[α](fm: F[M[(B, α)]]) = { + def apply[α](fm: F[M[(B, α)]]): M[(B, F[α])] = { k(fm) >>= { f => g(f ∘ (_._1)) ∘ ((_, f ∘ (_._2))) } } } @@ -454,9 +455,9 @@ package object matryoshka { * @group dist */ def distZygoT[F[_]: Functor, W[_]: Comonad, B]( - g: Algebra[F, B], k: DistributiveLaw[F, W]) = + g: Algebra[F, B], k: DistributiveLaw[F, W]): DistributiveLaw[F, EnvT[B, W, ?]] = new DistributiveLaw[F, EnvT[B, W, ?]] { - def apply[α](fe: F[EnvT[B, W, α]]) = + def apply[α](fe: F[EnvT[B, W, α]]): EnvT[B, W, F[α]] = EnvT((g(fe ∘ (_.ask)), k(fe ∘ (_.lower)))) } @@ -464,9 +465,9 @@ package object matryoshka { * * @group dist */ - def distHisto[F[_]: Functor] = + def distHisto[F[_]: Functor]: DistributiveLaw[F, Cofree[F, ?]] = new DistributiveLaw[F, Cofree[F, ?]] { - def apply[α](m: F[Cofree[F, α]]) = + def apply[α](m: F[Cofree[F, α]]): Cofree[F, F[α]] = distGHisto[F, F](NaturalTransformation.refl[λ[α => F[F[α]]]]).apply(m) } @@ -477,9 +478,9 @@ package object matryoshka { // TODO: Should be able to generalize this over `Recursive.Aux[T, EnvT[…]]` // somehow, then it wouldn’t depend on Scalaz and would work with any // `Cofree` representation. - def distGHisto[F[_]: Functor, H[_]: Functor](k: DistributiveLaw[F, H]) = + def distGHisto[F[_]: Functor, H[_]: Functor](k: DistributiveLaw[F, H]): DistributiveLaw[F, Cofree[H, ?]] = new DistributiveLaw[F, Cofree[H, ?]] { - def apply[α](m: F[Cofree[H, α]]) = + def apply[α](m: F[Cofree[H, α]]): Cofree[H, F[α]] = Cofree.unfold(m)(as => (as ∘ (_.copure), k(as ∘ (_.tail)))) } @@ -501,9 +502,9 @@ package object matryoshka { * * @group dist */ - def distGApo[F[_]: Functor, B](g: Coalgebra[F, B]) = + def distGApo[F[_]: Functor, B](g: Coalgebra[F, B]): DistributiveLaw[B \/ ?, F] = new DistributiveLaw[B \/ ?, F] { - def apply[α](m: B \/ F[α]) = m.bitraverse(g(_), x => x) + def apply[α](m: B \/ F[α]): F[B \/ α] = m.bitraverse(g(_), x => x) } /** Allows for more complex unfolds, like @@ -512,9 +513,9 @@ package object matryoshka { * @group dist */ def distGApoT[F[_]: Functor, M[_]: Functor, B]( - g: Coalgebra[F, B], k: DistributiveLaw[M, F]) = + g: Coalgebra[F, B], k: DistributiveLaw[M, F]): DistributiveLaw[EitherT[M, B, ?], F] = new DistributiveLaw[EitherT[M, B, ?], F] { - def apply[α](m: EitherT[M, B, F[α]]) = + def apply[α](m: EitherT[M, B, F[α]]): F[EitherT[M, B, α]] = k(m.run.map(distGApo(g).apply(_))).map(EitherT(_)) } @@ -522,9 +523,9 @@ package object matryoshka { * * @group dist */ - def distFutu[F[_]: Functor] = + def distFutu[F[_]: Functor]: DistributiveLaw[Free[F, ?], F] = new DistributiveLaw[Free[F, ?], F] { - def apply[α](m: Free[F, F[α]]) = + def apply[α](m: Free[F, F[α]]): F[Free[F, α]] = distGFutu[F, F](NaturalTransformation.refl[λ[α => F[F[α]]]]).apply(m) } @@ -538,7 +539,7 @@ package object matryoshka { def distGFutu[H[_]: Functor, F[_]: Functor](k: DistributiveLaw[H, F]) : DistributiveLaw[Free[H, ?], F] = new DistributiveLaw[Free[H, ?], F] { - def apply[A](m: Free[H, F[A]]) = + def apply[A](m: Free[H, F[A]]): F[Free[H, A]] = m.cata[F[Free[H, A]]](_.run.fold(_ ∘ Free.point, k(_) ∘ Free.roll)) } @@ -574,7 +575,7 @@ package object matryoshka { * @group algtrans */ object attributeAlgebraM { - def apply[T] = new PartiallyApplied[T] + def apply[T]: PartiallyApplied[T] = new PartiallyApplied[T] final class PartiallyApplied[T] { def apply[F[_]: Functor, M[_]: Functor, A] @@ -590,7 +591,7 @@ package object matryoshka { * @group algtrans */ object attributeAlgebra { - def apply[T] = new PartiallyApplied[T] + def apply[T]: PartiallyApplied[T] = new PartiallyApplied[T] final class PartiallyApplied[T] { def apply[F[_]: Functor, A] @@ -628,7 +629,7 @@ package object matryoshka { * @group algtrans */ object attrK { - def apply[T] = new PartiallyApplied[T] + def apply[T]: PartiallyApplied[T] = new PartiallyApplied[T] final class PartiallyApplied[T] { def apply[F[_]: Functor, A] @@ -644,7 +645,7 @@ package object matryoshka { * @group algtrans */ object attrSelf { - def apply[T] = new PartiallyApplied[T] + def apply[T]: PartiallyApplied[T] = new PartiallyApplied[T] final class PartiallyApplied[T] { def apply[U, F[_]: Functor] @@ -659,7 +660,7 @@ package object matryoshka { * @group algtrans */ object attributeElgotM { - def apply[W[_], M[_], T] = new PartiallyApplied[W, M, T] + def apply[W[_], M[_], T]: PartiallyApplied[W, M, T] = new PartiallyApplied[W, M, T] final class PartiallyApplied[W[_], M[_], T] { def apply[F[_]: Functor, A] @@ -675,7 +676,7 @@ package object matryoshka { * @group algtrans */ object attributeElgot { - def apply[W[_], T] = new PartiallyApplied[W, T] + def apply[W[_], T]: PartiallyApplied[W, T] = new PartiallyApplied[W, T] final class PartiallyApplied[W[_], T] { def apply[F[_]: Functor, A] @@ -716,7 +717,7 @@ package object matryoshka { * * @group algtrans */ - implicit def AlgebraZip[F[_]: Functor] = GAlgebraZip[Id, F] + implicit def AlgebraZip[F[_]: Functor]: Zip[GAlgebra[Id, F, ?]] = GAlgebraZip[Id, F] /** * @@ -732,7 +733,7 @@ package object matryoshka { * * @group algtrans */ - implicit def ElgotAlgebraZip[W[_]: Functor, F[_]: Functor] = + implicit def ElgotAlgebraZip[W[_]: Functor, F[_]: Functor]: Zip[ElgotAlgebraM[W, Id, F, ?]] = ElgotAlgebraMZip[W, Id, F] // (ann, node) => node.unfzip.bimap(f(ann, _), g(ann, _)) @@ -745,7 +746,8 @@ package object matryoshka { * @group algtrans */ object repeatedly { - def apply[P] = new PartiallyApplied[P] + def apply[P]: PartiallyApplied[P] = new PartiallyApplied[P] + class PartiallyApplied[P] { def apply[A](f: A => Option[A])(implicit P: Corecursive.Aux[P, A \/ ?]) : A => P = @@ -783,7 +785,8 @@ package object matryoshka { * @group algebras */ object size { - def apply[N] = new PartiallyApplied[N] + def apply[N]: PartiallyApplied[N] = new PartiallyApplied[N] + class PartiallyApplied[N] { def apply[F[_]: Foldable](implicit N: Birecursive.Aux[N, Option]) : Algebra[F, N] = @@ -899,9 +902,9 @@ package object matryoshka { new Recursive[T[F]] { type Base[A] = F[A] - def project(t: T[F])(implicit F: Functor[F]) = + def project(t: T[F])(implicit F: Functor[F]): F[T[F]] = RecursiveT[T].projectT[F](t) - override def cata[A](t: T[F])(f: Algebra[F, A])(implicit F: Functor[F]) = + override def cata[A](t: T[F])(f: Algebra[F, A])(implicit F: Functor[F]): A = RecursiveT[T].cataT[F, A](t)(f) } @@ -909,9 +912,9 @@ package object matryoshka { new Corecursive[T[F]] { type Base[A] = F[A] - def embed(t: F[T[F]])(implicit F: Functor[F]) = + def embed(t: F[T[F]])(implicit F: Functor[F]): T[F] = CorecursiveT[T].embedT[F](t) - override def ana[A](a: A)(f: Coalgebra[F, A])(implicit F: Functor[F]) = + override def ana[A](a: A)(f: Coalgebra[F, A])(implicit F: Functor[F]): T[F] = CorecursiveT[T].anaT[F, A](a)(f) } @@ -919,14 +922,14 @@ package object matryoshka { new Birecursive[T[F]] { type Base[A] = F[A] - def project(t: T[F])(implicit F: Functor[F]) = + def project(t: T[F])(implicit F: Functor[F]): F[T[F]] = BirecursiveT[T].projectT[F](t) - override def cata[A](t: T[F])(f: Algebra[F, A])(implicit F: Functor[F]) = + override def cata[A](t: T[F])(f: Algebra[F, A])(implicit F: Functor[F]): A = BirecursiveT[T].cataT[F, A](t)(f) - def embed(t: F[T[F]])(implicit F: Functor[F]) = + def embed(t: F[T[F]])(implicit F: Functor[F]): T[F] = BirecursiveT[T].embedT[F](t) - override def ana[A](a: A)(f: Coalgebra[F, A])(implicit F: Functor[F]) = + override def ana[A](a: A)(f: Coalgebra[F, A])(implicit F: Functor[F]): T[F] = BirecursiveT[T].anaT[F, A](a)(f) } diff --git a/core/shared/src/main/scala/matryoshka/patterns/AndMaybe.scala b/core/shared/src/main/scala/matryoshka/patterns/AndMaybe.scala index e43b6ec7..462df682 100644 --- a/core/shared/src/main/scala/matryoshka/patterns/AndMaybe.scala +++ b/core/shared/src/main/scala/matryoshka/patterns/AndMaybe.scala @@ -37,10 +37,11 @@ final case class Indeed[A, B](h: A, t: B) extends AndMaybe[A, B] final case class Only[A, B](a: A) extends AndMaybe[A, B] object AndMaybe extends AndMaybeInstances { - def envTIso[A, B] = Iso[AndMaybe[A, B], EnvT[A, Option, B]] { - case Indeed(h, t) => EnvT((h, t.some)) - case Only(h) => EnvT((h, none)) - } (envt => envt.lower.fold[AndMaybe[A, B]](Only(envt.ask))(Indeed(envt.ask, _))) + def envTIso[A, B]: Iso[AndMaybe[A, B], EnvT[A, Option, B]] = + Iso[AndMaybe[A, B], EnvT[A, Option, B]] { + case Indeed(h, t) => EnvT((h, t.some)) + case Only(h) => EnvT((h, none)) + } (envt => envt.lower.fold[AndMaybe[A, B]](Only(envt.ask))(Indeed(envt.ask, _))) def find[A](p: A => Boolean): Algebra[AndMaybe[A, ?], Option[A]] = l => if (p(l.head)) some(l.head) else l.tailOption.join diff --git a/core/shared/src/main/scala/matryoshka/patterns/CoEnv.scala b/core/shared/src/main/scala/matryoshka/patterns/CoEnv.scala index f7adcb00..ac3cdaf5 100644 --- a/core/shared/src/main/scala/matryoshka/patterns/CoEnv.scala +++ b/core/shared/src/main/scala/matryoshka/patterns/CoEnv.scala @@ -26,16 +26,17 @@ final case class CoEnv[E, F[_], A](run: E \/ F[A]) object CoEnv extends CoEnvInstances { def coEnv[E, F[_], A](v: E \/ F[A]): CoEnv[E, F, A] = CoEnv(v) - def hmap[F[_], G[_], A](f: F ~> G) = + def hmap[F[_], G[_], A](f: F ~> G): CoEnv[A, F, ?] ~> CoEnv[A, G, ?] = λ[CoEnv[A, F, ?] ~> CoEnv[A, G, ?]](fa => CoEnv(fa.run.map(f(_)))) - def htraverse[G[_]: Applicative, F[_], H[_], A](f: F ~> (G ∘ H)#λ) = + def htraverse[G[_]: Applicative, F[_], H[_], A](f: F ~> (G ∘ H)#λ): CoEnv[A, F, ?] ~> (G ∘ CoEnv[A, H, ?])#λ = λ[CoEnv[A, F, ?] ~> (G ∘ CoEnv[A, H, ?])#λ]( _.run.traverse(f(_)).map(CoEnv(_))) - def freeIso[E, F[_]: Functor] = AlgebraIso[CoEnv[E, F, ?], Free[F, E]]( - coe => coe.run.fold(_.point[Free[F, ?]], Free.roll))( - fr => CoEnv(fr.fold(_.left, _.right))) + def freeIso[E, F[_]: Functor]: AlgebraIso[CoEnv[E, F, ?], Free[F, E]] = + AlgebraIso[CoEnv[E, F, ?], Free[F, E]]( + coe => coe.run.fold(_.point[Free[F, ?]], Free.roll))( + fr => CoEnv(fr.fold(_.left, _.right))) } sealed abstract class CoEnvInstances extends CoEnvInstances0 { diff --git a/core/shared/src/main/scala/matryoshka/patterns/Diffable.scala b/core/shared/src/main/scala/matryoshka/patterns/Diffable.scala index 0a84b0f6..24ab8fdd 100644 --- a/core/shared/src/main/scala/matryoshka/patterns/Diffable.scala +++ b/core/shared/src/main/scala/matryoshka/patterns/Diffable.scala @@ -63,3 +63,6 @@ import simulacrum._ DiffT[T, F] = LocallyDifferent[T, F, T[Diff[T, F, ?]]](diffTraverse[T, F](left, right), right.void).embed } + +@java.lang.SuppressWarnings(scala.Array("org.wartremover.warts.PublicInference")) +object Diffable diff --git a/core/shared/src/main/scala/matryoshka/patterns/EnvT.scala b/core/shared/src/main/scala/matryoshka/patterns/EnvT.scala index 64dae954..ba967033 100644 --- a/core/shared/src/main/scala/matryoshka/patterns/EnvT.scala +++ b/core/shared/src/main/scala/matryoshka/patterns/EnvT.scala @@ -36,13 +36,13 @@ final case class EnvT[E, W[_], A](run: (E, W[A])) { self => } object EnvT extends EnvTInstances with EnvTFunctions { - def hmap[F[_], G[_], E, A](f: F ~> G) = + def hmap[F[_], G[_], E, A](f: F ~> G): EnvT[E, F, ?] ~> EnvT[E, G, ?] = λ[EnvT[E, F, ?] ~> EnvT[E, G, ?]](env => EnvT((env.ask, f(env.lower)))) - def htraverse[G[_]: Applicative, F[_], H[_], A](f: F ~> (G ∘ H)#λ) = + def htraverse[G[_]: Applicative, F[_], H[_], A](f: F ~> (G ∘ H)#λ): EnvT[A, F, ?] ~> (G ∘ EnvT[A, H, ?])#λ = λ[EnvT[A, F, ?] ~> (G ∘ EnvT[A, H, ?])#λ](_.run.traverse(f(_)).map(EnvT(_))) - def lower[F[_], E] = λ[EnvT[E, F, ?] ~> F](_.lower) + def lower[F[_], E]: EnvT[E, F, ?] ~> F = λ[EnvT[E, F, ?] ~> F](_.lower) } sealed abstract class EnvTInstances1 { @@ -88,9 +88,10 @@ sealed abstract class EnvTInstances extends EnvTInstances0 { trait EnvTFunctions { def envT[E, W[_], A](v: (E, W[A])): EnvT[E, W, A] = EnvT(v) - def cofreeIso[E, W[_]] = AlgebraIso[EnvT[E, W, ?], Cofree[W, E]]( - et => Cofree(et.ask, et.lower))( - cof => EnvT((cof.head, cof.tail))) + def cofreeIso[E, W[_]]: AlgebraIso[EnvT[E, W, ?], Cofree[W, E]] = + AlgebraIso[EnvT[E, W, ?], Cofree[W, E]]( + et => Cofree(et.ask, et.lower))( + cof => EnvT((cof.head, cof.tail))) } // diff --git a/core/shared/src/main/scala/matryoshka/patterns/ListF.scala b/core/shared/src/main/scala/matryoshka/patterns/ListF.scala index 4f422c33..bbb45b46 100644 --- a/core/shared/src/main/scala/matryoshka/patterns/ListF.scala +++ b/core/shared/src/main/scala/matryoshka/patterns/ListF.scala @@ -36,13 +36,14 @@ final case class ConsF[A, B](car: A, cdr: B) extends ListF[A, B] final case class NilF[A, B]() extends ListF[A, B] object ListF { - def listIso[A] = AlgebraIso[ListF[A, ?], List[A]] { - case ConsF(h, t) => h :: t - case NilF() => Nil - } { - case h :: t => ConsF(h, t) - case Nil => NilF() - } + def listIso[A]: AlgebraIso[ListF[A, ?], List[A]] = + AlgebraIso[ListF[A, ?], List[A]] { + case ConsF(h, t) => h :: t + case NilF() => Nil + } { + case h :: t => ConsF(h, t) + case Nil => NilF() + } def takeUpTo[N, T, A](implicit N: Recursive.Aux[N, Option], T: Recursive.Aux[T, ListF[A, ?]]): Coalgebra[ListF[A, ?], (N, T)] = pair => pair._1.project.fold[ListF[A, (N, T)]](NilF())(p => pair._2.project.map((p, _))) diff --git a/scalacheck/shared/src/main/scala/matryoshka/scalacheck/shrink.scala b/scalacheck/shared/src/main/scala/matryoshka/scalacheck/shrink.scala index ce835dea..62d03eaa 100644 --- a/scalacheck/shared/src/main/scala/matryoshka/scalacheck/shrink.scala +++ b/scalacheck/shared/src/main/scala/matryoshka/scalacheck/shrink.scala @@ -53,13 +53,13 @@ trait ShrinkInstances extends ShrinkInstancesʹ { : Shrink[T] = Shrink(t => shrinkCorecursiveShrink[T, F].shrink(t) ++ recursiveShrink[T, F].shrink(t)) - implicit def fixShrink[F[_]: Functor: Foldable](implicit F: Shrink[F[Nu[F]]]): Shrink[Fix[F]] = + implicit def fixShrink[F[_]: Functor: Foldable]/*(implicit F: Shrink[F[Nu[F]]])*/: Shrink[Fix[F]] = corecursiveShrink[Fix[F], F] - implicit def muShrink[F[_]: Functor: Foldable](implicit F: Shrink[F[Nu[F]]]): Shrink[Mu[F]] = + implicit def muShrink[F[_]: Functor: Foldable]/*(implicit F: Shrink[F[Nu[F]]])*/: Shrink[Mu[F]] = corecursiveShrink[Mu[F], F] - implicit def nuShrink[F[_]: Functor: Foldable](implicit F: Shrink[F[Nu[F]]]): Shrink[Nu[F]] = + implicit def nuShrink[F[_]: Functor: Foldable]/*(implicit F: Shrink[F[Nu[F]]])*/: Shrink[Nu[F]] = corecursiveShrink[Nu[F], F] } From aa5ebd8b459e6080b46e82c8649170a9a47764ce Mon Sep 17 00:00:00 2001 From: David Hoyt Date: Thu, 21 Feb 2019 16:40:50 -0800 Subject: [PATCH 3/8] Remove unused implicits. --- core/shared/src/main/scala/matryoshka/Recursive.scala | 4 ++-- .../src/main/scala/matryoshka/implicits/AlgebraOps.scala | 2 +- core/shared/src/main/scala/matryoshka/package.scala | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/shared/src/main/scala/matryoshka/Recursive.scala b/core/shared/src/main/scala/matryoshka/Recursive.scala index f989f20e..2f2eba87 100644 --- a/core/shared/src/main/scala/matryoshka/Recursive.scala +++ b/core/shared/src/main/scala/matryoshka/Recursive.scala @@ -171,7 +171,7 @@ trait Recursive[T] extends Based[T] { self => def gcataZygo[W[_]: Comonad, A, B] (t: T) (k: DistributiveLaw[Base, W], f: GAlgebra[W, Base, B], g: GAlgebra[(B, ?), Base, A]) - (implicit BF: Functor[Base], BU: Unzip[Base]): A = + (implicit BF: Functor[Base]/*, BU: Unzip[Base]*/): A = gcata[(W[B], ?), A]( t)( distZygo(fwa => k(fwa.map(_.cojoin)).map(f)), @@ -445,7 +445,7 @@ object Recursive { typeClassInstance.ghisto(self)(g, f) def gcataZygo[W[_]: Comonad, A, B] (w: DistributiveLaw[F, W], f: GAlgebra[W, F, B], g: GAlgebra[(B, ?), F, A]) - (implicit BF: Functor[F], BU: Unzip[F]) + (implicit BF: Functor[F]/*, BU: Unzip[F]*/) : A = typeClassInstance.gcataZygo[W, A, B](self)(w, f, g) def paraZygo[A, B] diff --git a/core/shared/src/main/scala/matryoshka/implicits/AlgebraOps.scala b/core/shared/src/main/scala/matryoshka/implicits/AlgebraOps.scala index 1357b96c..74e2c58b 100644 --- a/core/shared/src/main/scala/matryoshka/implicits/AlgebraOps.scala +++ b/core/shared/src/main/scala/matryoshka/implicits/AlgebraOps.scala @@ -24,7 +24,7 @@ sealed class AlgebraOps[F[_], A](self: Algebra[F, A]) { def generalize[W[_]: Comonad](implicit F: Functor[F]): GAlgebra[W, F, A] = node => self(node ∘ (_.copoint)) - def generalizeM[M[_]: Applicative](implicit F: Functor[F]): AlgebraM[M, F, A] = + def generalizeM[M[_]: Applicative]/*(implicit F: Functor[F])*/: AlgebraM[M, F, A] = node => self(node).point[M] def generalizeElgot[W[_]: Comonad]: ElgotAlgebra[W, F, A] = diff --git a/core/shared/src/main/scala/matryoshka/package.scala b/core/shared/src/main/scala/matryoshka/package.scala index 5b546129..da3cc0d5 100644 --- a/core/shared/src/main/scala/matryoshka/package.scala +++ b/core/shared/src/main/scala/matryoshka/package.scala @@ -776,7 +776,7 @@ package object matryoshka { */ def count[T: Equal, F[_]: Functor: Foldable] (form: T) - (implicit T: Recursive.Aux[T, F]) + /*(implicit T: Recursive.Aux[T, F])*/ : ElgotAlgebra[(T, ?), F, Int] = e => (e._1 ≟ form).fold(1, 0) + e._2.foldRight(0)(_ + _) From a43230b1ad3587334ea070079c3f6d6cd686d14c Mon Sep 17 00:00:00 2001 From: David Hoyt Date: Thu, 28 Feb 2019 08:19:01 -0800 Subject: [PATCH 4/8] Cleanup using slamdata.Predef. --- core/shared/src/main/scala/matryoshka/Based.scala | 4 +++- core/shared/src/main/scala/matryoshka/EqualT.scala | 2 +- core/shared/src/main/scala/matryoshka/Merge.scala | 2 +- core/shared/src/main/scala/matryoshka/ShowT.scala | 5 ++--- .../shared/src/main/scala/matryoshka/patterns/Diffable.scala | 2 +- .../src/test/scala/matryoshka/helpers/AlgebraChecks.scala | 4 ++-- 6 files changed, 10 insertions(+), 9 deletions(-) diff --git a/core/shared/src/main/scala/matryoshka/Based.scala b/core/shared/src/main/scala/matryoshka/Based.scala index 697b63cc..ce860838 100644 --- a/core/shared/src/main/scala/matryoshka/Based.scala +++ b/core/shared/src/main/scala/matryoshka/Based.scala @@ -16,6 +16,8 @@ package matryoshka +import slamdata.Predef._ + import simulacrum.typeclass /** Provides a type describing the pattern functor of some {co}recursive type @@ -28,5 +30,5 @@ import simulacrum.typeclass type Base[A] } -@java.lang.SuppressWarnings(scala.Array("org.wartremover.warts.PublicInference")) +@SuppressWarnings(Array("org.wartremover.warts.PublicInference")) object Based diff --git a/core/shared/src/main/scala/matryoshka/EqualT.scala b/core/shared/src/main/scala/matryoshka/EqualT.scala index b626b183..5d0b053c 100644 --- a/core/shared/src/main/scala/matryoshka/EqualT.scala +++ b/core/shared/src/main/scala/matryoshka/EqualT.scala @@ -30,7 +30,7 @@ import simulacrum._ Equal.equal[T[F]](equal[F](_, _)(Functor[F], delay)) } -@java.lang.SuppressWarnings(scala.Array("org.wartremover.warts.PublicInference")) +@SuppressWarnings(Array("org.wartremover.warts.PublicInference")) object EqualT { def recursiveT[T[_[_]]: RecursiveT]: EqualT[T] = new EqualT[T] { def equal[F[_]: Functor] diff --git a/core/shared/src/main/scala/matryoshka/Merge.scala b/core/shared/src/main/scala/matryoshka/Merge.scala index cbfa80fa..5081f4db 100644 --- a/core/shared/src/main/scala/matryoshka/Merge.scala +++ b/core/shared/src/main/scala/matryoshka/Merge.scala @@ -35,7 +35,7 @@ import scalaz._, Scalaz._ merge(fa, fb).map(_ ∘ g.tupled) } -@java.lang.SuppressWarnings(scala.Array("org.wartremover.warts.PublicInference")) +@SuppressWarnings(Array("org.wartremover.warts.PublicInference")) object Merge { implicit def fromTraverse[F[_]: Traverse](implicit E: Equal[F[Unit]]): Merge[F] = diff --git a/core/shared/src/main/scala/matryoshka/ShowT.scala b/core/shared/src/main/scala/matryoshka/ShowT.scala index 351882ec..06f48b95 100644 --- a/core/shared/src/main/scala/matryoshka/ShowT.scala +++ b/core/shared/src/main/scala/matryoshka/ShowT.scala @@ -16,10 +16,9 @@ package matryoshka +import slamdata.Predef._ import matryoshka.implicits._ -import java.lang.String - import scalaz._ import simulacrum._ @@ -34,7 +33,7 @@ import simulacrum._ Show.show[T[F]](show[F](_)(Functor[F], delay)) } -@java.lang.SuppressWarnings(scala.Array("org.wartremover.warts.PublicInference")) +@SuppressWarnings(Array("org.wartremover.warts.PublicInference")) object ShowT { def recursiveT[T[_[_]]: RecursiveT]: ShowT[T] = new ShowT[T] { override def show[F[_]: Functor](tf: T[F])(implicit del: Delay[Show, F]) = diff --git a/core/shared/src/main/scala/matryoshka/patterns/Diffable.scala b/core/shared/src/main/scala/matryoshka/patterns/Diffable.scala index 24ab8fdd..1bd9c630 100644 --- a/core/shared/src/main/scala/matryoshka/patterns/Diffable.scala +++ b/core/shared/src/main/scala/matryoshka/patterns/Diffable.scala @@ -64,5 +64,5 @@ import simulacrum._ LocallyDifferent[T, F, T[Diff[T, F, ?]]](diffTraverse[T, F](left, right), right.void).embed } -@java.lang.SuppressWarnings(scala.Array("org.wartremover.warts.PublicInference")) +@SuppressWarnings(Array("org.wartremover.warts.PublicInference")) object Diffable diff --git a/tests/shared/src/test/scala/matryoshka/helpers/AlgebraChecks.scala b/tests/shared/src/test/scala/matryoshka/helpers/AlgebraChecks.scala index 78167182..618dc037 100644 --- a/tests/shared/src/test/scala/matryoshka/helpers/AlgebraChecks.scala +++ b/tests/shared/src/test/scala/matryoshka/helpers/AlgebraChecks.scala @@ -16,12 +16,12 @@ package matryoshka.helpers +import slamdata.Predef._ + import matryoshka._ import matryoshka.scalacheck.arbitrary._ import matryoshka.scalacheck.cogen._ -import java.lang.String - import monocle.law.discipline._ import org.scalacheck._ import org.specs2.mutable._ From aca524ac11ae55165d1d3bc54b51b0cbbd20e4b4 Mon Sep 17 00:00:00 2001 From: David Hoyt Date: Thu, 28 Feb 2019 08:27:21 -0800 Subject: [PATCH 5/8] Fix spacing in docs. --- docs/src/main/mdoc/docs/02-A-First-Example.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/src/main/mdoc/docs/02-A-First-Example.md b/docs/src/main/mdoc/docs/02-A-First-Example.md index 96fa77ac..72b2509d 100644 --- a/docs/src/main/mdoc/docs/02-A-First-Example.md +++ b/docs/src/main/mdoc/docs/02-A-First-Example.md @@ -40,7 +40,7 @@ implicit val traverse: Traverse[ArithmeticF] = new Traverse[ArithmeticF] { (f: A => G [B]) (implicit G: Applicative[G]) = fa match { - case NumberF(v) => G.point(NumberF(v)) + case NumberF(v) => G.point(NumberF(v)) case AddF(a, b) => (f(a) ⊛ f(b))(AddF(_, _)) case SubtractF(a, b) => (f(a) ⊛ f(b))(SubtractF(_, _)) case MultiplyF(a, b) => (f(a) ⊛ f(b))(MultiplyF(_, _)) From eccc7aa0f991e989480d4f1d97999526639df9f5 Mon Sep 17 00:00:00 2001 From: David Hoyt Date: Thu, 28 Feb 2019 08:28:07 -0800 Subject: [PATCH 6/8] Remove commented code related to unused implicits. --- core/shared/src/main/scala/matryoshka/Recursive.scala | 4 ++-- .../src/main/scala/matryoshka/implicits/AlgebraOps.scala | 2 +- core/shared/src/main/scala/matryoshka/package.scala | 1 - .../src/main/scala/matryoshka/scalacheck/shrink.scala | 6 +++--- 4 files changed, 6 insertions(+), 7 deletions(-) diff --git a/core/shared/src/main/scala/matryoshka/Recursive.scala b/core/shared/src/main/scala/matryoshka/Recursive.scala index 2f2eba87..5456d0c7 100644 --- a/core/shared/src/main/scala/matryoshka/Recursive.scala +++ b/core/shared/src/main/scala/matryoshka/Recursive.scala @@ -171,7 +171,7 @@ trait Recursive[T] extends Based[T] { self => def gcataZygo[W[_]: Comonad, A, B] (t: T) (k: DistributiveLaw[Base, W], f: GAlgebra[W, Base, B], g: GAlgebra[(B, ?), Base, A]) - (implicit BF: Functor[Base]/*, BU: Unzip[Base]*/): A = + (implicit BF: Functor[Base]): A = gcata[(W[B], ?), A]( t)( distZygo(fwa => k(fwa.map(_.cojoin)).map(f)), @@ -445,7 +445,7 @@ object Recursive { typeClassInstance.ghisto(self)(g, f) def gcataZygo[W[_]: Comonad, A, B] (w: DistributiveLaw[F, W], f: GAlgebra[W, F, B], g: GAlgebra[(B, ?), F, A]) - (implicit BF: Functor[F]/*, BU: Unzip[F]*/) + (implicit BF: Functor[F]) : A = typeClassInstance.gcataZygo[W, A, B](self)(w, f, g) def paraZygo[A, B] diff --git a/core/shared/src/main/scala/matryoshka/implicits/AlgebraOps.scala b/core/shared/src/main/scala/matryoshka/implicits/AlgebraOps.scala index 74e2c58b..2a8c637f 100644 --- a/core/shared/src/main/scala/matryoshka/implicits/AlgebraOps.scala +++ b/core/shared/src/main/scala/matryoshka/implicits/AlgebraOps.scala @@ -24,7 +24,7 @@ sealed class AlgebraOps[F[_], A](self: Algebra[F, A]) { def generalize[W[_]: Comonad](implicit F: Functor[F]): GAlgebra[W, F, A] = node => self(node ∘ (_.copoint)) - def generalizeM[M[_]: Applicative]/*(implicit F: Functor[F])*/: AlgebraM[M, F, A] = + def generalizeM[M[_]: Applicative]: AlgebraM[M, F, A] = node => self(node).point[M] def generalizeElgot[W[_]: Comonad]: ElgotAlgebra[W, F, A] = diff --git a/core/shared/src/main/scala/matryoshka/package.scala b/core/shared/src/main/scala/matryoshka/package.scala index da3cc0d5..d0d60886 100644 --- a/core/shared/src/main/scala/matryoshka/package.scala +++ b/core/shared/src/main/scala/matryoshka/package.scala @@ -776,7 +776,6 @@ package object matryoshka { */ def count[T: Equal, F[_]: Functor: Foldable] (form: T) - /*(implicit T: Recursive.Aux[T, F])*/ : ElgotAlgebra[(T, ?), F, Int] = e => (e._1 ≟ form).fold(1, 0) + e._2.foldRight(0)(_ + _) diff --git a/scalacheck/shared/src/main/scala/matryoshka/scalacheck/shrink.scala b/scalacheck/shared/src/main/scala/matryoshka/scalacheck/shrink.scala index 62d03eaa..6fee943d 100644 --- a/scalacheck/shared/src/main/scala/matryoshka/scalacheck/shrink.scala +++ b/scalacheck/shared/src/main/scala/matryoshka/scalacheck/shrink.scala @@ -53,13 +53,13 @@ trait ShrinkInstances extends ShrinkInstancesʹ { : Shrink[T] = Shrink(t => shrinkCorecursiveShrink[T, F].shrink(t) ++ recursiveShrink[T, F].shrink(t)) - implicit def fixShrink[F[_]: Functor: Foldable]/*(implicit F: Shrink[F[Nu[F]]])*/: Shrink[Fix[F]] = + implicit def fixShrink[F[_]: Functor: Foldable]: Shrink[Fix[F]] = corecursiveShrink[Fix[F], F] - implicit def muShrink[F[_]: Functor: Foldable]/*(implicit F: Shrink[F[Nu[F]]])*/: Shrink[Mu[F]] = + implicit def muShrink[F[_]: Functor: Foldable]: Shrink[Mu[F]] = corecursiveShrink[Mu[F], F] - implicit def nuShrink[F[_]: Functor: Foldable]/*(implicit F: Shrink[F[Nu[F]]])*/: Shrink[Nu[F]] = + implicit def nuShrink[F[_]: Functor: Foldable]: Shrink[Nu[F]] = corecursiveShrink[Nu[F], F] } From a415acb46457da8241f21abeeebbcafd84ded792 Mon Sep 17 00:00:00 2001 From: David Hoyt Date: Thu, 28 Feb 2019 08:28:50 -0800 Subject: [PATCH 7/8] Use sbt-slamdata for the metabuild. --- project/project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/project/plugins.sbt b/project/project/plugins.sbt index 1b456b5a..0233d015 100644 --- a/project/project/plugins.sbt +++ b/project/project/plugins.sbt @@ -2,4 +2,4 @@ resolvers += Resolver.sonatypeRepo("releases") resolvers += Resolver.bintrayRepo("slamdata-inc", "maven-public") addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.1.0-M9") -//addSbtPlugin("com.slamdata" % "sbt-slamdata" % "2.4.1") +addSbtPlugin("com.slamdata" % "sbt-slamdata" % "2.4.1") From ec7ce4c17b54b93e470a1b926d7f88bae4754513 Mon Sep 17 00:00:00 2001 From: David Hoyt Date: Thu, 28 Feb 2019 08:45:57 -0800 Subject: [PATCH 8/8] Revert "Use sbt-slamdata for the metabuild." --- project/project/plugins.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/project/project/plugins.sbt b/project/project/plugins.sbt index 0233d015..1b456b5a 100644 --- a/project/project/plugins.sbt +++ b/project/project/plugins.sbt @@ -2,4 +2,4 @@ resolvers += Resolver.sonatypeRepo("releases") resolvers += Resolver.bintrayRepo("slamdata-inc", "maven-public") addSbtPlugin("io.get-coursier" % "sbt-coursier" % "1.1.0-M9") -addSbtPlugin("com.slamdata" % "sbt-slamdata" % "2.4.1") +//addSbtPlugin("com.slamdata" % "sbt-slamdata" % "2.4.1")