This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data Foo = Foo1 String | |
| Foo2 String Int | |
data Bar = Bar Foo | |
foo1 :: String -> Bar | |
foo1 = Bar . Foo1 | |
foo2 :: String -> Int -> Bar | |
foo2 a b = Bar (Foo2 a b) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parseAddresses :: Object -> Parser [[String]] | |
parseAddresses v = v .: "vout" >>= mapM (.: "scriptPubKey") >>= mapM (.: "addresses") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
arrToListObj :: Maybe Value -> Maybe [Object] | |
arrToListObj (Just (Array arr@(Object v))) = Just $ V.toList arr | |
arrToListObj _ = Nothing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
objToArray :: Value -> Array | |
objToArray obj@(Object v) = V.singleton obj | |
--I need a value of type Value for further processing. How can I make the result Array into a Value type? | |
-- Definitions of types from source of Data.Aeson.Types | |
-- | A JSON \"object\" (key\/value map). | |
type Object = HashMap Text Value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parseInvoices :: L.ByteString -> Either String [Invoice] | |
parseInvoices s = do | |
result <- eitherDecode s | |
flip parseEither result $ \obj -> do | |
d <- (obj .: "invoices") >>= (.: "invoice") | |
case d of | |
Object v -> return [v] | |
Array v -> return v |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type Point = (Int, Int) -- Could have more elements | |
type Range = (Int, Int) | |
pointsInRanges :: Range -> Range -> [Point] -> [Point] -- All points where fst p is in the first range and snd p is in the second range. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
in my html: | |
<script> | |
angular.module('myApp').value('initData, | |
{myjson} | |
) | |
<script> | |
in my controller: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
These are my results: | |
{1: 2.327260809430917, | |
2: 1.7694565749482591, | |
3: 1.3241503620006503, | |
4: 0.7659831585049286, | |
5: 0.786389897507167, | |
6: 0.4727930181724931, | |
7: 0.5592591157981355, | |
8: 0.5410198394120904, | |
9: 0.4966728396999276, |
NewerOlder