- view
- page
- topnav
- content (needs email)
- left
- right
- article
- page
- widget (needs email)
This file contains 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
module Html where | |
import Control.Monad.Reader (Reader, ask, runReader) | |
import Data.List (intercalate) | |
import Data.String | |
import Prelude hiding (div) | |
import System.Environment (getArgs) | |
import System.IO (writeFile) | |
main :: IO () |
This file contains 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
main :: IO () | |
main = do | |
putStrLn "what is your email address?" | |
email <- getLine | |
putStrLn . show $ runReader view email | |
view :: Reader Email Html | |
view = do | |
page' <- page | |
return $ div |
This file contains 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
main :: IO () | |
main = | |
putStrLn "what is your email address?" >> | |
getLine >>= \email -> | |
putStrLn . show $ runReader view email | |
view :: Reader Email Html | |
view = | |
page >>= \page' -> | |
return $ div |
This file contains 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
newtype Reader e a = Reader { runReader :: e -> a } | |
instance Functor (Reader a) where | |
fmap f (Reader g) = Reader $ f . g | |
instance Applicative (Reader a) where | |
pure x = Reader $ \_ -> x | |
m <*> n = Reader $ \e -> (runReader m e) (runReader n e) | |
instance Monad (Reader a) where |
This file contains 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
main :: IO () | |
main = | |
putStrLn "what is your email address?" >> | |
getLine >>= \email -> | |
putStrLn . show $ view email | |
view :: Email -> Html | |
view email = | |
div | |
[ page email |
This file contains 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
module Html where | |
import Control.Monad.Reader (Reader, ask, runReader) | |
import Data.List (intercalate) | |
import Prelude hiding (div) | |
type Html = String | |
type Email = String | |
div :: [Html] -> Html |
This file contains 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 { curry } from 'ramda' | |
function maybeMap<A, B> (f: (val: A) => B, m: Maybe<A>): Maybe<B> { | |
switch (m.type) { | |
case MaybeType.Nothing: | |
return Nothing() | |
case MaybeType.Just: | |
return Just(f(m.value)) | |
} | |
} |
This file contains 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 UpperCaseHead = (list: ReadonlyArray<string>) => Maybe<string> | |
const upperCaseHead: UpperCaseHead = compose( | |
Maybe.map(toUpper), | |
safeHead, | |
) as UpperCaseHead | |
console.log(upperCaseHead([])) // { type: Maybe.Nothing } ie. Nothing | |
console.log(upperCaseHead([ 'rick', 'morty' ])) // { type: Maybe.Just, value: 'RICK' } ie. Just 'RICK' |
NewerOlder