[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Elm and Guix
From: |
jgart |
Subject: |
Elm and Guix |
Date: |
Tue, 13 Sep 2022 19:27:24 -0500 |
From: jgart <jgart@dismail.de>
To: Guix Help <help-guix@gnu.org>
Cc: Philip McGrath <philip@philipmcgrath.com>
Bcc:
Subject: Using elm with Guix
Reply-To:
In-Reply-To:
Hi,
I'v been trying to use elm with Guix at the repl and by compiling a
src/Main.elm file and elm doesn't find any of the Guix-installed dependencies:
```
guix-shell elm make src/Main.elm
Detected problems in 1 module.
-- MODULE NOT FOUND ----------------------------------------------- src/Main.elm
You are trying to import a `Http` module:
10| import Http
^^^^
I checked the "dependencies" and "source-directories" listed in your elm.json,
but I cannot find it! Maybe it is a typo for one of these names?
Set
Dict
Main
Task
Hint: Maybe you want the `Http` module defined in the elm/http package? Running
elm install elm/http should make it available!
```
Is there a way that I'm supposed to be using elm with Guix in order to discover
the dependencies.
The usage of this for elm developers using Guix looks undocumented.
What I tried:
```
guix shell elm elm-json elm-html emacs-http
mkdir elm_play
cd elm_play
elm init
elm make src/Main.elm
```
Main.elm:
```
module Main exposing (..)
-- Make a GET request to load a book called "Public Opinion"
--
-- Read how it works:
-- https://guide.elm-lang.org/effects/http.html
--
import Browser
import Html exposing (Html, text, pre)
import Http
-- MAIN
main =
Browser.element
{ init = init
, update = update
, subscriptions = subscriptions
, view = view
}
-- MODEL
type Model
= Failure
| Loading
| Success String
init : () -> (Model, Cmd Msg)
init _ =
( Loading
, Http.get
{ url = "https://elm-lang.org/assets/public-opinion.txt"
, expect = Http.expectString GotText
}
)
-- UPDATE
type Msg
= GotText (Result Http.Error String)
update : Msg -> Model -> (Model, Cmd Msg)
update msg model =
case msg of
GotText result ->
case result of
Ok fullText ->
(Success fullText, Cmd.none)
Err _ ->
(Failure, Cmd.none)
-- SUBSCRIPTIONS
subscriptions : Model -> Sub Msg
subscriptions model =
Sub.none
-- VIEW
view : Model -> Html Msg
view model =
case model of
Failure ->
text "I was unable to load your book."
Loading ->
text "Loading..."
Success fullText ->
pre [] [ text fullText ]
```
wdyt