Skip to content

[BUG] -XOverloadedRecordDot doesn't handle properly #28

Open
@s-and-witch

Description

@s-and-witch

Description

Attempt to use -XOverloadedRecordDot inside the interpolation would cause an error, because foo.bar is parsed as foo . bar

To Reproduce

{-# LANGUAGE QuasiQuotes, TemplateHaskell, OverloadedRecordDot, NoFieldSelectors #-}
module Main where
import Text.Interpolation.Nyan
import Data.Text (Text)

main :: IO ()
main = pure ()

data X = MkX { field :: Int }

foo :: X -> Text
foo x = [int|| X is #{x.field} |]

This would cause an error:

    • Variable not in scope: field :: a0 -> b0

If you try to remove -XNoFieldSelectors, then there would be an error about types mismatch

    • Couldn't match expected type ‘Int -> c0’ with actual type ‘X’
    • In the first argument of ‘(.)’, namely ‘x’

Expected behavior

Successful compilation, like in foo x = let f = x.field in [int|| X is #{f} |]

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions