when does ghc(i) expand type synonyms?

Dear cafe, my students were asking: why are types printed differently here? ghci> :set +t ghci> "foo" "foo" it :: String ghci> reverse "foo" "oof" it :: [Char] ... and I add ghci> fst ("foo", 42) "foo" it :: String compiler docs do not really explain the difference https://downloads.haskell.org/ghc/latest/docs/users_guide/ghci.html#ghci-cmd... (it says "display the type of .." while technically it is "display some representation of the type of ..."?) I found this explanation of a somewhat related issue https://gitlab.haskell.org/ghc/ghc/-/issues/9183#note_83743 While playing around with this, I noticed: ghci> let x = "foo" in (x <> reverse x) "foooof" it :: String ghci> let x = "foo" in (x ++ reverse x) "foooof" it :: [Char] Well, it's just optics: when I extract the type programmatically, the synonym necessarily does get expanded ghci> import Data.Data ghci> typeOf (let x = "foo" in (x <> reverse x)) [Char] it :: TypeRep - Johannes

Adjacently, I think a valuable question to ask is "how can you set type alias defaults in things like :t and in errors?"
participants (2)
-
Dan Dart
-
Johannes Waldmann