From c99e94bdbc37e91993a1a03057e03d2b77efdf99 Mon Sep 17 00:00:00 2001 From: "Patrick M. Niedzielski" Date: Wed, 20 Mar 2024 06:24:01 +0000 Subject: [PATCH] Sort generated subjects alphabetically This patch sorts all IRI subject declarations that are generated from an RDFS or OWL input alphabetically. This has the side effect of placing all classes first and all predicates after. --- src/Data/RDF/Vocabulary/Generator/VocabularyGenerator.hs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Data/RDF/Vocabulary/Generator/VocabularyGenerator.hs b/src/Data/RDF/Vocabulary/Generator/VocabularyGenerator.hs index 4286ffa..1cfca09 100644 --- a/src/Data/RDF/Vocabulary/Generator/VocabularyGenerator.hs +++ b/src/Data/RDF/Vocabulary/Generator/VocabularyGenerator.hs @@ -8,7 +8,7 @@ where import Control.Monad (join) import Data.Char (isLower) -import Data.List (nub) +import Data.List (nub, sortBy) import qualified Data.Map as M import Data.Maybe (maybeToList) import Data.RDF @@ -78,7 +78,7 @@ vocabulary graph = (prefix, iri) <- M.toList prefixMappings' let name = mkName . T.unpack . escape $ prefix <> "NS" return $ declarePrefix name prefix iri - iriDecls = snd <$> nameDecls + iriDecls = fmap snd . sortBy (\x y -> fst y `compare` fst x) $ nameDecls irisDecl = declareIRIs $ fst <$> nameDecls in sequence $ irisDecl : namespaceDecls <> iriDecls