git.iko.soy/rowtype-yoga/purescript-native
on bbf00f2 help sign in
68 lines 2.2 kB history raw
1-----------------------------------------------------------------------------
2--
3-- Module : Language.PureScript.Sugar
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-- Desugaring passes
13--
14-----------------------------------------------------------------------------
16module Language.PureScript.Sugar (desugar, module S) where
18import Control.Monad
19import Control.Category ((>>>))
20import Control.Monad.Trans.Class
22import Language.PureScript.AST
23import Language.PureScript.Errors
24import Language.PureScript.Supply
26import Language.PureScript.Sugar.BindingGroups as S
27import Language.PureScript.Sugar.CaseDeclarations as S
28import Language.PureScript.Sugar.DoNotation as S
29import Language.PureScript.Sugar.Names as S
30import Language.PureScript.Sugar.ObjectWildcards as S
31import Language.PureScript.Sugar.Operators as S
32import Language.PureScript.Sugar.TypeClasses as S
33import Language.PureScript.Sugar.TypeDeclarations as S
35-- |
36-- The desugaring pipeline proceeds as follows:
37--
38-- * Remove signed literals in favour of `negate` applications
39--
40-- * Desugar object literals with wildcards into lambdas
41--
42-- * Desugar operator sections
43--
44-- * Desugar do-notation using the @Prelude.Monad@ type class
45--
46-- * Desugar top-level case declarations into explicit case expressions
47--
48-- * Desugar type declarations into value declarations with explicit type annotations
49--
50-- * Qualify any unqualified names and types
51--
52-- * Rebracket user-defined binary operators
53--
54-- * Introduce type synonyms for type class dictionaries
55--
56-- * Group mutually recursive value and data declarations into binding groups.
57--
58desugar :: [Module] -> SupplyT (Either ErrorStack) [Module]
59desugar = map removeSignedLiterals
60 >>> mapM desugarObjectConstructors
61 >=> mapM desugarOperatorSections
62 >=> mapM desugarDoModule
63 >=> desugarCasesModule
64 >=> lift . (desugarTypeDeclarationsModule
65 >=> desugarImports
66 >=> rebracket)
67 >=> desugarTypeClasses
68 >=> lift . createBindingGroupsModule