Skip to content

Instantly share code, notes, and snippets.

View emilaxelsson's full-sized avatar

Emil Axelsson emilaxelsson

View GitHub Profile
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE KindSignatures #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE TypeOperators #-}
import Data.Type.Equality
import GHC.TypeLits
@emilaxelsson
emilaxelsson / gist:5170284
Last active December 15, 2015 00:08
Virtual tuples in Feldspar

Proposal for feldspar-language and feldspar-compiler.

Background

Tuples are currently compiled to structs whenever they are forced by a Syntax-overloaded function, such as condition or forLoop. In most cases, we would like to avoid the struct and just have the members as separate variables.

Consider the example

@emilaxelsson
emilaxelsson / gist:5028556
Last active December 14, 2015 04:29
Liveness analysis and variable reuse for a list of assignments. Assumptions: All variables have the same type and size.
{-# LANGUAGE DeriveFoldable #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE TypeOperators #-}
import Control.Monad.State
import Data.Foldable (Foldable)
import qualified Data.Foldable as Fold
import Data.Map (Map)
import qualified Data.Map as Map