1{-# LANGUAGE OverloadedStrings #-}
12 , basics, char, string
13 , maybe, result, list, array, dict, tuple
17 , jsonDecode, jsonEncode
18 , webgl, texture, vector2, vector3, vector4, matrix4
23import Control.Monad (liftM2)
24import Data.Binary (Binary(..))
25import qualified Data.Char as Char
26import qualified Data.Name as Name
27import qualified Data.Text as Text
28import Prelude hiding (maybe)
29import qualified System.FilePath as FP
31import qualified Elm.Package as Pkg
32import qualified Json.Decode as Decode
33import qualified Json.Encode as Encode
43nameToString :: Raw -> String
48nameToSlashPath :: Raw -> FilePath
50 map (\c -> if c == '.' then FP.pathSeparator else c) (Name.toString name)
53nameToHyphenPath :: Raw -> FilePath
54nameToHyphenPath name =
55 map (\c -> if c == '.' then '-' else c) (Name.toString name)
58fromHyphenPath :: Text.Text -> Maybe Raw
60 let str = Text.unpack txt in
61 if all isGoodChunk (splitOn '-' str)
62 then Just (Name.fromString (map (\c -> if c == '-' then '.' else c) str))
70encode :: Raw -> Encode.Value
75decoder :: Decode.Decoder Text.Text Raw
78 let str = Text.unpack txt
79 if all isGoodChunk (splitOn '.' str)
80 then Decode.succeed (Name.fromString str)
84isGoodChunk :: String -> Bool
91 Char.isUpper first && all isGoodChar rest
94isGoodChar :: Char -> Bool
96 Char.isAlphaNum c || c == '_'
99splitOn :: Char -> String -> [String]
101 uncurry (:) (splitOnHelp sep str)
104splitOnHelp :: Char -> String -> (String, [String])
112 (chunk,chunks) = splitOnHelp sep rest
126 { _package :: !Pkg.Name
127 , _module :: !Name.Name
132canonicalIsKernel :: Canonical -> Bool
133canonicalIsKernel (Canonical _ name) =
141instance Eq Canonical where
142 (==) (Canonical pkg1 name1) (Canonical pkg2 name2) =
143 name1 == name2 && pkg1 == pkg2
146instance Binary Canonical where
147 put (Canonical a b) = put a >> put b
148 get = liftM2 Canonical get get
155{-# NOINLINE basics #-}
157basics = Canonical Pkg.core Name.basics
162char = Canonical Pkg.core Name.char
165{-# NOINLINE string #-}
167string = Canonical Pkg.core Name.string
170{-# NOINLINE maybe #-}
172maybe = Canonical Pkg.core Name.maybe
175{-# NOINLINE result #-}
177result = Canonical Pkg.core Name.result
182list = Canonical Pkg.core Name.list
185{-# NOINLINE array #-}
187array = Canonical Pkg.core Name.array
192dict = Canonical Pkg.core Name.dict
195{-# NOINLINE tuple #-}
197tuple = Canonical Pkg.core Name.tuple
200{-# NOINLINE platform #-}
202platform = Canonical Pkg.core Name.platform
207cmd = Canonical Pkg.core "Platform.Cmd"
212sub = Canonical Pkg.core "Platform.Sub"
215{-# NOINLINE debug #-}
217debug = Canonical Pkg.core Name.debug
220{-# NOINLINE bitwise #-}
222bitwise = Canonical Pkg.core Name.bitwise
229{-# NOINLINE virtualDom #-}
230virtualDom :: Canonical
231virtualDom = Canonical Pkg.virtualDom Name.virtualDom
238{-# NOINLINE jsonDecode #-}
239jsonDecode :: Canonical
240jsonDecode = Canonical Pkg.json "Json.Decode"
243{-# NOINLINE jsonEncode #-}
244jsonEncode :: Canonical
245jsonEncode = Canonical Pkg.json "Json.Encode"
252{-# NOINLINE webgl #-}
254webgl = Canonical Pkg.webgl "WebGL"
257{-# NOINLINE texture #-}
259texture = Canonical Pkg.webgl "WebGL.Texture"
262{-# NOINLINE vector2 #-}
264vector2 = Canonical Pkg.linearAlgebra "Math.Vector2"
267{-# NOINLINE vector3 #-}
269vector3 = Canonical Pkg.linearAlgebra "Math.Vector3"
272{-# NOINLINE vector4 #-}
274vector4 = Canonical Pkg.linearAlgebra "Math.Vector4"
277{-# NOINLINE matrix4 #-}
279matrix4 = Canonical Pkg.linearAlgebra "Math.Matrix4"
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