Support for simple phantom types
- 主要言語
- Elm
- スター
- 107
- フォーク
- 28
- PR マージ指標
- 30日以内にマージされた PR はありません
説明
Currently, if we have a simple phantom type like this in Haskell:
```haskell
newtype Id a = Id { unId :: Text }
```
there exists a valid elm equivalent of:
```elm
type Id a = Id { unId : String }
```
However, trying to derive it with `deriveElmDef` fails with the error message:
```
Oops, can only derive data and newtype, not this: NewtypeD [] Main.Id [KindedTV a_6989586621679074905 StarT] Nothing (RecC Main.Id [(Main.unId,Bang NoSourceUnpackedness NoSourceStrictness,ConT Data.Text.Internal.Text)]) []
```
Redefining the initial definition of `Id` to use `data` instead of `newtype` and passing in a dummy type in the `DefineElm` clause like `DefineElm (Proxy @(Id Text))` will produce the following elm code which is invalid:
```elm
type alias Id a =
{ unId: String
}
```
and fails with the error message:
```
Type alias `Id` cannot have unused type variables: a
12|>type alias Id a =
13|> { unId: String
14|> }
You probably need to change the declaration like this:
type alias Id = ...
```
---
What is the current best strategy for sharing simple phantom types across Haskell and Elm?
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
評価
この issue はまだ評価されていません。