Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Baldur
    @Iceland_jack_twitter
    Good paper ;)
    It also shows not-so-nice alternatives
    Ben Spencer
    @BRS999
    A friend sent it to me to read :)
    Baldur
    @Iceland_jack_twitter
    (==) :: a -> a -> Bool
    would be a horrible type for equality
    Ben Spencer
    @BRS999
    Something seems off about it
    Baldur
    @Iceland_jack_twitter
    If you recall our conversation about mystery :: a -> a -> a
    The only implementations for (==) :: a -> a -> Bool ought to be
    eq1 :: a -> a -> Bool
    eq1 _ _ = False
    
    eq2 :: a -> a -> Bool
    eq2 _ _ = True
    apart from silly ones like eq1 = undefined
    Ben Spencer
    @BRS999
    Interesting
    Baldur
    @Iceland_jack_twitter
    Because the a's could be any type, even ones not-yet-defined
    Ben Spencer
    @BRS999
    Ah ha
    That’s right
    Baldur
    @Iceland_jack_twitter
    We know nothing about it, thus we can't do anything with them
    That's why functions of type a -> b can't be implemented
    (for the rest of eternity, I will elide all sorts of undefined implementations)
    Ben Spencer
    @BRS999
    Haha, even though you could do that how useful would it be?
    Baldur
    @Iceland_jack_twitter
    do what?
    undefineds?
    Ben Spencer
    @BRS999
    Yes
    Baldur
    @Iceland_jack_twitter
    Only useful when developing
    Ben Spencer
    @BRS999
    For this example
    The idea being you can go back and fill them in?
    Baldur
    @Iceland_jack_twitter
    exactly
    not useful at all, but every time this topic is discussed some Besserwisser points them out
    Ben Spencer
    @BRS999
    Excellent
    haha
    Baldur
    @Iceland_jack_twitter

    <Iceland_jack> There is only one valid implementation of

    id :: a -> a
    id x = x

    <Human> What about id = id?

    I shouldn't call people jerks, I'll edit it :)
    Ben Spencer
    @BRS999
    haha
    Could you say one useful implementation?
    Baldur
    @Iceland_jack_twitter
    Yes you could
    Baldur
    @Iceland_jack_twitter
    afk
    Ben Spencer
    @BRS999
    For sure I need to think about dinner myself
    Baldur
    @Iceland_jack_twitter
    Monoids: themes and variations
    Nagarjuna pamu
    @pamu
    I am currently going through data types a la carte paper. How do I understand this one data Expr f = In (f (Expr f)). Please let me know any blogs or stackoverflow posts or wikis available explaining this recursive structure
    Baldur
    @Iceland_jack_twitter
    Search "fixed point of Functor" or "newtype Fix" and you will find many resources
    It is basically
    f (f (f (f (f ..)))
    Nagarjuna pamu
    @pamu
    @Iceland_jack_twitter cool, Thanks.
    sondereden
    @sondereden
    It's time that Haskell has the reputation it has earned
    it should be renamed Hack for SEO reasons
    this alone
    could change the coding market
    for decades
    years at the least
    ...
    Kalind Karia
    @kalindkaria
    Hi everyone
    I am looking for the guidance in hardware software co-design field using Haskell
    any papers or tutorials which I can follow to get started?
    skyyeow714
    @skyyeow714

    Hello, can anyone help me out with this?

    choose :: PickingMonad m => [a] -> m a
    choose = undefined
    
    - choose xs should run without error for any non-empty list xs :: [a] (for the empty list it can do anything)
    - in the case of the monad m = IO, choose xs should run in time proportional to the length of xs
    - in the case of the monad m = Dist, choose xs :: Dist a should compute a (not necessarily normalised) 
    distribution where each value in xs is assigned a probability proportional to the number of times it occurs in xs.  
    That is, prob xs x should be equal to k / n, where k = length [y | y <- xs, x == y] and n = length xs.

    I have written the code in the way like this, not sure if its correct concept, but i get errors.

    choose :: PickingMonad m => [a] -> m a
    choose [] = error "Error"
    choose xs = do
                let n = length xs
                i <- getRandomR (0, n-1)
                return (xs !! i)