News for hackers. Stuff that matters.
Re:GHCJS - Haskell in the Browser by tome on Wednesday June 26, 2013 @01:47PM (#5947620)
I never really understood how Fay users could avoid using typeclasses, since it means (presumably) avoiding functors, applicatives, monads and all that other Haskelly stuff.
Re:GHCJS - Haskell in the Browser by tel on Wednesday June 26, 2013 @02:40PM (#5948080)
Typeclasses provide nothing but convenience there (see [1] for instance). The real power comes from the Algebraic Data Types which are intact.

[1] http://www.haskellforall.com/2012/05/scrap-your-type-classes...

Re:GHCJS - Haskell in the Browser by colanderman on Wednesday June 26, 2013 @04:13PM (#5948693)
I don't see how that mechanism provides subtyping (which typeclasses do)? Last I checked Haskell's structures weren't structurally typed.
Re:GHCJS - Haskell in the Browser by tel on Wednesday June 26, 2013 @04:21PM (#5948744)
You could do it like in Agda,

    data ApplicativeI f = 
      AI { pure      :: forall a. a -> f a
         , ap        :: forall a b. f (a -> b) -> f a -> f b
         , _FunctorI :: FunctorI f }

    data MonadI m = 
      AI { bind          :: forall a b. (a -> m b) -> m a -> m b
         , _ApplicativeI :: ApplicativeI m }

    return :: _MonadI m -> a -> m a
    return (MonadI { _ApplicativeI = ApplicativeI { pure = fn } }) = fn
Re:GHCJS - Haskell in the Browser by colanderman on Wednesday June 26, 2013 @07:29PM (#5949794)
Almost, but that's not extensible: I can't declare some new typeclass Foo and then declare that every x s.t. Monad x is also Foo x without editing the definition of Monad.
Re:GHCJS - Haskell in the Browser by tome on Thursday June 27, 2013 @03:29AM (#5951087)
Instead of providing an instance declaration you provide a value of MonadI f -> FooI f.
Re:GHCJS - Haskell in the Browser by tel on Thursday June 27, 2013 @03:01PM (#5954077)
Exactly, and then that function is "proof" of the relationship.
Re:GHCJS - Haskell in the Browser by tome on Wednesday June 26, 2013 @04:42PM (#5948885)
Personally I wouldn't want to do the instance plumbing by hand.