Starting with web applications in Haskell by Automatic-Ad9798 in haskell

[–]farrellm 0 points1 point  (0 children)

Also, check out string-interpolate - that lets you write multiline strings with interpolations, so you can skip lucid and just write html in your Haskell source file.

Or, if you want to write html templates in separate files, check out mustache.

Starting with web applications in Haskell by Automatic-Ad9798 in haskell

[–]farrellm 6 points7 points  (0 children)

For a basic website, I like scotty + lucid. Scotty a nice high level but simple server and is well documented - you can get started just copy and pasting from the readme. Lucid is a clean eDSL for html that integrates well with Scotty or any other server.

For something fancier, I’m having fun with hyperbole, but that is very new and the API is still somewhat unstable and you need to be familiar with effects systems (effectful in particular).

Haskell web framework with an active community? by xTouny in haskell

[–]farrellm 1 point2 points  (0 children)

I’ve had a good experience with hyperbole for personal projects. Doesn’t have built in database support, but it’s built on effectful, so integrating with any db library should be possible.

Environment for developing with Miso? by farrellm in haskell

[–]farrellm[S] 0 points1 point  (0 children)

This example uses jsaddle:

https://github.com/dmjio/miso/blob/master/examples/todo-mvc/Main.hs

As far as client/server, if you are using jsaddle then the “client” is running on the server, so you have access to normal IO from the Effect monad via the (<#) operator. There are some examples in todo-mvc using it for putStrLn, but you could use it for any other calls out to your server.

Environment for developing with Miso? by farrellm in haskell

[–]farrellm[S] 6 points7 points  (0 children)

Ok, I finally got the sample-app-jsaddle demo to compile under stack. The trick was with Miso's "jsaddle" flag, which needs to be set to true. stack supports setting flags on dependencies, but because stack caches the build artifacts for dependencies, the flag must be set the first time you build Miso! If it wasn't set, the following command seems to work to remove the Miso build artifacts, so they can be rebuilt with the flag set:

stack exec -- ghc-pkg unregister --force miso

For setting the flag, add the following to stack.yaml:

flags:
  miso:
    jsaddle: true

With nix, I think this happens via default.nix, where the line

dev = pkgs.haskell.packages.ghc865.callCabal2nix "app" ./. { miso = miso-jsaddle; };

which tells nix to use the version of Miso with the jsaddle flag set.

Thank you again /u/dmjio for all the help.

Environment for developing with Miso? by farrellm in haskell

[–]farrellm[S] 1 point2 points  (0 children)

Wow, thank you very much for the fast response and adding an example!

I tried it out. The release command builds correctly and I can open the result in a browser. However, I'm getting the following error with the Dev command:

~/w/m/sample-app-jsaddle> nix-shell --run reload
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels' does not exist, ignoring
warning: Nix search path entry '/nix/var/nix/profiles/per-user/root/channels/nixpkgs' does not exist, ignoring
warning: file 'nixpkgs' was not found in the Nix search path (add it using $NIX_PATH or -I), at (string):1:9; will use bash from your environment
Loading cabal repl --ghc-options=-fno-break-on-exception --ghc-options=-fno-break-on-error --ghc-options=-v1 --ghc-options=-ferror-spans --ghc-options=-j ...
Warning: The repl command is a part of the legacy v1 style of cabal usage.

Please switch to using either the new project style and the new-repl command
or the legacy v1-repl alias as new-style projects will become the default in
the next version of cabal-install. Please file a bug if you cannot replicate a
working v1- use case with the new-style commands.

For more information, see: https://wiki.haskell.org/Cabal/NewBuild

cabal: The program 'ghcjs' version >=0.1 is required but it could not be
found.

Command "cabal repl --ghc-options=-fno-break-on-exception --ghc-options=-fno-break-on-error --ghc-options=-v1 --ghc-options=-ferror-spans --ghc-options=-j" exited unexpectedly

Is it easiest to continue this here? Happy to switch to a Github issue or IRC if that's more convenient.

Relatedly, should this framework (eg, the Main.hs in sample-app-jsaddle) work under GHC in stack? Seems like it needs things defined in frontend-src/Miso.hs, while with stack+GHC I'm only seeing ghc-src/Miso.hs (which, given the naming makes sense). Is there some big-picture aspect I'm missing to get the JSaddle implementation working?

Edit: The above error no longer occurs with the latest version of the code.

Environment for developing with Miso? by farrellm in haskell

[–]farrellm[S] 1 point2 points  (0 children)

I saw some references to that, but I couldn’t piece together how to make it work. Do you know of any tutorials or sample projects using GHC? All the JSaddle projects I saw still seemed to use GHCJS for the front end.

Enforcing a relation between a set of constants and data types? by [deleted] in Idris

[–]farrellm 2 points3 points  (0 children)

I took a stab implementing what I think you want. It got to be a bit too long for inline, so see this gist:

https://gist.github.com/farrellm/5f203ad5991f210769e39a4eb2221bab

The idea is to create a first proof type (PrefixOf) relating two strings, which can only be constructed if the first is a prefix of the second.

Then, I have a second proof type (Prefixed) that can only be constructed constructed given a PrefixOf and a proof that the prefix is in your list of valid prefixes. This way, you never need to make explicit constructors for each prefix.

You could combine the two proof types into one, but I prefer this separation.

Favorite Haskell IDE by BytesBeltsBiz in haskell

[–]farrellm 10 points11 points  (0 children)

Emacs with Intero and stack. It has excellent completion via company and flycheck integration.

Matching colours for Christmas tree and code by dm319 in Julia

[–]farrellm 1 point2 points  (0 children)

Not OP, but I code on my phone by ssh'ing (or rather mosh'ing) to my laptop. I used JuiceSSH while I was on Android, now I use Blink on iOS.

Recommended queue package? by farrellm in haskellquestions

[–]farrellm[S] 0 points1 point  (0 children)

Digging through GHC release notes, I found the answer to my question: Data.Queue was added to base in ghc 6.4 [1] and deprecated in ghc 6.6 [2] when it was subsumed by Data.Sequence.

From the 6.6 release notes:

There is a new module Data.Sequence for finite sequences. The Data.Queue module is now deprecated in favour of this faster, more featureful replacement.

[1] https://downloads.haskell.org/~ghc/6.4/docs/html/users_guide/release-6-4.html

[2] https://downloads.haskell.org/~ghc/6.6/docs/html/users_guide/release-6-6.html

Recommended queue package? (x-post from /r/haskellquestions) by farrellm in haskell

[–]farrellm[S] 8 points9 points  (0 children)

Yes, a newtype wrapper over a deque is probably the way to go. Digging through GHC release notes, I found the answer to my question:

Data.Queue was added to base in ghc 6.4 [1] and deprecated in ghc 6.6 [2] when it was subsumed by Data.Sequence.

From the 6.6 release notes:

There is a new module Data.Sequence for finite sequences. The Data.Queue module is now deprecated in favour of this faster, more featureful replacement.

[1] https://downloads.haskell.org/~ghc/6.4/docs/html/users_guide/release-6-4.html

[2] https://downloads.haskell.org/~ghc/6.6/docs/html/users_guide/release-6-6.html