1{-# LANGUAGE OverloadedStrings #-}
4import Control.Applicative ((<$>),(<*>))
5import Control.Arrow (second)
7import Data.Aeson ((.:), (.:?), (.=))
8import qualified Data.Aeson as Json
9import qualified Data.ByteString.Lazy.Char8 as BS
10import qualified Data.Text as Text
12import qualified Elm.Compiler.Module as Module
13import qualified Elm.Compiler.Type as Type
16data Documentation = Documentation
17 { moduleName :: Module.Name
27 , aliasComment :: String
28 , aliasArgs :: [String]
29 , aliasType :: Type.Type
35 , unionComment :: String
36 , unionArgs :: [String]
37 , unionCases :: [(String, [Type.Type])]
43 , valueComment :: String
44 , valueType :: Type.Type
45 , valueAssocPrec :: Maybe (String,Int)
49-- JSON for DOCUMENTATION
51instance Json.ToJSON Documentation where
52 toJSON (Documentation name comment aliases types values) =
55 , "comment" .= comment
56 , "aliases" .= aliases
61instance Json.FromJSON Documentation where
62 parseJSON (Json.Object obj) =
71 fail $ "Cannot decode Documentation from: " ++ BS.unpack (Json.encode value)
76instance Json.ToJSON Alias where
77 toJSON (Alias name comment args tipe) =
80 , "comment" .= comment
85instance Json.FromJSON Alias where
86 parseJSON (Json.Object obj) =
94 fail $ "Cannot decode Alias from: " ++ BS.unpack (Json.encode value)
99instance Json.ToJSON Union where
100 toJSON (Union name comment args cases) =
103 , "comment" .= comment
108instance Json.FromJSON Union where
109 parseJSON (Json.Object obj) =
117 fail $ "Cannot decode Union from: " ++ BS.unpack (Json.encode value)
122instance Json.ToJSON Value where
123 toJSON (Value name comment tipe assocPrec) =
124 Json.object (fields ++ possibleFields)
128 , "comment" .= comment
135 Just (assoc, prec) ->
136 [ "associativity" .= assoc
137 , "precedence" .= prec
141instance Json.FromJSON Value where
142 parseJSON (Json.Object obj) =
147 <*> (liftM2 (,) <$> obj .:? "associativity" <*> obj .:? "precedence")
150 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