[Haskell-cafe] about GADTs on ghci

Luke Palmer lrpalmer at gmail.com
Tue Nov 27 08:16:36 EST 2007


On Nov 27, 2007 12:57 PM, Yu-Teh Shen <shenyute at gmail.com> wrote:
> i have seen the documents in
> http://www.haskell.org/haskellwiki/Generalised_algebraic_datatype
> but i can not run the following code on ghci
>
> ex:
>
> data Term x where
>     K :: Term (a -> b -> a)
>     S :: Term ((a -> b -> c)  -> (a -> b) -> a -> c)
>     Const :: a -> Term a
>     (:@) :: Term (a -> b) -> (Term a) -> Term b
> infixl 6 :@
>
> could any tell me how to run the code?

Put it in a file (eg ski.hs), and run:

  % ghci -fglasgow-exts ski.hs

You cannot enter it directly into ghci; you can't define new data
types interactively.

You can also put the line

{-# OPTIONS_GHC -fglasgow-exts #-}

At the top, to turn on glasgow extensions whenever GHC compiles this file.

Luke


More information about the Haskell-Cafe mailing list