Find this presentation at:
http://slides.com/danielbachler/elm-for-science
Third party molecule drawing widget
Animated tooltips (Bootstrap)
Design workflow (html-to-elm)
type NumberParseError
= Empty
| InvalidCharacters
| OutOfRange
type alias NumericField numberType =
{ textContent : String
, parseResult : Result NumberParseError numberType
}
type alias FloatField =
NumericField Float
type alias IntField =
NumericField Int
type: object
properties:
name:
type: string
age:
type: integer
type SimpleDataType
= TypeInteger
| TypeFloat
| TypeString
| TypeBoolean
type alias ObjectField =
{ fieldname : String
, content : DataType
}
type DataType
= TypeSimple SimpleDataType
| TypeObject (List (ObjectField))
type: object
properties:
name:
type: string
address:
$ref: '#/definitions/Address'
age:
type: integer
type SimpleDataType
= TypeInteger
| TypeFloat
| TypeString
| TypeBoolean
type alias ObjectField =
{ fieldname : String
, content : DataType
}
type DataType
= TypeSimple SimpleDataType
| TypeObject (List (ObjectField))
| Ref String
Annoying to consume (dereference at every usage)
type alias ObjectFieldWithRef =
{ fieldname : String
, content : DataTypeWithRef
}
type DataTypeWithRef
= TypeSimpleWithRef SimpleDataType
| TypeObjectWithRef (List (ObjectField))
| Ref String
type alias ObjectFieldWithoutRef =
{ fieldname : String
, content : DataTypeWithoutRef
}
type DataTypeWithoutRef
= TypeSimpleWithoutRef SimpleDataType
| TypeObjectWithoutRef (List (ObjectField))
type alias ObjectField referencekind =
{ fieldname : String
, content : referencekind
}
type DataType referencekind
= TypeSimple SimpleDataType
| TypeObject (List (ObjectField referencekind ))
type DataTypeOrRef
= Reference String
| SpecifiedDataType DataType
type DataTypeValOnly
= DataTypeValOnly DataType
deref : DataType DataTypeOrRef -> DataType DataTypeValOnly
deref dataTypeWithRefs =
-- ...
type Cell
= IntCell Int
| FloatCell Float
| StringCell String
buildJsonDecoder : DataType DataTypeValOnly
-> Decode.Decoder (List Cell)
buildJsonDecoder dataTypeNode =
case dataTypeNode of
TypeSimple simpleType ->
case simpleType of
TypeInteger ->
Decode.map (List.singleton << IntCell) Decode.int
-- ...
TypeObject fieldDefinitions ->
-- fold over list of fields and accumulate
-- decoders of lists of cells and concat them
Newtypes
Restricting type variables
newtype Ref = String
type alias RefDict = Dict Ref String
Find me on Twitter: @danyx23
This presentation is available at: