packages feed

elm-export 0.5.0.0 → 0.5.0.1

raw patch · 18 files changed

+238/−2 lines, 18 filesdep ~elm-export

Dependency ranges changed: elm-export

Files

elm-export.cabal view
@@ -1,5 +1,5 @@ name: elm-export-version: 0.5.0.0+version: 0.5.0.1 cabal-version: >=1.10 build-type: Simple license: OtherLicense@@ -13,6 +13,8 @@     Generate Elm source code automatically from Haskell types. Using GHC.Generics, we can automatically derive Elm type declarations, and Aeson-compatible JSON decoders & encoders. category: Web author: Kris Jenkins+extra-source-files:+    test/*.elm  source-repository head     type: git@@ -49,7 +51,7 @@         base >=4.8.2.0 && <4.9,         bytestring >=0.10.6.0 && <0.11,         containers >=0.5.6.2 && <0.6,-        elm-export >=0.5.0.0 && <0.6,+        elm-export >=0.5.0.1 && <0.6,         hspec >=2.2.3 && <2.3,         hspec-core >=2.2.3 && <2.3,         quickcheck-instances >=0.3.12 && <0.4,
src/Elm/Type.hs view
@@ -8,6 +8,7 @@  module Elm.Type where +import           Data.Int     (Int16, Int32, Int64, Int8) import           Data.Map import           Data.Proxy import           Data.Text@@ -147,6 +148,18 @@  instance ElmType Double where     toElmType _ = ElmPrimitive EFloat++instance ElmType Int8 where+    toElmType _ = Primitive "Int"++instance ElmType Int16 where+    toElmType _ = Primitive "Int"++instance ElmType Int32 where+    toElmType _ = Primitive "Int"++instance ElmType Int64 where+    toElmType _ = Primitive "Int"  instance (ElmType a, ElmType b) =>          ElmType (a, b) where
+ test/CommentDecoder.elm view
@@ -0,0 +1,18 @@+module CommentDecoder exposing (..)++import CommentType exposing (..)+import Date+import Dict+import Json.Decode exposing (..)+import Json.Decode.Pipeline exposing (..)+++decodeComment : Decoder Comment+decodeComment =+    decode Comment+        |> required "postId" int+        |> required "text" string+        |> required "mainCategories" (tuple2 (,) string string)+        |> required "published" bool+        |> required "created" (customDecoder string Date.fromString)+        |> required "tags" (map Dict.fromList (list (tuple2 (,) string int)))
+ test/CommentDecoderWithOptions.elm view
@@ -0,0 +1,18 @@+module CommentDecoderWithOptions exposing (..)++import CommentType exposing (..)+import Date+import Dict+import Json.Decode exposing (..)+import Json.Decode.Pipeline exposing (..)+++decodeComment : Decoder Comment+decodeComment =+    decode Comment+        |> required "commentPostId" int+        |> required "commentText" string+        |> required "commentMainCategories" (tuple2 (,) string string)+        |> required "commentPublished" bool+        |> required "commentCreated" (customDecoder string Date.fromString)+        |> required "commentTags" (map Dict.fromList (list (tuple2 (,) string int)))
+ test/CommentEncoder.elm view
@@ -0,0 +1,18 @@+module CommentEncoder exposing (..)++import CommentType exposing (..)+import Exts.Date exposing (..)+import Exts.Json.Encode exposing (..)+import Json.Encode+++encodeComment : Comment -> Json.Encode.Value+encodeComment x =+    Json.Encode.object+        [ ( "postId", Json.Encode.int x.postId )+        , ( "text", Json.Encode.string x.text )+        , ( "mainCategories", (tuple2 Json.Encode.string Json.Encode.string) x.mainCategories )+        , ( "published", Json.Encode.bool x.published )+        , ( "created", (Json.Encode.string << toISOString) x.created )+        , ( "tags", (dict Json.Encode.string Json.Encode.int) x.tags )+        ]
+ test/CommentEncoderWithOptions.elm view
@@ -0,0 +1,18 @@+module CommentEncoderWithOptions exposing (..)++import CommentType exposing (..)+import Exts.Date exposing (..)+import Exts.Json.Encode exposing (..)+import Json.Encode+++encodeComment : Comment -> Json.Encode.Value+encodeComment x =+    Json.Encode.object+        [ ( "commentPostId", Json.Encode.int x.postId )+        , ( "commentText", Json.Encode.string x.text )+        , ( "commentMainCategories", (tuple2 Json.Encode.string Json.Encode.string) x.mainCategories )+        , ( "commentPublished", Json.Encode.bool x.published )+        , ( "commentCreated", (Json.Encode.string << toISOString) x.created )+        , ( "commentTags", (dict Json.Encode.string Json.Encode.int) x.tags )+        ]
+ test/CommentType.elm view
@@ -0,0 +1,14 @@+module CommentType exposing (..)++import Date exposing (Date)+import Dict exposing (Dict)+++type alias Comment =+    { postId : Int+    , text : String+    , mainCategories : ( String, String )+    , published : Bool+    , created : Date+    , tags : Dict (String) (Int)+    }
+ test/CommentTypeWithOptions.elm view
@@ -0,0 +1,14 @@+module CommentTypeWithOptions exposing (..)++import Date exposing (Date)+import Dict exposing (Dict)+++type alias Comment =+    { commentPostId : Int+    , commentText : String+    , commentMainCategories : ( String, String )+    , commentPublished : Bool+    , commentCreated : Date+    , commentTags : Dict (String) (Int)+    }
+ test/FavoritePlacesType.elm view
@@ -0,0 +1,8 @@+module FavoritePlacesType exposing (..)++import PositionType exposing (..)+++type alias FavoritePlaces =+    { positionsByUser : Dict (String) (List (Position))+    }
+ test/PositionType.elm view
@@ -0,0 +1,7 @@+module PositionType exposing (..)+++type Position+    = Beginning+    | Middle+    | End
+ test/PostDecoder.elm view
@@ -0,0 +1,17 @@+module PostDecoder exposing (..)++import CommentDecoder exposing (..)+import Json.Decode exposing (..)+import Json.Decode.Pipeline exposing (..)+import PostType exposing (..)+++decodePost : Decoder Post+decodePost =+    decode Post+        |> required "id" int+        |> required "name" string+        |> required "age" (maybe float)+        |> required "comments" (list decodeComment)+        |> required "promoted" (maybe decodeComment)+        |> required "author" (maybe string)
+ test/PostDecoderWithOptions.elm view
@@ -0,0 +1,17 @@+module PostDecoderWithOptions exposing (..)++import CommentDecoder exposing (..)+import Json.Decode exposing (..)+import Json.Decode.Pipeline exposing (..)+import PostType exposing (..)+++decodePost : Decoder Post+decodePost =+    decode Post+        |> required "postId" int+        |> required "postName" string+        |> required "postAge" (maybe float)+        |> required "postComments" (list decodeComment)+        |> required "postPromoted" (maybe decodeComment)+        |> required "postAuthor" (maybe string)
+ test/PostEncoder.elm view
@@ -0,0 +1,17 @@+module PostEncoder exposing (..)++import CommentEncoder exposing (..)+import Json.Encode+import PostType exposing (..)+++encodePost : Post -> Json.Encode.Value+encodePost x =+    Json.Encode.object+        [ ( "id", Json.Encode.int x.id )+        , ( "name", Json.Encode.string x.name )+        , ( "age", (Maybe.withDefault Json.Encode.null << Maybe.map Json.Encode.float) x.age )+        , ( "comments", (Json.Encode.list << List.map encodeComment) x.comments )+        , ( "promoted", (Maybe.withDefault Json.Encode.null << Maybe.map encodeComment) x.promoted )+        , ( "author", (Maybe.withDefault Json.Encode.null << Maybe.map Json.Encode.string) x.author )+        ]
+ test/PostEncoderWithOptions.elm view
@@ -0,0 +1,17 @@+module PostEncoderWithOptions exposing (..)++import CommentEncoder exposing (..)+import Json.Encode+import PostType exposing (..)+++encodePost : Post -> Json.Encode.Value+encodePost x =+    Json.Encode.object+        [ ( "postId", Json.Encode.int x.id )+        , ( "postName", Json.Encode.string x.name )+        , ( "postAge", (Maybe.withDefault Json.Encode.null << Maybe.map Json.Encode.float) x.age )+        , ( "postComments", (Json.Encode.list << List.map encodeComment) x.comments )+        , ( "postPromoted", (Maybe.withDefault Json.Encode.null << Maybe.map encodeComment) x.promoted )+        , ( "postAuthor", (Maybe.withDefault Json.Encode.null << Maybe.map Json.Encode.string) x.author )+        ]
+ test/PostType.elm view
@@ -0,0 +1,13 @@+module PostType exposing (..)++import CommentType exposing (..)+++type alias Post =+    { id : Int+    , name : String+    , age : Maybe (Float)+    , comments : List (Comment)+    , promoted : Maybe (Comment)+    , author : Maybe (String)+    }
+ test/PostTypeWithOptions.elm view
@@ -0,0 +1,13 @@+module PostTypeWithOptions exposing (..)++import CommentType exposing (..)+++type alias Post =+    { postId : Int+    , postName : String+    , postAge : Maybe (Float)+    , postComments : List (Comment)+    , postPromoted : Maybe (Comment)+    , postAuthor : Maybe (String)+    }
+ test/TimingType.elm view
@@ -0,0 +1,7 @@+module TimingType exposing (..)+++type Timing+    = Start+    | Continue Float+    | Stop
+ test/UselessType.elm view
@@ -0,0 +1,5 @@+module UselessType exposing (..)+++type Useless+    = Useless ()