I want to use a little of elm/parser. Can I reference Parser.(|.) without importing the operator at the top level? So far neither Parser.|. or Parser.(|.) works.
Currently, I could just import them, as long as I never need to import another operator by the same name.
Since Elm 0.19 doesn’t allow user-defined operators, you’re very unlikely (maybe even guaranteed?) to never run into a conflict with another operator, since all the operators you could possibly use are defined in the elm/* packages.
Then use it by ‘merging’ it with the actual Parser module:
module Main
import Parser exposing (Parser)
import Parser.NamedFunctions as Parser
type alias Point =
{ x : Int
, y : Int
}
pointParser : Parser Point
pointParser =
Parser.succeed Point
|> Parser.ignore (Parser.symbol "(")
|> Parser.keep Parser.int
|> Parser.ignore (Parser.symbol ",")
|> Parser.keep Parser.int
|> Parser.ignore (Parser.symbol ")")
This way the operators are only exposed at the top level within the Parser.NamedFunctions module.
(Note: I agree with @adeschamps that you shouldn’t actually have to worry about conflicts. I just prefer normal functions to operators anyways!)
Thanks. Wondered if I was missing something. I knew it wasn’t a big deal without user operators, and that a renamer-module would be a workaround in a pinch.