Skip to content

Instantly share code, notes, and snippets.

@robinske
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robinske/11197860 to your computer and use it in GitHub Desktop.
Save robinske/11197860 to your computer and use it in GitHub Desktop.
def lessonDelta[M]
(sm: ServiceModel[M], uid: UserId, courseKey: String)
(delta: IndexedSeq[Lesson] => ModelState[M, IndexedSeq[Lesson]]): ModelState[M, Unit] =
for {
courseId <- sm.findCourseId(courseKey)
_ <- sm.asAuthor(uid, courseId)
oldStatus <- sm.getSandboxStatusById(courseId)
courseToUpdate <- sm.sandboxedCourse(courseId, oldStatus)
oldPalette <- sm.getGadgetPalette(courseId, Course.SANDBOX)
// this line is failing:
changedLessons <- delta(courseToUpdate.lessons)
newPalette <- CourseParser.derivePalette(sm, oldPalette, changedLessons)
updatedSandboxCourse <- courseToUpdate.updateLessons(changedLessons)
updatedSandboxStatus =
SandboxChanges.validate(updatedSandboxCourse, sm.stagedStatus(oldStatus))
_ <- sm.mc.setSandboxStatus(courseId, updatedSandboxStatus)
_ <- sm.mc.setGadgetPalette(courseId, Course.SANDBOX, newPalette)
} yield ()
//[error] /Users/kelleyrobinson/src/rest-api/src/main/scala/endpoints/CourseEndpoints.scala:774:
// Unable to unapply type `com.versal.restapi.Course` into a type constructor of kind `M[_]`
// that is classified by the type class `scalaz.Functor`
//[error] 1) Check that the type class is defined by compiling `implicitly[scalaz.Functor[<type constructor>]]`.
//[error] 2) Review the implicits in object Unapply, which only cover common type 'shapes'
//[error] (implicit not found: scalaz.Unapply[scalaz.Functor, com.versal.restapi.Course])
//[error] updatedSandboxCourse <- courseToUpdate.updateLessons(changedLessons)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment