... This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0. ... If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/. (.require [library [lux (.except) [abstract [equivalence (.only Equivalence)] [hash (.only Hash)] [order (.only Order)] [codec (.only Codec)]] [data ["[0]" text (.use "[1]#[0]" equivalence monoid)] ["[0]" product]]]]) ... (type Symbol ... [Text Text]) (with_template [] [(def .public ( [module short]) (-> Symbol Text) )] [module] [short] ) (def .public hash (Hash Symbol) (product.hash text.hash text.hash)) (def .public equivalence (Equivalence Symbol) (of ..hash equivalence)) (def .public order (Order Symbol) (implementation (def equivalence ..equivalence) (def (< [moduleP shortP] [moduleS shortS]) (if (text#= moduleP moduleS) (of text.order < shortP shortS) (of text.order < moduleP moduleS))))) (def .public separator ".") (def .public absolute (Codec Text Symbol) (implementation (def (encoded [module short]) (when module "" short _ (all text#composite module ..separator short))) (def (decoded input) (when (text.all_split_by ..separator input) (list short) {.#Right ["" short]} (list module short) {.#Right [module short]} _ {.#Left (text#composite "Invalid format for Symbol: " input)})))) (def .public (relative expected) (-> Text (Codec Text Symbol)) (implementation (def (encoded [module short]) (when module "" short .prelude (all text#composite ..separator short) _ (all text#composite (if (text#= expected module) ..separator module) ..separator short))) (def (decoded input) (when (text.all_split_by ..separator input) (list short) {.#Right ["" short]} (list "" short) {.#Right [.prelude short]} (list module short) {.#Right [module short]} (list "" "" short) {.#Right [expected short]} _ {.#Left (text#composite "Invalid format for Symbol: " input)}))))