[Haskell-beginners] what type is 'Val 9' when 'Val Int' a ctor for 'Expr e'?

Daniel Fischer daniel.is.fischer at web.de
Thu Oct 23 00:10:21 EDT 2008


Am Donnerstag, 23. Oktober 2008 05:36 schrieb Larry Evans:
> Thanks Deaniel.  The fog in my head begins to clear.
> I took Antoine's suggestion and got:
> <---cut here ---
> GHCi, version 6.8.2: http://www.haskell.org/ghc/  :? for help
> Loading package base ... linking ... done.
> Prelude> :load
> "/home/evansl/prog_dev/haskell/my-code/uniplate.try.phantom.hs"
> [1 of 1] Compiling Main             (
> /home/evansl/prog_dev/haskell/my-code/uniplate.try.phantom.hs, interpreted
> ) Ok, modules loaded: Main.
> *Main> let val_9 = Val 9
> Loading package mtl-1.1.0.0 ... linking ... done.
> Loading package array-0.1.0.0 ... linking ... done.
> Loading package containers-0.1.0.1 ... linking ... done.
> Loading package uniplate-1.2.0.1 ... linking ... done.
> *Main> :t val_9
> val_9 :: Expr e
> *Main> print val_9
> Val 9
> *Main>
>
>  >---cut here---
>
> I guess the phantom type mentioned in Antoine's post  is the e in:
>
> val_9::Expr e
>
> ?

Exactly. That type is never used in any value of type (Expr e), therefore it 
is called a 'phantom' type. It only serves as a tag to prevent mixing Expr's 
with different type parameters.

Cheers,
Daniel


More information about the Beginners mailing list