Skip to content

Commit

Permalink
Sort generated subjects alphabetically
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pniedzielski committed Mar 20, 2024
1 parent 09a4034 commit c99e94b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Data/RDF/Vocabulary/Generator/VocabularyGenerator.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit c99e94b

Please sign in to comment.