type family Bar a :: * type instance Bar () = String data Foo a = Bar a | Baz a a
ghci> Bar () What happens? There is a lot of ambiguity between term and type levels in Haskell. (,); []; etc. It's only the overall structure of the language that disambiguates them; you can't necessarily tell just by looking at an expression and the existing definitions in scope. -- Dan On Tue, Sep 20, 2011 at 7:02 PM, <[email protected]> wrote: > Would it be possible to have no command at all? Types are distinguished by > upper-case letters, so it should be possible to tell whether a given > expression is a value-level or a type-level expression. > > I guess that's not strictly true, since the expression could be _only_ type > variables -- but then I think it would be forgivable to just use the > value-level evaluator for those ambiguous ones. > > ~d > > Quoting Simon Peyton-Jones <[email protected]>: > >> Sean >> >> Yes, this has been asked for before, and it wouldn't be hard to implement. >> >> >> What should the GHCi command be *called*? >> >> We already have :kind, which displays the kind of a type. Maybe :kind! >> should evaluate the type as well? Or perhaps :kind should evaluate anyway >> (although that would be a bit inconsistent with :type which does not >> evaluate the expression) >> >> Or :normtype? short for normalise type >> >> Simon >> >> From: [email protected] >> [mailto:[email protected]] On Behalf Of Sean Leather >> Sent: 20 September 2011 11:34 >> To: GHC Users List >> Subject: Evaluating type expressions in GHCi >> >> I would like to ask GHCi for the type that a type expression will evaluate >> to, once all definitions of type synonyms and (when possible) type families >> have been inlined. >> >> It appears that I can do some part of this for type T by using ":t >> undefined :: T": >> >> type family F a >> type instance F Int = Bool >> type instance F Bool = Int >> type instance F (a, b) = (F a, F b) >> >> ghci> :t undefined :: F (Int, Bool) >> undefined :: F (Int, Bool) :: (Bool, Int) >> >> I also get what I expect here: >> >> ghci> :t undefined :: F (a, Bool) >> undefined :: F (a, Bool) :: (F a, Int) >> >> Of course, this doesn't work on types of kinds other than *. >> >> Is it possible and worth having another GHCi command to perform this >> operation for any types? It could be the type analogue to :t such that it >> evaluates the type and gives its kind. >> >> Regards, >> Sean >> > > > > _______________________________________________ > Glasgow-haskell-users mailing list > [email protected] > http://www.haskell.org/mailman/listinfo/glasgow-haskell-users > _______________________________________________ Glasgow-haskell-users mailing list [email protected] http://www.haskell.org/mailman/listinfo/glasgow-haskell-users
