From 21053c1c4e9d646438997be776d70a0b5238e4f9 Mon Sep 17 00:00:00 2001 From: Rashad Gover Date: Sat, 1 Oct 2022 22:50:58 +0000 Subject: [PATCH] Get started on realword-htmx example app --- .ghci | 3 + .ghcid | 1 + .gitignore | 3 + examples/realworld-htmx/Main.hs | 234 +++++ .../Conduit/Auth.hs | 0 .../Conduit/Database.hs | 0 .../Conduit/Database/Query.hs | 0 .../Conduit/Database/Setup.hs | 0 .../Conduit/Server.hs | 0 .../Conduit/Type.hs | 0 .../Conduit/Type/Request.hs | 0 .../Conduit/Type/Response.hs | 0 .../{realworld => realworld-json}/Main.hs | 0 okapi.cabal | 921 ++++++++++-------- package.yaml | 16 +- stack.yaml | 71 -- stack.yaml.lock | 62 -- 17 files changed, 750 insertions(+), 561 deletions(-) create mode 100644 .ghci create mode 100644 .ghcid create mode 100644 examples/realworld-htmx/Main.hs rename examples/{realworld => realworld-json}/Conduit/Auth.hs (100%) rename examples/{realworld => realworld-json}/Conduit/Database.hs (100%) rename examples/{realworld => realworld-json}/Conduit/Database/Query.hs (100%) rename examples/{realworld => realworld-json}/Conduit/Database/Setup.hs (100%) rename examples/{realworld => realworld-json}/Conduit/Server.hs (100%) rename examples/{realworld => realworld-json}/Conduit/Type.hs (100%) rename examples/{realworld => realworld-json}/Conduit/Type/Request.hs (100%) rename examples/{realworld => realworld-json}/Conduit/Type/Response.hs (100%) rename examples/{realworld => realworld-json}/Main.hs (100%) delete mode 100644 stack.yaml delete mode 100644 stack.yaml.lock diff --git a/.ghci b/.ghci new file mode 100644 index 0000000..38592a6 --- /dev/null +++ b/.ghci @@ -0,0 +1,3 @@ +:set -fwarn-unused-binds -fwarn-unused-imports +:set -isrc +:load Main diff --git a/.ghcid b/.ghcid new file mode 100644 index 0000000..269edbd --- /dev/null +++ b/.ghcid @@ -0,0 +1 @@ +--command=cabal v2-repl okapi:realworld-htmx-exe diff --git a/.gitignore b/.gitignore index 5550d8c..fda07be 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,6 @@ *~ dist-newstyle docs/syntax.zip +experimental/stack.yaml +experimental/stack.yaml.lock + diff --git a/examples/realworld-htmx/Main.hs b/examples/realworld-htmx/Main.hs new file mode 100644 index 0000000..8da7756 --- /dev/null +++ b/examples/realworld-htmx/Main.hs @@ -0,0 +1,234 @@ +{-# language BlockArguments #-} +{-# language ConstraintKinds #-} +{-# language DeriveAnyClass #-} +{-# language DeriveGeneric #-} +{-# language DerivingStrategies #-} +{-# language DerivingVia #-} +{-# language DuplicateRecordFields #-} +{-# language FlexibleContexts #-} +{-# language GeneralizedNewtypeDeriving #-} +{-# language OverloadedStrings #-} +{-# language StandaloneDeriving #-} +{-# language TypeApplications #-} +{-# language TypeFamilies #-} + +module Main where + +import qualified Control.Monad.Reader as Reader +import qualified Control.Monad.IO.Class as IO +import qualified Control.Monad.Combinators as Combinators +import qualified Data.ByteString as BS +import Data.Function ((&)) +import qualified Hasql.Connection as Hasql +import qualified Lucid +import Lucid + ( h1_ + , head_ + , html_ + , meta_ + , src_ + , charset_ + , title_ + , link_ + , href_ + , rel_ + , type_ + , script_ + , li_ + , ul_ + , body_ + , footer_ + , a_ + , div_ + , class_ + , span_ + , id_ + , nav_ + , p_ + ) +import qualified Lucid.Htmx as Htmx +import qualified Okapi +import qualified Rel8 + +newtype App a = App + { unApp :: Reader.ReaderT Hasql.Connection IO a + } + deriving newtype (Functor, Applicative, Monad, IO.MonadIO, Reader.MonadReader Hasql.Connection) + +type HasDBConnection m = Reader.MonadReader Hasql.Connection m + +main :: IO () +main = do + -- Get database connection + secret <- BS.readFile "secret.txt" + let settings = Hasql.settings "localhost" 5432 "realworld" secret "realworld" + Right connection <- Hasql.acquire settings + + -- Run server + Okapi.run (executeApp connection) server + +executeApp :: Hasql.Connection -> App a -> IO a +executeApp connection (App app) = Reader.runReaderT app connection + +setLucid :: Lucid.Html () -> Okapi.Response -> Okapi.Response +setLucid = Okapi.setHTML . Lucid.renderBS + +server :: (Okapi.MonadOkapi m, HasDBConnection m) => m Okapi.Response +server = Combinators.choice + [ home + , signupForm + , submitSignupForm + , loginForm + , submitLoginForm + , logout + , follow + , unfollow + ] + +-- Home + +home :: (Okapi.MonadOkapi m, HasDBConnection m) => m Okapi.Response +home = homeRoute >> homeHandler + +homeRoute :: Okapi.MonadOkapi m => m () +homeRoute = do + Okapi.methodGET + Okapi.pathEnd + +homeHandler :: HasDBConnection m => m Okapi.Response +homeHandler = + Okapi.ok + & setLucid do + wrapHtml do -- TODO: Only wrap if not htmx request + div_ [class_ "home-page"] do + div_ [class_ "banner"] do + div_ [class_ "container"] do + h1_ [class_ "logo-font"] "conduit" + p_ "A place to share your knowledge." + div_ [class_ "container page"] do + div_ [class_ "row"] do + -- FEED + div_ [id_ "feeds", class_ "col-md-9"] do + h1_ [] "Empty Feed" + -- TAGS + div_ [id_ "tags", class_ "col-md-3"] do + div_ [class_ "sidebar"] $ do + p_ "Popular Tags" + div_ [class_ "tag-list"] do + a_ [href_ "#", class_ "tag-pill tag-default"] "fake-tag" + & return + +emptyHtml :: Lucid.Html () +emptyHtml = "" + +wrapHtml :: Lucid.Html () -> Lucid.Html () +wrapHtml innerHtml = + html_ do + head_ do + meta_ [charset_ "utf-8"] + title_ "Conduit" + link_ [href_ "//code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css", rel_ "stylesheet", type_ "text/css"] + link_ [href_ "//fonts.googleapis.com/css?family=Titillium+Web:700|Source+Serif+Pro:400,700|Merriweather+Sans:400,700|Source+Sans+Pro:400,300,600,700,300italic,400italic,600italic,700italic", rel_ "stylesheet", type_ "text/css"] + link_ [rel_ "stylesheet", href_ "//demo.productionready.io/main.css"] + script_ [src_ "https://unpkg.com/htmx.org@1.8.0"] emptyHtml + body_ do + + nav_ [ id_ "navbar", class_ "navbar navbar-light"] do + div_ [class_ "container"] do + -- TODO: Does it make sense to use hxGet_ and href_ for boost? + a_ [class_ "navbar-brand"] "conduit" + ul_ [class_ "nav navbar-nav pull-xs-right"] do + li_ [class_ "nav-item"] do + a_ [class_ "nav-link"] "Home" + li_ [class_ "nav-item"] do + a_ [class_ "nav-link"] "Sign in" + li_ [class_ "nav-item"] do + a_ [class_ "nav-link"] "Sign up" + + div_ [id_ "content-slot"] innerHtml + + footer_ do + div_ [class_ "container"] do + a_ [href_ "/", class_ "logo-font"] "conduit" + span_ [class_ "attribution"] do + " An interactive learning project from " + a_ [href_ "https://thinkster.io"] "Thinkster" + ". Code & design licensed under MIT. " + + +-- Signup Form + +signupForm :: (Okapi.MonadOkapi m, HasDBConnection m) => m Okapi.Response +signupForm = signupFormRoute >>= signupFormHandler + +signupFormRoute :: Okapi.MonadOkapi m => m () +signupFormRoute = undefined + +signupFormHandler :: HasDBConnection m => () -> m Okapi.Response +signupFormHandler = undefined + +-- Submit Signup Form + +submitSignupForm :: (Okapi.MonadOkapi m, HasDBConnection m) => m Okapi.Response +submitSignupForm = submitSignupFormRoute >>= submitSignupFormHandler + +submitSignupFormRoute :: Okapi.MonadOkapi m => m () +submitSignupFormRoute = undefined + +submitSignupFormHandler :: HasDBConnection m => () -> m Okapi.Response +submitSignupFormHandler = undefined + +-- Login Form + +loginForm :: (Okapi.MonadOkapi m, HasDBConnection m) => m Okapi.Response +loginForm = loginFormRoute >>= loginFormHandler + +loginFormRoute :: Okapi.MonadOkapi m => m () +loginFormRoute = undefined + +loginFormHandler :: HasDBConnection m => () -> m Okapi.Response +loginFormHandler = undefined + +-- Submit Login Form + +submitLoginForm :: (Okapi.MonadOkapi m, HasDBConnection m) => m Okapi.Response +submitLoginForm = submitLoginFormRoute >>= submitLoginFormHandler + +submitLoginFormRoute :: Okapi.MonadOkapi m => m () +submitLoginFormRoute = undefined + +submitLoginFormHandler :: HasDBConnection m => () -> m Okapi.Response +submitLoginFormHandler = undefined + +-- Logout + +logout :: (Okapi.MonadOkapi m, HasDBConnection m) => m Okapi.Response +logout = logoutRoute >>= logoutHandler + +logoutRoute :: Okapi.MonadOkapi m => m () +logoutRoute = undefined + +logoutHandler :: HasDBConnection m => () -> m Okapi.Response +logoutHandler = undefined + +-- Follow + +follow :: (Okapi.MonadOkapi m, HasDBConnection m) => m Okapi.Response +follow = followRoute >>= followHandler + +followRoute :: Okapi.MonadOkapi m => m () +followRoute = undefined + +followHandler :: HasDBConnection m => () -> m Okapi.Response +followHandler = undefined + +-- Unfollow + +unfollow :: (Okapi.MonadOkapi m, HasDBConnection m) => m Okapi.Response +unfollow = unfollowRoute >>= unfollowHandler + +unfollowRoute :: Okapi.MonadOkapi m => m () +unfollowRoute = undefined + +unfollowHandler :: HasDBConnection m => () -> m Okapi.Response +unfollowHandler = undefined diff --git a/examples/realworld/Conduit/Auth.hs b/examples/realworld-json/Conduit/Auth.hs similarity index 100% rename from examples/realworld/Conduit/Auth.hs rename to examples/realworld-json/Conduit/Auth.hs diff --git a/examples/realworld/Conduit/Database.hs b/examples/realworld-json/Conduit/Database.hs similarity index 100% rename from examples/realworld/Conduit/Database.hs rename to examples/realworld-json/Conduit/Database.hs diff --git a/examples/realworld/Conduit/Database/Query.hs b/examples/realworld-json/Conduit/Database/Query.hs similarity index 100% rename from examples/realworld/Conduit/Database/Query.hs rename to examples/realworld-json/Conduit/Database/Query.hs diff --git a/examples/realworld/Conduit/Database/Setup.hs b/examples/realworld-json/Conduit/Database/Setup.hs similarity index 100% rename from examples/realworld/Conduit/Database/Setup.hs rename to examples/realworld-json/Conduit/Database/Setup.hs diff --git a/examples/realworld/Conduit/Server.hs b/examples/realworld-json/Conduit/Server.hs similarity index 100% rename from examples/realworld/Conduit/Server.hs rename to examples/realworld-json/Conduit/Server.hs diff --git a/examples/realworld/Conduit/Type.hs b/examples/realworld-json/Conduit/Type.hs similarity index 100% rename from examples/realworld/Conduit/Type.hs rename to examples/realworld-json/Conduit/Type.hs diff --git a/examples/realworld/Conduit/Type/Request.hs b/examples/realworld-json/Conduit/Type/Request.hs similarity index 100% rename from examples/realworld/Conduit/Type/Request.hs rename to examples/realworld-json/Conduit/Type/Request.hs diff --git a/examples/realworld/Conduit/Type/Response.hs b/examples/realworld-json/Conduit/Type/Response.hs similarity index 100% rename from examples/realworld/Conduit/Type/Response.hs rename to examples/realworld-json/Conduit/Type/Response.hs diff --git a/examples/realworld/Main.hs b/examples/realworld-json/Main.hs similarity index 100% rename from examples/realworld/Main.hs rename to examples/realworld-json/Main.hs diff --git a/okapi.cabal b/okapi.cabal index 135317b..1a0d870 100644 --- a/okapi.cabal +++ b/okapi.cabal @@ -1,456 +1,525 @@ -cabal-version: 1.12 -name: okapi -version: 0.2.0.0 -license: BSD3 -license-file: LICENSE -copyright: 2022 Monadic Systems LLC -maintainer: tech@monadic.systems -author: Monadic Systems LLC -homepage: https://github.com/monadicsystems/okapi#readme -bug-reports: https://github.com/monadicsystems/okapi/issues -synopsis: A micro web framework based on monadic parsing -description: - Please see the README on GitHub at +cabal-version: 1.12 -category: Web -build-type: Simple +-- This file has been generated from package.yaml by hpack version 0.34.4. +-- +-- see: https://github.com/sol/hpack + +name: okapi +version: 0.2.0.0 +synopsis: A micro web framework based on monadic parsing +description: Please see the README on GitHub at +category: Web +homepage: https://github.com/monadicsystems/okapi#readme +bug-reports: https://github.com/monadicsystems/okapi/issues +author: Monadic Systems LLC +maintainer: tech@monadic.systems +copyright: 2022 Monadic Systems LLC +license: BSD3 +license-file: LICENSE +build-type: Simple extra-source-files: README.md ChangeLog.md source-repository head - type: git - location: https://github.com/monadicsystems/okapi + type: git + location: https://github.com/monadicsystems/okapi library - exposed-modules: Okapi - hs-source-dirs: src - other-modules: Paths_okapi - default-language: Haskell2010 - build-depends: - aeson >=1.4.7, - attoparsec, - base >=4.7 && <5, - base64, - bytestring, - containers, - cookie, - cryptonite, - extra, - http-api-data, - http-types, - memory, - mmorph, - mtl, - network, - parser-combinators, - text, - transformers, - unagi-chan, - vault, - wai, - wai-extra, - wai-websockets, - warp, - warp-tls, - websockets + exposed-modules: + Okapi + other-modules: + Paths_okapi + hs-source-dirs: + src + build-depends: + aeson >=1.4.7 + , attoparsec + , base >=4.7 && <5 + , base64 + , bytestring + , containers + , cookie + , cryptonite + , extra + , http-api-data + , http-types + , memory + , mmorph + , mtl + , network + , parser-combinators + , text + , transformers + , unagi-chan + , vault + , wai + , wai-extra + , wai-websockets + , warp + , warp-tls + , websockets + default-language: Haskell2010 executable calculator-exe - main-is: Main.hs - hs-source-dirs: examples/calculator - other-modules: Paths_okapi - default-language: Haskell2010 - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: - aeson >=1.4.7, - attoparsec, - base >=4.7 && <5, - base64, - bytestring, - containers, - cookie, - cryptonite, - extra, - http-api-data, - http-types, - memory, - mmorph, - mtl, - network, - okapi, - parser-combinators, - text, - transformers, - unagi-chan, - vault, - wai, - wai-extra, - wai-websockets, - warp, - warp-tls, - websockets + main-is: Main.hs + other-modules: + Paths_okapi + hs-source-dirs: + examples/calculator + ghc-options: -threaded -rtsopts -with-rtsopts=-N + build-depends: + aeson >=1.4.7 + , attoparsec + , base >=4.7 && <5 + , base64 + , bytestring + , containers + , cookie + , cryptonite + , extra + , http-api-data + , http-types + , memory + , mmorph + , mtl + , network + , okapi + , parser-combinators + , text + , transformers + , unagi-chan + , vault + , wai + , wai-extra + , wai-websockets + , warp + , warp-tls + , websockets + default-language: Haskell2010 executable calculator2-exe - main-is: Main.hs - hs-source-dirs: examples/calculator2 - other-modules: Paths_okapi - default-language: Haskell2010 - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: - aeson, - attoparsec, - base >=4.7 && <5, - base64, - bytestring, - containers, - cookie, - cryptonite, - extra, - http-api-data, - http-types, - memory, - mmorph, - mtl, - network, - okapi, - parser-combinators, - text, - transformers, - unagi-chan, - vault, - wai, - wai-extra, - wai-websockets, - warp, - warp-tls, - websockets + main-is: Main.hs + other-modules: + Paths_okapi + hs-source-dirs: + examples/calculator2 + ghc-options: -threaded -rtsopts -with-rtsopts=-N + build-depends: + aeson + , attoparsec + , base >=4.7 && <5 + , base64 + , bytestring + , containers + , cookie + , cryptonite + , extra + , http-api-data + , http-types + , memory + , mmorph + , mtl + , network + , okapi + , parser-combinators + , text + , transformers + , unagi-chan + , vault + , wai + , wai-extra + , wai-websockets + , warp + , warp-tls + , websockets + default-language: Haskell2010 executable car-dealership-exe - main-is: Main.hs - hs-source-dirs: examples/car-dealership - other-modules: Paths_okapi - default-language: Haskell2010 - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: - aeson >=1.4.7, - attoparsec, - base >=4.7 && <5, - base64, - bytestring, - containers, - cookie, - cryptonite, - extra, - http-api-data, - http-types, - interpolatedstring-perl6, - memory, - mmorph, - mtl, - network, - okapi, - parser-combinators, - random, - sqlite-simple, - text, - transformers, - unagi-chan, - vault, - wai, - wai-extra, - wai-websockets, - warp, - warp-tls, - websockets + main-is: Main.hs + other-modules: + Paths_okapi + hs-source-dirs: + examples/car-dealership + ghc-options: -threaded -rtsopts -with-rtsopts=-N + build-depends: + aeson >=1.4.7 + , attoparsec + , base >=4.7 && <5 + , base64 + , bytestring + , containers + , cookie + , cryptonite + , extra + , http-api-data + , http-types + , interpolatedstring-perl6 + , memory + , mmorph + , mtl + , network + , okapi + , parser-combinators + , random + , sqlite-simple + , text + , transformers + , unagi-chan + , vault + , wai + , wai-extra + , wai-websockets + , warp + , warp-tls + , websockets + default-language: Haskell2010 executable dotodo-exe - main-is: Main.hs - hs-source-dirs: examples/dotodo - other-modules: Paths_okapi - default-language: Haskell2010 - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: - aeson >=1.4.7, - attoparsec, - base >=4.7 && <5, - base64, - bytestring, - containers, - cookie, - cryptonite, - extra, - http-api-data, - http-types, - lucid2, - lucid2-htmx, - memory, - mmorph, - mtl, - network, - okapi, - parser-combinators, - sqlite-simple, - text, - transformers, - unagi-chan, - vault, - wai, - wai-extra, - wai-websockets, - warp, - warp-tls, - websockets + main-is: Main.hs + other-modules: + Paths_okapi + hs-source-dirs: + examples/dotodo + ghc-options: -threaded -rtsopts -with-rtsopts=-N + build-depends: + aeson >=1.4.7 + , attoparsec + , base >=4.7 && <5 + , base64 + , bytestring + , containers + , cookie + , cryptonite + , extra + , http-api-data + , http-types + , lucid2 + , lucid2-htmx + , memory + , mmorph + , mtl + , network + , okapi + , parser-combinators + , sqlite-simple + , text + , transformers + , unagi-chan + , vault + , wai + , wai-extra + , wai-websockets + , warp + , warp-tls + , websockets + default-language: Haskell2010 + +executable realworld-htmx-exe + main-is: Main.hs + other-modules: + Paths_okapi + hs-source-dirs: + examples/realworld-htmx + ghc-options: -threaded -rtsopts -with-rtsopts=-N + build-depends: + aeson >=1.4.7 + , attoparsec + , base >=4.7 && <5 + , base64 + , bytestring + , containers + , cookie + , cryptonite + , extra + , hasql + , http-api-data + , http-types + , lucid2 + , lucid2-htmx + , memory + , mmorph + , mtl + , network + , okapi + , parser-combinators + , rel8 + , text + , transformers + , unagi-chan + , vault + , wai + , wai-extra + , wai-websockets + , warp + , warp-tls + , websockets + default-language: Haskell2010 executable sse-exe - main-is: Main.hs - hs-source-dirs: examples/sse - other-modules: Paths_okapi - default-language: Haskell2010 - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: - aeson >=1.4.7, - attoparsec, - base >=4.7 && <5, - base64, - bytestring, - containers, - cookie, - cryptonite, - extra, - http-api-data, - http-types, - memory, - mmorph, - mtl, - network, - okapi, - parser-combinators, - slave-thread, - text, - time, - transformers, - unagi-chan, - vault, - wai, - wai-extra, - wai-websockets, - warp, - warp-tls, - websockets + main-is: Main.hs + other-modules: + Paths_okapi + hs-source-dirs: + examples/sse + ghc-options: -threaded -rtsopts -with-rtsopts=-N + build-depends: + aeson >=1.4.7 + , attoparsec + , base >=4.7 && <5 + , base64 + , bytestring + , containers + , cookie + , cryptonite + , extra + , http-api-data + , http-types + , memory + , mmorph + , mtl + , network + , okapi + , parser-combinators + , slave-thread + , text + , time + , transformers + , unagi-chan + , vault + , wai + , wai-extra + , wai-websockets + , warp + , warp-tls + , websockets + default-language: Haskell2010 executable static-exe - main-is: Main.hs - hs-source-dirs: examples/static - other-modules: Paths_okapi - default-language: Haskell2010 - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: - aeson >=1.4.7, - attoparsec, - base >=4.7 && <5, - base64, - bytestring, - containers, - cookie, - cryptonite, - extra, - http-api-data, - http-types, - memory, - mmorph, - mtl, - network, - okapi, - parser-combinators, - text, - transformers, - unagi-chan, - vault, - wai, - wai-extra, - wai-websockets, - warp, - warp-tls, - websockets + main-is: Main.hs + other-modules: + Paths_okapi + hs-source-dirs: + examples/static + ghc-options: -threaded -rtsopts -with-rtsopts=-N + build-depends: + aeson >=1.4.7 + , attoparsec + , base >=4.7 && <5 + , base64 + , bytestring + , containers + , cookie + , cryptonite + , extra + , http-api-data + , http-types + , memory + , mmorph + , mtl + , network + , okapi + , parser-combinators + , text + , transformers + , unagi-chan + , vault + , wai + , wai-extra + , wai-websockets + , warp + , warp-tls + , websockets + default-language: Haskell2010 executable todo-exe - main-is: Main.hs - hs-source-dirs: examples/todo - other-modules: Paths_okapi - default-language: Haskell2010 - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: - aeson >=1.4.7, - attoparsec, - base >=4.7 && <5, - base64, - bytestring, - containers, - cookie, - cryptonite, - extra, - http-api-data, - http-types, - memory, - mmorph, - mtl, - network, - okapi, - parser-combinators, - sqlite-simple, - text, - transformers, - unagi-chan, - vault, - wai, - wai-extra, - wai-websockets, - warp, - warp-tls, - websockets + main-is: Main.hs + other-modules: + Paths_okapi + hs-source-dirs: + examples/todo + ghc-options: -threaded -rtsopts -with-rtsopts=-N + build-depends: + aeson >=1.4.7 + , attoparsec + , base >=4.7 && <5 + , base64 + , bytestring + , containers + , cookie + , cryptonite + , extra + , http-api-data + , http-types + , memory + , mmorph + , mtl + , network + , okapi + , parser-combinators + , sqlite-simple + , text + , transformers + , unagi-chan + , vault + , wai + , wai-extra + , wai-websockets + , warp + , warp-tls + , websockets + default-language: Haskell2010 executable todo2-exe - main-is: Main.hs - hs-source-dirs: examples/todo2 - other-modules: Paths_okapi - default-language: Haskell2010 - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: - aeson >=1.4.7, - attoparsec, - base >=4.7 && <5, - base64, - bytestring, - containers, - cookie, - cryptonite, - extra, - http-api-data, - http-types, - memory, - mmorph, - mtl, - network, - okapi, - parser-combinators, - sqlite-simple, - text, - transformers, - unagi-chan, - vault, - wai, - wai-extra, - wai-websockets, - warp, - warp-tls, - websockets + main-is: Main.hs + other-modules: + Paths_okapi + hs-source-dirs: + examples/todo2 + ghc-options: -threaded -rtsopts -with-rtsopts=-N + build-depends: + aeson >=1.4.7 + , attoparsec + , base >=4.7 && <5 + , base64 + , bytestring + , containers + , cookie + , cryptonite + , extra + , http-api-data + , http-types + , memory + , mmorph + , mtl + , network + , okapi + , parser-combinators + , sqlite-simple + , text + , transformers + , unagi-chan + , vault + , wai + , wai-extra + , wai-websockets + , warp + , warp-tls + , websockets + default-language: Haskell2010 executable todo3-exe - main-is: Main.hs - hs-source-dirs: examples/todo3 - other-modules: Paths_okapi - default-language: Haskell2010 - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: - aeson >=1.4.7, - attoparsec, - base >=4.7 && <5, - base64, - bytestring, - containers, - cookie, - cryptonite, - extra, - http-api-data, - http-types, - interpolatedstring-perl6, - memory, - mmorph, - mtl, - network, - okapi, - parser-combinators, - sqlite-simple, - text, - transformers, - unagi-chan, - vault, - wai, - wai-extra, - wai-websockets, - warp, - warp-tls, - websockets + main-is: Main.hs + other-modules: + Paths_okapi + hs-source-dirs: + examples/todo3 + ghc-options: -threaded -rtsopts -with-rtsopts=-N + build-depends: + aeson >=1.4.7 + , attoparsec + , base >=4.7 && <5 + , base64 + , bytestring + , containers + , cookie + , cryptonite + , extra + , http-api-data + , http-types + , interpolatedstring-perl6 + , memory + , mmorph + , mtl + , network + , okapi + , parser-combinators + , sqlite-simple + , text + , transformers + , unagi-chan + , vault + , wai + , wai-extra + , wai-websockets + , warp + , warp-tls + , websockets + default-language: Haskell2010 executable twitter-clone-exe - main-is: Main.hs - hs-source-dirs: examples/twitter-clone - other-modules: Paths_okapi - default-language: Haskell2010 - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: - aeson >=1.4.7, - attoparsec, - base >=4.7 && <5, - base64, - bytestring, - containers, - cookie, - cryptonite, - extra, - http-api-data, - http-types, - memory, - mmorph, - mtl, - network, - okapi, - parser-combinators, - rel8, - text, - transformers, - unagi-chan, - vault, - wai, - wai-extra, - wai-websockets, - warp, - warp-tls, - websockets + main-is: Main.hs + other-modules: + Paths_okapi + hs-source-dirs: + examples/twitter-clone + ghc-options: -threaded -rtsopts -with-rtsopts=-N + build-depends: + aeson >=1.4.7 + , attoparsec + , base >=4.7 && <5 + , base64 + , bytestring + , containers + , cookie + , cryptonite + , extra + , http-api-data + , http-types + , memory + , mmorph + , mtl + , network + , okapi + , parser-combinators + , rel8 + , text + , transformers + , unagi-chan + , vault + , wai + , wai-extra + , wai-websockets + , warp + , warp-tls + , websockets + default-language: Haskell2010 test-suite okapi-test - type: exitcode-stdio-1.0 - main-is: Spec.hs - hs-source-dirs: test - other-modules: Paths_okapi - default-language: Haskell2010 - ghc-options: -threaded -rtsopts -with-rtsopts=-N - build-depends: - aeson >=1.4.7, - attoparsec, - base >=4.7 && <5, - base64, - bytestring, - containers, - cookie, - cryptonite, - doctest-parallel, - extra, - http-api-data, - http-types, - memory, - mmorph, - mtl, - network, - okapi, - parser-combinators, - text, - transformers, - unagi-chan, - vault, - wai, - wai-extra, - wai-websockets, - warp, - warp-tls, - websockets + type: exitcode-stdio-1.0 + main-is: Spec.hs + other-modules: + Paths_okapi + hs-source-dirs: + test + ghc-options: -threaded -rtsopts -with-rtsopts=-N + build-depends: + aeson >=1.4.7 + , attoparsec + , base >=4.7 && <5 + , base64 + , bytestring + , containers + , cookie + , cryptonite + , doctest-parallel + , extra + , http-api-data + , http-types + , memory + , mmorph + , mtl + , network + , okapi + , parser-combinators + , text + , transformers + , unagi-chan + , vault + , wai + , wai-extra + , wai-websockets + , warp + , warp-tls + , websockets + default-language: Haskell2010 diff --git a/package.yaml b/package.yaml index 8bbc46b..faca44a 100644 --- a/package.yaml +++ b/package.yaml @@ -49,9 +49,9 @@ library: source-dirs: src executables: - # realworld-exe: + # realworld-json-exe: # main: Main.hs - # source-dirs: examples/realworld + # source-dirs: examples/realworld-json # ghc-options: # - -threaded # - -rtsopts @@ -66,6 +66,18 @@ executables: # - time # - vector # - profunctors + realworld-htmx-exe: + main: Main.hs + source-dirs: examples/realworld-htmx + ghc-options: + - -threaded + - -rtsopts + - -with-rtsopts=-N + dependencies: + - okapi + - rel8 + - lucid2-htmx + - lucid2 calculator-exe: main: Main.hs source-dirs: examples/calculator diff --git a/stack.yaml b/stack.yaml deleted file mode 100644 index ef2d8a8..0000000 --- a/stack.yaml +++ /dev/null @@ -1,71 +0,0 @@ -# This file was automatically generated by 'stack init' -# -# Some commonly used options have been documented as comments in this file. -# For advanced use and comprehensive documentation of the format, please see: -# https://docs.haskellstack.org/en/stable/yaml_configuration/ - -# Resolver to choose a 'specific' stackage snapshot or a compiler version. -# A snapshot resolver dictates the compiler version and the set of packages -# to be used for project dependencies. For example: -# -# resolver: lts-3.5 -# resolver: nightly-2015-09-21 -# resolver: ghc-7.10.2 -# -# The location of a snapshot can be provided as a file or url. Stack assumes -# a snapshot provided as a file might change, whereas a url resource does not. -# -# resolver: ./custom-snapshot.yaml -# resolver: https://example.com/snapshots/2018-01-01.yaml -resolver: - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/1.yaml - -# User packages to be built. -# Various formats can be used as shown in the example below. -# -# packages: -# - some-directory -# - https://example.com/foo/bar/baz-0.0.2.tar.gz -# subdirs: -# - auto-update -# - wai -packages: -- . -# Dependency packages to be pulled from upstream that are not in the resolver. -# These entries can reference officially published versions as well as -# forks / in-progress versions pinned to a git hash. For example: -# -extra-deps: -- lucid2-0.0.20220526@sha256:b5d346d428a63610d458aba1c4e0fe4924628fec609f028d74777bfaca1d92b5,1877 -- containers-0.6.6@sha256:008d007dfff018954e05ecdb8d628d8e32531f7dc3c6bb7e9bd55118c1224514,2589 -- lucid2-htmx-0.1.0.8@sha256:cde494a8e4d199dfcc59331f41c72e1a60c3d2106e1bee56e61d97b09425f850,1541 -- Cabal-3.6.3.0@sha256:ff97c442b0c679c1c9876acd15f73ac4f602b973c45bde42b43ec28265ee48f4,12459 -- binary-0.8.9.1@sha256:81f468c1c75fd6535152ab69b2d32ac6cfcc03e345267b069abe4da56ec95801,6523 -- parsec-3.1.15.1@sha256:8c7a36aaadff12a38817fc3c4ff6c87e3352cffd1a58df640de7ed7a97ad8fa3,4601 -- text-1.2.5.0@sha256:791f0f6c97ed96113f17ab520cf0efe1a3a4f883a8c85910a5660567c8241c40,7895 - -pvp-bounds: both - -# Override default flag values for local packages and extra-deps -# flags: {} - -# Extra package databases containing global packages -# extra-package-dbs: [] - -# Control whether we use the GHC we find on the path -# system-ghc: true -# -# Require a specific version of stack, using version ranges -# require-stack-version: -any # Default -# require-stack-version: ">=2.7" -# -# Override the architecture used by stack, especially useful on Windows -# arch: i386 -# arch: x86_64 -# -# Extra directories used by stack for building -# extra-include-dirs: [/path/to/dir] -# extra-lib-dirs: [/path/to/dir] -# -# Allow a newer minor version of GHC than the snapshot specifies -# compiler-check: newer-minor diff --git a/stack.yaml.lock b/stack.yaml.lock deleted file mode 100644 index 3303c57..0000000 --- a/stack.yaml.lock +++ /dev/null @@ -1,62 +0,0 @@ -# This file was autogenerated by Stack. -# You should not edit this file by hand. -# For more information, please see the documentation at: -# https://docs.haskellstack.org/en/stable/lock_files - -packages: -- completed: - hackage: lucid2-0.0.20220526@sha256:b5d346d428a63610d458aba1c4e0fe4924628fec609f028d74777bfaca1d92b5,1877 - pantry-tree: - size: 477 - sha256: 355acf57a4ac40d06c48f903c41eda4136d4a218f38bdbfebee7960d23651421 - original: - hackage: lucid2-0.0.20220526@sha256:b5d346d428a63610d458aba1c4e0fe4924628fec609f028d74777bfaca1d92b5,1877 -- completed: - hackage: containers-0.6.6@sha256:008d007dfff018954e05ecdb8d628d8e32531f7dc3c6bb7e9bd55118c1224514,2589 - pantry-tree: - size: 2822 - sha256: de48bcf6b468c4793bbdd22f969d940bfe74425c74654b0efbf0487792c239b5 - original: - hackage: containers-0.6.6@sha256:008d007dfff018954e05ecdb8d628d8e32531f7dc3c6bb7e9bd55118c1224514,2589 -- completed: - hackage: lucid2-htmx-0.1.0.8@sha256:cde494a8e4d199dfcc59331f41c72e1a60c3d2106e1bee56e61d97b09425f850,1541 - pantry-tree: - size: 318 - sha256: bccf8d27fd23db6daa9b1a7e64d54715537161014db7817dc9905015b1de5214 - original: - hackage: lucid2-htmx-0.1.0.8@sha256:cde494a8e4d199dfcc59331f41c72e1a60c3d2106e1bee56e61d97b09425f850,1541 -- completed: - hackage: Cabal-3.6.3.0@sha256:ff97c442b0c679c1c9876acd15f73ac4f602b973c45bde42b43ec28265ee48f4,12459 - pantry-tree: - size: 19757 - sha256: b250a53bdb56844f047a2927833bb565b936a289abfa85dfc2a63148d776368a - original: - hackage: Cabal-3.6.3.0@sha256:ff97c442b0c679c1c9876acd15f73ac4f602b973c45bde42b43ec28265ee48f4,12459 -- completed: - hackage: binary-0.8.9.1@sha256:81f468c1c75fd6535152ab69b2d32ac6cfcc03e345267b069abe4da56ec95801,6523 - pantry-tree: - size: 1976 - sha256: 956ecd662408f69615977b87a92e042abcdc447b7824b8aabf5788c4393c10c5 - original: - hackage: binary-0.8.9.1@sha256:81f468c1c75fd6535152ab69b2d32ac6cfcc03e345267b069abe4da56ec95801,6523 -- completed: - hackage: parsec-3.1.15.1@sha256:8c7a36aaadff12a38817fc3c4ff6c87e3352cffd1a58df640de7ed7a97ad8fa3,4601 - pantry-tree: - size: 2630 - sha256: 147ad21b8aa90273721903a6b294cc4ecd660d229d88c4e84c6275bc5d630ae6 - original: - hackage: parsec-3.1.15.1@sha256:8c7a36aaadff12a38817fc3c4ff6c87e3352cffd1a58df640de7ed7a97ad8fa3,4601 -- completed: - hackage: text-1.2.5.0@sha256:791f0f6c97ed96113f17ab520cf0efe1a3a4f883a8c85910a5660567c8241c40,7895 - pantry-tree: - size: 7395 - sha256: f41504ec5c04a3f3358ef104362f02fdef29cbce4e5e4e6dbd6b6db70c40d4bf - original: - hackage: text-1.2.5.0@sha256:791f0f6c97ed96113f17ab520cf0efe1a3a4f883a8c85910a5660567c8241c40,7895 -snapshots: -- completed: - size: 617355 - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/1.yaml - sha256: cbd5e8593869445794924668479b5bd9f1738d075898623dceacc13b2576b6e3 - original: - url: https://raw.githubusercontent.com/commercialhaskell/stackage-snapshots/master/lts/19/1.yaml