mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-28 23:12:22 +03:00
Update docs.
This commit is contained in:
parent
86c3dac0fa
commit
af657dbafa
@ -1,10 +1,17 @@
|
||||
module Pages.PageUrl exposing (PageUrl, toUrl)
|
||||
|
||||
{-|
|
||||
|
||||
@docs PageUrl, toUrl
|
||||
|
||||
-}
|
||||
|
||||
import Path exposing (Path)
|
||||
import QueryParams exposing (QueryParams)
|
||||
import Url
|
||||
|
||||
|
||||
{-| -}
|
||||
type alias PageUrl =
|
||||
{ protocol : Url.Protocol
|
||||
, host : String
|
||||
@ -15,6 +22,7 @@ type alias PageUrl =
|
||||
}
|
||||
|
||||
|
||||
{-| -}
|
||||
toUrl : PageUrl -> Url.Url
|
||||
toUrl url =
|
||||
{ protocol = url.protocol
|
||||
|
@ -1,32 +1,67 @@
|
||||
module QueryParams exposing (Parser, QueryParams, andThen, fail, fromResult, fromString, map2, oneOf, optionalString, parse, string, strings, succeed, toDict, toString)
|
||||
module QueryParams exposing
|
||||
( QueryParams
|
||||
, Parser
|
||||
, andThen, fail, fromResult, fromString, optionalString, parse, string, strings, succeed
|
||||
, map2, oneOf
|
||||
, toDict, toString
|
||||
)
|
||||
|
||||
{-|
|
||||
|
||||
@docs QueryParams
|
||||
|
||||
|
||||
## Parsing
|
||||
|
||||
@docs Parser
|
||||
|
||||
@docs andThen, fail, fromResult, fromString, optionalString, parse, string, strings, succeed
|
||||
|
||||
|
||||
## Combining
|
||||
|
||||
@docs map2, oneOf
|
||||
|
||||
|
||||
## Accessing as Built-In Types
|
||||
|
||||
@docs toDict, toString
|
||||
|
||||
-}
|
||||
|
||||
import Dict exposing (Dict)
|
||||
import Url
|
||||
|
||||
|
||||
{-| -}
|
||||
type QueryParams
|
||||
= QueryParams String
|
||||
|
||||
|
||||
{-| -}
|
||||
type Parser a
|
||||
= Parser (Dict String (List String) -> Result String a)
|
||||
|
||||
|
||||
{-| -}
|
||||
succeed : a -> Parser a
|
||||
succeed value =
|
||||
Parser (\_ -> Ok value)
|
||||
|
||||
|
||||
{-| -}
|
||||
fail : String -> Parser a
|
||||
fail errorMessage =
|
||||
Parser (\_ -> Err errorMessage)
|
||||
|
||||
|
||||
{-| -}
|
||||
fromResult : Result String a -> Parser a
|
||||
fromResult result =
|
||||
Parser (\_ -> result)
|
||||
|
||||
|
||||
{-| -}
|
||||
andThen : (a -> Parser b) -> Parser a -> Parser b
|
||||
andThen andThenFn (Parser parser) =
|
||||
Parser
|
||||
@ -40,12 +75,14 @@ andThen andThenFn (Parser parser) =
|
||||
)
|
||||
|
||||
|
||||
{-| -}
|
||||
oneOf : List (Parser a) -> Parser a
|
||||
oneOf parsers =
|
||||
Parser
|
||||
(tryParser parsers)
|
||||
|
||||
|
||||
{-| -}
|
||||
tryParser : List (Parser a) -> Dict String (List String) -> Result String a
|
||||
tryParser parsers dict =
|
||||
case parsers of
|
||||
@ -61,6 +98,7 @@ tryParser parsers dict =
|
||||
tryParser otherParsers dict
|
||||
|
||||
|
||||
{-| -}
|
||||
map2 : (a -> b -> combined) -> Parser a -> Parser b -> Parser combined
|
||||
map2 func (Parser a) (Parser b) =
|
||||
Parser <|
|
||||
@ -68,6 +106,7 @@ map2 func (Parser a) (Parser b) =
|
||||
Result.map2 func (a dict) (b dict)
|
||||
|
||||
|
||||
{-| -}
|
||||
optionalString : String -> Parser (Maybe String)
|
||||
optionalString key =
|
||||
custom key
|
||||
@ -81,6 +120,7 @@ optionalString key =
|
||||
)
|
||||
|
||||
|
||||
{-| -}
|
||||
string : String -> Parser String
|
||||
string key =
|
||||
custom key
|
||||
@ -94,6 +134,7 @@ string key =
|
||||
)
|
||||
|
||||
|
||||
{-| -}
|
||||
custom : String -> (List String -> Result String a) -> Parser a
|
||||
custom key customFn =
|
||||
Parser <|
|
||||
@ -101,22 +142,26 @@ custom key customFn =
|
||||
customFn (Maybe.withDefault [] (Dict.get key dict))
|
||||
|
||||
|
||||
{-| -}
|
||||
strings : String -> Parser (List String)
|
||||
strings key =
|
||||
custom key
|
||||
(\stringList -> Ok stringList)
|
||||
|
||||
|
||||
{-| -}
|
||||
fromString : String -> QueryParams
|
||||
fromString =
|
||||
QueryParams
|
||||
|
||||
|
||||
{-| -}
|
||||
toString : QueryParams -> String
|
||||
toString (QueryParams queryParams) =
|
||||
queryParams
|
||||
|
||||
|
||||
{-| -}
|
||||
parse : Parser a -> QueryParams -> Result String a
|
||||
parse (Parser queryParser) queryParams =
|
||||
queryParams
|
||||
@ -124,6 +169,7 @@ parse (Parser queryParser) queryParams =
|
||||
|> queryParser
|
||||
|
||||
|
||||
{-| -}
|
||||
toDict : QueryParams -> Dict String (List String)
|
||||
toDict (QueryParams queryParams) =
|
||||
prepareQuery (Just queryParams)
|
||||
|
Loading…
Reference in New Issue
Block a user