on master help sign in
Track whether a module name was specified
commit3a02ad4c1d8757fd57dd5f3922bfd226da7e19a5 authorEvan Czaplicki <evancz@users.noreply.github.com> dateFri 22 Feb 2019, 11:29 (8 years ago) parent6ea473d
1 file changed+16−1
compiler/src/AST/Source.hs+16−1
compiler/src/AST/Source.hs+16−1
@@ -1,10 +1,13 @@
11{-# OPTIONS_GHC -Wall #-}
2+{-# LANGUAGE OverloadedStrings #-}
23module AST.Source
34 ( Expr, Expr_(..), VarType(..)
45 , Def(..)
56 , Pattern, Pattern_(..)
67 , Type, Type_(..)
78 , Module(..)
9+ , getName
10+ , getImport
811 , Import(..)
912 , Value(..)
1013 , Union(..)
@@ -119,7 +122,7 @@ data Type_
119122
120123data Module =
121124 Module
122− { _name :: Name
125+ { _name :: Maybe Name
123126 , _exports :: A.Located Exposing
124127 , _imports :: [Import]
125128 , _values :: [A.Located Value]
@@ -130,6 +133,18 @@ data Module =
130133 }
131134
132135
136+getName :: Module -> Name
137+getName (Module maybeName _ _ _ _ _ _ _) =
138+ case maybeName of
139+ Just name -> name
140+ Nothing -> "Main"
141+
142+
143+getImport :: Import -> Name
144+getImport (Import (A.At _ name) _ _) =
145+ name
146+
147+
133148data Import =
134149 Import
135150 { _import :: A.Located Name