Comment by corrral

3 years ago

    {- You can optionally add types

       `x : T` means that `x` has type `T`
    -}

    let Config : Type =

Config's type is Type?

Clear as mud.

Config is a type, so it's type is Type.

  • Figured, but it's a pretty goofy way to introduce it after that comment.

    [EDIT] I mean, you can almost "who's on first?" this.

    "OK, what type do you want this to be?"

    "Type."

    "Yes, what type do you want it to be?"

    "Type."

    "Great, ok, yes, the type, what type is Config?"

    "Type."

    "WHAT IS THE NAME OF THE TYPE YOU WANT CONFIG TO BE???"

    "Type."

    flips desk

    • Is it? My takeaway is "oh cool, first-class types". Experimenting with this, I can write the following:

        let ConfigOf : Type -> Type = \(type : Type) ->
              {- What happens if you add another field here? -}
              { home : type
              , privateKey : type
              , publicKey : type
              }
        
        let Config : Type = ConfigOf Text
      

      and the rest of the example still works and evaluates the same.

      Also in a later example it has the expression `generate 10 Config buildUser`, which also works because of first-class types. Instead of needing generics, you just take a type as a regular parameter.