begin type interop

This commit is contained in:
mtgmonkey 2025-05-04 13:11:51 -04:00
parent 6c4557289b
commit c86f613ccc
6 changed files with 94 additions and 3 deletions

File diff suppressed because one or more lines are too long

View file

@ -1,7 +1,7 @@
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-}
-- import Lib
import Lib
import Data.Text.Lazy (Text)
import Network.Wai.Handler.Warp (Port)
import Network.Wai.Middleware.RequestLogger (logStdoutDev)

View file

@ -18,6 +18,8 @@ extra-source-files:
CHANGELOG.md
library
exposed-modules:
ElmskellTypes
other-modules:
Paths_hs_server
autogen-modules:
@ -30,6 +32,7 @@ library
, blaze-html >=0.9.2 && <0.10
, blaze-markup >=0.8.3 && <0.9
, directory >=1.3.8 && <1.4
, elm-bridge >=0.8.4 && <0.9
, http-types >=0.12.4 && <0.13
, scotty ==0.22.*
, text >=2.1.1 && <2.2
@ -51,6 +54,7 @@ executable hs-server-exe
, blaze-html >=0.9.2 && <0.10
, blaze-markup >=0.8.3 && <0.9
, directory >=1.3.8 && <1.4
, elm-bridge >=0.8.4 && <0.9
, hs-server
, http-types >=0.12.4 && <0.13
, scotty ==0.22.*
@ -74,6 +78,7 @@ test-suite hs-server-test
, blaze-html >=0.9.2 && <0.10
, blaze-markup >=0.8.3 && <0.9
, directory >=1.3.8 && <1.4
, elm-bridge >=0.8.4 && <0.9
, hs-server
, http-types >=0.12.4 && <0.13
, scotty ==0.22.*

View file

@ -0,0 +1,20 @@
{-# LANGUAGE TemplateHaskell #-}
module ElmskellTypes
import Elm.Derive
import Elm.Module
data Foo
= Foo
{ name :: String
, blablub :: Int
} deriving (Show, Eq)
deriveBoth defaultOptions ''Foo
main :: IO ()
main =
putStrLn $ makeElmModule "Foo"
[ DefineElm (Proxy :: Proxy Foo)
]

View file

@ -185,6 +185,7 @@ update msg model =
type Command
= Help
| Clear
| Colors
| Cookies
| FontCommand
| Hello
@ -213,6 +214,9 @@ parseInput input =
Just "clear" ->
Ok Clear
Just "colors" ->
Ok Colors
Just "cookies" ->
Ok Cookies
@ -269,6 +273,9 @@ runCommand model input =
Clear ->
runClear
Colors ->
runColors
Cookies ->
runCookies
@ -341,6 +348,9 @@ runHelp model args =
[ text <| "\nclear clears the screen"
]
Just "colors" ->
[ text "\ncolors ", coloredText (coreColor BrightCyan) "[UNIMPLEMENTED]" ]
Just "cookies" ->
[ text <|
"\ncookies prints info about the current cookie settings"
@ -407,6 +417,25 @@ runClear model args =
)
runColors : CommandRunner
runColors model args =
case List.head args of
Nothing ->
( { model | content = model.content ++ wrongArgs Colors 1 args }, Cmd.none )
Just "test" ->
( { model
| content =
model.content
++ [ coloredText (coreColor Red) "Red" ]
}
, Cmd.none
)
Just _ ->
( { model | content = model.content ++ wrongArgs Colors 1 args }, Cmd.none )
runCookies : CommandRunner
runCookies model args =
case List.head args of
@ -669,6 +698,7 @@ runTodo model args =
++ "\n- Something like Neofetch"
++ "\n- Collect and store feedback in a database"
++ "\n- Create a style guide for programs involving console colors"
++ "\n- Modularise the code (to have something more elegant than a single 2k line file)"
++ "\n"
++ "\nUpcoming commands to look forward to:"
++ "\nfunfetch"
@ -710,6 +740,9 @@ wrongArgs command expected args =
Clear ->
"clear"
Colors ->
"colors"
Cookies ->
"cookies"
@ -941,6 +974,37 @@ type ThemeColor
| BrightWhite
allColors : Model -> List Color
allColors model =
List.map
coreColor
[ Red
, Green
, Yellow
, Blue
, Magenta
, Cyan
, BrightRed
, BrightGreen
, BrightYellow
, BrightBlue
, BrightMagenta
, BrightCyan
]
++
List.map
(themeColor model)
[ Background
, Foreground
, Cursor
, Black
, White
, BrightBlack
, BrightWhite
]
-- Colors from Root Loops
-- flavor: intense

View file

@ -16,9 +16,11 @@
];
in
pkgs.mkShell {
nativeBuildInputs = [
buildInputs = [
elmInputs
haskellInputs
];
packages = [
buildTools
cliTools
];