-
Notifications
You must be signed in to change notification settings - Fork 25
clarify that a var name may refer to a type #114
base: master
Are you sure you want to change the base?
Conversation
I am confident this is how we use VarName's internally already as I found this snippet from the Elm.Data.Exposing module: type ExposedItem = ExposedValue VarName -- exposing (foo) | ExposedType VarName -- exposing (Foo) | ExposedTypeAndAllConstructors VarName -- exposing (Foo(..))
To be more precise, type ConcreteType a
= ...
| UserDefinedType
{ qualifiedness : a
, name : String <---------------------------------
, args : List (ConcreteType a)
}
parseTypeAnnotation "x : MyAwesomeType"
-->
{ varName = "x"
, type_ =
UserDefinedType
{ qualifiedness = PossiblyQualified Nothing
, name = "MyAwesomeType"
, args = []
}
} So... yeah we could say type alias TypeName = String and use that? eg. type ExposedItem
= ExposedValue VarName -- exposing (foo)
| ExposedType TypeName -- exposing (Foo)
| ExposedTypeAndAllConstructors TypeName -- exposing (Foo(..)) This |
Aha that makes sense, I will update this PR to change |
Counter point in type alias Module expr annotation qualifiedness =
-- TODO comments? doc comments?
{ -- TODO somewhere check that dependencies' exposing lists contain only what's in that module's exposing list
imports : Dict ModuleName Import
, name : ModuleName
, filePath : FilePath
, declarations : Dict VarName (Declaration expr annotation qualifiedness)
, type_ : ModuleType
, exposing_ : Exposing
} specifically |
Fair enough. I don't see a way from this other than |
The root issue here is that we are using a type alias rather than a custom type, which means keeping these string like types consistent is tricky. |
@harrysarson In an earlier version of this codebase I had What's your stance on that? TypeAlias [ VarName "a" ] (Maybe (Var 0)) instead of TypeAlias ["a"] (Maybe (Var 0)) (I guess it's not that bad now that I look at it 🤔 ) |
I am confident this is how we use VarName's internally already as
I found this snippet from the Elm.Data.Exposing module: