From 088c3f7d907589148bfd395c92024cc5763b90f1 Mon Sep 17 00:00:00 2001 From: towards-a-new-leftypol Date: Thu, 14 Dec 2023 07:18:25 -0500 Subject: [PATCH] Hello world --- chandlr.cabal | 11 +++------- src/Main.hs | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 59 insertions(+), 9 deletions(-) diff --git a/chandlr.cabal b/chandlr.cabal index 0f79866..cb04735 100644 --- a/chandlr.cabal +++ b/chandlr.cabal @@ -52,19 +52,14 @@ extra-doc-files: CHANGELOG.md -- Extra source files to be distributed with the package, such as examples, or a tutorial module. -- extra-source-files: -common warnings - ghc-options: -Wall - executable chandlr - -- if !impl(ghcjs) - -- buildable: False - - -- Import common warning flags. - import: warnings + if !impl(ghcjs) + buildable: False -- .hs or .lhs file containing the Main module. main-is: Main.hs + ghc-options: -Wall -O2 ghcjs-options: -dedupe -- Modules included in this executable, other than Main. diff --git a/src/Main.hs b/src/Main.hs index 65ae4a0..39a9d58 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -1,4 +1,59 @@ +{-# LANGUAGE OverloadedStrings #-} + module Main where +import Miso + ( View + , startApp + , App (..) + , h1_ + , text + , Effect + --, (#>) + , noEff + , defaultEvents + ) + +data Unit = Unit + deriving Eq + +type Model = Unit + +type Action = Unit + main :: IO () -main = putStrLn "Hello, Haskell!" +main = startApp App + { model = Unit + , update = mainUpdate + , view = mainView + , subs = [] + , events = defaultEvents + , initialAction = Unit + , mountPoint = Nothing + } + +mainView :: Model -> View Action +mainView = const $ h1_ [] [ text "Hello World" ] + +mainUpdate :: Action -> Model -> Effect Action Model +-- mainUpdate = const $ (#>) (pure Unit) -- this is an infinite loop! +mainUpdate = const noEff + +{- + - TODO: + - - Create Hello World page render ✓ + - - Create CatalogGrid component (static at first) + -} + +{- + - + - TODO: + - - Initial page just needs to display the search bar, fetch catalog and + - display it + - Make Model + - - single value representing that we need to go fetch the initial page + - + - maybe immediately create the CatalogGrid component with its own model? That + - would allow us to swap it out with a thread / overboard component later, and + - tell it what to render + -}