1{-# OPTIONS_GHC -Wall #-}
2module Transform.Canonicalize.Type (tipe) where
4import Control.Applicative ((<$>),(<*>))
5import Control.Monad.Error
6import Data.Traversable (traverse)
8import qualified AST.Type as T
9import qualified AST.Variable as Var
11import Transform.Canonicalize.Environment
12import qualified Transform.Canonicalize.Variable as Canonicalize
18 -> Canonicalizer String T.CanonicalType
29 canonicalizeApp env typ []
32 canonicalizeApp env t ts
35 T.Lambda <$> go a <*> go b
37 T.Aliased name args t ->
38 T.Aliased name <$> mapM goSnd args <*> go t
40 T.Record fields ext ->
41 T.Record <$> mapM goSnd fields <*> traverse go ext
48 -> Canonicalizer String T.CanonicalType
49canonicalizeApp env f args =
51 T.Type (Var.Raw rawName) ->
52 do answer <- Canonicalize.tvar env rawName
55 canonicalizeAlias env alias args
59 [] -> return (T.Type name)
61 T.App (T.Type name) <$> mapM (tipe env) args
64 T.App <$> tipe env f <*> mapM (tipe env) args
69 -> (Var.Canonical, [String], T.CanonicalType)
71 -> Canonicalizer String T.CanonicalType
72canonicalizeAlias env (name, tvars, dealiasedTipe) tipes =
73 do when (tipesLen /= tvarsLen) (throwError msg)
74 tipes' <- mapM (tipe env) tipes
75 return $ T.Aliased name (zip tvars tipes') dealiasedTipe
77 tipesLen = length tipes
78 tvarsLen = length tvars
82 "Type alias '" ++ Var.toString name ++ "' expects " ++ show tvarsLen ++
83 " type argument" ++ (if tvarsLen == 1 then "" else "s") ++
84 " but was given " ++ show tipesLen
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list