on d87affe help sign in
elk/src/Elm/Compiler/Type/Extract.hs
30 lines 773 B history raw
1module Elm.Compiler.Type.Extract where
3import Control.Arrow (second)
4import qualified AST.Type as Type
5import qualified AST.Variable as Var
6import qualified Elm.Compiler.Type as T
9-- INTERNAL TYPE to PUBLIC TYPE
11fromInternalType :: Var.ToString a => Type.Type a -> T.Type
12fromInternalType astType =
13 case astType of
14 Type.Lambda t1 t2 ->
15 T.Lambda (fromInternalType t1) (fromInternalType t2)
17 Type.Var x ->
18 T.Var x
20 Type.Type var ->
21 T.Type (Var.toString var)
23 Type.App t ts ->
24 T.App (fromInternalType t) (map fromInternalType ts)
26 Type.Record fields ext ->
27 T.Record (map (second fromInternalType) fields) (fmap fromInternalType ext)
29 Type.Aliased _ t ->
30 fromInternalType t