在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):krisajenkins/elm-export开源软件地址(OpenSource Url):https://github.com/krisajenkins/elm-export开源编程语言(OpenSource Language):Haskell 82.9%开源软件介绍(OpenSource Introduction):Elm ExportCreate Elm classes and JSON decoders from Haskell DataTypes. InstallationElm Export is available on Hackage. UsageTo use this library, you must first make the types you want to export
implement {-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DeriveAnyClass #-}
module Db where
import Elm
import GHC.Generics
data Person = Person
{ id :: Int
, name :: Maybe String
} deriving (Show, Eq, Generic, ElmType) That's it for the type. Now you'll want to write a main that generates the Elm source code: module Main where
import Data.Proxy
import Db
import Elm
spec :: Spec
spec =
Spec
["Db", "Types"]
[ "import Json.Decode exposing (..)"
, "import Json.Decode.Pipeline exposing (..)"
, toElmTypeSource (Proxy :: Proxy Person)
, toElmDecoderSource (Proxy :: Proxy Person)
]
main :: IO ()
main = specsToDir [spec] "some/where/output" Run this and the directory All the hard work here is done by Required Elm PackagesThe decoders we produce require these extra Elm packages installed: elm package install NoRedInk/elm-decode-pipeline
elm package install krisajenkins/elm-exts DevelopmentYou will need Stack. Buildingstack build Testingstack test --file-watch Change LogV0.3.0.0
V0.2.0.0
V0.1.0.0
StatusAlpha. The author is using it in production, but it is not yet expected to work for every reasonable case. There are some Haskell datatypes that cannot be represented in Elm. Obviously we will not support those. But there are some which are legal Haskell and legal Elm, but we do not yet generate. Please send examples, PRs and code-suggestions! ContributorsLicenseCopyright © 2015-2017 Kris Jenkins Distributed under the Eclipse Public License. See AlsoElm Bridge is a different implementation of the same goal. That project uses Template Haskell, this one uses GHC Generics. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论