compiler icon indicating copy to clipboard operation
compiler copied to clipboard

Extracting function-argument as type-alias is a API-breaking change

Open opvasger opened this issue 6 years ago • 3 comments

Quick Summary: elm diff outputs that my function signature is a breaking the API of my package if I redefine its arguments as a type alias. I think this is related to #1895.

SSCCE

1.0 API

module packageApi exposing (foo)

foo : { bar : String } -> ()
foo = always ()

2.0 API, but could be 1.1.0?

module packageApi exposing (Bar, foo)

type alias Bar = 
    { bar : String
    }

foo : Bar -> ()
foo = always ()

But this doesn't seem breaking, and could probably be 1.1.0 with some changes to elm diff?

  • Elm: 0.19.0
  • Browser: No browser
  • Operating System: MacOS Mojave v10.14.6 (18G87)

Additional Details

I wouldn't mind taking a stab at implementing this into elm diff, but I'm not fluent in Haskell and dunno if this is trivial or complicated. Let me know if I should give it a try! :sunny:

I haven't tested this with arguments that isn't records, but I assume this would be the same.

opvasger avatar Aug 27 '19 16:08 opvasger

That actually is breaking since it removes the record constructor function, and you can't use Bar in your own type annotations

dullbananas avatar Jun 23 '20 04:06 dullbananas

Only the opposite change would actually be breaking; this issue talks about adding the Bar record constructor, not removing it.

harrysarson avatar Jun 23 '20 11:06 harrysarson

i swear i saw it the other way around

dullbananas avatar Jun 24 '20 20:06 dullbananas