aboutsummaryrefslogtreecommitdiffstats
path: root/src/Data/JLD/Model/URI.hs
blob: 07cf8a9dd04fe4fa48c4110108b1946251ea0695 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
module Data.JLD.Model.URI (parseUri, uriToIri) where

import Data.JLD.Prelude

import Data.RDF (IRIRef, parseIRI)
import Text.Megaparsec (MonadParsec (..), Parsec, runParser)
import Text.URI (URI, parser, render)

parseUri :: Text -> Maybe URI
parseUri = runParser (parser <* eof :: Parsec Void Text URI) "" .> either (const Nothing) Just

uriToIri :: URI -> Maybe IRIRef
uriToIri = render .> parseIRI .> either (const Nothing) Just