Skip to content

Instantly share code, notes, and snippets.

view : { id : String, incomingPort : String } -> Signal.Address Action -> Model -> Html
view context address model =
input
[ type' "file"
, title " "
, accept "image/*"
, attribute "capture" "true"
, attribute "onchange" ("window.photoFieldOnChange(\"" ++ context.id ++ "\", this.files, \"" ++ context.incomingPort ++ "\")")
] []
.modal {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: #000000;
opacity: 0.7;
}
Apache CouchDB 1.6.1 (LogLevel=info) is starting.
[error] [<0.105.0>] {error_report,<0.31.0>,
{<0.105.0>,crash_report,
[[{initial_call,
{couch_stats_aggregator,init,['Argument__1']}},
{pid,<0.105.0>},
{registered_name,[]},
{error_info,
{exit,
{{badmatch,{error,enoent}},
-- Given a feature, either return that feature or nothing depending on its featureType property
poi : Feature -> Maybe Feature
poi feature =
GeoJson.property "featureType" feature
|> Maybe.map (JD.decodeValue JD.string >> Result.toMaybe)
|> Maybe.Extra.join
|> Maybe.map (\featureType -> if featureType == "POI" then Just feature else Nothing)
|> Maybe.Extra.join

I've create this design document in the tours database:

{
   "_id": "_design/spatial",
   "_rev": "1-a767cce1bb12d7048a2b577000884878",
   "spatial": {
       "geometry": "function(doc) { return emit([doc.geometry.features[0].geometry], null); }"
   }
}
module GeoJson
( GeoJson(GeoJsonGeometry, GeoJsonFeature, GeoJsonFeatureCollection)
, Geometry(Point, LineString, Polygon)
, Feature
, FeatureCollection
, Position
, decoder
) where
{-| Library for working with GeoJSON data in Elm.
{-
The goal here is to make a component with 3 drop downs, each containing a letter, which sends out a *single* concatenated string
on its address when any of the selects are chosen. I don't want to use the normal Elm architecture pattern to do this because I
want the component to output a single value and internalize the individual states.
This is a contrived example to demonstrate the problem, but the real world example that brought this up is a date of birth selector
component with a drop down for date, month and year, where I want to have an elm-html style function to create the selectors:
dateOfBirthField : Signal.Address Date -> Date -> Html
dateOfBirthField address currentDate =
module Form.Form (selectField, selectCountryField, dateOfBirthField) where
import Html exposing (..)
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import List.Extra exposing (zip)
import Date exposing (Date)
import Date.Core exposing (monthList)
import Date.Utils exposing (dateFromFields)
import Json.Decode as JD
type Gender = Male | Female
type Action = ChangeGender Gender
type alias Model = { user : User }
type alias User = { gender : Gender }
view : Signal.Address Action -> Model -> Html
view address model =
import Task exposing (Task, andThen)
import Json.Decode as JD
import Json.Encode as JE
import Native.PouchDB
type PouchDB = POUCHDB_IMPLEMENTED_IN_JAVASCRIPT
type PouchError
= Error
| JsonDecodeError String