Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Clean

Name: Anonymous 2009-01-01 14:40

Does anyone use Haskell Clean?
Its faster then GHC

Name: Anonymous 2009-01-01 14:42

Does anyone use Haskell g++?
Its faster then GHC

Name: Anonymous 2009-01-01 14:46

Does anyone use Haskell python.exe?
Its faster than GHC

Name: Anonymous 2009-01-01 15:12

Does anyone use Haskell Clojure?
Its faster then GHC

Name: Anonymous 2009-01-01 15:27

/prog/ Doesn't know Haskell. They just play a game of pretend.
The most they've read about is some thread about Haskell and its Wikipedia article.

Name: Anonymous 2009-01-01 15:31

>>5
Silly wabit i can write a factorial function.

Name: Anonymous 2009-01-01 16:16

>>6
which is in the Haskell Wikipedia article

Name: Anonymous 2009-01-01 16:24

fact n = last.loeb $ const 1:[(*x).(!!(x-2)) | x <- [2..n]]

Name: Anonymous 2009-01-01 16:44

fact 1 = 1
fact 2 = 2
fact 3 = 6
fact 4 = 24
fact 5 = 120
fact 6 = 720
fact 7 = 5040
fact n = error "Error occurred"

Name: Anonymous 2009-01-01 16:54

loeb is fuckign lame

Name: Anonymous 2009-01-01 16:54

URE ALL FAT CUNTS

Name: Anonymous 2009-01-01 17:20

[code]import Control.Monad.ST
import Control.Monad
import Data.STRef

whileM cond action = do
    action
    b <- cond
    if b then whileM cond action else return ()

factorial n = do
    acc <- newSTRef 1
    i <- newSTRef 1
    whileM (do liftM (<= n) $ readSTRef i) $ do
        i' <- readSTRef i
        modifySTRef acc (*i')
        modifySTRef i (+1)
        return ()
    readSTRef acc

main = print (runST $ factorial 7)[code]

Name: Anonymous 2009-01-01 18:48

REAL WORLD FACTORIALS

Name: Anonymous 2009-01-01 19:26

>>11
[citation needed]

Name: Anonymous 2009-01-01 22:04

>>12
EXPERT C PROGRAMMER

Name: Anonymous 2009-01-02 13:40

in after factorial in haskell thread

Name: Anonymous 2009-03-06 6:38

Dynamic typing causes some   errors to take   a random quote   from a txt   file say every   definition in this   form Who are   you mister an.

Name: Anonymous 2013-08-05 16:42

Lisp.

Name: Anonymous 2013-08-06 17:21

>>6

I can write an fibonacci function, it is easy in haskell. Just define a parametric higher-order abstract syntax lambda calculus with recursive binders as extension (mu binders) then use this DSL to express fibonacci in it:


{-# LANGUAGE RankNTypes, GADTs, MultiParamTypeClasses, FlexibleInstances, ViewPatterns, KindSignatures,   OverlappingInstances, NoMonomorphismRestriction, IncoherentInstances #-}
module Main where

import Control.Monad.Fix
import Control.Applicative


-- | A PHOAS encoded lambda calculus with mu-binders
data Term v t where
    Var :: v t -> Term v t
    App :: Term v (a -> b) -> Term v a -> Term v b
    Lam :: (v a -> Term v b) -> Term v (a -> b)
    Lam2 :: (v a -> v b -> Term v c) -> Term v (a -> b -> c) 
    If :: Term v Bool -> Term v t -> Term v t -> Term v t 
    Eq :: Eq a => Term v a -> Term v a -> Term v Bool
    Mu :: (v t -> Term v t) -> Term v t 
    MuN :: ([v t] -> [Term v t]) -> Term v t

-- | Hide the structure used as variables
--  This makes direct instantiation impossible and thus enforces the structure
data Exp t where
    Exp :: Variable v => Term v t -> Exp t

-- | Some helper to work with variables 
-- lower . raise = id
-- raise . lower = id_v
class Variable (v :: * -> *)  where
    raise :: a ->   v a
    lower :: v a -> a 
    on :: (a -> b) -> v a -> v b
    on f = raise . f . lower

instance Variable Id  where
    raise a = (Id a)
    lower ((Id a)) = a

-- | Lift any value into the language 
class Liftable t where
    lift :: Variable v => t -> Term v t

instance Liftable a where
    lift i = Var (raise i)


instance Liftable b => Liftable (a -> b) where
    lift f = Lam $ \x -> lift (f (lower x))

-- | A phoas term is a Functor
instance Variable v => Functor (Term v) where
    fmap f m = App (lift f) m

-- | And it is an applicative, this is handy for composition of lambdas
instance Variable v => Applicative (Term v) where
    pure = lift    
    (<*>) = App

-- | Some underlying functor for instantiating v
newtype Id a = Id {
        unId :: a
    }

{- | A couple of helper functions -}

-- | Non lifting application
($$) = App
-- | RHS lifting application
($.) f n =  App f (lift n)
-- | LHS lifting application
(.$) f n = App (lift f) n
-- | Both lifting application
(.$.) f n = App (lift f) (lift n)

-- | l to r Composition
($<) :: (Variable v, Liftable a, Liftable b, Liftable c) => Term v (b -> c) -> Term v (a -> b) -> Term v (a -> c)
($<) f g = (Lam (\(lower -> a) -> f $$ (g $. a)))

-- | r to l composition
($>) :: (Variable v, Liftable a, Liftable b, Liftable c) => Term v (a -> b) -> Term v (b -> c) -> Term v (a -> c)
($>) f g = (Lam (\(lower -> a) -> g $$ (f $. a)))

infixl 1 $$
infixl 1 .$
infixl 1 $.
infixl 1 .$.
infix 4 `eq`
infixr 9 $<
infixr 1 $>

lam = Lam
mu = Mu
eq = Eq

-- | Recursive definition of factorial (using mu binders)
fact :: Term Id (Integer -> Integer)
fact = mu (\(lower -> f) -> lam (\(lower -> n) ->
        If (pred n)
            (pure 1)
            $
            (*n) <$> (f <$> (pure $ n - 1))
    ))
  where
    next f n =   pure (f  (n - 1))
    pred n = pure (n == 0)

-- | Factorial function
fac :: Integer -> Integer
fac = eval (Exp fact)

-- | Recursive definition of fibonacci (using mu binders)
fibt :: Term Id (Integer -> Integer)
fibt = mu (\(lower -> f) -> lam (\(lower -> n) ->
        If (pred n)
            (pure 1)
            (next f n)
    ))
    where pred n = pure (n<1)
          next f n = let n1 = f <$> pure (n - 1)
                 n2 = f <$> pure (n - 2)
             in (+) <$>  n1 <*> n2 
-- | Fib function
fib :: Integer -> Integer
fib = eval (Exp fibt)          

-- | Evaluator for a expression
eval :: Exp t -> t
eval (Exp f) = evalC f  

-- | Evaluator for a PHOAS term
-- Evaluation of mu terms is defined with fix `fix f = let x = f x in x` to optimize sharing.
evalC :: Variable v => Term v t -> t
evalC (App f a) = evalC f $ evalC a
evalC (Var t) = lower t
evalC (Lam f) = \a -> evalC ( f (raise a)) 
evalC (If cond th el) = case evalC (cond) of
                True -> evalC th
                False -> evalC el
evalC (Eq a b) = evalC a == evalC b
evalC (Mu f) = fix (evalC . f . raise)
evalC (MuN f) = head $ fix (fmap evalC . f . fmap raise)

Name: Anonymous 2013-08-06 18:08

>>22
Easy.

Name: Anonymous 2013-08-06 20:01

>>22
that is more disgusting than Perl code

Name: Anonymous 2013-08-06 22:19

>>24
and your mom is more disgusting than that

Name: Anonymous 2013-08-07 4:06

>>24

It is not that horrible, because the applicative interface let you embed unlifted symbols quite easily. The purpose is to create an interface, which makes building cyclic structures explicit and enforces sharing. Eg:


cyclicList :: Term Id [Integer]
cyclicList  = mu $ \(lower -> k) -> pure (1 : 2 : k)


Which looks pretty clean. Now I could create special operations, which preserve sharing.

And if I want the list at last, I simply evaluate it:


getCyclicList :: [Integer]
getCyclicList = eval (Exp cyclicList)

Name: Anonymous 2013-08-07 4:17

Or a cyclic tree structure:


data Tree a = Node a [Tree a]
    deriving Show
-- | Same as
-- letrec x = Node 1 [Node 2 [], Node 3 [x,y]]
--        y = Node 2 [x]
-- in Node 1 [y]
cyclicTree :: Term Id (Tree Integer)
cyclicTree = muN $ \ ~( _ : (lower -> x): (lower -> y):_) -> [
            pure (Node 1000 [y]),
            pure (Node 1 [Node 2 [], Node 3 [x,y]]),
            pure (Node 2 [x])

    ]


getCyclicTree = eval (Exp cyclicTree)

Name: Anonymous 2013-08-07 4:59

>>27
A cyclic data structure you say?

\x -> x x

just kidding. I like haskell.

Name: Anonymous 2013-08-07 7:06

Does anyone use Clang?
Its faster then GCC

Name: Anonymous 2013-08-07 7:49

>>28

haha, you are so funny, /b/ro XD BROFIST :(8)

Name: Anonymous 2013-08-07 9:15

>>30
                         `
:(8)

what are you eating?

Name: Anonymous 2013-08-07 9:26

LMAO!!!

Name: Anonymous 2013-08-07 12:30

Wouldn't something like
factorial n = product [2..n] work ?

Name: Anonymous 2013-08-07 13:32

>>31


Balls in the mouth XD


>>33

That works too, but it is a bit mundane.

Name: Anonymous 2013-08-07 13:37

>>34

le joke e/g/in, /g/roksi LEEELLLLL XD

Name: Anonymous 2013-08-07 14:14

>>35
What?

Name: Anonymous 2013-08-08 10:28

>>36

What what? It is lelcunt, how can you know what it says?

Name: Anonymous 2013-08-08 10:29

>>37
Because I'm an e/g/in /g/ro from le re/g/g/it! Install le /g/ento XDDDDDDDDDDDD lelelelelelllllllleeeeeeeeeeellllllllll

Name: Anonymous 2013-08-08 10:52

lel voor je harses

Name: Anonymous 2013-08-08 11:17

>>39

LEEEEL IN LE CUNT

Name: Anonymous 2013-08-08 12:15

>>37
how can you know what it says?
That's what I was asking? It's all gibberish to me.

Name: Anonymous 2013-08-08 12:50

>>41
A detailed explanation:

* >>34-san used an emoticon (namely ``XD''), which makes him look like an infantile imageboard/Reddit user.
* >>35-san is known as ``lel-cunt'', a well-known denizen of /prog/, makes ironic replies in a childish style so as to make fun of imageboard users (such as /g/ users), as they always act in a childish way and try to cram as many ``e/g/in memes'' (a parody of e/b/in memes) as they can in their posts.
* From your ignorance of the legendary ``lel-cunt'' denizen, I can only infer that you aren't from here, therefore getting a stern welcome from our friend ``lel-cunt''.

If you want to avoid further harassment from ``lel-cunt'', please refrain from acting like a imageboard user and respect the customs of this textboard (as weird as they might seen). If you can't do this, I'd suggest going back to your home imageboard/subreddit, as you will feel more comfortable there.

Name: Anonymous 2013-08-08 15:05

>>41
LLLLLLLLLLLLLLLLLLLLLLEEEEEEEEEEEEEEEEEEEEEEEEEEELLLLLLLLLLLLLLLLLLLL

Don't change these.
Name: Email:
Entire Thread Thread List