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 DeriveGeneric #-}
{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE OverloadedStrings #-}
-- import Lib import Lib
import Data.Text.Lazy (Text) import Data.Text.Lazy (Text)
import Network.Wai.Handler.Warp (Port) import Network.Wai.Handler.Warp (Port)
import Network.Wai.Middleware.RequestLogger (logStdoutDev) import Network.Wai.Middleware.RequestLogger (logStdoutDev)

View file

@ -18,6 +18,8 @@ extra-source-files:
CHANGELOG.md CHANGELOG.md
library library
exposed-modules:
ElmskellTypes
other-modules: other-modules:
Paths_hs_server Paths_hs_server
autogen-modules: autogen-modules:
@ -30,6 +32,7 @@ library
, blaze-html >=0.9.2 && <0.10 , blaze-html >=0.9.2 && <0.10
, blaze-markup >=0.8.3 && <0.9 , blaze-markup >=0.8.3 && <0.9
, directory >=1.3.8 && <1.4 , directory >=1.3.8 && <1.4
, elm-bridge >=0.8.4 && <0.9
, http-types >=0.12.4 && <0.13 , http-types >=0.12.4 && <0.13
, scotty ==0.22.* , scotty ==0.22.*
, text >=2.1.1 && <2.2 , text >=2.1.1 && <2.2
@ -51,6 +54,7 @@ executable hs-server-exe
, blaze-html >=0.9.2 && <0.10 , blaze-html >=0.9.2 && <0.10
, blaze-markup >=0.8.3 && <0.9 , blaze-markup >=0.8.3 && <0.9
, directory >=1.3.8 && <1.4 , directory >=1.3.8 && <1.4
, elm-bridge >=0.8.4 && <0.9
, hs-server , hs-server
, http-types >=0.12.4 && <0.13 , http-types >=0.12.4 && <0.13
, scotty ==0.22.* , scotty ==0.22.*
@ -74,6 +78,7 @@ test-suite hs-server-test
, blaze-html >=0.9.2 && <0.10 , blaze-html >=0.9.2 && <0.10
, blaze-markup >=0.8.3 && <0.9 , blaze-markup >=0.8.3 && <0.9
, directory >=1.3.8 && <1.4 , directory >=1.3.8 && <1.4
, elm-bridge >=0.8.4 && <0.9
, hs-server , hs-server
, http-types >=0.12.4 && <0.13 , http-types >=0.12.4 && <0.13
, scotty ==0.22.* , 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 type Command
= Help = Help
| Clear | Clear
| Colors
| Cookies | Cookies
| FontCommand | FontCommand
| Hello | Hello
@ -213,6 +214,9 @@ parseInput input =
Just "clear" -> Just "clear" ->
Ok Clear Ok Clear
Just "colors" ->
Ok Colors
Just "cookies" -> Just "cookies" ->
Ok Cookies Ok Cookies
@ -269,6 +273,9 @@ runCommand model input =
Clear -> Clear ->
runClear runClear
Colors ->
runColors
Cookies -> Cookies ->
runCookies runCookies
@ -341,6 +348,9 @@ runHelp model args =
[ text <| "\nclear clears the screen" [ text <| "\nclear clears the screen"
] ]
Just "colors" ->
[ text "\ncolors ", coloredText (coreColor BrightCyan) "[UNIMPLEMENTED]" ]
Just "cookies" -> Just "cookies" ->
[ text <| [ text <|
"\ncookies prints info about the current cookie settings" "\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 : CommandRunner
runCookies model args = runCookies model args =
case List.head args of case List.head args of
@ -669,6 +698,7 @@ runTodo model args =
++ "\n- Something like Neofetch" ++ "\n- Something like Neofetch"
++ "\n- Collect and store feedback in a database" ++ "\n- Collect and store feedback in a database"
++ "\n- Create a style guide for programs involving console colors" ++ "\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" ++ "\n"
++ "\nUpcoming commands to look forward to:" ++ "\nUpcoming commands to look forward to:"
++ "\nfunfetch" ++ "\nfunfetch"
@ -710,6 +740,9 @@ wrongArgs command expected args =
Clear -> Clear ->
"clear" "clear"
Colors ->
"colors"
Cookies -> Cookies ->
"cookies" "cookies"
@ -941,6 +974,37 @@ type ThemeColor
| BrightWhite | 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 -- Colors from Root Loops
-- flavor: intense -- flavor: intense

View file

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