Skip to content

Commit

Permalink
Add toRecovered util for unifying parse results
Browse files Browse the repository at this point in the history
  • Loading branch information
natefaubion committed Mar 27, 2021
1 parent 4a04fe1 commit 0fa3a7a
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/PureScript/CST.purs
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ module PureScript.CST
, parseType
, parseBinder
, printModule
, toRecovered
) where

import Prelude
import Prim hiding (Type)

import Data.Array.NonEmpty (NonEmptyArray)
import Data.Array.NonEmpty as NonEmptyArray
Expand All @@ -21,7 +23,6 @@ import Data.Lazy as Z
import Data.Maybe (Maybe(..))
import Data.Newtype (unwrap)
import Data.Tuple (Tuple(..))
import Prim hiding (Type)
import PureScript.CST.Lexer (lex)
import PureScript.CST.Parser (Recovered, parseModuleBody, parseModuleHeader)
import PureScript.CST.Parser as Parser
Expand Down Expand Up @@ -50,6 +51,9 @@ toRecoveredParserResult = case _ of
Left err ->
ParseFailed err

toRecovered :: forall f. f Void -> Recovered f
toRecovered = unsafeCoerce

runRecoveredParser :: forall a. Parser (Recovered a) -> String -> RecoveredParserResult a
runRecoveredParser p = toRecoveredParserResult <<< flip runParser p <<< lex

Expand Down

0 comments on commit 0fa3a7a

Please sign in to comment.