[Haskell] Announcing Djinn, version 2004-12-11, a coding wizard
Donald Bruce Stewart
dons at cse.unsw.edu.au
Sun Dec 11 18:50:07 EST 2005
lennart:
> Howdy, y'all!
>
> I've written a small program that takes a (Haskell) type
> and gives you back a function of that type if one exists.
> It's kind of fun, so I thought I'd share it.
>
> It's probably best explained with a sample session.
>
> calvin% djinn
> Welcome to Djinn version 2005-12-11.
> Type :h to get help.
> # Djinn is interactive if not given any arguments.
> # Let's see if it can find the identity function.
> Djinn> f ? a->a
> f :: a -> a
> f x1 = x1
> # Yes, that was easy. Let's try some tuple munging.
> Djinn> sel ? ((a,b),(c,d)) -> (b,c)
> sel :: ((a, b), (c, d)) -> (b, c)
> sel ((_, v5), (v6, _)) = (v5, v6)
I've written a little plugin to use Djinn from lambdabot. You
can interact with it on the #haskell irc channel *right now*
Transcript:
15:39:01 <dons> @djinn a -> b -> a
15:39:02 <lambdabot> x :: a -> b -> a
15:39:02 <lambdabot> x x1 _ = x1
15:39:11 <dons> @djinn (a -> b -> c) -> ((a,b) -> c)
15:39:11 <lambdabot> x :: (a -> b -> c) -> (a, b) -> c
15:39:11 <lambdabot> x x1 (v3, v4) = x1 v3 v4
15:39:27 <dons> @djinn (a -> b) -> (c -> b) -> Either a c -> b
15:39:27 <lambdabot> x :: (a -> b) -> (c -> b) -> Either a c -> b
15:39:27 <lambdabot> x x1 x2 x3 = case x3 of
15:39:27 <lambdabot> Left l4 -> x1 l4
15:39:27 <lambdabot> Right r5 -> x2 r5
15:40:06 <xerox> @djinn a -> [a] -> [a]
15:40:07 <lambdabot> x :: a -> [a] -> [a]
15:40:07 <lambdabot> x _ x2 = x2
15:40:08 <dons> @help djinn
15:40:09 <lambdabot> @djinn <type>
15:40:09 <lambdabot> Generates Haskell code from a type.
And then we go crazy with @djinn for about 10 minutes :)
Great stuff Lennart.
Cheers,
Don
More information about the Haskell
mailing list