unisonweb/unison

Pattern matching requires full qualification, construction does not

Open

#1,272 opened on Feb 25, 2020

View on GitHub
 (0 comments) (0 reactions) (0 assignees)Haskell (304 forks)batch import
bugdxhelp wanted

Repository metrics

Stars
 (6,624 stars)
PR merge metrics
 (Avg merge 12d 19h) (6 merged PRs in 30d)

Description

I ran into something I've been able to boil down to this:

type Foo = Bar Nat

bar2 = Bar 2

extractFoo foo = match foo with
  Foo.Bar x -> x

I'm able to construct a Bar without qualifying it as Foo.Bar, but when pattern matching on it, the qualification is required. Without it, I guess this error:

  I don't know about any data constructor named Bar. Maybe make sure it's correctly spelled and
  that you've imported it:
  
      6 |   Bar x -> x

This feels quite inconsistent, and unless I'm overlooking something, I should be able to leave out the Foo qualification in this case.

I'm running the current master, release/M2-base-541-g2adb598e.

Contributor guide