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
| {-# LANGUAGE DeriveFunctor #-} | |
| {-# LANGUAGE TypeSynonymInstances #-} | |
| import Data.Functor.Foldable | |
| newtype Object a = Object {getObject :: a} deriving (Show, Eq, Functor) | |
| data Label l a = Label { label :: l, inner :: a } deriving (Show, Eq, Functor) | |
| data FooF l a = FooF { nested :: (Label l) (Object a) } | |
| type LabelFunctor l = Fix (FooF l) |
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 JSONTypeF l a = | |
| JSONTypeF | |
| { jsObject :: (Compose Maybe (Label l)) (JObject a) | |
| , jsArray :: (Compose Maybe (Label l)) (JArray a) | |
| , jsInvalidArray :: (Compose Maybe (Label l)) (JInvalidArray a) | |
| , jsString :: (Compose Maybe (Label l)) JString | |
| , jsNumber :: (Compose Maybe (Label l)) JNumber | |
| , jsBool :: (Compose Maybe (Label l)) JBool | |
| , jsNull :: (Compose Maybe (Label l)) JNull | |
| } deriving (Generic, Functor, Eq) |
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
| {-# LANGUAGE QuasiQuotes #-} | |
| {-# LANGUAGE OverloadedLists #-} | |
| {-# LANGUAGE OverloadedStrings #-} | |
| import Data.Aeson.QQ | |
| import Data.Aeson (Value) | |
| import Test.Hspec | |
| import Control.Comonad.Cofree | |
| import Data.Functor.Compose | |
| import qualified Data.Vector as Vector | |
| import Data.Semigroup |
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
| 89 11 error error: | |
| • Couldn't match type ‘Group b’ with ‘HashMap.HashMap Text t0’ | |
| Expected type: m (HashMap.HashMap Text t0 | |
| -> JSONTypeF a -> b -> JSONTypeF t0 -> JSONTypeF a -> ()) | |
| Actual type: (JSONTypeF t0 | |
| -> JSONTypeF a -> JSONTypeF t0 -> JSONTypeF a -> ()) | |
| -> Group b -> JSONTypeF a -> b -> JSONTypeF t0 -> JSONTypeF a -> () | |
| • Possible cause: ‘flip’ is applied to too many arguments | |
| In a stmt of a 'do' block: kb <- flip getGroup | |
| In the expression: |
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
| #!/usr/bin/stack | |
| {- stack --install-ghc | |
| --resolver lts-9.0 | |
| script | |
| --compile | |
| --package bytestring | |
| --package conduit | |
| --package lens | |
| --package conduit-combinators | |
| --package conduit-extra |
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
| sample :: Monad m => Int -> ConduitM a a m () | |
| sample every = | |
| whileM_ (pure True) $ do | |
| dropC (every -1) | |
| takeC 1 |
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
| #!/usr/bin/stack | |
| {- stack --install-ghc | |
| --resolver lts-9.0 | |
| script | |
| --compile | |
| --package bytestring | |
| --package conduit | |
| --package lens | |
| --package conduit-combinators | |
| --package conduit-extra |
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
| #!/usr/bin/stack | |
| {- stack --install-ghc | |
| --resolver lts-9.0 | |
| script | |
| --compile | |
| --package bytestring | |
| --package conduit | |
| --package lens | |
| --package conduit-combinators | |
| --package conduit-extra |
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
| import scala.collection.mutable | |
| object IteratorUtils { | |
| def tailRecM[State, Out](initial: State)(more: State => Iterator[Either[State, Out]]): Iterator[Out] = { | |
| new Iterator[Out] { | |
| private val states: mutable.Queue[State] = mutable.Queue(initial) | |
| private var nextElement: Option[Out] = None | |
| private var moreHolder: Option[Iterator[Either[State, Out]]] = None | |
| def next: Out = { |
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Title</title> | |
| <meta charset="utf-8"> | |
| <style> | |
| @import url(https://fonts.googleapis.com/css?family=Yanone+Kaffeesatz); | |
| @import url(https://fonts.googleapis.com/css?family=Droid+Serif:400,700,400italic); | |
| @import url(https://fonts.googleapis.com/css?family=Ubuntu+Mono:400,700,400italic); | |
| body { font-family: 'Droid Serif'; } |