Compiles!

This commit is contained in:
Philippe Pittoli 2024-01-18 05:00:11 +01:00
parent efe41a0d3f
commit 1ef64aafc2
2 changed files with 8 additions and 9 deletions

View File

@ -21,7 +21,6 @@ to generate this file without the comments in this block.
, "maybe" , "maybe"
, "prelude" , "prelude"
, "strings" , "strings"
, "tuples"
] ]
, packages = ./packages.dhall , packages = ./packages.dhall
, sources = [ "src/**/*.purs", "test/**/*.purs" ] , sources = [ "src/**/*.purs", "test/**/*.purs" ]

View File

@ -1,6 +1,6 @@
module Main where module Main where
import Parser (Parser, parse) import Parser (Parser(..))
import DomainParser (domain, label, ldh_str, sub_eof, subdomain) import DomainParser (domain, label, ldh_str, sub_eof, subdomain)
import Prelude (Unit, discard, show, ($), (<>)) import Prelude (Unit, discard, show, ($), (<>))
@ -8,8 +8,9 @@ import Prelude (Unit, discard, show, ($), (<>))
import Effect (Effect) import Effect (Effect)
import Effect.Console (log) import Effect.Console (log)
import Data.Maybe (Maybe(..)) import Data.Either (Either(..))
import Data.Tuple (Tuple(..)) --import Data.Maybe (Maybe(..))
--import Data.Tuple (Tuple(..))
import Data.String.CodeUnits (fromCharArray) import Data.String.CodeUnits (fromCharArray)
@ -39,12 +40,11 @@ import Data.String.CodeUnits (fromCharArray)
-- log $ toprint <> ", rest: " <> str -- log $ toprint <> ", rest: " <> str
logtest :: forall e v. String -> Parser e v -> String -> (v -> String) -> Effect Unit logtest :: forall e v. String -> Parser e v -> String -> (v -> String) -> Effect Unit
logtest fname (Parse p) str r = do logtest fname (Parser p) str r = do
log $ "(" <> fname <> ") parsing '" <> str <> "': " log $ "(" <> fname <> ") parsing '" <> str <> "': "
<> case p str of <> case p { string: str, position: 0 } of
Left { pos: pos, input: input, error: error } -> "failed: " <> error Left { position, error: _ } -> "failed at position " <> show position
Right { pos: pos, input: input, result: value } -> show (r x) <> " " <> show y Right { suffix, result } -> show (r result) <> " '" <> suffix.string <> "'"
Nothing -> "failed"
id :: forall a. a -> a id :: forall a. a -> a
id a = a id a = a