Holmusk / elm-street

:deciduous_tree: Crossing the road between Haskell and Elm
Mozilla Public License 2.0
88 stars 6 forks source link

Newtypes wrapping a list is not supported without a record name #98

Closed arbus closed 5 years ago

arbus commented 5 years ago

If you have the following newtype:

newtype Foo = Foo [Text]

it gets converted to the Elm type:

type Foo = Foo List String

which is a compile error as the List String needs to be wrapped in parenthesis. If the newtype is instead wrapped with a record name:

newtype Foo = Foo { unFoo :: [Text] }

this converts just file as it becomes a record without the Foo Constructor.

I know that writing newtypes without a record name is not best practice, so is this a pattern that we want to support? If not, maybe we should update the README