haskell-servant / servant-elm

Automatically derive Elm functions to query servant webservices
BSD 3-Clause "New" or "Revised" License
164 stars 48 forks source link

Allow to use Maps (Dicts) in record fields #7

Closed soenkehahn closed 8 years ago

soenkehahn commented 8 years ago

I had to add src to the source directories of the test-suite to be able to import Servant.Elm.Foreign.

mattjbray commented 8 years ago

Adding the Dict import to defElmImports will generate warnings when people who aren't using Dict compile their Elm projects with --warn.

For now, the simplest way is for users to customise defElmImports according to their needs:

myElmImports :: String
myElmImports =
  unlines (defElmImports ++ ["import Dict exposing (Dict)"])

spec :: Spec
spec = Spec ["Generated", "MyApi"]
            (myElmImports
             : generateElmForAPI (Proxy :: Proxy BooksApi))

In the future, elm-export could be modified to provide a list of the imports required to use the code it generates.

soenkehahn commented 8 years ago

I see. Makes sense. Thanks for explaining.