Skip to content

Instantly share code, notes, and snippets.

@KaneTW
Created June 17, 2016 11:14
Show Gist options
  • Save KaneTW/e618339a4b11e06971d60c3218fbc3e6 to your computer and use it in GitHub Desktop.
Save KaneTW/e618339a4b11e06971d60c3218fbc3e6 to your computer and use it in GitHub Desktop.
-- GHC8
-- the below code is docCommentLine from src/Idris/Parser/Helpers.hs, contentsInner is the do block at lines 202-206
*Idris.Parser.Helpers> runparser (string "|||" >> many (satisfy (==' ')) >> option "" contentsInner >>= \contents -> eol >> someSpace >> return contents) idrisInit "" "||| foo"
Success "foo"
*Idris.Parser.Helpers> let pars = string "|||" >> many (satisfy (==' ')) >> option "" contentsInner >>= \contents -> eol >> someSpace >> return contents
*Idris.Parser.Helpers> runparser pars idrisInit "" "|||foo"
Failure (ErrInfo {_errDoc = :1:7: error: unexpected
EOF, expected: end of line
|||foo<EOF>
^ , _errDeltas = [Directed "" 0 6 6 6]})
*Idris.Parser.Helpers> :t runparser (string "|||" >> many (satisfy (==' ')) >> option "" contentsInner >>= \contents -> eol >> someSpace >> return contents)
:: TokenParsing (StateT st IdrisInnerParser) =>
st -> String -> String -> Result [Char]
*Idris.Parser.Helpers> :t runparser pars
runparser pars :: st -> String -> String -> Result [Char]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment