Syntactically invalid result on Esqueleto code #101

Closed
opened 2018-01-04 05:03:44 +01:00 by MaxGabriel · 6 comments
MaxGabriel commented 2018-01-04 05:03:44 +01:00 (Migrated from github.com)

Running brittany /Users/maximiliantagher/Documents/Mercury/hs/mercury-web-backend/src/Handler/Home.hs gives me: "ERROR: brittany pretty printer returned syntactically invalid result.", even though the code compiles fine.

Source file:

module Handler.Home where

import Import
import qualified Database.Esqueleto      as E
import           Database.Esqueleto      ((^.))
import Data.String.Conversions

getHomeR :: Handler Value
getHomeR = do
    result <- runDB $
        E.select $
        E.from $ \(u `E.InnerJoin` ou `E.InnerJoin` o) -> do
        E.on (ou ^. OrganizationUserOrganizationId E.==. o ^. OrganizationId)
        E.on (u ^. UserId E.==. ou ^. OrganizationUserUserId)
        return (u, ou, o)
    putStrLn $ cs $ show result
    returnJson [1 :: Integer]

If you remove the Esqueleto code (the result <- ... block of code), brittany runs successfully.

Version:

maximiliantagher@Maximilians-MacBook-Pro ~> brittany --version
brittany version 0.9.0.0
Copyright (C) 2016-2017 Lennart Spitzner
There is NO WARRANTY, to the extent permitted by law.

OS: macOS High Sierra 10.13.2
GHC: Should be 8.2.2 since brittany was installed with LTS 10.

Installation method: stack install brittany --resolver lts-10.0

I also tried with my older version of brittany, which was 0.8.something, and compiled with GHC 8.0.x.

Brittany configuration:

conf_debug:
  dconf_roundtrip_exactprint_only: false
  dconf_dump_bridoc_simpl_par: false
  dconf_dump_ast_unknown: false
  dconf_dump_bridoc_simpl_floating: false
  dconf_dump_config: false
  dconf_dump_bridoc_raw: false
  dconf_dump_bridoc_final: false
  dconf_dump_bridoc_simpl_alt: false
  dconf_dump_bridoc_simpl_indent: false
  dconf_dump_annotations: false
  dconf_dump_bridoc_simpl_columns: false
  dconf_dump_ast_full: false
conf_forward:
  options_ghc:
  - -XLambdaCase
  - -XMultiWayIf
  - -XGADTs
  - -XPatternGuards
  - -XViewPatterns
  - -XRecursiveDo
  - -XTupleSections
  - -XExplicitForAll
  - -XImplicitParams
  - -XQuasiQuotes
  - -XTemplateHaskell
  - -XBangPatterns
  - -XFlexibleContexts
  - -XOverloadedStrings
  - -XRecordWildCards
  - -XMultiParamTypeClasses
  - -XTypeFamilies
  - -XFlexibleInstances
  - -XGeneralizedNewtypeDeriving
conf_errorHandling:
  econf_ExactPrintFallback: ExactPrintFallbackModeInline
  econf_Werror: false
  econf_omit_output_valid_check: false
  econf_produceOutputOnErrors: false
conf_preprocessor:
  ppconf_CPPMode: CPPModeAbort
  ppconf_hackAroundIncludes: false
conf_version: 1
conf_layout:
  lconfig_altChooser:
    tag: AltChooserBoundedSearch
    contents: 3
  lconfig_importColumn: 60
  lconfig_alignmentLimit: 30
  lconfig_indentListSpecial: true
  lconfig_indentAmount: 2
  lconfig_alignmentBreakOnMultiline: true
  lconfig_cols: 160
  lconfig_indentPolicy: IndentPolicyFree
  lconfig_indentWhereSpecial: true
  lconfig_columnAlignMode:
    tag: ColumnAlignModeMajority
    contents: 0.7

If you'd like, I can try to reproduce in a standalone file that you could compile yourself (this is just a random file in a web server I'm working on).

Running `brittany /Users/maximiliantagher/Documents/Mercury/hs/mercury-web-backend/src/Handler/Home.hs` gives me: "ERROR: brittany pretty printer returned syntactically invalid result.", even though the code compiles fine. Source file: ```haskell module Handler.Home where import Import import qualified Database.Esqueleto as E import Database.Esqueleto ((^.)) import Data.String.Conversions getHomeR :: Handler Value getHomeR = do result <- runDB $ E.select $ E.from $ \(u `E.InnerJoin` ou `E.InnerJoin` o) -> do E.on (ou ^. OrganizationUserOrganizationId E.==. o ^. OrganizationId) E.on (u ^. UserId E.==. ou ^. OrganizationUserUserId) return (u, ou, o) putStrLn $ cs $ show result returnJson [1 :: Integer] ``` If you remove the Esqueleto code (the `result <- ...` block of code), brittany runs successfully. Version: ``` maximiliantagher@Maximilians-MacBook-Pro ~> brittany --version brittany version 0.9.0.0 Copyright (C) 2016-2017 Lennart Spitzner There is NO WARRANTY, to the extent permitted by law. ``` OS: macOS High Sierra 10.13.2 GHC: Should be 8.2.2 since brittany was installed with LTS 10. Installation method: `stack install brittany --resolver lts-10.0` I also tried with my older version of brittany, which was 0.8.something, and compiled with GHC 8.0.x. Brittany configuration: ```yaml conf_debug: dconf_roundtrip_exactprint_only: false dconf_dump_bridoc_simpl_par: false dconf_dump_ast_unknown: false dconf_dump_bridoc_simpl_floating: false dconf_dump_config: false dconf_dump_bridoc_raw: false dconf_dump_bridoc_final: false dconf_dump_bridoc_simpl_alt: false dconf_dump_bridoc_simpl_indent: false dconf_dump_annotations: false dconf_dump_bridoc_simpl_columns: false dconf_dump_ast_full: false conf_forward: options_ghc: - -XLambdaCase - -XMultiWayIf - -XGADTs - -XPatternGuards - -XViewPatterns - -XRecursiveDo - -XTupleSections - -XExplicitForAll - -XImplicitParams - -XQuasiQuotes - -XTemplateHaskell - -XBangPatterns - -XFlexibleContexts - -XOverloadedStrings - -XRecordWildCards - -XMultiParamTypeClasses - -XTypeFamilies - -XFlexibleInstances - -XGeneralizedNewtypeDeriving conf_errorHandling: econf_ExactPrintFallback: ExactPrintFallbackModeInline econf_Werror: false econf_omit_output_valid_check: false econf_produceOutputOnErrors: false conf_preprocessor: ppconf_CPPMode: CPPModeAbort ppconf_hackAroundIncludes: false conf_version: 1 conf_layout: lconfig_altChooser: tag: AltChooserBoundedSearch contents: 3 lconfig_importColumn: 60 lconfig_alignmentLimit: 30 lconfig_indentListSpecial: true lconfig_indentAmount: 2 lconfig_alignmentBreakOnMultiline: true lconfig_cols: 160 lconfig_indentPolicy: IndentPolicyFree lconfig_indentWhereSpecial: true lconfig_columnAlignMode: tag: ColumnAlignModeMajority contents: 0.7 ``` If you'd like, I can try to reproduce in a standalone file that you could compile yourself (this is just a random file in a web server I'm working on).
eborden commented 2018-01-15 21:32:51 +01:00 (Migrated from github.com)

As far as I can tell this is an issue with infix type constructors.

This explodes:

getHomeR = E.from $ \(u `E.InnerJoin` ou) -> return (u, ou)

This does not:

getHomeR = E.from $ \(E.InnerJoin u ou) -> return (u, ou)
As far as I can tell this is an issue with infix type constructors. This explodes: ``` getHomeR = E.from $ \(u `E.InnerJoin` ou) -> return (u, ou) ``` This does not: ``` getHomeR = E.from $ \(E.InnerJoin u ou) -> return (u, ou) ```
eborden commented 2018-01-15 21:42:31 +01:00 (Migrated from github.com)

produced with --omit-output-check

getHomeR = \(uE.InnerJoinou) -> return (u, ou)

getHomeR = \(E.InnerJoin u ou) -> return (u, ou)
produced with `--omit-output-check` ``` getHomeR = \(uE.InnerJoinou) -> return (u, ou) getHomeR = \(E.InnerJoin u ou) -> return (u, ou) ```
eborden commented 2018-01-15 21:55:46 +01:00 (Migrated from github.com)

Should have a fix for this soon.

Should have a fix for this soon.
eborden commented 2018-01-15 22:15:39 +01:00 (Migrated from github.com)

With the linked fix:

module Handler.Home where

import Import
import qualified Database.Esqueleto      as E
import           Database.Esqueleto      ((^.))
import Data.String.Conversions

getHomeR :: Handler Value
getHomeR = do
  result <-
    runDB $ E.select $ E.from $ \(u `E.InnerJoin` ou `E.InnerJoin` o) -> do
      E.on (ou ^. OrganizationUserOrganizationId E.==. o ^. OrganizationId)
      E.on (u ^. UserId E.==. ou ^. OrganizationUserUserId)
      return (u, ou, o)
  putStrLn $ cs $ show result
  returnJson [1 :: Integer]
With the linked fix: ``` module Handler.Home where import Import import qualified Database.Esqueleto as E import Database.Esqueleto ((^.)) import Data.String.Conversions getHomeR :: Handler Value getHomeR = do result <- runDB $ E.select $ E.from $ \(u `E.InnerJoin` ou `E.InnerJoin` o) -> do E.on (ou ^. OrganizationUserOrganizationId E.==. o ^. OrganizationId) E.on (u ^. UserId E.==. ou ^. OrganizationUserUserId) return (u, ou, o) putStrLn $ cs $ show result returnJson [1 :: Integer] ```
MaxGabriel commented 2018-01-16 01:28:39 +01:00 (Migrated from github.com)

Thank you! Do you need me to test this or anything?

Thank you! Do you need me to test this or anything?
lspitzner commented 2018-03-12 23:18:52 +01:00 (Migrated from github.com)

The fix by eborden is published as part of 0.9.0.1.

The fix by eborden is published as part of 0.9.0.1.
Sign in to join this conversation.
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: hexagoxel/brittany#101
There is no content yet.