Skip to content

Commit

Permalink
Adopt Realm from Eucalyptus
Browse files Browse the repository at this point in the history
  • Loading branch information
propensive committed Feb 19, 2024
1 parent 14ecf92 commit 401e6b6
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/core/realm.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package fulminate

import anticipation.*

import scala.quoted.*

object Realm:
def make(name: Text): Realm = new Realm(name)

case class Realm(name: Text)

object Fulminate:
def realm(context: Expr[StringContext])(using Quotes): Expr[Realm] =
import quotes.reflect.*
val name: String = context.valueOrAbort.parts.head
if !name.matches("[a-z]+") then fail(msg"the realm name should comprise only of lowercase letters")
else '{Realm.make(${Expr(name)}.tt)}

extension (inline context: StringContext)
inline def realm(): Realm = ${Fulminate.realm('context)}

0 comments on commit 401e6b6

Please sign in to comment.