1{-# LANGUAGE PatternGuards #-}
3module Idris.Transforms where
10 transform :: (a -> a) -> a -> a
12instance Transform (TT Name) where
13 transform t x = t (trans' x) where
14 trans' (Bind n b sc) = Bind n (fmap (transform t) b) (transform t sc)
15 trans' (App f a) = App (transform t f) (transform t a)
18type TTOpt = TT Name -> TT Name
20optimisations :: [TTOpt]
21optimisations = [zero, suc]
23instance Transform SC where
24 transform t x = t (trans' x) where
25 trans' (Case n alts) = Case n (map transAlt alts)
28 transAlt (ConCase n i as sc) = ConCase n i as (trans' sc)
29 transAlt (ConstCase c sc) = ConstCase c (trans' sc)
30 transAlt (DefaultCase sc) = DefaultCase (trans' sc)
32type CaseOpt = SC -> SC
35zero (P _ n _) | n == NS (UN "O") ["nat","prelude"]
40suc (App (P _ s _) a) | s == NS (UN "S") ["nat","prelude"]
41 = mkApp (P Ref (UN "prim__addBigInt") Erased) [Constant (BI 1), a]
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list