Skip to content

Instantly share code, notes, and snippets.

module PouchDB where
import Task exposing (Task)
import Native.PouchDB
type PouchDB = POUCHDB_IMPLEMENTED_IN_JAVASCRIPT
type PouchError
= Error
type alias RDoc a = { a | id : Int }
type alias RUser = RDoc { userName : String }
type alias RGroup = RDoc { groupName : String }
type RSelectedDoc
= RSelectedUser RUser
| RSelectedGroup RGroup
type Action
= StudentEdit Student.Student
| UnitEdit Unit.Unit
| StudentDeleteConfirm Student.Student
| StudentDeleteConfirmed Student.Student (Maybe Bool)
| StudentDeleted Student.Student (Result PouchDB.PouchError Bool)
| UnitDeleteConfirm Unit.Unit
| UnitDeleteConfirmed Unit.Unit (Maybe Bool)
type alias Doc a = { a | id : Int }
type alias User = Doc { userName : String }
type alias Group = Doc { groupName : String }
user1 = { id = 1, userName = "dave" }
group1 = { id = 100, groupName = "some group" }
getIdFromDoc : Doc a -> Int
update : Action -> Model -> (Model, Effects.Effects Action)
update action model =
case action of
-- This bit gets repeated again, and again, and again for every nested component. Why can't I abstract it?
StudentEditorAction studentEditorAction ->
let
(childModel, childEffects) = Components.Settings.StudentEditor.update studentEditorAction model.studentEditorModel
in
( { model | studentEditorModel = childModel }
, Effects.none)
withSubmoduleUpdates : List String -> (a -> b)
withSubmoduleUpdates names update =
update
-- PORT ERROR -------- ././app/assets/javascripts/Component/SchoolSearch/API.elm
This module has ports, but ports can only appear in the main module.
98| port theOutboundPort : Signal Value
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Ports in library code would create hidden dependencies where importing a
module could bring in constraints not captured in the public API. Furthermore,
if the module is imported twice, do we send values out the port twice?
@ccapndave
ccapndave / App.elm
Last active November 29, 2015 14:37
module App (init, update, view, Action(StudentAction)) where
import Effects
import Html exposing (Html, text)
import Debug
import Student
import Components.StudentsPage
type Page
Rx.Observable.prototype.sendToTimeline = function(name) {
const addToTimeline = (group, data, className) => {
items.add({
start: new Date(),
content: stringify(data),
group: group.id,
className
});
if (shouldFit) timeline.fit();
//: Playground - noun: a place where people can play
import UIKit
import AVFoundation
do {
let documentDirectoryURL = try! NSFileManager.defaultManager().URLForDirectory(.DocumentDirectory, inDomain: .UserDomainMask, appropriateForURL: nil, create: true)
let outputURL = documentDirectoryURL.URLByAppendingPathComponent("output.mov")
if (NSFileManager.defaultManager().fileExistsAtPath(outputURL.path!)) {
try NSFileManager.defaultManager().removeItemAtPath(outputURL.path!)