Christophe Poucet wrote:
> I'm not certain but I think this will still fail for exactly the piece that
> you ignored, which is the crux of the problem.
-- You're not looking for this solution, right?
import List
type Var = String
type Const = String
data MonoType mt = TyVar Var
| TyConst Const [mt] deriving (Eq, Show)
data PolyType mt = TyPoly [Var] mt deriving (Show)
newtype FMT = FMT (MonoType FMT)
class Types a where
freeVars :: a -> [Var]
instance Types FMT where
freeVars (FMT (TyVar x)) = [x]
freeVars (FMT (TyConst _ xs)) = nub . concatMap freeVars $ xs
main = print $ freeVars
(FMT (TyConst
"foo"
[(FMT (TyVar "abc")),
(FMT (TyVar "123")),
(FMT (TyConst
"bar"
[(FMT (TyVar "www"))]))]))
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe