Skip to content

Commit 5ee5f4c

Browse files
Language.Nix.Identifier: add parseM examples
1 parent 1c0287d commit 5ee5f4c

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

language-nix/src/Language/Nix/Identifier.hs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ import Text.PrettyPrint.HughesPJClass as PP
3333
-- >>> pPrint (ident # "foo.bar")
3434
-- "foo.bar"
3535
--
36+
-- The 'HasParser' class allows parsing rendered identifiers even if they are
37+
-- quoted:
38+
--
39+
-- >>> parseM "Identifier" "hello" :: Maybe Identifier
40+
-- Just (Identifier "hello")
41+
-- >>> parseM "Identifier" "\"3rd party\"" :: Maybe Identifier
42+
-- Just (Identifier "3rd party")
43+
--
3644
-- __Warning__: Identifiers /may not/ contain @\'\\0\'@, but this is not
3745
-- checked during construction!
3846
--

0 commit comments

Comments
 (0)