@@ -64,6 +64,7 @@ data ElmOptions = ElmOptions
64 , stringElmTypes :: [EType]
64 , stringElmTypes :: [EType]
65 -- ^ Types that represent a String.
65 -- ^ Types that represent a String.
66 , expectJsonMethod :: Text
66 , expectJsonMethod :: Text
67+ , expectStringMethod :: Text
67 , httpErrorType :: Text
68 , httpErrorType :: Text
@@ -104,6 +105,7 @@ defElmOptions = ElmOptions
104 , toElmType (Proxy :: Proxy T.Text)
105 , toElmType (Proxy :: Proxy T.Text)
106 , expectJsonMethod = "Http.expectJson"
107 , expectJsonMethod = "Http.expectJson"
108+ , expectStringMethod = "Http.expectString"
107 , httpErrorType = "Http.Error"
109 , httpErrorType = "Http.Error"
@@ -313,7 +315,7 @@ mkTypeSignature opts request =
313 toMsgType :: Maybe Doc
315 toMsgType :: Maybe Doc
314 toMsgType = do
316 toMsgType = do
315 result <- fmap elmTypeRef $ request ^. F.reqReturnType
317 result <- fmap elmTypeRef $ request ^. F.reqReturnType
316− Just ("(Result" <+> stext (httpErrorType opts) <+> parens result <+> " -> msg)")
318+ Just ("(Result" <+> stext (httpErrorType opts) <+> parens result <+> "-> msg)")
318 returnType :: Maybe Doc
320 returnType :: Maybe Doc
319 returnType = do
321 returnType = do
@@ -505,11 +507,11 @@ mkRequest opts request =
505 | isEmptyType opts $ (elmTypeAlterations opts) elmTypeExpr
507 | isEmptyType opts $ (elmTypeAlterations opts) elmTypeExpr
506 -- let elmConstructor = T.pack (renderElm elmTypeExpr)
508 -- let elmConstructor = T.pack (renderElm elmTypeExpr)
508− "Http.expectString " <> line <+> indent i "(\\x -> case x of" <> line <+>
510+ stext (expectStringMethod opts) <> line <+> indent i "(\\x -> case x of" <> line <+>
509 indent i "Err e -> toMsg (Err e)" <> line <+>
511 indent i "Err e -> toMsg (Err e)" <> line <+>
510 indent i "Ok _ -> toMsg (Ok ()))"
512 indent i "Ok _ -> toMsg (Ok ()))"
511 Just elmTypeExpr ->
513 Just elmTypeExpr ->
512− stext (expectJsonMethod opts) <+> " toMsg" <+> renderDecoderName ((elmTypeAlterations opts) elmTypeExpr)
514+ stext (expectJsonMethod opts) <+> "toMsg" <+> renderDecoderName ((elmTypeAlterations opts) elmTypeExpr)
513 Nothing -> error "mkHttpRequest: no reqReturnType?"
515 Nothing -> error "mkHttpRequest: no reqReturnType?"
514 -- case request ^. F.reqReturnType of
516 -- case request ^. F.reqReturnType of
515 -- Just elmTypeExpr | isEmptyType opts elmTypeExpr ->
517 -- Just elmTypeExpr | isEmptyType opts elmTypeExpr ->