1{-# LANGUAGE OverloadedStrings #-}
4import Control.Applicative ((<$>),(<*>))
6import Data.Aeson ((.:), (.:?), (.=))
7import qualified Data.Aeson as Json
8import qualified Data.ByteString.Lazy.Char8 as BS
10import qualified Elm.Compiler.Module as Module
11import qualified Elm.Compiler.Type as Type
14data Documentation = Documentation
15 { moduleName :: Module.Name
25 , aliasComment :: String
26 , aliasArgs :: [String]
27 , aliasType :: Type.Type
33 , unionComment :: String
34 , unionArgs :: [String]
35 , unionCases :: [(String, [Type.Type])]
41 , valueComment :: String
42 , valueType :: Type.Type
43 , valueAssocPrec :: Maybe (String,Int)
47-- JSON for DOCUMENTATION
49instance Json.ToJSON Documentation where
50 toJSON (Documentation name comment aliases types values) =
53 , "comment" .= comment
54 , "aliases" .= aliases
59instance Json.FromJSON Documentation where
60 parseJSON (Json.Object obj) =
69 fail $ "Cannot decode Documentation from: " ++ BS.unpack (Json.encode value)
74instance Json.ToJSON Alias where
75 toJSON (Alias name comment args tipe) =
78 , "comment" .= comment
83instance Json.FromJSON Alias where
84 parseJSON (Json.Object obj) =
92 fail $ "Cannot decode Alias from: " ++ BS.unpack (Json.encode value)
97instance Json.ToJSON Union where
98 toJSON (Union name comment args cases) =
101 , "comment" .= comment
106instance Json.FromJSON Union where
107 parseJSON (Json.Object obj) =
115 fail $ "Cannot decode Union from: " ++ BS.unpack (Json.encode value)
120instance Json.ToJSON Value where
121 toJSON (Value name comment tipe assocPrec) =
122 Json.object (fields ++ possibleFields)
126 , "comment" .= comment
133 Just (assoc, prec) ->
134 [ "associativity" .= assoc
135 , "precedence" .= prec
139instance Json.FromJSON Value where
140 parseJSON (Json.Object obj) =
145 <*> (liftM2 (,) <$> obj .:? "associativity" <*> obj .:? "precedence")
148 fail $ "Cannot decode Value from: " ++ BS.unpack (Json.encode value)
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