
Instead of storing the Constr, which was messy, we now store a String (to allow comparison of constructor types during unification) and a function to reform the type at the end of the type checking.
35 lines
1.1 KiB
Haskell
35 lines
1.1 KiB
Haskell
{-
|
|
Tock: a compiler for parallel languages
|
|
Copyright (C) 2008 University of Kent
|
|
|
|
This program is free software; you can redistribute it and/or modify it
|
|
under the terms of the GNU General Public License as published by the
|
|
Free Software Foundation, either version 2 of the License, or (at your
|
|
option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful, but
|
|
WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
-}
|
|
|
|
module UnifyType where
|
|
|
|
import Data.Generics
|
|
import Data.IORef
|
|
|
|
import qualified AST as A
|
|
|
|
type Ptr a = IORef (Maybe (TypeExp a))
|
|
|
|
data Typeable a => TypeExp a
|
|
= MutVar (Ptr a)
|
|
| GenVar Int
|
|
-- Either a list of integers that must fit, or a concrete type
|
|
| NumLit (IORef (Either [Integer] A.Type))
|
|
| OperType String ([A.Type] -> A.Type) [ TypeExp a ]
|
|
deriving (Typeable, Data)
|