Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cli/example/elm.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"elm/http": "2.0.0",
"elm/json": "1.1.3",
"elm/parser": "1.1.0",
"elm/regex": "1.0.0",
"elm/time": "1.0.0",
"elm/url": "1.0.0",
"elm-community/json-extra": "4.3.0",
Expand All @@ -27,7 +28,6 @@
"NoRedInk/elm-random-pcg-extended": "1.0.0",
"elm/file": "1.0.5",
"elm/html": "1.0.0",
"elm/regex": "1.0.0",
"elm/virtual-dom": "1.0.3",
"rtfeldman/elm-iso8601-date-strings": "1.1.4"
}
Expand Down
1 change: 1 addition & 0 deletions cli/src/Cli.elm
Original file line number Diff line number Diff line change
Expand Up @@ -1219,6 +1219,7 @@ printSuccessMessageAndWarnings ( outputPaths, { requiredPackages, warnings } ) =
|> FastSet.insert "elm/json"
|> FastSet.insert "elm/url"
|> FastSet.insert "elm/bytes"
|> FastSet.insert "elm/regex"
|> FastSet.toList

toInstall : String -> Pretty.Doc ()
Expand Down
3 changes: 2 additions & 1 deletion codegen/elm.codegen.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
"elm/parser": "1.1.0",
"wolfadex/elm-rfc3339": "2.0.0",
"danfishgold/base64-bytes": "1.1.0",
"cachix/elm-uuid": "2.0.0"
"cachix/elm-uuid": "2.0.0",
"elm/regex": "1.0.0"
},
"local": [
"helpers"
Expand Down
1 change: 1 addition & 0 deletions src/Common.elm
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,7 @@ type Type
BasicType
{ format : Maybe String
, const : Maybe ConstValue
, pattern : Maybe String
}
| Null
| List Type
Expand Down
263 changes: 263 additions & 0 deletions src/Gen/Regex.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,263 @@
module Gen.Regex exposing
( fromString, never
, call_
)

{-|


# Generated bindings for Regex

@docs fromString, never
@docs call_

-}

import Elm
import Elm.Annotation as Type


{-| Try to create a `Regex`. Not all strings are valid though, so you get a
\`Maybe' back. This means you can safely accept input from users.

import Regex

lowerCase : Regex.Regex
lowerCase =
Maybe.withDefault Regex.never <|
Regex.fromString "[a-z]+"

**Note:** There are some [shorthand character classes][short] like `\w` for
word characters, `\s` for whitespace characters, and `\d` for digits. **Make
sure they are properly escaped!** If you specify them directly in your code,
they would look like `"\\w\\s\\d"`.

[short]: https://www.regular-expressions.info/shorthand.html

fromString: String -> Maybe Regex.Regex

-}
fromString : String -> Elm.Expression
fromString fromStringArg_ =
Elm.apply
(Elm.value
{ importFrom = [ "Regex" ]
, name = "fromString"
, annotation =
Just
(Type.function
[ Type.string ]
(Type.maybe (Type.namedWith [ "Regex" ] "Regex" []))
)
}
)
[ Elm.string fromStringArg_ ]


{-| A regular expression that never matches any string.

never: Regex.Regex

-}
never : Elm.Expression
never =
Elm.value
{ importFrom = [ "Regex" ]
, name = "never"
, annotation = Just (Type.namedWith [ "Regex" ] "Regex" [])
}


call_ :
{ fromString : Elm.Expression -> Elm.Expression
, fromStringWith : Elm.Expression -> Elm.Expression -> Elm.Expression
, contains : Elm.Expression -> Elm.Expression -> Elm.Expression
, split : Elm.Expression -> Elm.Expression -> Elm.Expression
, find : Elm.Expression -> Elm.Expression -> Elm.Expression
, replace :
Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression
, splitAtMost :
Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression
, findAtMost :
Elm.Expression -> Elm.Expression -> Elm.Expression -> Elm.Expression
, replaceAtMost :
Elm.Expression
-> Elm.Expression
-> Elm.Expression
-> Elm.Expression
-> Elm.Expression
}
call_ =
{ fromString =
\fromStringArg_ ->
Elm.apply
(Elm.value
{ importFrom = [ "Regex" ]
, name = "fromString"
, annotation =
Just
(Type.function
[ Type.string ]
(Type.maybe
(Type.namedWith [ "Regex" ] "Regex" [])
)
)
}
)
[ fromStringArg_ ]
, fromStringWith =
\fromStringWithArg_ fromStringWithArg_0 ->
Elm.apply
(Elm.value
{ importFrom = [ "Regex" ]
, name = "fromStringWith"
, annotation =
Just
(Type.function
[ Type.namedWith [ "Regex" ] "Options" []
, Type.string
]
(Type.maybe
(Type.namedWith [ "Regex" ] "Regex" [])
)
)
}
)
[ fromStringWithArg_, fromStringWithArg_0 ]
, contains =
\containsArg_ containsArg_0 ->
Elm.apply
(Elm.value
{ importFrom = [ "Regex" ]
, name = "contains"
, annotation =
Just
(Type.function
[ Type.namedWith [ "Regex" ] "Regex" []
, Type.string
]
Type.bool
)
}
)
[ containsArg_, containsArg_0 ]
, split =
\splitArg_ splitArg_0 ->
Elm.apply
(Elm.value
{ importFrom = [ "Regex" ]
, name = "split"
, annotation =
Just
(Type.function
[ Type.namedWith [ "Regex" ] "Regex" []
, Type.string
]
(Type.list Type.string)
)
}
)
[ splitArg_, splitArg_0 ]
, find =
\findArg_ findArg_0 ->
Elm.apply
(Elm.value
{ importFrom = [ "Regex" ]
, name = "find"
, annotation =
Just
(Type.function
[ Type.namedWith [ "Regex" ] "Regex" []
, Type.string
]
(Type.list
(Type.namedWith [ "Regex" ] "Match" [])
)
)
}
)
[ findArg_, findArg_0 ]
, replace =
\replaceArg_ replaceArg_0 replaceArg_1 ->
Elm.apply
(Elm.value
{ importFrom = [ "Regex" ]
, name = "replace"
, annotation =
Just
(Type.function
[ Type.namedWith [ "Regex" ] "Regex" []
, Type.function
[ Type.namedWith [ "Regex" ] "Match" [] ]
Type.string
, Type.string
]
Type.string
)
}
)
[ replaceArg_, replaceArg_0, replaceArg_1 ]
, splitAtMost =
\splitAtMostArg_ splitAtMostArg_0 splitAtMostArg_1 ->
Elm.apply
(Elm.value
{ importFrom = [ "Regex" ]
, name = "splitAtMost"
, annotation =
Just
(Type.function
[ Type.int
, Type.namedWith [ "Regex" ] "Regex" []
, Type.string
]
(Type.list Type.string)
)
}
)
[ splitAtMostArg_, splitAtMostArg_0, splitAtMostArg_1 ]
, findAtMost =
\findAtMostArg_ findAtMostArg_0 findAtMostArg_1 ->
Elm.apply
(Elm.value
{ importFrom = [ "Regex" ]
, name = "findAtMost"
, annotation =
Just
(Type.function
[ Type.int
, Type.namedWith [ "Regex" ] "Regex" []
, Type.string
]
(Type.list
(Type.namedWith [ "Regex" ] "Match" [])
)
)
}
)
[ findAtMostArg_, findAtMostArg_0, findAtMostArg_1 ]
, replaceAtMost =
\replaceAtMostArg_ replaceAtMostArg_0 replaceAtMostArg_1 replaceAtMostArg_2 ->
Elm.apply
(Elm.value
{ importFrom = [ "Regex" ]
, name = "replaceAtMost"
, annotation =
Just
(Type.function
[ Type.int
, Type.namedWith [ "Regex" ] "Regex" []
, Type.function
[ Type.namedWith [ "Regex" ] "Match" [] ]
Type.string
, Type.string
]
Type.string
)
}
)
[ replaceAtMostArg_
, replaceAtMostArg_0
, replaceAtMostArg_1
, replaceAtMostArg_2
]
}
1 change: 1 addition & 0 deletions src/OpenApi/Generate.elm
Original file line number Diff line number Diff line change
Expand Up @@ -2723,6 +2723,7 @@ operationToTypesExpectAndResolver effectTypes method pathUrl operation =
Common.Basic Common.String
{ const = Nothing
, format = Nothing
, pattern = Nothing
}
|> SuccessType
, bodyTypeAnnotation = Elm.Annotation.string
Expand Down
Loading
Loading