git.iko.soy/rowtype-yoga/purescript-native
on 4189e7f help sign in
83 lines 2.7 kB history raw
1-----------------------------------------------------------------------------
2--
3-- Module : Language.PureScript.Declarations
4-- Copyright : (c) Phil Freeman 2013
5-- License : MIT
6--
7-- Maintainer : Phil Freeman <paf31@cantab.net>
8-- Stability : experimental
9-- Portability :
10--
11-- |
12--
13-----------------------------------------------------------------------------
15{-# LANGUAGE DeriveDataTypeable #-}
17module Language.PureScript.Declarations where
19import Language.PureScript.Values
20import Language.PureScript.Types
21import Language.PureScript.Names
22import Language.PureScript.Kinds
23import Language.PureScript.CodeGen.JS.AST
25import qualified Data.Data as D
27type Precedence = Integer
29data Associativity = Infixl | Infixr deriving (Show, D.Data, D.Typeable)
31data Fixity = Fixity Associativity Precedence deriving (Show, D.Data, D.Typeable)
33data Module = Module ProperName [Declaration] deriving (Show, D.Data, D.Typeable)
35data ForeignImportType
36 = ForeignImport
37 | TypeClassDictionaryImport
38 | TypeClassAccessorImport deriving (Show, Eq, D.Data, D.Typeable)
40data Declaration
41 = DataDeclaration ProperName [String] [(ProperName, Maybe Type)]
42 | DataBindingGroupDeclaration [Declaration]
43 | TypeSynonymDeclaration ProperName [String] Type
44 | TypeDeclaration Ident Type
45 | ValueDeclaration Ident [[Binder]] (Maybe Guard) Value
46 | BindingGroupDeclaration [(Ident, Value)]
47 | ExternDeclaration ForeignImportType Ident (Maybe JS) Type
48 | ExternDataDeclaration ProperName Kind
49 | FixityDeclaration Fixity String
50 | ImportDeclaration ModuleName (Maybe [Either Ident ProperName])
51 | TypeClassDeclaration ProperName String [Declaration]
52 | TypeInstanceDeclaration [(Qualified ProperName, Type)] (Qualified ProperName) Type [Declaration]
53 deriving (Show, D.Data, D.Typeable)
55isValueDecl :: Declaration -> Bool
56isValueDecl (ValueDeclaration _ _ _ _) = True
57isValueDecl _ = False
59isDataDecl :: Declaration -> Bool
60isDataDecl (DataDeclaration _ _ _) = True
61isDataDecl (TypeSynonymDeclaration _ _ _) = True
62isDataDecl _ = False
64isImportDecl :: Declaration -> Bool
65isImportDecl (ImportDeclaration _ _) = True
66isImportDecl _ = False
68isExternDataDecl :: Declaration -> Bool
69isExternDataDecl (ExternDataDeclaration _ _) = True
70isExternDataDecl _ = False
72isFixityDecl :: Declaration -> Bool
73isFixityDecl (FixityDeclaration _ _) = True
74isFixityDecl _ = False
76isExternDecl :: Declaration -> Bool
77isExternDecl (ExternDeclaration _ _ _ _) = True
78isExternDecl _ = False
80isTypeClassDeclaration :: Declaration -> Bool
81isTypeClassDeclaration (TypeClassDeclaration _ _ _) = True
82isTypeClassDeclaration (TypeInstanceDeclaration _ _ _ _) = True
83isTypeClassDeclaration _ = False