Skip to content

Instantly share code, notes, and snippets.

@dacr
Last active February 3, 2026 20:22
Show Gist options
  • Select an option

  • Save dacr/18ff8eb58cd6da07fd320ed4f2832d04 to your computer and use it in GitHub Desktop.

Select an option

Save dacr/18ff8eb58cd6da07fd320ed4f2832d04 to your computer and use it in GitHub Desktop.
cats-parse graph query language experiment - hello world 1 / published by https://github.com/dacr/code-examples-manager #0d961a8d-0863-4c3f-92d5-793e6f86ff7a/f43eda0d7f0d565e5c20b665f65e44ea04cd8cb7
// summary : cats-parse graph query language experiment - hello world 1
// keywords : scala, typelevel, cats-parse, hello-world, @testable
// publish : gist
// authors : David Crosson
// license : Apache License Version 2.0 (https://www.apache.org/licenses/LICENSE-2.0.txt)
// id : 0d961a8d-0863-4c3f-92d5-793e6f86ff7a
// created-on : 2025-03-13T14:02:18+01:00
// managed-by : https://github.com/dacr/code-examples-manager
// run-with : scala-cli $file
// ---------------------
//> using scala "3.6.4"
//> using dep "org.typelevel::cats-parse:1.1.0"
//> using dep "com.lihaoyi::pprint:0.9.0"
// ---------------------
import cats.parse.Parser
import cats.parse.Rfc5234.lwsp
val helloParser = lwsp *> Parser.ignoreCase("hello") *> lwsp *> Parser.ignoreCase("world") *> lwsp
val results = List(
"hello world",
"Hello World",
" Hello World ",
"HelloWorld"
).map(s => helloParser.parseAll(s))
pprint.pprintln(results)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment