So, as many of you know, GHCJS is pretty hard to get set up.
Clearly, some people have gotten GHCJS set up, and some will be in a VM image.
So, I'm requesting that someone share that image.
I've tried the Vagrant images, but they haven't worked for me, even the pre-built ones. They don't seem to have been updated for quite some time, and I get errors running vagrant up with them.
GHCJS would be great if it were easy, but in the meantime, I think having a good starter VM floating around would be a good solution.
That said, if someone has a good guide of how to get the vagrant images up and working, that would be great. But would much prefer a VM image I can just download and run.submitted by jmite
[link] [14 comments]
Can you recommend reliable open-source Snap projects?
I have some knowledge of Haskell (mostly gained from Learn You a Haskell), and I have experience creating web apps with Django.
The idea is to see good examples of web development using Haskell that we can learn from. (The focus of my interest would be project structuring, testing and session handling.)submitted by danbal
[link] [6 comments]
I made a function in Haskell that takes in a number and returns a list of integers from 1 to that number.gen x = [1..x] gen 4 -> [1, 2, 3, 4]
As I was learning about the monads I noticed that I could bind a list into this function as it has the type of (a -> m a).[2, 3, 6, 1, 4] >>= gen -> [1, 2, 1, 2, 3, 1, 2, 3, 4, 5, 6, 1, 1, 2, 3, 4]
Then I wanted to write a function that would reverse the (>>= gen) and i came up with this function.revgen (x:xs) = case (null xs) of False -> case ((head xs) - x) of 1 -> 1 + revgen xs otherwise -> 0 : revgen xs True -> 1 : 
But it doesn't work, I think because of the revgen returning both numbers and lists. But I can't come up with a way to do this any other way with one function. Also the nested cases look ugly as hell but I quess they work as intented because at least it compiles.submitted by SpacemanInBikini
[link] [10 comments]
I apologize if this is way off topic, but I've been poring over this for a while and I think this might be a good place to ask: has there been any research on 'inverse types'? Either in Haskell or in general.
I'm trying to learn more about abstract algebra and algebraic data types, and from what I can tell the types form a semiring (though if there's a more accurate/complete structure please let me know!). What I'm wondering is if it's possible to extend this semiring to a full ring, or even a field. I've heard of a Grothendieck construction for groups and suspect it is also applicable to semirings, but I haven't really investigated that area very much.
Additionally I can't seem to find any intuitive expression of the additive or multiplicative inverse of a type offhand, but I'm curious if there even is one. Additive inverses seem to make a little bit of sense perhaps in a resource consumption sort of way, but it's shaky at best. And I have no idea what the reciprocal of a type would represent either, though I did see a 'quotient type' mentioned at the end of the clowns and jokers paper.submitted by asampson
[link] [30 comments]
I have:type family Flip a where Flip (a -> b) = b -> a > :kind! Flip (Int -> Bool) Flip (Int -> Bool) :: * = Bool -> Int
but it doesn't work for unboxed values:> Flip (Int# -> Bool) Flip (Int# -> Bool) :: * = Flip (Int# -> Bool) > import Data.Type.Equality > :t Refl :: (Flip (Int# -> Bool) :~: (Bool -> Int#)) <interactive>:1:1: Warning: Couldn't match type ‘Flip (Int# -> Bool)’ with ‘Bool -> Int#’ Expected type: Flip (Int# -> Bool) :~: (Bool -> Int#) Actual type: (Bool -> Int#) :~: (Bool -> Int#) In the expression: Refl :: Flip (Int# -> Bool) :~: (Bool -> Int#) Refl :: (Flip (Int# -> Bool) :~: (Bool -> Int#)) :: (Bool -> Int#) :~: (Bool -> Int#)
Is there any way to fix that?submitted by haskellthrowaway
[link] [8 comments]
Cyrus Omar, Darya Kurilova, Ligia Nistor, Benjamin Chung, Alex Potanin, and Jonathan Aldrich, "Safely Composable Type-Specific Languages", ECOOP14.
Programming languages often include specialized syntax for common datatypes (e.g. lists) and some also build in support for specific specialized datatypes (e.g. regular expressions), but user-defined types must use general-purpose syntax. Frustration with this causes developers to use strings, rather than structured data, with alarming frequency, leading to correctness, performance, security, and usability issues. Allowing library providers to modularly extend a language with new syntax could help address these issues. Unfortunately, prior mechanisms either limit expressiveness or are not safely composable: individually unambiguous extensions can still cause ambiguities when used together. We introduce type-specific languages (TSLs): logic associated with a type that determines how the bodies of generic literals, able to contain arbitrary syntax, are parsed and elaborated, hygienically. The TSL for a type is invoked only when a literal appears where a term of that type is expected, guaranteeing non-interference. We give evidence supporting the applicability of this approach and formally specify it with a bidirectionally typed elaboration semantics for the Wyvern programming language.
Is there any way to make a type class that looks something like:class Unbox ty where type Unboxed ty :: # unbox :: ty -> Unboxed ty instance Unbox Int where type Unboxed Int = Int# unbox (I# i) = i
Fails with an unsurprising error. Making the kind of Unboxed ty * I used the fact that Int -> Int# :: * but that compiles:class Unbox ty where type Unboxed ty unbox :: Unboxed ty instance Unboxed Int where type Unboxed Int = Int -> Int# unbox (I# i) = i instance Unboxed Float where type Unboxed Float = Float -> Float# unbox (F# f) = f
But isn't actually usable:> :t unbox ... :: Unbox a => Unboxed a > :t unbox (5 :: Int) ... :: (Unbox a, Unboxed a ~ (Int -> t)) => t > :t unbox (5 :: Int) :: Int# <interactive>:1:1: Warning: No instance for (Unbox a0) arising from a use of ‘unbox’ The type variables ‘k0’, ‘a0’ are ambiguous Note: there is a potential instance available: instance [overlap ok] Unbox Int -- Defined at /tmp/tmp.4JSrL7ihDP.hs:211:10 In the expression: unbox (5 :: Int) :: Int# <interactive>:1:1: Warning: Couldn't match expected type ‘Int -> Int#’ with actual type ‘Unboxed a0’ The type variables ‘k0’, ‘a0’ are ambiguous The function ‘unbox’ is applied to one argument, but its type ‘Unboxed a0’ has none In the expression: unbox (5 :: Int) :: Int#
Comments welcomesubmitted by haskellthrowaway
[link] [5 comments]
Appearing in the paper Unboxed value as first class citizens in a non-strict functional language, GHC allows allowing user defined data types to contain unboxed values.
This seems to have worked great in Haskell and allows adding optimizations like -ffast-math as a library. THe paper appeared in 1991, have any other languages adopted this view of unboxed values? If not, is it because it only benefits non-strict languages? Something else?submitted by haskellthrowaway
[link] [2 comments]