Git Product home page Git Product logo

Comments (4)

phischu avatar phischu commented on July 20, 2024

In the first case the information at 6:14 should be:

PFieldWildcard
  (Scoped (RecPatWildcard [
    Selector (ModuleName () "RecordSelector") (Ident () "field") (Ident () "Record") [Ident () "Record"]])
      (SrcSpanInfo{srcInfoSpan = SrcSpan "RecordSelector.hs" 6 14 6 16,
                  srcInfoPoints = []}))

This should allow you to figure out that the local value "field" came from a record pattern wildcard.

Alternatively we could add more information to the LocalValue constructor.

In the second case the left-hand-side of the record field pattern should be resolved to a global symbol that refers to the record selector.

from haskell-names.

nomeata avatar nomeata commented on July 20, 2024

This should allow you to figure out that the local value "field" came from a record pattern wildcard.

Fair enough. I guess I was hoping to not have to keep track of any kind of environment for this renaming (which would allow me to do the renaming using a simple generic traversal instead of manually going through the AST), but maybe that is expecting too much.

In the second case the left-hand-side of the record field pattern should be resolved to a global symbol that refers to the record selector.

Right – so that is a bug, isn’t it?

from haskell-names.

phischu avatar phischu commented on July 20, 2024

Right – so that is a bug, isn’t it?

Yes, should be fixed by #89 which also fixes the other bug you encountered.

I am thinking about adding a field to LocalValue but it feels a little ad-hoc.

In the meantime I can offer you two workarounds:

  1. Rename local values too.
data RecordSelector_Record a = RecordSelector_Record { RecordSelector_field :: a }
RecordSelector_unRecord RecordSelector_r = RecordSelector_field
  where RecordSelector_Record { .. } = RecordSelector_r
  1. Desugar record wildcards and puns.
data RecordSelector_Record a = RecordSelector_Record { RecordSelector_field :: a }
RecordSelector_unRecord r = field
  where RecordSelector_Record { RecordSelector_field = field } = r

P.S.: Last time I tried to merge Haskell programs into one big module I got stuck because the TypeFamilies extension broke code from another module.

from haskell-names.

nomeata avatar nomeata commented on July 20, 2024
  1. Rename local values too.

Well, to do so in my case I need to know what module the Record is defined in, so that the names of the renamed local values match that.

  1. Desugar record wildcards and puns.

That might be the way to go. I did that by hand for now.

P.S.: Last time I tried to merge Haskell programs into one big module I got stuck because the TypeFamilies extension broke code from another module.

Luckily the itch I was scratching does not use TypeFamilies.

from haskell-names.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.