\documentclass{article}
\pagestyle{empty}
\usepackage{relsize}
\usepackage{amssymb}
\usepackage[unicode,hidelinks]{hyperref}
\usepackage[makeindex,nomain]{glossaries-extra}
\newglossary[nlg]{notation}{not}{ntn}{Symbols}
\makeglossaries
\newcommand{\booleanSetSymbol}{\mathbb{B}}%%% for pdflatex
% \newcommand{\booleanSetSymbol}{𝔹}%%% for lualatex
\DeclareFontEncoding{LS1}{}{}
\DeclareFontSubstitution{LS1}{stix}{m}{n}
\DeclareSymbolFont{stixsymbols2}{LS1}{stixfrak}{m}{n}%%% for \typecolon (we call is \hasSortSymbol) ⦂ (U+2982)
\newcommand{\hasSortSymbol}{{\fontencoding{LS1}\fontfamily{stixfrak}\selectfont\smaller\char"25}}%%% for pdflatex
% \newcommand{\hasSortSymbol}{⦂}%%% for lualatex
%\usepackage{unicode-math}%%% for lualatex
\glssetcategoryattribute{mathrelation}{hyperoutside}{false}
\glssetcategoryattribute{mathrelation}{textformat}{mathrel}
\newglossaryentry{not:booleanValues}{type=notation, name=\(\booleanSetSymbol\), text=\booleanSetSymbol, description={The set of Boolean values.}}
\newglossaryentry{not:function}{type=notation, name={\(\_\mathord{\to}\_\)}, text={\_\to\_}, sort={function}, description={The notation \(X{\to}Y\) means the set of all functions with domain \(X\) and codomain \(Y\). Following Bourbaki, we see a function as a triple (function graph, domain, codomain); a function \(f\penalty1\in\penalty1 X{\to}Y\), traditionally written as \(f\colon\penalty1 X\penalty2\to\penalty2 Y\), is thus \(\bigl(\mskip-1mu plus.5mu minus.5mu\{(x,f\mskip-.4mu plus.2mu minus.2mu (x\mskip-.3mu plus.15mu minus.15mu)\mskip-.5mu plus.25mu minus.25mu)\penalty2\mid\penalty1 x\mskip-3mu plus1mu minus1mu\in\mskip-3mu plus1mu minus1mu X \penalty3\land\penalty3 y\mskip-3mu plus1mu minus1mu\in\mskip-3mu plus1mu minus1mu Y\},\penalty1 X,\penalty1 Y\mskip-.3mu plus.15mu minus.15mu\bigr)\).}, user1={function}, user2={functions}, user3={map}, user4={maps}, user5={\colon}, user6={\to}}
\newglossaryentry{not:hasSort}{type=notation, name={\hasSortSymbol}, category=mathrelation, text={\text{\hasSortSymbol}}, sort={:}, description={Typing relation: \(x\mathrel{\text{\hasSortSymbol}} S\) means that the variable \(x\) has sort \(S\).}}
\begin{document}%
\newlength{\myLen}\setlength{\myLen}{32em}%
\noindent Line 1. With gls:\\
\hspace*{\myLen}\(f\gls{not:hasSort}\Sigma\mathrel{\glsuservi{not:function}}\gls{not:booleanValues}\)\\
\noindent Line 4. With gls and wrgloss=after:\\
\hspace*{\myLen}\(f\gls{not:hasSort}\Sigma\mathrel{\glsuservi{not:function}}\gls[wrgloss=after]{not:booleanValues}\)\\
\noindent Line 7.
\renewcommand*{\glslinkwrcontent}[1]{#1}%%% a quick hack according to the text concerning v1.48 in http://mirrors.ctan.org/macros/latex/contrib/glossaries-extra/CHANGES .  Without this hack, as above, the distances around \gls{not:hasSort} are improper: it should be spaced as mathrel, but it isn't.  With this hack, as below, there is a spurious space after an automatic line break.
With gls:\\
\hspace*{\myLen}\(f\gls{not:hasSort}\Sigma\mathrel{\glsuservi{not:function}}\gls{not:booleanValues}\)\\
\noindent Line 10. With gls and wrgloss=after:\\
\hspace*{\myLen}\(f\gls{not:hasSort}\Sigma\mathrel{\glsuservi{not:function}}\gls[wrgloss=after]{not:booleanValues}\)\\
\noindent Line 13.
\printglossaries
\end{document}