diff --git a/app/Main.hs b/app/Main.hs index cbbd268..3900d7f 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -6,4 +6,4 @@ main :: IO () main = do text <- getContents - print $ Parsec.parse (File.parse <* Parsec.eof) "" text + print $ Parsec.parse (File.parse "" <* Parsec.eof) "" text diff --git a/src/Ubc/Parse/Syntax/File.hs b/src/Ubc/Parse/Syntax/File.hs index 3b94785..2ee3026 100644 --- a/src/Ubc/Parse/Syntax/File.hs +++ b/src/Ubc/Parse/Syntax/File.hs @@ -19,7 +19,7 @@ import qualified Ubc.Parse.Syntax.Struct as Struct import qualified Ubc.Parse.Syntax.Function as Function import qualified Ubc.Parse.Syntax.Statement as Statement import qualified Ubc.Parse.Syntax.Enumeration as Enumeration -import GHC.Generics (Generic) +import GHC.Generics (Generic, Generically(..)) import Data.Functor ((<&>)) data File = File @@ -35,10 +35,11 @@ data FileBody = FileBody , enumerations :: [Enumeration] } deriving stock (Show, Generic) - deriving (Semigroup, Monoid) via FileBody + deriving (Semigroup, Monoid) via Generically FileBody +-- dont use `deriving ... via FileBody` because that leads to a loop, somehow -parse :: Monad m => ParsecT String u m File -parse = File "" <$!> mconcat <$!> many fileMember +parse :: Monad m => String -> ParsecT String u m File +parse source = File source <$!> mconcat <$!> many fileMember fileMember :: Monad m => ParsecT String u m FileBody fileMember = choice diff --git a/src/Ubc/Parse/Syntax/Struct.hs b/src/Ubc/Parse/Syntax/Struct.hs index 03ab5ee..c8855b8 100644 --- a/src/Ubc/Parse/Syntax/Struct.hs +++ b/src/Ubc/Parse/Syntax/Struct.hs @@ -7,7 +7,7 @@ module Ubc.Parse.Syntax.Struct where -- yay, explicit dependency on ghc -import GHC.Generics (Generic) +import GHC.Generics (Generic, Generically(..)) import Control.Monad ((<$!>)) @@ -39,7 +39,7 @@ data StructBody = StructBody , functions :: [Function] } deriving stock (Generic, Show) - deriving (Semigroup, Monoid) via StructBody + deriving (Semigroup, Monoid) via Generically StructBody parse :: Monad m => ParsecT String u m Struct parse = do