News for hackers. Stuff that matters.
Re:Why I prefer scheme to Haskell by TylerE on Monday April 09, 2012 @09:36AM (#3816873)
But that is I think OP's point, Haskell forces you to "model", versus something like scheme or python where you can just sling dicts around.

Haskell absolutely forces you to do a non-trivial amount of thinking up front, which is counter-productive when you're trying to throw something together in 10 minutes.

Re:Why I prefer scheme to Haskell by DanWaterworth on Monday April 09, 2012 @09:42AM (#3816894)
You can sling dicts around in Haskell too if you want to. The reason people don't is that the alternative is easier.
Re:Why I prefer scheme to Haskell by jayferd on Monday April 09, 2012 @01:48PM (#3818212)
+100. That's one of the things I love about Haskell - it makes the "right" things easy and the "wrong" things hard.
Re:Why I prefer scheme to Haskell by stcredzero on Monday April 09, 2012 @03:32PM (#3818784)
You can sling dicts around in Haskell too if you want to. The reason people don't is that the alternative is easier.

This is extraordinary if it is true -- it would mean something in Haskell has succeeded in making the designed/intended "right way" in a programming language the "easy way."

I'm not so sure finding the right way to design a language/environment is right for a sole design focus anymore. A programming language/environment should be designed to unify and leverage the power of a community, in a way that elevates it above the level of "pop culture." (Where a pop culture is defined as one where the rate of change far outstrips the growth of actual value/knowledge.)

Re:Why I prefer scheme to Haskell by TylerE on Monday April 09, 2012 @01:54PM (#3818258)
But, if I remember correctly, the haskell map is typed, isn't it?

In python you can mix the types of both keys and values in a single dict freely.

Re:Why I prefer scheme to Haskell by jrockway on Monday April 09, 2012 @02:08PM (#3818340)
You can easily define your own type that is "everything". But how useful is a dict in python with keys and values of varying types? I've certainly never used one.
Re:Why I prefer scheme to Haskell by TylerE on Monday April 09, 2012 @02:27PM (#3818451)
It's very useful.

Use it like you'd use a bare object in Javascript, as a freeform data container to hold whatever properties you need. A bit like a key-value NoSQL store, actually.

Re:Why I prefer scheme to Haskell by jrockway on Monday April 09, 2012 @02:28PM (#3818457)
Values, yes, but keys?
Re:Why I prefer scheme to Haskell by TylerE on Monday April 09, 2012 @02:33PM (#3818492)
Sure, why not. I mean, I can't offhand of a time that I've really used mixed keys, but I also can't come with any compelling reason why it's a bad idea. Ad-hoc data comes up all the time.
Re:Why I prefer scheme to Haskell by DanWaterworth on Tuesday April 10, 2012 @02:42AM (#3821045)
It's possible in Haskell:

  {-# LANGUAGE ExistentialQuantification #-}

  import Data.Maybe
  import Data.Typeable
  import Data.Dynamic

  import Data.Map (Map)
  import qualified Data.Map as M

  data Orderable = forall a. (Ord a, Typeable a) => Orderable a

  instance Eq Orderable where
    (Orderable a) == (Orderable b) =
      case cast b of
        Just b' -> a == b'
        Nothing -> False

  instance Ord Orderable where
    (Orderable a) < (Orderable b) =
      case typeOf a `compare` typeOf b of
        GT -> False
        LT -> True
        EQ -> a == fromJust (cast b)
    a > b = b < a
    a <= b = not (a > b)
    a >= b = not (a < b)

  toOrd :: (Ord a, Typeable a) => a -> Orderable
  toOrd = Orderable

  fromOrd :: (Ord a, Typeable a) => Orderable -> Maybe a
  fromOrd (Orderable a) = cast a

  m1 = M.empty
  m2 = M.insert (toOrd "hello world") (toDyn (4 :: Int)) m1
  m3 = M.insert (toOrd True) (toDyn "foo") m2
  m4 = M.insert (toOrd (5 :: Int)) (toDyn False) m3

  main = print ((fromJust (fromDynamic (fromJust (M.lookup (toOrd "hello world") m4)))) :: Int)