git.iko.soy/rowtype-yoga/purescript-native
on abde79f help sign in
57 lines 1.7 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
20import Language.PureScript.Declarations
22import Language.PureScript.Sugar.Operators as S
23import Language.PureScript.Sugar.DoNotation as S
24import Language.PureScript.Sugar.CaseDeclarations as S
25import Language.PureScript.Sugar.TypeDeclarations as S
26import Language.PureScript.Sugar.BindingGroups as S
27import Language.PureScript.Sugar.TypeClasses as S
28import Language.PureScript.Sugar.Names as S
30import Control.Category ((>>>))
32-- |
33-- The desugaring pipeline proceeds as follows:
34--
35-- * Introduce type synonyms for type class dictionaries
36--
37-- * Rebracket user-defined binary operators
38--
39-- * Desugar do-notation using the @Prelude.Monad@ type class
40--
41-- * Desugar top-level case declarations into explicit case expressions
42--
43-- * Desugar type declarations into value declarations with explicit type annotations
44--
45-- * Group mutually recursive value and data declarations into binding groups.
46--
47-- * Qualify any unqualified names and types
48--
49desugar :: [Module] -> Either String [Module]
50desugar = removeSignedLiterals
51 >>> desugarDo
52 >=> desugarCasesModule
53 >=> desugarTypeDeclarationsModule
54 >=> desugarImports
55 >=> rebracket
56 >=> desugarTypeClasses
57 >=> createBindingGroupsModule