module CLaSH.Core.FreeVars where

import Unbound.LocallyNameless (Collection, fv)

import CLaSH.Core.Term         (Term, TmName)
import CLaSH.Core.Type         (TyName, Type)

-- | Gives the free type-variables in a Type
typeFreeVars :: Collection c
             => Type
             -> c TyName
typeFreeVars = fv

-- | Gives the free type-variables and free term-variables of a Term
termFreeVars :: Collection c
             => Term
             -> (c TyName, c TmName)
termFreeVars tm = (termFreeTyVars tm, termFreeIds tm)

-- | Gives the free term-variables of a Term
termFreeIds :: Collection c
            => Term
            -> c TmName
termFreeIds = snd . termFreeVars

-- | Gives the free type-variables of a Term
termFreeTyVars :: Collection c
               => Term
               -> c TyName
termFreeTyVars = fst . termFreeVars

module CLaSH.Core.FreeVars where

import Unbound.LocallyNameless (Collection, fv)

import CLaSH.Core.Term         (Term, TmName)
import CLaSH.Core.Type         (TyName, Type)

-- | Gives the free type-variables in a Type
typeFreeVars :: Collection c
             => Type
             -> c TyName
typeFreeVars = fv

-- | Gives the free type-variables and free term-variables of a Term
termFreeVars :: Collection c
             => Term
             -> (c TyName, c TmName)
termFreeVars tm = (termFreeTyVars tm, termFreeIds tm)

-- | Gives the free term-variables of a Term
termFreeIds :: Collection c
            => Term
            -> c TmName
termFreeIds = fv

-- | Gives the free type-variables of a Term
termFreeTyVars :: Collection c
               => Term
               -> c TyName
termFreeTyVars = fv

Fix circular reasoning in free variable calculation
Fix circular reasoning in free variable calculation
